stage1_2/iec_bison.yy
author mjsousa
Sun, 08 May 2016 20:01:15 +0100
changeset 1011 76175defb87b
parent 980 9ed5aff159db
child 1012 1f2af384fb1f
permissions -rw-r--r--
Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     1
/*
264
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
     3
 *
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
     4
 *  Copyright (C) 2003-2011  Mario de Sousa (msousa@fe.up.pt)
279
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 278
diff changeset
     5
 *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
264
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
     6
 *
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
     7
 *  This program is free software: you can redistribute it and/or modify
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
     8
 *  it under the terms of the GNU General Public License as published by
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
     9
 *  the Free Software Foundation, either version 3 of the License, or
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
    10
 *  (at your option) any later version.
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
    11
 *
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
    12
 *  This program is distributed in the hope that it will be useful,
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
    13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
    14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
    15
 *  GNU General Public License for more details.
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
    16
 *
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
    17
 *  You should have received a copy of the GNU General Public License
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
    18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
    19
 *
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    20
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    21
 * This code is made available on the understanding that it will not be
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    22
 * used in safety-critical situations without a full and competent review.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    23
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    24
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    25
/*
264
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 258
diff changeset
    26
 * An IEC 61131-3 compiler.
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    27
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    28
 * Based on the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    29
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    30
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    31
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    32
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    33
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    34
 * Stage 2
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    35
 * =======
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    36
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    37
 *  This file contains the syntax definition of the textual
91
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
    38
 *  languages IL and ST, as well as the textual version of SFC.
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
    39
 *  The syntax parser, comprising the 2nd stage of the overall 
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
    40
 *  compiler, is generated by runing bison on this file.
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    41
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    42
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    43
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    44
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    45
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    46
/**********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    47
/**********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    48
/**********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    49
/**********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    50
/*******                                                        *******/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    51
/*******   The following syntax does not have any conflicts.    *******/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    52
/*******                                                        *******/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    53
/*******   P L E A S E    K E E P    I T    T H A T    W A Y !  *******/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    54
/*******   ===================================================  *******/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    55
/*******                                                        *******/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    56
/**********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    57
/**********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    58
/**********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    59
/**********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    60
547
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
    61
/* NOTE: the following file contains many rules used merely for detecting errors in
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
    62
 * the IEC source code being parsed.
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
    63
 * To remove all these rules, simply execute the command (first replace all '%' with '/'):
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
    64
 * $sed '\:%\* ERROR_CHECK_BEGIN \*%:,\:%\* ERROR_CHECK_END \*%: d' iec_bison.yy
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
    65
 *
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
    66
 * The above command had to be edited ('/' replaced by '%') so as not to include the C syntax that closes
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
    67
 * comments inside this comment!
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
    68
 * If you place the command in a shell script, be sure to remove the backslashes '\' before each asterisk '*' !!
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
    69
 */
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
    70
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
    71
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    72
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    73
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    74
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    75
%{
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    76
#include <string.h>	/* required for strdup()  */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    77
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    78
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    79
/* declare the token parser generated by flex... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    80
int yylex(void);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    81
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    82
/* declare the error handler defined at the end of this file */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    83
void yyerror (const char *error_msg);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    84
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    85
/* produce a more verbose parsing error message */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    86
#define YYERROR_VERBOSE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    87
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    88
/* Include debuging code.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    89
 * Printing of debug info must then be activated by setting
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    90
 * the variable yydebug to 1.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    91
 */
41
8998c8b24b60 First working IEC std lib test, actually test from string and to_string functions.
etisserant
parents: 40
diff changeset
    92
#define YYDEBUG 0
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    93
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    94
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    95
/* file with declaration of absyntax classes... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    96
#include "../absyntax/absyntax.hh"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    97
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    98
/* file with declaration of token constants. Generated by bison! */
822
a7d9e0b8636b Fix build on Ubuntu 13.10
Edouard Tisserant
parents: 811
diff changeset
    99
#include "iec_bison.hh"
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   100
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   101
/* The interface through which bison and flex interact. */
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   102
#include "stage1_2_priv.hh"
748
ad4265253528 Start to change code like Mario suggestions.
Manuele Conti <conti.ma@alice.it>
parents: 747
diff changeset
   103
#include "create_enumtype_conversion_functions.hh"
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   104
315
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
   105
#include "../absyntax_utils/add_en_eno_param_decl.hh"	/* required for  add_en_eno_param_decl_c */
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
   106
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   107
/* an ugly hack!!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   108
 * We will probably not need it when we decide
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   109
 *  to cut down the abstract syntax down to size.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   110
 *  We keep it as it is until we get to write
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   111
 *  stages 3 and 4 of the compiler. Who knows,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   112
 *  we might just find out that we really do need
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   113
 *  the abstract syntax tree to stay as it is
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   114
 *  afterall!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   115
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   116
/* for each element <elem> in list_c * <list>
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   117
 * execute the code <code>
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   118
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   119
#define FOR_EACH_ELEMENT(elem, list, code) {		\
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   120
  symbol_c *elem;					\
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   121
  for(int i = 0; i < list->n; i++) {			\
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   122
    elem = list->elements[i];				\
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   123
    code;						\
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   124
  }							\
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   125
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   126
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   127
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   128
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   129
/* Macros used to pass the line and column locations when
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   130
 * creating a new object for the abstract syntax tree.
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   131
 */
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   132
#define locloc(foo) foo.first_line, foo.first_column, foo.first_file, foo.first_order, foo.last_line, foo.last_column, foo.last_file, foo.last_order
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   133
#define   locf(foo) foo.first_line, foo.first_column, foo.first_file, foo.first_order
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   134
#define   locl(foo) foo.last_line,  foo.last_column,  foo.last_file,  foo.last_order
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   135
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   136
/* Redefine the default action to take for each rule, so that the filenames are correctly processed... */
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   137
# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   138
         do                                                                  \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   139
           if (N)                                                            \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   140
             {                                                               \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   141
               (Current).first_line   = YYRHSLOC(Rhs, 1).first_line;         \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   142
               (Current).first_column = YYRHSLOC(Rhs, 1).first_column;       \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   143
               (Current).first_file   = YYRHSLOC(Rhs, 1).first_file;         \
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   144
               (Current).first_order  = YYRHSLOC(Rhs, 1).first_order;        \
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   145
               (Current).last_line    = YYRHSLOC(Rhs, N).last_line;          \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   146
               (Current).last_column  = YYRHSLOC(Rhs, N).last_column;        \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   147
               (Current).last_file    = YYRHSLOC(Rhs, 1).last_file;          \
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   148
               (Current).last_order   = YYRHSLOC(Rhs, 1).last_order;         \
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   149
             }                                                               \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   150
           else                                                              \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   151
             {                                                               \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   152
               (Current).first_line   = (Current).last_line   =              \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   153
                 YYRHSLOC(Rhs, 0).last_line;                                 \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   154
               (Current).first_column = (Current).last_column =              \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   155
                 YYRHSLOC(Rhs, 0).last_column;                               \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   156
               (Current).first_file   = (Current).last_file   =              \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   157
                 YYRHSLOC(Rhs, 0).last_file;                                 \
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   158
               (Current).first_order  = (Current).last_order  =              \
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   159
                 YYRHSLOC(Rhs, 0).last_order;                                \
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   160
             }                                                               \
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   161
         while (0)
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   162
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   163
596
4efb11e44065 Add ERROR_MSG macro && move extract_XXX() functions to constant_folding.cc
Mario de Sousa <msousa@fe.up.pt>
parents: 584
diff changeset
   164
#include "../main.hh" // required for ERROR() and ERROR_MSG() macros.
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   165
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   166
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   167
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   168
/*************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   169
/* global variables...   */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   170
/*************************/
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   171
/* NOTE: For some strange reason bison ver 2.3 is including these declarations
822
a7d9e0b8636b Fix build on Ubuntu 13.10
Edouard Tisserant
parents: 811
diff changeset
   172
 *       in the iec_bison.hh file, which is in turn included by flex.
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   173
 *       We cannot therefore define any variables over here, but merely declare 
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   174
 *       their existance (otherwise we get errors when linking the code, since we
822
a7d9e0b8636b Fix build on Ubuntu 13.10
Edouard Tisserant
parents: 811
diff changeset
   175
 *       would get a new variable defined each time iec_bison.hh is included!).
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   176
 *       Even though the variables are declared 'extern' over here, they will in
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   177
 *       fact be defined towards the end of this same file (i.e. in the prologue)
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   178
 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   179
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   180
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   181
/* NOTE: These variable are really parameters we would like the stage2__ function to pass
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   182
 *       to the yyparse() function. However, the yyparse() function is created automatically
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   183
 *       by bison, so we cannot add parameters to this function. The only other
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   184
 *       option is to use global variables! yuck!
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   185
 */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   186
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   187
/* A global flag used to tell the parser if overloaded funtions should be allowed.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   188
 * The IEC 61131-3 standard allows overloaded funtions in the standard library,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   189
 * but disallows them in user code...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   190
 */
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   191
extern bool allow_function_overloading;
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   192
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
   193
/* A flag to tell the compiler whether to allow the declaration
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
   194
 * of extensible function (i.e. functions that may have a variable number of
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
   195
 * input parameters, such as AND(word#33, word#44, word#55, word#66).
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
   196
 * This is an extension to the standard syntax.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
   197
 * See comments below for details why we support this!
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
   198
 */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
   199
extern bool allow_extensible_function_parameters;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
   200
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
   201
/* A global flag used to tell the parser whether to include the full variable location when printing out error messages... */
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   202
extern bool full_token_loc;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   203
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
   204
/* A global flag used to tell the parser whether to generate conversion function for enumerated data types. */
934
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
   205
extern bool conversion_functions;
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
   206
1011
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 980
diff changeset
   207
/* A global flag used to tell the parser whether to disable generation of implicit EN and ENO parameters. */
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 980
diff changeset
   208
extern bool disable_implicit_en_eno;
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 980
diff changeset
   209
934
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
   210
/* A global flag used to tell the parser whether to allow use of DREF and '^' operators (defined in IEC 61131-3 v3) */
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
   211
extern bool allow_ref_dereferencing;
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
   212
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
   213
/* A global flag used to tell the parser whether to allow use of REF_TO ANY datatypes (non-standard extension to IEC 61131-3 v3) */
924
9e824bb0c3d4 Make support for REF_TO ANY a command line option.
mjsousa
parents: 923
diff changeset
   214
extern bool allow_ref_to_any;
9e824bb0c3d4 Make support for REF_TO ANY a command line option.
mjsousa
parents: 923
diff changeset
   215
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
   216
/* A global flag used to tell the parser whether to allow use of REF_TO as a struct or array element (non-standard extension) */
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
   217
extern bool allow_ref_to_in_derived_datatypes;
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
   218
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
   219
/* A pointer to the root of the parsing tree that will be generated  by bison. */
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   220
extern symbol_c *tree_root;
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   221
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   222
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   223
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   224
/************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   225
/* forward declarations */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   226
/************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   227
/* The functions declared here are defined at the end of this file... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   228
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   229
/* Convert an il_operator_c into an identifier_c */
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
   230
identifier_c         *il_operator_c_2_identifier_c        (symbol_c *il_operator);
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
   231
/* Convert an il_operator_c into an poutype_identifier_c */
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
   232
poutype_identifier_c *il_operator_c_2_poutype_identifier_c(symbol_c *il_operator);
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
   233
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   234
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
   235
/* return if current token is a syntax element */
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   236
/* ERROR_CHECK_BEGIN */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
   237
bool is_current_syntax_token();
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   238
/* ERROR_CHECK_END */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
   239
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   240
/* print an error message */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
   241
void print_err_msg(int first_line,
95
b119b1db0a7a Changing format of error reporting.
mario
parents: 94
diff changeset
   242
                   int first_column,
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   243
                   const char *first_filename,
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   244
                   long int first_order,
95
b119b1db0a7a Changing format of error reporting.
mario
parents: 94
diff changeset
   245
                   int last_line,
b119b1db0a7a Changing format of error reporting.
mario
parents: 94
diff changeset
   246
                   int last_column,
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   247
                   const char *last_filename,
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   248
                   long int last_order,
756
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
   249
                   const char *additional_error_msg);    
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   250
%}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   251
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   252
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   253
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   254
20
81a06a308b7e *** empty log message ***
mario
parents: 17
diff changeset
   255
// %glr-parser
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
   256
// %expect-rr 1
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
   257
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
   258
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   259
/* The following definitions need to be inside a '%code requires' 
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   260
 * so that they are also included in the header files. If this were not the case,
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   261
 * YYLTYPE would be delcared as something in the iec.cc file, and another thing
822
a7d9e0b8636b Fix build on Ubuntu 13.10
Edouard Tisserant
parents: 811
diff changeset
   262
 * (actually the default value of YYLTYPE) in the iec_bison.hh heder file.
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   263
 */
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   264
%code requires {
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   265
/* define a new data type to store the locations, so we can also store
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   266
 * the filename in which the token is expressed.
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   267
 */
822
a7d9e0b8636b Fix build on Ubuntu 13.10
Edouard Tisserant
parents: 811
diff changeset
   268
/* NOTE: since this code will be placed in the iec_bison.hh header file,
a7d9e0b8636b Fix build on Ubuntu 13.10
Edouard Tisserant
parents: 811
diff changeset
   269
 * as well as the iec.cc file that also includes the iec_bison.hh header file,
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   270
 * declaring the typedef struct yyltype__local here would result in a 
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   271
 * compilation error when compiling iec.cc, as this struct would be
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   272
 * declared twice.
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   273
 * We therefore use the #if !defined YYLTYPE ...
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   274
 * to make sure only the first declaration is parsed by the C++ compiler.
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   275
 */
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   276
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
415
5c115720149c Fix YYLTYPE declaration.
Manuele Conti <conti.ma@alice.it>
parents: 382
diff changeset
   277
typedef struct YYLTYPE {
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   278
    int         first_line;
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   279
    int         first_column;
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   280
    const char *first_file;
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   281
    long int    first_order;
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   282
    int         last_line;
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   283
    int         last_column;
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   284
    const char *last_file;
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   285
    long int    last_order;
415
5c115720149c Fix YYLTYPE declaration.
Manuele Conti <conti.ma@alice.it>
parents: 382
diff changeset
   286
} YYLTYPE;
5c115720149c Fix YYLTYPE declaration.
Manuele Conti <conti.ma@alice.it>
parents: 382
diff changeset
   287
#define YYLTYPE_IS_DECLARED 1
823
c95f42f28b69 Declare that YYLSTYPE is not the default trivial datatype used by bison. (was causing compile errors in bison ver >= 2.7)
Mario de Sousa <msousa@fe.up.pt>
parents: 811
diff changeset
   288
#define YYLTYPE_IS_TRIVIAL 0
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   289
#endif
415
5c115720149c Fix YYLTYPE declaration.
Manuele Conti <conti.ma@alice.it>
parents: 382
diff changeset
   290
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   291
}
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   292
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
   293
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
   294
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   295
%union {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   296
    symbol_c 	*leaf;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   297
    list_c	*list;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   298
    char 	*ID;	/* token value */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   299
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   300
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   301
/*
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   302
 TODO: DO we need to define a destructor do free
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   303
       memory when recovering from errors, or do the
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   304
       class destructors already handle this?
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   305
       Following is example on how to define
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   306
       detructors, using the syntax:
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   307
       %destructor { CODE } SYMBOLS
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   308
%union
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   309
      {
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   310
        char *string;
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   311
      }
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   312
      %token <string> STRING
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   313
      %type  <string> string
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   314
      %destructor { free ($$); } STRING string
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   315
*/
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   316
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   317
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   318
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   319
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   320
/*************************************/
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   321
/* Prelimenary helpful constructs... */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   322
/*************************************/
73
0e623bbdee95 fixing infinite error loops at library level, and ...
mario
parents: 68
diff changeset
   323
/* A token used to identify the very end of the input file
0e623bbdee95 fixing infinite error loops at library level, and ...
mario
parents: 68
diff changeset
   324
 * after all includes have already been processed.
0e623bbdee95 fixing infinite error loops at library level, and ...
mario
parents: 68
diff changeset
   325
 *
0e623bbdee95 fixing infinite error loops at library level, and ...
mario
parents: 68
diff changeset
   326
 * Flex automatically returns the token with value 0
74
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
   327
 * at the end of the file. We therefore specify here
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
   328
 * a token with that exact same value here, so we can use it
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
   329
 * to detect the very end of the input files.
73
0e623bbdee95 fixing infinite error loops at library level, and ...
mario
parents: 68
diff changeset
   330
 */
0e623bbdee95 fixing infinite error loops at library level, and ...
mario
parents: 68
diff changeset
   331
%token END_OF_INPUT 0
0e623bbdee95 fixing infinite error loops at library level, and ...
mario
parents: 68
diff changeset
   332
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   333
/* A bogus token that, in principle, flex MUST NEVER generate */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   334
/* USE 1:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   335
 * ======
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   336
 * This token is currently also being used as the default
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   337
 * initialisation value of the token_id member in
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   338
 * the symbol_c base class.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   339
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   340
 * USE 2
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   341
 * =====
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   342
 * This token may also be used in the future to remove
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   343
 * mysterious reduce/reduce conflicts due to the fact
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   344
 * that our grammar may not be LALR(1) but merely LR(1).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   345
 * This means that bison cannot handle it without some
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   346
 * caoxing from ourselves. We will then need this token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   347
 * to do the coaxing...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   348
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   349
%token BOGUS_TOKEN_ID
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   350
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   351
%type <leaf>	start
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   352
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   353
%type <leaf>	any_identifier
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   354
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   355
%token <ID>	prev_declared_variable_name_token
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
   356
%token <ID>	prev_declared_direct_variable_token
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   357
%token <ID>	prev_declared_fb_name_token
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   358
%type <leaf>	prev_declared_variable_name
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
   359
%type <leaf>	prev_declared_direct_variable
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   360
%type <leaf>	prev_declared_fb_name
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   361
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   362
%token  <ID>	prev_declared_simple_type_name_token
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   363
%token  <ID>	prev_declared_subrange_type_name_token
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   364
%token  <ID>	prev_declared_enumerated_type_name_token
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   365
%token  <ID>	prev_declared_array_type_name_token
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   366
%token  <ID>	prev_declared_structure_type_name_token
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   367
%token  <ID>	prev_declared_string_type_name_token
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
   368
%token  <ID>	prev_declared_ref_type_name_token  /* defined in IEC 61131-3 v3 */
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   369
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   370
%type  <leaf>	prev_declared_simple_type_name
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   371
%type  <leaf>	prev_declared_subrange_type_name
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   372
%type  <leaf>	prev_declared_enumerated_type_name
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   373
%type  <leaf>	prev_declared_array_type_name
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   374
%type  <leaf>	prev_declared_structure_type_name
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   375
%type  <leaf>	prev_declared_string_type_name
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
   376
%type  <leaf>	prev_declared_ref_type_name  /* defined in IEC 61131-3 v3 */
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   377
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   378
%token <ID>	prev_declared_derived_function_name_token
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   379
%token <ID>	prev_declared_derived_function_block_name_token
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   380
%token <ID>	prev_declared_program_type_name_token
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   381
%type  <leaf>	prev_declared_derived_function_name
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   382
%type  <leaf>	prev_declared_derived_function_block_name
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   383
%type  <leaf>	prev_declared_program_type_name
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   384
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   385
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   386
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
   387
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   388
/**********************************************************************************/
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   389
/* B XXX - Things that are missing from the standard, but should have been there! */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   390
/**********************************************************************************/
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   391
267
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   392
/* Pragmas that our compiler will accept.
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   393
 * See the comment in iec.flex for why these pragmas exist. 
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   394
 */
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   395
%token          disable_code_generation_pragma_token
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   396
%token          enable_code_generation_pragma_token
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   397
%type <leaf>	disable_code_generation_pragma
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   398
%type <leaf>	enable_code_generation_pragma
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   399
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   400
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   401
/* All other pragmas that we do not support... */
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   402
/* In most stage 4, the text inside the pragmas will simply be copied to the output file.
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   403
 * This allows us to insert C code (if using stage 4 generating C code) 
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   404
 * inside/interningled with the IEC 61131-3 code!
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   405
 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   406
%token <ID>	pragma_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   407
%type <leaf>	pragma
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   408
267
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   409
/* The joining of all previous pragmas, i.e. any possible pragma */
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   410
%type <leaf>	any_pragma
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
   411
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   412
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   413
/* Where do these tokens belong?? They are missing from the standard! */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   414
/* NOTE: There are other tokens related to these 'EN' ENO', that are also 
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   415
 * missing from the standard. However, their location in the annex B is 
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   416
 * relatively obvious, so they have been inserted in what seems to us their 
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   417
 * correct place in order to ease understanding of the parser...
315
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
   418
 *
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
   419
 * please read the comment above the definition of 'variable' in section B1.4 for details.
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   420
 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   421
%token	EN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   422
%token	ENO
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   423
%type <leaf>	en_identifier
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   424
%type <leaf>	eno_identifier
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   425
919
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   426
/* Keywords in IEC 61131-3 v3 */
873
dea39ef02847 Add limited support for the REF() operator (defined in v3 of IEC 61131-3)
mjsousa
parents: 862
diff changeset
   427
%token	REF
933
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
   428
%token	DREF
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
   429
%token	REF_TO
919
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   430
%token	NULL_token  /* cannot use simply 'NULL', as it conflicts with the NULL keyword in C++ */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   431
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   432
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   433
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   434
/***************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   435
/* B 0 - Programming Model */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   436
/***************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   437
%type <list>	library
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   438
%type <leaf>	library_element_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   439
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   440
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   441
/*******************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   442
/* B 1.1 - Letters, digits and identifiers */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   443
/*******************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   444
/* Done totally within flex...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   445
  letter
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   446
  digit
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   447
  octal_digit
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   448
  hex_digit
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   449
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   450
%token <ID>	identifier_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   451
%type  <leaf>	identifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   452
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   453
/*********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   454
/* B 1.2 - Constants */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   455
/*********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   456
%type <leaf>	constant
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
   457
%type <leaf>	non_int_or_real_constant
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   458
919
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   459
/*********************************/
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   460
/* B 1.2.XX - Reference Literals */
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   461
/*********************************/
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   462
/* NOTE: The following syntax was added by MJS in order to add support for the NULL keyword, defined in  IEC 61131-3 v3
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   463
 *       In v3 expressions that reduce to a reference datatype (REF_TO) are handled explicitly in the syntax 
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   464
 *       (e.g., any variable that is a of reference datatpe falls under the 'ref_name' rule), which means 
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   465
 *       that we would need to keep track of which variables are declared as REF_TO. 
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   466
 *       In order to reduce the changes to the current IEC 61131-3 v2 syntax, I have opted not to do this,
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   467
 *       and simply let the ref_expressions (Ref_Assign, Ref_Compare) be interpreted as all other standard expressions 
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   468
 *       in v2. However, ref_expressions allow the use of the 'NULL' constant, which is handled explicitly
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   469
 *       in the ref_expressions syntax of v3.
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   470
 *       To allow the use of the 'NULL' constant in this extended v2, I have opted to interpret this 'NULL' constant 
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   471
 *       as a literal.
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   472
 */
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   473
%type  <leaf>	ref_value_null_literal  /* defined in IEC 61131-3 v3 - Basically the 'NULL' keyword! */
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   474
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
   475
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   476
/******************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   477
/* B 1.2.1 - Numeric Literals */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   478
/******************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   479
/* Done totally within flex...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   480
  bit
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   481
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   482
%type  <leaf> numeric_literal
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   483
%type  <leaf> integer_literal
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   484
%type  <leaf> signed_integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   485
%token <ID>   integer_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   486
%type  <leaf> integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   487
%token <ID>   binary_integer_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   488
%type  <leaf> binary_integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   489
%token <ID>   octal_integer_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   490
%type  <leaf> octal_integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   491
%token <ID>   hex_integer_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   492
%type  <leaf> hex_integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   493
%token <ID>   real_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   494
%type  <leaf> real
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   495
%type  <leaf> signed_real
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   496
%type  <leaf> real_literal
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   497
// %type  <leaf> exponent
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   498
%type  <leaf> bit_string_literal
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   499
%type  <leaf> boolean_literal
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   500
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   501
%token safeboolean_true_literal_token
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   502
%token safeboolean_false_literal_token
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   503
%token boolean_true_literal_token
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   504
%token boolean_false_literal_token
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   505
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   506
%token FALSE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   507
%token TRUE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   508
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   509
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   510
/*******************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   511
/* B 1.2.2 - Character Strings */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   512
/*******************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   513
%token <ID>   single_byte_character_string_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   514
%token <ID>   double_byte_character_string_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   515
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   516
%type  <leaf> character_string
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   517
%type  <leaf> single_byte_character_string
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   518
%type  <leaf> double_byte_character_string
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   519
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   520
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   521
/***************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   522
/* B 1.2.3 - Time Literals */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   523
/***************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   524
%type  <leaf> time_literal
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   525
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   526
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   527
/************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   528
/* B 1.2.3.1 - Duration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   529
/************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   530
%type  <leaf>	duration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   531
%type  <leaf>	interval
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   532
%type  <leaf>	days
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   533
%type  <leaf>	fixed_point
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   534
%type  <leaf>	hours
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   535
%type  <leaf>	minutes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   536
%type  <leaf>	seconds
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   537
%type  <leaf>	milliseconds
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   538
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   539
%token <ID>	fixed_point_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   540
%token <ID>	fixed_point_d_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   541
%token <ID>	integer_d_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   542
%token <ID>	fixed_point_h_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   543
%token <ID>	integer_h_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   544
%token <ID>	fixed_point_m_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   545
%token <ID>	integer_m_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   546
%token <ID>	fixed_point_s_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   547
%token <ID>	integer_s_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   548
%token <ID>	fixed_point_ms_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   549
%token <ID>	integer_ms_token
547
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
   550
%token <ID>	end_interval_token
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
   551
%token <ID>	erroneous_interval_token
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   552
// %token TIME
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   553
%token T_SHARP
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   554
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   555
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   556
/************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   557
/* B 1.2.3.2 - Time of day and Date */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   558
/************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   559
%type  <leaf>	time_of_day
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   560
%type  <leaf>	daytime
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   561
%type  <leaf>	day_hour
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   562
%type  <leaf>	day_minute
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   563
%type  <leaf>	day_second
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   564
%type  <leaf>	date
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   565
%type  <leaf>	date_literal
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   566
%type  <leaf>	year
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   567
%type  <leaf>	month
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   568
%type  <leaf>	day
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   569
%type  <leaf>	date_and_time
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   570
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   571
// %token TIME_OF_DAY
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   572
// %token DATE
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   573
%token D_SHARP
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   574
// %token DATE_AND_TIME
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   575
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   576
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   577
/**********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   578
/* B 1.3 - Data Types */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   579
/**********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   580
/* Strangely, the following symbol does seem to be required! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   581
// %type  <leaf> data_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   582
%type  <leaf> non_generic_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   583
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   584
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   585
/***********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   586
/* B 1.3.1 - Elementary Data Types */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   587
/***********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   588
/* NOTES:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   589
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   590
 *    - To make the definition of bit_string_literal more
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   591
 *      concise, it is useful to use an extra non-terminal
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   592
 *      symbol (i.e. a grouping or construct) that groups the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   593
 *      following elements (BYTE, WORD, DWORD, LWORD).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   594
 *      Note that the definition of bit_string_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   595
 *      (according to the spec) includes the above elements
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   596
 *      and an extra BOOL.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   597
 *      We could use an extra construct with the first four
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   598
 *      elements to be used solely in the definition of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   599
 *      bit_string_literal, but with the objective of not
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   600
 *      having to replicate the actions (if we ever need
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   601
 *      to change them, they would need to be changed in both
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   602
 *      bit_string_type_name and the extra grouping), we
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   603
 *      have re-defined bit_string_type_name as only including
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   604
 *      the first four elements.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   605
 *      In order to have our parser implement the specification
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   606
 *      correctly we have augmented every occurence of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   607
 *      bit_string_type_name in other rules with the BOOL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   608
 *      token. Since bit_string_type_name only appears in
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   609
 *      the rule for elementary_type_name, this does not
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   610
 *      seem to be a big concession to make!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   611
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   612
 *    - We have added a helper symbol to concentrate the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   613
 *      instantiation of STRING and WSTRING into a single
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   614
 *      location (elementary_string_type_name).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   615
 *      These two elements show up in several other rules,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   616
 *      but we want to create the equivalent abstract syntax
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   617
 *      in a single location of this file, in order to make
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   618
 *      possible future changes easier to edit...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   619
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   620
%type  <leaf>	elementary_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   621
%type  <leaf>	numeric_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   622
%type  <leaf>	integer_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   623
%type  <leaf>	signed_integer_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   624
%type  <leaf>	unsigned_integer_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   625
%type  <leaf>	real_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   626
%type  <leaf>	date_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   627
%type  <leaf>	bit_string_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   628
/* helper symbol to concentrate the instantiation
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   629
 * of STRING and WSTRING into a single location
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   630
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   631
%type  <leaf>	elementary_string_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   632
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   633
%token BYTE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   634
%token WORD
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   635
%token DWORD
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   636
%token LWORD
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   637
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   638
%token LREAL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   639
%token REAL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   640
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   641
%token SINT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   642
%token INT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   643
%token DINT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   644
%token LINT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   645
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   646
%token USINT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   647
%token UINT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   648
%token UDINT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   649
%token ULINT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   650
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   651
%token WSTRING
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   652
%token STRING
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   653
%token BOOL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   654
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   655
%token TIME
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   656
%token DATE
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   657
%token DATE_AND_TIME
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   658
%token DT
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   659
%token TIME_OF_DAY
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   660
%token TOD
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   661
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   662
/******************************************************/
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   663
/* Symbols defined in                                 */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   664
/* "Safety Software Technical Specification,          */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   665
/*  Part 1: Concepts and Function Blocks,             */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   666
/*  Version 1.0 – Official Release"                   */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   667
/* by PLCopen - Technical Committee 5 - 2006-01-31    */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   668
/******************************************************/
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   669
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   670
%token SAFEBYTE
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   671
%token SAFEWORD
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   672
%token SAFEDWORD
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   673
%token SAFELWORD
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   674
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   675
%token SAFELREAL
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   676
%token SAFEREAL
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   677
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   678
%token SAFESINT
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   679
%token SAFEINT
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   680
%token SAFEDINT
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   681
%token SAFELINT
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   682
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   683
%token SAFEUSINT
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   684
%token SAFEUINT
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   685
%token SAFEUDINT
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   686
%token SAFEULINT
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   687
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   688
%token SAFEWSTRING
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   689
%token SAFESTRING
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   690
%token SAFEBOOL
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   691
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   692
%token SAFETIME
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   693
%token SAFEDATE
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   694
%token SAFEDATE_AND_TIME
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   695
%token SAFEDT
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   696
%token SAFETIME_OF_DAY
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
   697
%token SAFETOD
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   698
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   699
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   700
/* B 1.3.2 - Generic data types */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   701
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   702
/* Strangely, the following symbol does seem to be required! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   703
// %type  <leaf>	generic_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   704
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   705
/* The following tokens do not seem to be used either
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   706
 * but we declare them so they become reserved words...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   707
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   708
%token ANY
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   709
%token ANY_DERIVED
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   710
%token ANY_ELEMENTARY
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   711
%token ANY_MAGNITUDE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   712
%token ANY_NUM
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   713
%token ANY_REAL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   714
%token ANY_INT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   715
%token ANY_BIT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   716
%token ANY_STRING
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   717
%token ANY_DATE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   718
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   719
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   720
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   721
/* B 1.3.3 - Derived data types */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   722
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   723
%type  <leaf>	derived_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   724
%type  <leaf>	single_element_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   725
// %type  <leaf>	simple_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   726
// %type  <leaf>	subrange_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   727
// %type  <leaf>	enumerated_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   728
// %type  <leaf>	array_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   729
// %type  <leaf>	structure_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   730
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   731
%type  <leaf>	data_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   732
/* helper symbol for data_type_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   733
%type  <list>	type_declaration_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   734
%type  <leaf>	type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   735
%type  <leaf>	single_element_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   736
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   737
%type  <leaf>	simple_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   738
%type  <leaf>	simple_spec_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   739
%type  <leaf>	simple_specification
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   740
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   741
%type  <leaf>	subrange_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   742
%type  <leaf>	subrange_spec_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   743
%type  <leaf>	subrange_specification
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   744
%type  <leaf>	subrange
960
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
   745
/* A non standard construct, used to support the use of variables in array subranges. e.g.: ARRAY [12..max] OF INT */
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
   746
%type  <leaf>	subrange_with_var
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   747
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   748
%type  <leaf>	enumerated_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   749
%type  <leaf>	enumerated_spec_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   750
%type  <leaf>	enumerated_specification
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   751
/* helper symbol for enumerated_value */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   752
%type  <list>	enumerated_value_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   753
%type  <leaf>	enumerated_value
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
   754
//%type  <leaf>	enumerated_value_without_identifier
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   755
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   756
%type  <leaf>	array_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   757
%type  <leaf>	array_spec_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   758
%type  <leaf>	array_specification
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   759
/* helper symbol for array_specification */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   760
%type  <list>	array_subrange_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   761
%type  <leaf>	array_initialization
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   762
/* helper symbol for array_initialization */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   763
%type  <list>	array_initial_elements_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   764
%type  <leaf>	array_initial_elements
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   765
%type  <leaf>	array_initial_element
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   766
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   767
%type  <leaf>	structure_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   768
%type  <leaf>	structure_specification
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   769
%type  <leaf>	initialized_structure
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   770
%type  <leaf>	structure_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   771
/* helper symbol for structure_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   772
%type  <list>	structure_element_declaration_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   773
%type  <leaf>	structure_element_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   774
%type  <leaf>	structure_element_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   775
%type  <leaf>	structure_initialization
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   776
/* helper symbol for structure_initialization */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   777
%type  <list>	structure_element_initialization_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   778
%type  <leaf>	structure_element_initialization
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   779
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   780
//%type  <leaf>	string_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   781
%type  <leaf>	string_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   782
/* helper symbol for string_type_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   783
%type  <leaf>	string_type_declaration_size
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   784
/* helper symbol for string_type_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   785
%type  <leaf>	string_type_declaration_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   786
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   787
%token ASSIGN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   788
%token DOTDOT  /* ".." */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   789
%token TYPE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   790
%token END_TYPE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   791
%token ARRAY
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   792
%token OF
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   793
%token STRUCT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   794
%token END_STRUCT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   795
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   796
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
   797
%type  <leaf>	ref_spec                 /* defined in IEC 61131-3 v3 */
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
   798
%type  <leaf>	ref_spec_non_recursive   /* helper symbol */
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
   799
%type  <leaf>	ref_spec_init            /* defined in IEC 61131-3 v3 */
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
   800
%type  <leaf>	ref_type_decl            /* defined in IEC 61131-3 v3 */
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
   801
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
   802
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   803
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   804
/*********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   805
/* B 1.4 - Variables */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   806
/*********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   807
%type  <leaf>	variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   808
%type  <leaf>	symbolic_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   809
/* helper symbol for prog_cnxn */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   810
%type  <leaf>	any_symbolic_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   811
%type  <leaf>	variable_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   812
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   813
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   814
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   815
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   816
/********************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   817
/* B.1.4.1   Directly Represented Variables */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   818
/********************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   819
/* Done totally within flex...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   820
 location_prefix
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   821
 size_prefix
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   822
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   823
%token <ID>	direct_variable_token
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
   824
//%type  <leaf>	direct_variable
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   825
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   826
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   827
/*************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   828
/* B.1.4.2   Multi-element Variables */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   829
/*************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   830
%type  <leaf>	multi_element_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   831
/* helper symbol for any_symbolic_variable */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   832
%type  <leaf>	any_multi_element_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   833
%type  <leaf>	array_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   834
/* helper symbol for any_symbolic_variable */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   835
%type  <leaf>	any_array_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   836
%type  <leaf>	subscripted_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   837
/* helper symbol for any_symbolic_variable */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   838
%type  <leaf>	any_subscripted_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   839
%type  <list>	subscript_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   840
%type  <leaf>	subscript
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   841
%type  <leaf>	structured_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   842
/* helper symbol for any_symbolic_variable */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   843
%type  <leaf>	any_structured_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   844
%type  <leaf>	record_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   845
/* helper symbol for any_symbolic_variable */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   846
%type  <leaf>	any_record_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   847
%type  <leaf>	field_selector
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   848
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   849
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   850
/******************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   851
/* B 1.4.3 - Declaration & Initialisation */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   852
/******************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   853
%type  <leaf>	input_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   854
/* helper symbol for input_declarations */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   855
%type  <list>	input_declaration_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   856
%type  <leaf>	input_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   857
%type  <leaf>	edge_declaration
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   858
/* en_param_declaration is not in the standard, but should be! */
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
   859
%type  <leaf>	en_param_declaration
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   860
%type  <leaf>	var_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   861
%type  <leaf>	var1_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   862
%type  <list>	var1_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   863
%type  <leaf>	array_var_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   864
%type  <leaf>	structured_var_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   865
%type  <leaf>	fb_name_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   866
/* helper symbol for fb_name_decl */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   867
%type  <list>	fb_name_list_with_colon
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   868
/* helper symbol for fb_name_list_with_colon */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   869
%type  <list>	var1_list_with_colon
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   870
// %type  <list>	fb_name_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   871
// %type  <leaf>	fb_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   872
%type  <leaf>	output_declarations
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
   873
%type  <leaf>	var_output_init_decl
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
   874
%type  <list>	var_output_init_decl_list
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
   875
/* eno_param_declaration is not in the standard, but should be! */
147
f34f9084a20e fixed typo eno_param_declaration
lbessard
parents: 146
diff changeset
   876
%type  <leaf>	eno_param_declaration
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   877
%type  <leaf>	input_output_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   878
/* helper symbol for input_output_declarations */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   879
%type  <list>	var_declaration_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   880
%type  <leaf>	var_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   881
%type  <leaf>	temp_var_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   882
%type  <leaf>	var1_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   883
%type  <leaf>	array_var_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   884
%type  <leaf>	structured_var_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   885
%type  <leaf>	var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   886
%type  <leaf>	retentive_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   887
%type  <leaf>	located_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   888
/* helper symbol for located_var_declarations */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   889
%type  <list>	located_var_decl_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   890
%type  <leaf>	located_var_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   891
%type  <leaf>	external_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   892
/* helper symbol for external_var_declarations */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   893
%type  <list>	external_declaration_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   894
%type  <leaf>	external_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   895
%type  <leaf>	global_var_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   896
%type  <leaf>	global_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   897
/* helper symbol for global_var_declarations */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   898
%type  <list>	global_var_decl_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   899
%type  <leaf>	global_var_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   900
%type  <leaf>	global_var_spec
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   901
%type  <leaf>	located_var_spec_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   902
%type  <leaf>	location
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   903
%type  <list>	global_var_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   904
%type  <leaf>	string_var_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   905
%type  <leaf>	single_byte_string_var_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   906
%type  <leaf>	single_byte_string_spec
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   907
%type  <leaf>	double_byte_string_var_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   908
%type  <leaf>	double_byte_string_spec
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   909
%type  <leaf>	incompl_located_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   910
/* helper symbol for incompl_located_var_declarations */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   911
%type  <list>	incompl_located_var_decl_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   912
%type  <leaf>	incompl_located_var_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   913
%type  <leaf>	incompl_location
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   914
%type  <leaf>	var_spec
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   915
/* helper symbol for var_spec */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   916
%type  <leaf>	string_spec
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   917
/* intermediate helper symbol for:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   918
 *  - non_retentive_var_decls
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
   919
 *  - var_declarations
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   920
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   921
%type  <list>	var_init_decl_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   922
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   923
%token  <ID>	incompl_location_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   924
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   925
%token VAR_INPUT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   926
%token VAR_OUTPUT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   927
%token VAR_IN_OUT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   928
%token VAR_EXTERNAL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   929
%token VAR_GLOBAL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   930
%token END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   931
%token RETAIN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   932
%token NON_RETAIN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   933
%token R_EDGE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   934
%token F_EDGE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   935
%token AT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   936
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   937
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   938
/***********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   939
/* B 1.5.1 - Functions */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   940
/***********************/
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
   941
// %type  <leaf>	function_name
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   942
/* helper symbol for IL language */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   943
%type  <leaf>	function_name_no_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   944
%type  <leaf>	function_name_simpleop_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   945
//%type  <leaf>	function_name_expression_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   946
/* helper symbols for ST language */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   947
//%type  <leaf>	function_name_NOT_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   948
%type  <leaf>	function_name_no_NOT_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   949
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   950
//%type  <leaf>	standard_function_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   951
/* helper symbols for IL language */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   952
%type  <leaf>	standard_function_name_no_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   953
%type  <leaf>	standard_function_name_simpleop_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   954
%type  <leaf>	standard_function_name_expression_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   955
/* helper symbols for ST language */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   956
%type  <leaf>	standard_function_name_NOT_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   957
%type  <leaf>	standard_function_name_no_NOT_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   958
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   959
%type  <leaf>	derived_function_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   960
%type  <leaf>	function_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   961
/* helper symbol for function_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   962
%type  <leaf>	function_name_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   963
%type  <leaf>	io_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   964
%type  <leaf>	function_var_decls
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   965
%type  <leaf>	function_body
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   966
%type  <leaf>	var2_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   967
/* intermediate helper symbol for function_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   968
%type  <list>	io_OR_function_var_declarations_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   969
/* intermediate helper symbol for function_var_decls */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   970
%type  <list>	var2_init_decl_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   971
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   972
%token <ID>	standard_function_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   973
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   974
%token FUNCTION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   975
%token END_FUNCTION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   976
%token CONSTANT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   977
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   978
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   979
/*****************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   980
/* B 1.5.2 - Function Blocks */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   981
/*****************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   982
%type  <leaf>	function_block_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   983
%type  <leaf>	standard_function_block_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   984
%type  <leaf>	derived_function_block_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   985
%type  <leaf>	function_block_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   986
%type  <leaf>	other_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   987
%type  <leaf>	temp_var_decls
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   988
%type  <leaf>	non_retentive_var_decls
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   989
%type  <leaf>	function_block_body
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   990
/* intermediate helper symbol for function_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   991
%type  <list>	io_OR_other_var_declarations_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   992
/* intermediate helper symbol for temp_var_decls */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   993
%type  <list>	temp_var_decls_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   994
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   995
%token <ID>	standard_function_block_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   996
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   997
%token FUNCTION_BLOCK
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   998
%token END_FUNCTION_BLOCK
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   999
%token VAR_TEMP
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1000
// %token END_VAR
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1001
%token VAR
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1002
// %token NON_RETAIN
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1003
// %token END_VAR
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1004
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1005
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1006
/**********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1007
/* B 1.5.3 - Programs */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1008
/**********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1009
%type  <leaf>	program_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1010
%type  <leaf>	program_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1011
/* helper symbol for program_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1012
%type  <list>	program_var_declarations_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1013
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1014
%token PROGRAM
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1015
%token END_PROGRAM
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1016
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1017
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1018
/********************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1019
/* B 1.6 Sequential Function Chart elements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1020
/********************************************/
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  1021
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1022
%type  <list>	sequential_function_chart
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  1023
%type  <list>	sfc_network
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1024
%type  <leaf>	initial_step
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1025
%type  <leaf>	step
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  1026
%type  <list>	action_association_list
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1027
%type  <leaf>	step_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1028
%type  <leaf>	action_association
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  1029
/* helper symbol for action_association */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1030
%type  <list>	indicator_name_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1031
%type  <leaf>	action_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1032
%type  <leaf>	action_qualifier
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  1033
%type  <leaf>	qualifier
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1034
%type  <leaf>	timed_qualifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1035
%type  <leaf>	action_time
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1036
%type  <leaf>	indicator_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1037
%type  <leaf>	transition
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1038
%type  <leaf>	steps
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1039
%type  <list>	step_name_list
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  1040
%type  <leaf>	transition_priority
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  1041
%type  <leaf>	transition_condition
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1042
%type  <leaf>	action
151
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  1043
%type  <leaf>	action_body
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  1044
%type  <leaf>	transition_name
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  1045
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1046
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1047
// %token ASSIGN
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1048
%token ACTION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1049
%token END_ACTION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1050
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1051
%token TRANSITION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1052
%token END_TRANSITION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1053
%token FROM
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1054
%token TO
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1055
%token PRIORITY
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1056
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1057
%token INITIAL_STEP
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1058
%token STEP
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1059
%token END_STEP
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1060
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1061
%token L
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1062
%token D
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1063
%token SD
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1064
%token DS
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1065
%token SL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1066
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1067
%token N
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1068
%token P
627
e7caa7d32ef5 Adding support for P0 and P1 qualifiers and fixing code generated for SL qualifier
Laurent Bessard
parents: 616
diff changeset
  1069
%token P0
e7caa7d32ef5 Adding support for P0 and P1 qualifiers and fixing code generated for SL qualifier
Laurent Bessard
parents: 616
diff changeset
  1070
%token P1
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1071
/* NOTE: the following two clash with the R and S IL operators.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1072
 * It will have to be handled when we include parsing of SFC...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1073
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1074
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1075
%token R
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1076
%token S
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1077
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1078
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1079
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1080
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1081
/* B 1.7 Configuration elements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1082
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1083
%type  <leaf>	configuration_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1084
%type  <leaf>	resource_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1085
%type  <leaf>	configuration_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1086
// helper symbol for
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1087
//  - configuration_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1088
//  - resource_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1089
//
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  1090
%type  <list>	global_var_declarations_list
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1091
// helper symbol for configuration_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1092
%type  <leaf>	optional_access_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1093
// helper symbol for configuration_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1094
%type  <leaf>	optional_instance_specific_initializations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1095
// helper symbol for configuration_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1096
%type  <list>	resource_declaration_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1097
%type  <leaf>	resource_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1098
%type  <leaf>	single_resource_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1099
// helper symbol for single_resource_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1100
%type  <list>	task_configuration_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1101
// helper symbol for single_resource_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1102
%type  <list>	program_configuration_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1103
%type  <leaf>	resource_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1104
// %type  <leaf>	access_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1105
// helper symbol for access_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1106
// %type  <leaf>	access_declaration_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1107
// %type  <leaf>	access_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1108
// %type  <leaf>	access_path
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1109
// helper symbol for access_path
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1110
%type  <list>	any_fb_name_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1111
%type  <leaf>	global_var_reference
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1112
// %type  <leaf>	access_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1113
%type  <leaf>	program_output_reference
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1114
%type  <leaf>	program_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1115
// %type  <leaf>	direction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1116
%type  <leaf>	task_configuration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1117
%type  <leaf>	task_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1118
%type  <leaf>	task_initialization
74
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  1119
// 3 helper symbols for task_initialization
75
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  1120
%type  <leaf>	task_initialization_single
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  1121
%type  <leaf>	task_initialization_interval
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  1122
%type  <leaf>	task_initialization_priority
74
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  1123
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1124
%type  <leaf>	data_source
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1125
%type  <leaf>	program_configuration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1126
// helper symbol for program_configuration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1127
%type  <leaf>	optional_task_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1128
// helper symbol for program_configuration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1129
%type  <leaf>	optional_prog_conf_elements
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1130
%type  <list>	prog_conf_elements
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1131
%type  <leaf>	prog_conf_element
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1132
%type  <leaf>	fb_task
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1133
%type  <leaf>	prog_cnxn
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1134
%type  <leaf>	prog_data_source
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1135
%type  <leaf>	data_sink
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1136
%type  <leaf>	instance_specific_initializations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1137
// helper symbol for instance_specific_initializations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1138
%type  <list>	instance_specific_init_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1139
%type  <leaf>	instance_specific_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1140
// helper symbol for instance_specific_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1141
%type  <leaf>	fb_initialization
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1142
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1143
%type  <leaf>	prev_declared_global_var_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1144
%token  <ID>	prev_declared_global_var_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1145
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1146
%type  <leaf>	prev_declared_program_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1147
%token  <ID>	prev_declared_program_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1148
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1149
%type  <leaf>	prev_declared_resource_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1150
%token  <ID>	prev_declared_resource_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1151
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  1152
%type  <leaf>	prev_declared_configuration_name
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1153
%token  <ID>	prev_declared_configuration_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1154
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1155
// %type  <leaf>	prev_declared_task_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1156
// %token  <ID>	prev_declared_task_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1157
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1158
%token CONFIGURATION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1159
%token END_CONFIGURATION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1160
%token TASK
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1161
%token RESOURCE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1162
%token ON
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1163
%token END_RESOURCE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1164
%token VAR_CONFIG
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1165
%token VAR_ACCESS
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1166
// %token END_VAR
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1167
%token WITH
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1168
// %token PROGRAM
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1169
// %token RETAIN
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1170
// %token NON_RETAIN
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1171
// %token PRIORITY
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1172
%token SINGLE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1173
%token INTERVAL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1174
%token READ_WRITE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1175
%token READ_ONLY
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1176
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1177
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1178
/***********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1179
/* B 2.1 Instructions and Operands */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1180
/***********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1181
%type  <list>	instruction_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1182
%type  <leaf>	il_instruction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1183
%type  <leaf>	il_incomplete_instruction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1184
%type  <leaf>	label
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1185
%type  <leaf>	il_simple_operation
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1186
// helper symbol for il_simple_operation
91
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  1187
//%type <tmp_symbol> il_simple_operator_clash_il_operand
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1188
%type  <leaf>	il_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1189
%type  <leaf>	il_jump_operation
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1190
%type  <leaf>	il_fb_call
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1191
%type  <leaf>	il_formal_funct_call
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1192
// helper symbol for il_formal_funct_call
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1193
%type  <leaf> il_expr_operator_clash_eol_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1194
%type  <leaf>	il_operand
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1195
%type  <list>	il_operand_list
91
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  1196
// helper symbol for il_simple_operation
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  1197
%type  <list>	il_operand_list2
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1198
%type  <list>	simple_instr_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1199
%type  <leaf>	il_simple_instruction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1200
%type  <list>	il_param_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1201
%type  <list>	il_param_instruction_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1202
%type  <leaf>	il_param_instruction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1203
%type  <leaf>	il_param_last_instruction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1204
%type  <leaf>	il_param_assignment
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1205
%type  <leaf>	il_param_out_assignment
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1206
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1207
%token EOL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1208
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1209
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1210
/*******************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1211
/* B 2.2 Operators */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1212
/*******************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1213
%token <ID>	sendto_identifier_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1214
%type  <leaf>	sendto_identifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1215
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1216
%type  <leaf>	LD_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1217
%type  <leaf>	LDN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1218
%type  <leaf>	ST_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1219
%type  <leaf>	STN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1220
%type  <leaf>	NOT_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1221
%type  <leaf>	S_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1222
%type  <leaf>	R_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1223
%type  <leaf>	S1_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1224
%type  <leaf>	R1_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1225
%type  <leaf>	CLK_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1226
%type  <leaf>	CU_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1227
%type  <leaf>	CD_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1228
%type  <leaf>	PV_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1229
%type  <leaf>	IN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1230
%type  <leaf>	PT_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1231
%type  <leaf>	AND_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1232
%type  <leaf>	AND2_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1233
%type  <leaf>	OR_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1234
%type  <leaf>	XOR_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1235
%type  <leaf>	ANDN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1236
%type  <leaf>	ANDN2_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1237
%type  <leaf>	ORN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1238
%type  <leaf>	XORN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1239
%type  <leaf>	ADD_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1240
%type  <leaf>	SUB_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1241
%type  <leaf>	MUL_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1242
%type  <leaf>	DIV_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1243
%type  <leaf>	MOD_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1244
%type  <leaf>	GT_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1245
%type  <leaf>	GE_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1246
%type  <leaf>	EQ_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1247
%type  <leaf>	LT_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1248
%type  <leaf>	LE_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1249
%type  <leaf>	NE_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1250
%type  <leaf>	CAL_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1251
%type  <leaf>	CALC_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1252
%type  <leaf>	CALCN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1253
%type  <leaf>	RET_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1254
%type  <leaf>	RETC_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1255
%type  <leaf>	RETCN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1256
%type  <leaf>	JMP_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1257
%type  <leaf>	JMPC_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1258
%type  <leaf>	JMPCN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1259
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1260
%type  <leaf>	il_simple_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1261
%type  <leaf>	il_simple_operator_clash
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1262
%type  <leaf>	il_simple_operator_clash1
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1263
%type  <leaf>	il_simple_operator_clash2
382
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  1264
%type  <leaf>	il_simple_operator_clash3
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1265
%type  <leaf>	il_simple_operator_noclash
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1266
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1267
//%type  <leaf>	il_expr_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1268
%type  <leaf>	il_expr_operator_clash
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1269
%type  <leaf>	il_expr_operator_noclash
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1270
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1271
%type  <leaf>	il_assign_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1272
%type  <leaf>	il_assign_out_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1273
%type  <leaf>	il_call_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1274
%type  <leaf>	il_return_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1275
%type  <leaf>	il_jump_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1276
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1277
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1278
%token LD
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1279
%token LDN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1280
%token ST
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1281
%token STN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1282
%token NOT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1283
%token S
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1284
%token R
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1285
%token S1
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1286
%token R1
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1287
%token CLK
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1288
%token CU
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1289
%token CD
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1290
%token PV
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1291
%token IN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1292
%token PT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1293
%token AND
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1294
%token AND2  /* character '&' in the source code*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1295
%token OR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1296
%token XOR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1297
%token ANDN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1298
%token ANDN2 /* characters '&N' in the source code */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1299
%token ORN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1300
%token XORN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1301
%token ADD
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1302
%token SUB
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1303
%token MUL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1304
%token DIV
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1305
%token MOD
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1306
%token GT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1307
%token GE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1308
%token EQ
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1309
%token LT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1310
%token LE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1311
%token NE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1312
%token CAL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1313
%token CALC
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1314
%token CALCN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1315
%token RET
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1316
%token RETC
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1317
%token RETCN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1318
%token JMP
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1319
%token JMPC
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1320
%token JMPCN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1321
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1322
%token SENDTO   /* "=>" */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1323
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1324
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1325
/***********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1326
/* B 3.1 - Expressions */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1327
/***********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1328
/* NOTE:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1329
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1330
 *    - unary_operator, multiply_operator,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1331
 *      add_operator and comparison_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1332
 *      are not required. Their values are integrated
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1333
 *      directly into other rules...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1334
 */
933
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  1335
%type  <leaf>	  ref_expression  /* an extension to the IEC 61131-3 v2 standard, based on the IEC 61131-3 v3 standard */ 
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  1336
%type  <leaf>	deref_expression  /* an extension to the IEC 61131-3 v2 standard, based on the IEC 61131-3 v3 standard */ 
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1337
%type  <leaf>	expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1338
%type  <leaf>	xor_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1339
%type  <leaf>	and_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1340
%type  <leaf>	comparison
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1341
%type  <leaf>	equ_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1342
// %type  <leaf>	comparison_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1343
%type  <leaf>	add_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1344
// %type  <leaf>	add_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1345
%type  <leaf>	term
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1346
// %type  <leaf>	multiply_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1347
%type  <leaf>	power_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1348
%type  <leaf>	unary_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1349
// %type  <leaf>	unary_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1350
%type  <leaf>	primary_expression
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1351
%type  <leaf>	non_int_or_real_primary_expression
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1352
/* intermediate helper symbol for primary_expression */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1353
%type  <leaf>	function_invocation
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1354
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1355
// %token AND
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1356
// %token XOR
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1357
// %token OR
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1358
// %token MOD
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1359
// %token NOT
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1360
%token OPER_NE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1361
%token OPER_GE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1362
%token OPER_LE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1363
%token OPER_EXP
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1364
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1365
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1366
/********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1367
/* B 3.2 Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1368
/********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1369
%type <list> statement_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1370
%type <leaf> statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1371
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1372
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1373
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1374
/*********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1375
/* B 3.2.1 Assignment Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1376
/*********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1377
%type <leaf> assignment_statement
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1378
// %token ASSIGN   /* ":=" */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1379
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1380
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1381
/*****************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1382
/* B 3.2.2 Subprogram Control Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1383
/*****************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1384
%type <leaf>	subprogram_control_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1385
%type <leaf>	return_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1386
%type <leaf>	fb_invocation
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  1387
// %type <leaf>	param_assignment
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  1388
%type <leaf>	param_assignment_formal
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  1389
%type <leaf>	param_assignment_nonformal
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  1390
/* helper symbols for fb_invocation */
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  1391
%type <list> param_assignment_formal_list
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  1392
%type <list> param_assignment_nonformal_list
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1393
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1394
// %token ASSIGN
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1395
// %token SENDTO   /* "=>" */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1396
%token RETURN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1397
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1398
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1399
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1400
/* B 3.2.3 Selection Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1401
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1402
%type <leaf>	selection_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1403
%type <leaf>	if_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1404
%type <leaf>	case_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1405
%type <leaf>	case_element
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1406
%type <list>	case_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1407
%type <leaf>	case_list_element
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1408
/* helper symbol for if_statement */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1409
%type <list>	elseif_statement_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1410
/* helper symbol for elseif_statement_list */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1411
%type <leaf>	elseif_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1412
/* helper symbol for case_statement */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1413
%type <list>	case_element_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1414
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1415
%token IF
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1416
%token THEN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1417
%token ELSIF
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1418
%token ELSE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1419
%token END_IF
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1420
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1421
%token CASE
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1422
// %token OF
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1423
// %token ELSE
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1424
%token END_CASE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1425
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1426
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1427
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1428
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1429
/* B 3.2.4 Iteration Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1430
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1431
%type <leaf>	iteration_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1432
%type <leaf>	for_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1433
%type <leaf>	control_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1434
%type <leaf>	while_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1435
%type <leaf>	repeat_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1436
%type <leaf>	exit_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1437
/* Integrated directly into for_statement */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1438
// %type <leaf>	for_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1439
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1440
%token FOR
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1441
// %token ASSIGN
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1442
// %token TO
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1443
%token BY
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1444
%token DO
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1445
%token END_FOR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1446
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1447
%token WHILE
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  1448
// %token DO
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1449
%token END_WHILE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1450
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1451
%token REPEAT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1452
%token UNTIL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1453
%token END_REPEAT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1454
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1455
%token EXIT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1456
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  1457
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1458
%%
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1459
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1460
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1461
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1462
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1463
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1464
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1465
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1466
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1467
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1468
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1469
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1470
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1471
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1472
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1473
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1474
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1475
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1476
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1477
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1478
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1479
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1480
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1481
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1482
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1483
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1484
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1485
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1486
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1487
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1488
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1489
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1490
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1491
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1492
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1493
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1494
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1495
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1496
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1497
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1498
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1499
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1500
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1501
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1502
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1503
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1504
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1505
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1506
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1507
/********************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1508
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1509
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1510
start:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1511
  library	{$$ = $1;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1512
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1513
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1514
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1515
/**********************************************************************************/
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1516
/* B XXX - Things that are missing from the standard, but should have been there! */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1517
/**********************************************************************************/
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1518
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1519
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1520
/* the pragmas... */
267
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1521
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1522
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1523
disable_code_generation_pragma:
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1524
  disable_code_generation_pragma_token	{$$ = new disable_code_generation_pragma_c(locloc(@$));}
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1525
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1526
enable_code_generation_pragma:
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1527
  enable_code_generation_pragma_token	{$$ = new enable_code_generation_pragma_c(locloc(@$));}
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1528
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1529
pragma:
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  1530
  pragma_token	{$$ = new pragma_c($1, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1531
267
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1532
any_pragma:
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1533
  disable_code_generation_pragma
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1534
| enable_code_generation_pragma
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1535
| pragma
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1536
;
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1537
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1538
143
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  1539
/* EN/ENO */
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1540
/* Tese tokens are essentially used as variable names, so we handle them 
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1541
 * similarly to these...
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1542
 */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1543
en_identifier:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1544
  EN	{$$ = new identifier_c("EN", locloc(@$));}
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1545
;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1546
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1547
eno_identifier:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1548
  ENO	{$$ = new identifier_c("ENO", locloc(@$));}
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1549
;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1550
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1551
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1552
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1553
/*************************************/
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1554
/* Prelimenary helpful constructs... */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  1555
/*************************************/
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1556
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1557
/* NOTE:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1558
 *       short version:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1559
 *       identifier is used for previously undeclared identifiers
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1560
 *       any_identifier is used when any identifier, previously
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1561
 *       declared or not, is required in the syntax.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1562
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1563
 *       long version:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1564
 *       When flex comes across an identifier, it first
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1565
 *       searches through the currently declared variables,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1566
 *       functions, types, etc... to determine if it has
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1567
 *       been previously declared.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1568
 *       Only if the identifier has not yet been declared
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1569
 *       will it return an identifier_token (later turned into
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1570
 *       an identifier symbol by the bison generated syntax parser).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1571
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1572
 *       Some constructs in the syntax, such as when calling
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1573
 *       a function 'F(var1 := 1; var2 := 2);', will accept _any_
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1574
 *       identifier in 'var1', even if it has been previously
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1575
 *       declared in the current scope, since var1 belongs to
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1576
 *       another scope (the variables declared in function F).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1577
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1578
 *       For the above reason, we need to define the symbol
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1579
 *       any_identifier. All the symbols that may become an
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1580
 *       any_identifier are expected to be stored in the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1581
 *       abstract syntax as a identifier_c
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1582
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1583
/* NOTE:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1584
 *  Type names, function names, function block type names and
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1585
 *  program type names are considerd keywords once they are defined,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1586
 *  so may no longer be used for variable names!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1587
 *  BUT the spec is confusing on this issue, as it is not clear when
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1588
 *  a function name should be considered as defined. If it is to be
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1589
 *  considered defined only from the location from where it is declared
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1590
 *  and onwards, it means that before it is declared its name may be
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1591
 *  used for variable names!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1592
 *  This means that we must allow names previously used for functions
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1593
 *  (et. al.) to also constitue an any_identifier!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1594
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1595
any_identifier:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1596
  identifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1597
| prev_declared_fb_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1598
| prev_declared_variable_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1599
/**/
953
66697c05a147 Fix bug introduced when adding support for relaxed datatype model: change derived_datatype_identifier_c to identifier_c when used as an identifier
mjsousa
parents: 952
diff changeset
  1600
    /* ref_type_name is defined in IEC 61131-3 v3 */
66697c05a147 Fix bug introduced when adding support for relaxed datatype model: change derived_datatype_identifier_c to identifier_c when used as an identifier
mjsousa
parents: 952
diff changeset
  1601
| prev_declared_ref_type_name               {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
66697c05a147 Fix bug introduced when adding support for relaxed datatype model: change derived_datatype_identifier_c to identifier_c when used as an identifier
mjsousa
parents: 952
diff changeset
  1602
| prev_declared_simple_type_name            {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
66697c05a147 Fix bug introduced when adding support for relaxed datatype model: change derived_datatype_identifier_c to identifier_c when used as an identifier
mjsousa
parents: 952
diff changeset
  1603
| prev_declared_subrange_type_name          {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
66697c05a147 Fix bug introduced when adding support for relaxed datatype model: change derived_datatype_identifier_c to identifier_c when used as an identifier
mjsousa
parents: 952
diff changeset
  1604
| prev_declared_enumerated_type_name        {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
66697c05a147 Fix bug introduced when adding support for relaxed datatype model: change derived_datatype_identifier_c to identifier_c when used as an identifier
mjsousa
parents: 952
diff changeset
  1605
| prev_declared_array_type_name             {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
66697c05a147 Fix bug introduced when adding support for relaxed datatype model: change derived_datatype_identifier_c to identifier_c when used as an identifier
mjsousa
parents: 952
diff changeset
  1606
| prev_declared_structure_type_name         {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
66697c05a147 Fix bug introduced when adding support for relaxed datatype model: change derived_datatype_identifier_c to identifier_c when used as an identifier
mjsousa
parents: 952
diff changeset
  1607
| prev_declared_string_type_name            {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1608
| prev_declared_derived_function_name       {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the          poutype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1609
| prev_declared_derived_function_block_name {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the          poutype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1610
| prev_declared_program_type_name           {$$ = new identifier_c(((token_c *)$1)->value, locloc(@$));}; // change the          poutype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1611
/**/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1612
| prev_declared_resource_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1613
| prev_declared_program_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1614
| prev_declared_global_var_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1615
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1616
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1617
/* NOTE: Notice that the symbol classes:
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1618
 *            - derived_datatype_identifier_c
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1619
 *            - poutype_identifier_c
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1620
 *       are only inserted into the AST when referencing a derived dataype or a POU
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1621
 *       (e.g. when declaring a variable, making a function call, instantiating a program in a resource,
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1622
 *        or delaring a derived datatype that derives from another previously delcared datatype).
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1623
 *
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1624
 *       In the declaration of the datatype or POU itself, the name of the datatype or POU will be stored
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1625
 *       inside an identifier_c instead!!
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1626
 */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  1627
prev_declared_variable_name:        prev_declared_variable_name_token        {$$ = new identifier_c($1, locloc(@$));};
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  1628
prev_declared_fb_name:              prev_declared_fb_name_token              {$$ = new identifier_c($1, locloc(@$));};
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  1629
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  1630
prev_declared_simple_type_name:     prev_declared_simple_type_name_token     {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  1631
prev_declared_subrange_type_name:   prev_declared_subrange_type_name_token   {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
945
477393b00f95 Add support for relaxed datatype model for array datatypes.
mjsousa
parents: 936
diff changeset
  1632
prev_declared_enumerated_type_name: prev_declared_enumerated_type_name_token {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  1633
prev_declared_array_type_name:      prev_declared_array_type_name_token      {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  1634
prev_declared_structure_type_name:  prev_declared_structure_type_name_token  {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  1635
prev_declared_string_type_name:     prev_declared_string_type_name_token     {$$ = new derived_datatype_identifier_c($1, locloc(@$));};
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  1636
prev_declared_ref_type_name:        prev_declared_ref_type_name_token        {$$ = new derived_datatype_identifier_c($1, locloc(@$));};  /* defined in IEC 61131-3 v3 */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  1637
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1638
prev_declared_derived_function_name:       prev_declared_derived_function_name_token       {$$ = new poutype_identifier_c($1, locloc(@$));};
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1639
prev_declared_derived_function_block_name: prev_declared_derived_function_block_name_token {$$ = new poutype_identifier_c($1, locloc(@$));};
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1640
prev_declared_program_type_name:           prev_declared_program_type_name_token           {$$ = new poutype_identifier_c($1, locloc(@$));};
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1641
/* NOTE: The poutype_identifier_c was introduced to allow the implementation of remove_forward_dependencies_c */
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  1642
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1643
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1644
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1645
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1646
/***************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1647
/* B 0 - Programming Model */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1648
/***************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1649
library:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1650
  /* empty */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1651
	{if (tree_root == NULL)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1652
	  tree_root = new library_c();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1653
	 $$ = (list_c *)tree_root;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1654
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1655
| library library_element_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1656
	{$$ = $1; $$->add_element($2);}
267
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1657
| library any_pragma
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  1658
	{$$ = $1; $$->add_element($2);}
77
fe4ecf7efa79 adding some comments.
mario
parents: 75
diff changeset
  1659
/* ERROR_CHECK_BEGIN */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  1660
| library error library_element_declaration
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  1661
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unknown syntax error."); yyerrok;}
73
0e623bbdee95 fixing infinite error loops at library level, and ...
mario
parents: 68
diff changeset
  1662
| library error END_OF_INPUT
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  1663
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unknown syntax error."); yyerrok;}
77
fe4ecf7efa79 adding some comments.
mario
parents: 75
diff changeset
  1664
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1665
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1666
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1667
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1668
library_element_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1669
  data_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1670
| function_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1671
| function_block_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1672
| program_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1673
| configuration_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1674
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1675
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1676
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1677
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1678
/*******************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1679
/* B 1.1 - Letters, digits and identifiers */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1680
/*******************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1681
/* NOTE: the spec defines identifier as:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1682
 *         identifier ::= (letter|('_' (letter|digit))) {['_'] (letter|digit)}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1683
 *       In essence, any sequence of letters or digits, starting with a letter
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1684
 *       or '_'.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1685
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1686
 *       On section 2.1.3 (pg 26) , the spec states
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1687
 *       "The keywords listed in annex C shall not be used for any other purpose,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1688
 *         e.g., variable names or extensions as defined in 1.5.1."
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1689
 *       (NOTE: the spec itself does not follow this rule, as it defines standard
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1690
 *       functions with names identidal to keywords, e.g. 'MOD', 'NOT' !!. This is
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1691
 *       another issue altogether, and is worked around somewhere else...)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1692
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1693
 *       This means that we must re-define indentifier so as to exclude
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1694
 *       any keywords defined in annex C.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1695
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1696
 *       Note also that the list includes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1697
 *          - Data type names
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1698
 *          - Function names
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1699
 *          - Function Block names
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1700
 *       This means that any named used for a function name, data type name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1701
 *       or function block name, essentially becomes a keyword, and may therefore
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1702
 *       no longer be re-used for any other use! (see NOTE 2)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1703
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1704
 *       In our case, excluding the keywords is achieved in the lexical parser,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1705
 *       by two mechanisms:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1706
 *         (1) giving higher priority to the keywords (tokens) than to identifiers,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1707
 *             so when the lexical parser finds a keyword it will be parsed as a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1708
 *             token before being parsed as an identifier.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1709
 *         (2) when an identifier is found that is not a keyword, the lexical parser
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1710
 *             then looks in the global symbol table, and will not return an identifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1711
 *             if the name has been previously used as a data type name, function name,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1712
 *             or function block name! (In these cases it will return a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1713
 *             prev_declared_function_name_token, etc...).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1714
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1715
 *       Unfortunately, the language (especially IL) uses tokens that are
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1716
 *       not defined as keywords in the spec (e.g. 'IN', 'R1', 'S1', 'PT', etc...)!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1717
 *       This means that it is valid to name a function 'IN', a variable 'PT', etc...
78
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  1718
 *       In order to solve this potential ambiguity, flex only parses the above 
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  1719
 *       identifiers as keywords / tokens if we are currently parsing IL code.
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  1720
 *       When parsing all code other than IL code, the above identifiers are treated
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  1721
 *       just like any other identifier.
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1722
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1723
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1724
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1725
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1726
 * NOTE 2:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1727
 *         I (Mario) find it strange that the writers of the spec really want
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1728
 *         names previously used for function names, data type names or function
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1729
 *         block names, to become full fledged keywords. I understand that they
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1730
 *         do not want these names being used as variable names, but how about
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1731
 *         enumeration values? How about structure element names?
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1732
 *         If we interpret the spec literally, these would not be accepted,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1733
 *         which would probably burden the programmer quite a bit, in making sure
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1734
 *         all these name don't clash!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1735
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1736
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1737
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1738
 * NOTE 3: The keywords, as specified in Annex C are...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1739
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1740
 *          - Data type names
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1741
 *          - Function names
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1742
 *          - Function Block names
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1743
 *          - ACTION...END_ACTION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1744
 *          - ARRAY...OF
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1745
 *          - AT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1746
 *          - CASE...OF...ELSE...END_CASE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1747
 *          - CONFIGURATION...END_CONFIGURATION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1748
 *          - CONSTANT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1749
 *          - EN, ENO
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1750
 *          - EXIT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1751
 *          - FALSE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1752
 *          - F_EDGE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1753
 *          - FOR...TO...BY...DO...END_FOR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1754
 *          - FUNCTION...END_FUNCTION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1755
 *          - FUNCTION_BLOCK...END_FUNCTION_BLOCK
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1756
 *          - IF...THEN...ELSIF...ELSE...END_IF
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1757
 *          - INITIAL_STEP...END_STEP
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1758
 *          - NOT, MOD, AND, XOR, OR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1759
 *          - PROGRAM...WITH...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1760
 *          - PROGRAM...END_PROGRAM
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1761
 *          - R_EDGE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1762
 *          - READ_ONLY, READ_WRITE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1763
 *          - REPEAT...UNTIL...END_REPEAT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1764
 *          - RESOURCE...ON...END_RESOURCE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1765
 *          - RETAIN, NON_RETAIN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1766
 *          - RETURN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1767
 *          - STEP...END_STEP
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1768
 *          - STRUCT...END_STRUCT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1769
 *          - TASK
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1770
 *          - TRANSITION...FROM...TO...END_TRANSITION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1771
 *          - TRUE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1772
 *          - TYPE...END_TYPE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1773
 *          - VAR...END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1774
 *          - VAR_INPUT...END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1775
 *          - VAR_OUTPUT...END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1776
 *          - VAR_IN_OUT...END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1777
 *          - VAR_TEMP...END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1778
 *          - VAR_EXTERNAL...END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1779
 *          - VAR_ACCESS...END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1780
 *          - VAR_CONFIG...END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1781
 *          - VAR_GLOBAL...END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1782
 *          - WHILE...DO...END_WHILE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1783
 *          - WITH
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1784
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1785
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1786
identifier:
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  1787
  identifier_token	{$$ = new identifier_c($1, locloc(@$));}
78
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  1788
;
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  1789
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  1790
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1791
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1792
/*********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1793
/* B 1.2 - Constants */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1794
/*********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1795
constant:
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1796
  character_string
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1797
| time_literal
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1798
| bit_string_literal
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1799
| boolean_literal
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1800
| numeric_literal  
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1801
/* NOTE: Our definition of numeric_literal is diferent than the one in the standard.
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1802
 *       We will now add what is missing in our definition of numeric literal, so our
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1803
 *       definition of constant matches what the definition of constant in the standard.
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1804
 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1805
/* NOTE: in order to remove reduce/reduce conflicts,
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  1806
 * [between -9.5 being parsed as 
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  1807
 *     (i)   a signed real, 
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  1808
 *     (ii)  or as a real preceded by the '-' operator
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  1809
 *  ]
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  1810
 *  we need to define a variant of the constant construct
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1811
 *  where any real or integer constant is always preceded by 
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1812
 *  a sign (i.e. the '-' or '+' characters).
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1813
 *  (For more info, see comment in the construct non_int_or_real_primary_expression)
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1814
 *
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1815
 * For the above reason, our definition of the numeric_literal construct
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1816
 * is missing the integer and real constrcuts (when not preceded by a sign)
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1817
 * so we add then here explicitly!
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1818
 */
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1819
| real
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1820
| integer
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1821
/* NOTE: unsigned_integer, although used in some
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1822
 * rules, is not defined in the spec!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1823
 * We therefore replaced unsigned_integer as integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1824
 */
919
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
  1825
| ref_value_null_literal /* defined in IEC 61131-3 v3. Basically the 'NULL' keyword! */
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1826
;
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1827
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1828
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1829
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1830
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1831
non_int_or_real_constant:
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1832
  character_string
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1833
| time_literal
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1834
| bit_string_literal
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1835
| boolean_literal
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1836
| numeric_literal  
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1837
/* NOTE: Our definition of numeric_literal is diferent than the one in the standard.
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1838
 *       It is missing the integer and real when not prefixed by a sign 
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1839
 *       (i.e. -54, +42 is included in numerical_literal,
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1840
 *        but   54,  42 is not parsed as a numeric_literal!!)
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1841
 */
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  1842
/* NOTE: in order to remove reduce/reduce conflicts,
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  1843
 * [between -9.5 being parsed as 
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  1844
 *     (i)   a signed real, 
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  1845
 *     (ii)  or as a real preceded by the '-' operator
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  1846
 *  ]
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1847
 * [and a similar situation for integers!]
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  1848
 *  we need to define a variant of the constant construct
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1849
 *  where any real or integer constant is always preceded by 
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1850
 *  a sign (i.e. the '-' or '+' characters).
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1851
 *
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1852
 * For the above reason, our definition of the numeric_literal construct
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1853
 * is missing the integer and real constrcuts (when not preceded by a sign)
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1854
 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1855
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1856
919
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
  1857
/*********************************/
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
  1858
/* B 1.2.XX - Reference Literals */
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
  1859
/*********************************/
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
  1860
/* NOTE: The following syntax was added by MJS in order to add support for the NULL keyword, defined in  IEC 61131-3 v3
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
  1861
 *       Please read the comment where the 'ref_value_null_literal' is declared as a <leaf> 
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
  1862
 */
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
  1863
/* defined in IEC 61131-3 v3 - Basically the 'NULL' keyword! */
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
  1864
ref_value_null_literal: 
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
  1865
  NULL_token	{$$ = new ref_value_null_literal_c(locloc(@$));}
8da635655f37 Add support for the 'NULL' keyword, defined in version 3 of IEC 61131-3.
mjsousa
parents: 909
diff changeset
  1866
;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1867
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1868
/******************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1869
/* B 1.2.1 - Numeric Literals */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1870
/******************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1871
/* NOTES:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1872
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1873
 *    - integer is parsed by flex, but signed_integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1874
 *      is parsed by bison. Flex cannot parse a signed
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1875
 *      integer correctly!  For example: '123+456'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1876
 *      would be parsed by flex as an {integer} {signed_integer}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1877
 *      instead of {integer} '+' {integer}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1878
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1879
 *    - Neither flex nor bison can parse a real_literal
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1880
 *      completely (and correctly).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1881
 *      Note that we cannot use the definition of real in bison as
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1882
 *      real: signed_integer '.' integer [exponent]
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1883
 *      exponent: {'E'|'e'} ['+'|'-'] integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1884
 *      because 123e45 would be parsed by flex as
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1885
 *      integer (123) identifier (e45).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1886
 *      I.e., flex never hands over an 'e' directly to
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1887
 *      bison, but rather interprets it as an identifier.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1888
 *      I guess we could jump through hoops and get it
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1889
 *      working in bison, but the following alternative
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1890
 *      seems more straight forward...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1891
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1892
 *      We therefore had to break up the definition of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1893
 *      real_literal in discrete parts:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1894
 *      real_literal: [real_type_name '#'] singned_real
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1895
 *      signed_real: ['+'|'-'] real
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1896
 *      Flex handles real, while bison handles signed_real
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1897
 *      and real_literal.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1898
 *
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  1899
 *    - According to the spec, integer '.' integer
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1900
 *      may be reduced to either a real or a fixed_point.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1901
 *      It is nevertheless possible to figure out from the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1902
 *      context which of the two rules should be used in
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1903
 *      the reduction.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1904
 *      Unfortunately, due to the issue described above
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1905
 *      regarding the exponent of a real, the syntax
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1906
 *      integer '.' integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1907
 *      must be parsed by flex as a single token (i.e.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1908
 *      fixed_point_token). This means we must add fixed_point
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1909
 *      to the definition of real!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1910
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1911
 *    - The syntax also uses a construct
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1912
 *        fixed_point: integer ['.' integer]
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1913
 *      Notice that real is not defined based on fixed point,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1914
 *      but rather off integer thus:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1915
 *        real: integer '.' integer [exponent]
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1916
 *      This means that a real may not be composed of a single
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1917
 *      integer, unlike the construct fixed_point!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1918
 *      This also means that a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1919
 *        integer '.' integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1920
 *      could be reduced to either a real or a fixed_point
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1921
 *      construct. It is probably possible to decide by looking
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1922
 *      at the context, BUT:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1923
 *       Unfortunatley, due to the reasons explained way above,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1924
 *      a real (with an exponent) has to be handled by flex as a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1925
 *      whole. This means that we cannot leave to bison (the syntax
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1926
 *      parser) the decision of how to reduce an
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1927
 *        integer '.' integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1928
 *      (either to real or to fixed_point)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1929
 *      The decision on how to reduce it would need to be done by
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1930
 *      ther lexical analyser (i.e. flex). But flex cannot do this
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1931
 *      sort of thing.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1932
 *      The solution I (Mario) adopted is to have flex return
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1933
 *      a real_token on (notice that exponent is no longer optional)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1934
 *        integer '.' integer exponent
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1935
 *      and to return a fixed_point_token when it finds
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1936
 *        integer '.' integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1937
 *      We now redefine real and fixed_point to be
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1938
 *        fixed_point: fixed_point_token | integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1939
 *        real: real_token | fixed_point_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1940
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1941
real:
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  1942
  real_token		{$$ = new real_c($1, locloc(@$));}
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  1943
| fixed_point_token	{$$ = new real_c($1, locloc(@$));}
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  1944
;
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  1945
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  1946
integer:	integer_token		{$$ = new integer_c($1, locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  1947
binary_integer:	binary_integer_token	{$$ = new binary_integer_c($1, locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  1948
octal_integer:	octal_integer_token	{$$ = new octal_integer_c($1, locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  1949
hex_integer:	hex_integer_token	{$$ = new hex_integer_c($1, locloc(@$));};
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1950
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1951
numeric_literal:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1952
  integer_literal
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1953
| real_literal
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1954
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1955
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1956
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1957
integer_literal:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1958
  integer_type_name '#' signed_integer
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  1959
	{$$ = new integer_literal_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1960
| integer_type_name '#' binary_integer
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  1961
	{$$ = new integer_literal_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1962
| integer_type_name '#' octal_integer
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  1963
	{$$ = new integer_literal_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1964
| integer_type_name '#' hex_integer
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  1965
	{$$ = new integer_literal_c($1, $3, locloc(@$));}
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1966
| binary_integer
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1967
| octal_integer
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1968
| hex_integer
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1969
//|signed_integer  /* We expand the construct signed_integer here, so we can remove one of its constituents */
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1970
//|  integer       /* REMOVED! see note in the definition of constant for reason why integer is missing here! */
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1971
| '+' integer   {$$ = $2;}
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1972
| '-' integer	{$$ = new neg_integer_c($2, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  1973
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  1974
| integer_type_name signed_integer
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  1975
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between integer type name and value in integer literal."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  1976
| integer_type_name binary_integer
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  1977
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between integer type name and value in integer literal."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  1978
| integer_type_name octal_integer
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  1979
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between integer type name and value in integer literal."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  1980
| integer_type_name hex_integer
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  1981
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between integer type name and value in integer literal."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  1982
| integer_type_name '#' error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  1983
	{$$ = NULL; 
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  1984
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for integer literal.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  1985
	 else {print_err_msg(locf(@3), locl(@3), "invalid value for integer literal."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  1986
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  1987
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  1988
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1989
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1990
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1991
/* NOTE: this construct is used in the definition of integer_literal. However, in order to remove
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1992
 *       a reduce/reduce conflict (see NOTE in definition of constant for reason why)
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1993
 *       it is not used directly, but rather its expansion is copied there.
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1994
 *
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1995
 *       If for some reason you need to change the definition of signed_integer, don't forget
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1996
 *       to change its expansion in integer_literal too!
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  1997
*/
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1998
signed_integer:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1999
  integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2000
| '+' integer   {$$ = $2;}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2001
| '-' integer	{$$ = new neg_integer_c($2, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2002
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2003
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2004
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2005
real_literal:
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  2006
// signed_real /* We expand the construct signed_integer here, so we can remove one of its constituents */
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  2007
// real        /* REMOVED! see note in the definition of constant for reason why real is missing here! */
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  2008
  '+' real	{$$ = $2;}
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  2009
| '-' real	{$$ = new neg_real_c($2, locloc(@2));}
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  2010
| real_type_name '#' signed_real
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  2011
	{$$ = new real_literal_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2012
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2013
| real_type_name signed_real
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2014
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between real type name and value in real literal."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2015
| real_type_name '#' error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2016
  {$$ = NULL;
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2017
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for real literal.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2018
	 else {print_err_msg(locf(@3), locl(@3), "invalid value for real literal."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2019
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2020
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2021
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2022
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2023
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  2024
/* NOTE: this construct is used in the definition of real_literal. However, in order to remove
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  2025
 *       a reduce/reduce conflict (see NOTE in definition of constant for reason why)
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  2026
 *       it is not used directly, but rather its expansion is copied there.
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  2027
 *
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  2028
 *       If for some reason you need to change the definition of signed_real, don't forget
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  2029
 *       to change its expansion in real_literal too!
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  2030
*/
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2031
signed_real:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2032
  real
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2033
| '+' real	{$$ = $2;}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2034
| '-' real	{$$ = new neg_real_c($2, locloc(@2));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2035
;
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2036
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2037
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2038
bit_string_literal:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2039
  bit_string_type_name '#' integer  /* i.e. unsigned_integer */
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  2040
	{$$ = new bit_string_literal_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2041
| bit_string_type_name '#' binary_integer
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  2042
	{$$ = new bit_string_literal_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2043
| bit_string_type_name '#' octal_integer
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  2044
	{$$ = new bit_string_literal_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2045
| bit_string_type_name '#' hex_integer
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  2046
	{$$ = new bit_string_literal_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2047
/* NOTE: see note in the definition of constant for reason
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2048
 * why unsigned_integer, binary_integer, octal_integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2049
 * and hex_integer are missing here!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2050
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2051
/* NOTE: see note under the B 1.2.1 section of token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2052
 * and grouping type definition for reason why the use of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2053
 * bit_string_type_name, although seemingly incorrect, is
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2054
 * really correct here!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2055
 */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2056
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2057
| bit_string_type_name integer
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2058
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between bit string type name and value in bit string literal."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2059
| bit_string_type_name binary_integer
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2060
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between bit string type name and value in bit string literal."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2061
| bit_string_type_name octal_integer
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2062
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between bit string type name and value in bit string literal."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2063
| bit_string_type_name hex_integer
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2064
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between bit string type name and value in bit string literal."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2065
| bit_string_type_name '#' error
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2066
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2067
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for bit string literal.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2068
	 else {print_err_msg(locf(@3), locl(@3), "invalid value for bit string literal."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2069
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2070
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2071
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2072
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2073
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2074
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2075
boolean_literal:
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2076
  boolean_true_literal_token
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2077
	{$$ = new boolean_literal_c(new bool_type_name_c(locloc(@$)),
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2078
				    new boolean_true_c(locloc(@$)),
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2079
				    locloc(@$));
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2080
	}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2081
| boolean_false_literal_token
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2082
	{$$ = new boolean_literal_c(new bool_type_name_c(locloc(@$)),
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2083
				    new boolean_false_c(locloc(@$)),
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2084
				    locloc(@$));
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2085
	}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2086
| safeboolean_true_literal_token
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2087
	{$$ = new boolean_literal_c(new safebool_type_name_c(locloc(@$)),
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2088
				    new boolean_true_c(locloc(@$)),
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2089
				    locloc(@$));
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2090
	}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2091
| safeboolean_false_literal_token
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2092
	{$$ = new boolean_literal_c(new safebool_type_name_c(locloc(@$)),
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2093
				    new boolean_false_c(locloc(@$)),
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2094
				    locloc(@$));
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2095
	}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2096
| FALSE
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2097
	{$$ = new boolean_literal_c(NULL,
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2098
				    new boolean_false_c(locloc(@$)),
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2099
				    locloc(@$));
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2100
	}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2101
| TRUE
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2102
	{$$ = new boolean_literal_c(NULL,
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2103
				    new boolean_true_c(locloc(@$)),
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2104
				    locloc(@$));
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2105
	}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2106
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2107
|	BOOL '#' '1' {}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2108
|	BOOL '#' '0' {}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2109
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2110
/* NOTE: the rules
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2111
 * BOOL '#' '1'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2112
 * and
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2113
 * BOOL '#' '0'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2114
 * do not work as expected...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2115
 * Consider that we are using 'BOOL' and '#' as tokens
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2116
 * that flex hands over to bison (yacc). Because flex would
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2117
 * then parse the single '1' or '0' as an integer,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2118
 * the rule in bison would have to be
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2119
 * BOOL '#' integer, followed by verifying of the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2120
 * integer has the correct value!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2121
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2122
 * We therefore have flex return TRUE whenever it
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2123
 * comes across 'TRUE' or 'BOOL#1', and FALSE whenever
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2124
 * it comes across 'FALSE' or 'BOOL#0'.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2125
 * Note that this means that flex will parse "BOOL#01"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2126
 * as FALSE followed by an integer ('1').
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2127
 * Bison should detect this as an error, so we should
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2128
 * be OK.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2129
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2130
 * Another option would be to change the rules to accept
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2131
 * BOOL '#' integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2132
 * but then check whether the integer has a correct
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2133
 * value! At the moment I feel that the first option
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2134
 * is more straight forward.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2135
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2136
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2137
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2138
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2139
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2140
/*******************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2141
/* B 1.2.2 - Character Strings */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2142
/*******************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2143
/* Transform the tokens given us by flex into leafs */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2144
single_byte_character_string:	single_byte_character_string_token
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2145
	{$$ = new single_byte_character_string_c($1, locloc(@$));};
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2146
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2147
double_byte_character_string:	double_byte_character_string_token
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2148
	{$$ = new double_byte_character_string_c($1, locloc(@$));};
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2149
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2150
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2151
character_string:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2152
  single_byte_character_string
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2153
| double_byte_character_string
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2154
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2155
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2156
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2157
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2158
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2159
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2160
/***************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2161
/* B 1.2.3 - Time Literals */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2162
/***************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2163
time_literal:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2164
  time_of_day
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2165
| date
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2166
| date_and_time
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2167
| duration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2168
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2169
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2170
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2171
/************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2172
/* B 1.2.3.1 - Duration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2173
/************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2174
duration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2175
/*  (T | TIME) '#' ['-'] interval */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2176
/* NOTE: since TIME is also a data type, it is a keyword
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2177
 *       and may therefore be handled by a token.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2178
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2179
 *       Unfortunately T is not a data type, and therefore
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2180
 *       not a keyword. This means that we may have variables named T!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2181
 *       Flex cannot return the token TIME when it comes across a single T!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2182
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2183
 *       We therefore have flex returning the token T_SHARP
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2184
 *       when it comes across 'T#'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2185
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2186
  TIME '#' interval
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2187
	{$$ = new duration_c(new time_type_name_c(locloc(@1)), NULL, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2188
| TIME '#' '-' interval
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2189
	{$$ = new duration_c(new time_type_name_c(locloc(@1)), new neg_time_c(locloc(@$)), $4, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2190
| T_SHARP interval
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2191
	{$$ = new duration_c(new time_type_name_c(locloc(@1)), NULL, $2, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2192
| T_SHARP '-' interval
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2193
	{$$ = new duration_c(new time_type_name_c(locloc(@1)), new neg_time_c(locloc(@$)), $3, locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2194
| SAFETIME '#' interval
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2195
	{$$ = new duration_c(new safetime_type_name_c(locloc(@1)), NULL, $3, locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2196
| SAFETIME '#' '-' interval
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2197
	{$$ = new duration_c(new safetime_type_name_c(locloc(@1)), new neg_time_c(locloc(@$)), $4, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2198
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2199
| TIME interval
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2200
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'TIME' and interval in duration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2201
| TIME '-' interval
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2202
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'TIME' and interval in duration."); yynerrs++;}
547
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2203
| TIME '#' erroneous_interval_token
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2204
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid value for duration."); yynerrs++;}
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2205
| T_SHARP erroneous_interval_token
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2206
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid value for duration."); yynerrs++;}
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2207
| TIME '#' '-' erroneous_interval_token
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2208
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid value for duration."); yynerrs++;}
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2209
| T_SHARP '-' erroneous_interval_token
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2210
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid value for duration."); yynerrs++;}
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2211
/* ERROR_CHECK_END */
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2212
;
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2213
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2214
fixed_point:
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2215
  integer
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2216
| fixed_point_token	{$$ = new fixed_point_c($1, locloc(@$));};
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2217
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2218
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2219
interval:
547
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2220
  days hours minutes seconds milliseconds end_interval_token
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2221
	{$$ = new interval_c($1, $2, $3, $4, $5, locloc(@$));};
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2222
;
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2223
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2224
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2225
days:   /*  fixed_point ('d') */
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2226
  /* empty */		{$$ = NULL;}
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2227
| fixed_point_d_token	{$$ = new fixed_point_c($1, locloc(@$));};
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2228
| integer_d_token	{$$ = new integer_c($1, locloc(@$));};
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2229
;
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2230
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2231
hours:  /*  fixed_point ('h') */
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2232
  /* empty */		{$$ = NULL;}
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2233
| fixed_point_h_token	{$$ = new fixed_point_c($1, locloc(@$));};
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2234
| integer_h_token	{$$ = new integer_c($1, locloc(@$));};
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2235
;
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2236
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2237
minutes: /*  fixed_point ('m') */
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2238
  /* empty */		{$$ = NULL;}
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2239
| fixed_point_m_token	{$$ = new fixed_point_c($1, locloc(@$));};
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2240
| integer_m_token	{$$ = new integer_c($1, locloc(@$));};
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2241
;
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2242
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2243
seconds: /*  fixed_point ('s') */
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2244
  /* empty */		{$$ = NULL;}
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2245
| fixed_point_s_token	{$$ = new fixed_point_c($1, locloc(@$));};
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2246
| integer_s_token	{$$ = new integer_c($1, locloc(@$));};
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2247
;
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2248
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2249
milliseconds: /*  fixed_point ('ms') */
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2250
  /* empty */		{$$ = NULL;}
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2251
| fixed_point_ms_token	{$$ = new fixed_point_c($1, locloc(@$));};
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  2252
| integer_ms_token	{$$ = new integer_c($1, locloc(@$));};
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2253
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2254
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2255
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2256
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2257
/************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2258
/* B 1.2.3.2 - Time of day and Date */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2259
/************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2260
time_of_day:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2261
  TIME_OF_DAY '#' daytime
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2262
	{$$ = new time_of_day_c(new tod_type_name_c(locloc(@1)), $3, locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2263
| SAFETIME_OF_DAY '#' daytime
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2264
	{$$ = new time_of_day_c(new safetod_type_name_c(locloc(@1)), $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2265
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2266
| TIME_OF_DAY daytime
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2267
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'TIME_OF_DAY' and daytime in time of day."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2268
| TIME_OF_DAY '#' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2269
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2270
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for time of day.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2271
	 else {print_err_msg(locf(@3), locl(@3), "invalid value for time of day."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2272
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2273
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2274
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2275
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2276
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2277
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2278
daytime:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2279
  day_hour ':' day_minute ':' day_second
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2280
	{$$ = new daytime_c($1, $3, $5, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2281
/* ERROR_CHECK_BEGIN */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2282
| ':' day_minute ':' day_second
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2283
  {$$ = NULL; print_err_msg(locf(@1), locl(@4), "no value defined for hours in daytime."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2284
| error ':' day_minute ':' day_second
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2285
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid value defined for hours in daytime."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2286
| day_hour day_minute ':' day_second
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2287
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between hours and minutes in daytime."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2288
| day_hour ':' ':' day_second
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2289
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no value defined for minutes in daytime."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2290
| day_hour ':' error ':' day_second
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2291
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid value defined for minutes in daytime."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2292
| day_hour ':' day_minute day_second
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2293
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "':' missing between minutes and seconds in daytime."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2294
| day_hour ':' day_minute ':' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2295
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2296
	 if (is_current_syntax_token()) {print_err_msg(locl(@4), locf(@5), "no value defined for seconds in daytime.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2297
	 else {print_err_msg(locf(@5), locl(@5), "invalid value for seconds in daytime."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2298
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2299
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2300
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2301
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2302
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2303
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2304
day_hour: integer;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2305
day_minute: integer;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2306
day_second: fixed_point;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2307
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2308
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2309
date:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2310
  DATE '#' date_literal
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2311
	{$$ = new date_c(new date_type_name_c(locloc(@1)), $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2312
| D_SHARP date_literal
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2313
	{$$ = new date_c(new date_type_name_c(locloc(@1)), $2, locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2314
| SAFEDATE '#' date_literal
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2315
	{$$ = new date_c(new safedate_type_name_c(locloc(@1)), $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2316
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2317
| DATE date_literal
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2318
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'DATE' and date literal in date."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2319
| DATE '#' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2320
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2321
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for date.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2322
	 else {print_err_msg(locf(@3), locl(@3), "invalid value for date."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2323
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2324
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2325
| D_SHARP error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2326
  {$$ = NULL;
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2327
	 if (is_current_syntax_token()) {print_err_msg(locl(@1), locf(@2), "no value defined for date.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2328
	 else {print_err_msg(locf(@2), locl(@2), "invalid value for date."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2329
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2330
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2331
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2332
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2333
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2334
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2335
date_literal:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2336
  year '-' month '-' day
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2337
	{$$ = new date_literal_c($1, $3, $5, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2338
/* ERROR_CHECK_BEGIN */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2339
| '-' month '-' day
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2340
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no value defined for year in date literal."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2341
| year month '-' day
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2342
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'-' missing between year and month in date literal."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2343
| year '-' '-' day
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2344
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no value defined for month in date literal."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2345
| year '-' error '-' day
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2346
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid value defined for month in date literal."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2347
| year '-' month day
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2348
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "'-' missing between month and day in date literal."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2349
| year '-' month '-' error
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2350
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2351
	 if (is_current_syntax_token()) {print_err_msg(locl(@4), locf(@5), "no value defined for day in date literal.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2352
	 else {print_err_msg(locf(@5), locl(@5), "invalid value for day in date literal."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2353
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2354
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2355
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2356
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2357
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2358
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2359
year: integer;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2360
month: integer;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2361
day: integer;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2362
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2363
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2364
date_and_time:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2365
  DATE_AND_TIME '#' date_literal '-' daytime
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2366
	{$$ = new date_and_time_c(new dt_type_name_c(locloc(@1)), $3, $5, locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2367
| SAFEDATE_AND_TIME '#' date_literal '-' daytime
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2368
	{$$ = new date_and_time_c(new safedt_type_name_c(locloc(@1)), $3, $5, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2369
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2370
| DATE_AND_TIME date_literal '-' daytime
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2371
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'DATE_AND_TIME' and date literal in date and time."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2372
| DATE_AND_TIME '#' '-' daytime
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2373
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no value defined for date literal in date and time."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2374
| DATE_AND_TIME '#' error '-' daytime
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2375
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid value for date literal in date and time."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2376
| DATE_AND_TIME '#' date_literal daytime
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2377
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "'-' missing between date literal and daytime in date and time."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2378
| DATE_AND_TIME '#' date_literal '-' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2379
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2380
	 if (is_current_syntax_token()) {print_err_msg(locl(@4), locf(@5), "no value defined for daytime in date and time.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2381
	 else {print_err_msg(locf(@5), locl(@5), "invalid value for daytime in date and time."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2382
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2383
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2384
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2385
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2386
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2387
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2388
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2389
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2390
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2391
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2392
/**********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2393
/* B 1.3 - Data Types */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2394
/**********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2395
/* Strangely, the following symbol does seem to be required! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2396
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2397
data_type_name:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2398
  non_generic_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2399
| generic_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2400
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2401
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2402
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2403
non_generic_type_name:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2404
  elementary_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2405
| derived_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2406
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2407
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2408
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2409
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2410
/***********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2411
/* B 1.3.1 - Elementary Data Types */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2412
/***********************************/
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2413
    /******************************************************/
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2414
    /* SAFExxxx Symbols defined in                        */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2415
    /* "Safety Software Technical Specification,          */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2416
    /*  Part 1: Concepts and Function Blocks,             */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2417
    /*  Version 1.0 – Official Release"                   */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2418
    /* by PLCopen - Technical Committee 5 - 2006-01-31    */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2419
    /******************************************************/
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2420
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2421
elementary_type_name:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2422
  numeric_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2423
| date_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2424
| bit_string_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2425
| elementary_string_type_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2426
| TIME		{$$ = new time_type_name_c(locloc(@$));}
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2427
| BOOL		{$$ = new bool_type_name_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2428
/* NOTE: see note under the B 1.2.1 section of token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2429
 * and grouping type definition for reason why BOOL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2430
 * was added to this definition.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2431
 */
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2432
| SAFETIME	{$$ = new safetime_type_name_c(locloc(@$));}
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  2433
| SAFEBOOL	{$$ = new safebool_type_name_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2434
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2435
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2436
numeric_type_name:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2437
  integer_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2438
| real_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2439
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2440
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2441
integer_type_name:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2442
  signed_integer_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2443
| unsigned_integer_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2444
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2445
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2446
signed_integer_type_name:
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2447
  SINT		{$$ = new sint_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2448
| INT		{$$ = new int_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2449
| DINT		{$$ = new dint_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2450
| LINT		{$$ = new lint_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2451
| SAFESINT	{$$ = new safesint_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2452
| SAFEINT	{$$ = new safeint_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2453
| SAFEDINT	{$$ = new safedint_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2454
| SAFELINT	{$$ = new safelint_type_name_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2455
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2456
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2457
unsigned_integer_type_name:
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2458
  USINT		{$$ = new usint_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2459
| UINT		{$$ = new uint_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2460
| UDINT		{$$ = new udint_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2461
| ULINT		{$$ = new ulint_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2462
| SAFEUSINT	{$$ = new safeusint_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2463
| SAFEUINT	{$$ = new safeuint_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2464
| SAFEUDINT	{$$ = new safeudint_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2465
| SAFEULINT	{$$ = new safeulint_type_name_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2466
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2467
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2468
real_type_name:
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2469
  REAL		{$$ = new real_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2470
| LREAL		{$$ = new lreal_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2471
| SAFEREAL	{$$ = new safereal_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2472
| SAFELREAL	{$$ = new safelreal_type_name_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2473
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2474
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2475
date_type_name:
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2476
  DATE			{$$ = new date_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2477
| TIME_OF_DAY		{$$ = new tod_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2478
| TOD			{$$ = new tod_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2479
| DATE_AND_TIME		{$$ = new dt_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2480
| DT			{$$ = new dt_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2481
| SAFEDATE		{$$ = new safedate_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2482
| SAFETIME_OF_DAY	{$$ = new safetod_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2483
| SAFETOD		{$$ = new safetod_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2484
| SAFEDATE_AND_TIME	{$$ = new safedt_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2485
| SAFEDT		{$$ = new safedt_type_name_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2486
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2487
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2488
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2489
bit_string_type_name:
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2490
  BYTE		{$$ = new byte_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2491
| WORD		{$$ = new word_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2492
| DWORD		{$$ = new dword_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2493
| LWORD		{$$ = new lword_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2494
| SAFEBYTE	{$$ = new safebyte_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2495
| SAFEWORD	{$$ = new safeword_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2496
| SAFEDWORD	{$$ = new safedword_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2497
| SAFELWORD	{$$ = new safelword_type_name_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2498
/* NOTE: see note under the B 1.2.1 section of token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2499
 * and grouping type definition for reason why the BOOL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2500
 * was omitted from this definition.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2501
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2502
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2503
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2504
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2505
/* Helper symbol to concentrate the instantiation
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2506
 * of STRING and WSTRING into a single location.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2507
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2508
 * These two elements show up in several other rules,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2509
 * but we want to create the equivalent abstract syntax
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2510
 * in a single location of this file, in order to make
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2511
 * possible future changes easier to edit...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2512
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2513
elementary_string_type_name:
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2514
  STRING	{$$ = new string_type_name_c(locloc(@$));}
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2515
| WSTRING	{$$ = new wstring_type_name_c(locloc(@$));}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2516
| SAFESTRING	{$$ = new safestring_type_name_c(locloc(@$));}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  2517
| SAFEWSTRING	{$$ = new safewstring_type_name_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2518
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2519
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2520
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2521
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2522
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2523
/* B 1.3.2 - Generic data types */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2524
/********************************/
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2525
/* Strangely, the following symbol does not seem to be required! */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2526
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2527
generic_type_name:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2528
  ANY
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2529
| ANY_DERIVED
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2530
| ANY_ELEMENTARY
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2531
| ANY_MAGNITUDE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2532
| ANY_NUM
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2533
| ANY_REAL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2534
| ANY_INT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2535
| ANY_BIT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2536
| ANY_STRING
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2537
| ANY_DATE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2538
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2539
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2540
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2541
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2542
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2543
/* B 1.3.3 - Derived data types */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2544
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2545
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2546
derived_type_name:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2547
  single_element_type_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2548
| prev_declared_array_type_name
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2549
| prev_declared_structure_type_name
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2550
| prev_declared_string_type_name
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  2551
| prev_declared_ref_type_name  /* as defined in IEC 61131-3 v3 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2552
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2553
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2554
single_element_type_name:
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2555
  prev_declared_simple_type_name
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2556
/* Include the following if arrays of function blocks are to be allowed!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2557
 * Since the standard does not allow them,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2558
 * we leave it commented out for the time being...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2559
 */
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2560
//| prev_declared_derived_function_block_name
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2561
| prev_declared_subrange_type_name
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2562
| prev_declared_enumerated_type_name
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2563
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2564
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2565
/* NOTE: in order to remove a reduce/reduce conflict,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2566
 *       all occurences of simple_type_name, etc...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2567
 *       have been replaced with identifier!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2568
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2569
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2570
simple_type_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2571
subrange_type_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2572
enumerated_type_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2573
array_type_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2574
structure_type_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2575
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2576
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2577
data_type_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2578
  TYPE type_declaration_list END_TYPE
934
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
  2579
	{$$ = new data_type_declaration_c($2, locloc(@$)); if (conversion_functions) include_string((create_enumtype_conversion_functions_c::get_declaration($$)).c_str());}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2580
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2581
| TYPE END_TYPE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2582
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no data type declared in data type(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2583
| TYPE error type_declaration_list END_TYPE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2584
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'TYPE' in data type(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2585
| TYPE type_declaration_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2586
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed data type(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2587
| TYPE error END_TYPE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2588
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in data type(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2589
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2590
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2591
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2592
/* helper symbol for data_type_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2593
type_declaration_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2594
  type_declaration ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2595
	{$$ = new type_declaration_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2596
| type_declaration_list type_declaration ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2597
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2598
/* ERROR_CHECK_BEGIN */
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  2599
| error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2600
	{$$ = new type_declaration_list_c(locloc(@$)); print_err_msg(locf(@1), locl(@1), "invalid data type declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2601
| type_declaration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2602
	{$$ = new type_declaration_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at end of data type declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2603
| type_declaration_list type_declaration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2604
	{$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at end of data type declaration."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  2605
| type_declaration_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2606
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid data type declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2607
| type_declaration_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2608
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after data type declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2609
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2610
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2611
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2612
type_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2613
  single_element_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2614
| array_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2615
| structure_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2616
| string_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2617
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2618
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2619
single_element_type_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2620
  simple_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2621
| subrange_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2622
| enumerated_type_declaration
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  2623
| ref_type_decl  /* defined in IEC 61131-3 v3 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2624
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2625
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2626
simple_type_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2627
/*  simple_type_name ':' simple_spec_init */
734
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2628
/* To understand why simple_spec_init was brocken up into its consituent components in the following rules, please see note in the definition of 'enumerated_type_declaration'. */
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2629
/* PRE_PARSING or SINGLE_PHASE_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2630
/*  The following rules will be run either by:
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2631
 *      - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2632
 *      - the standard single phase parser (when preparsing command line option is not chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2633
 */
734
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2634
  identifier ':' simple_specification           {library_element_symtable.insert($1, prev_declared_simple_type_name_token);}
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2635
	{if (!get_preparse_state()) $$ = new simple_type_declaration_c($1, $3, locloc(@$));}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2636
| identifier ':' elementary_type_name           {library_element_symtable.insert($1, prev_declared_simple_type_name_token);} ASSIGN constant
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2637
	{if (!get_preparse_state()) $$ = new simple_type_declaration_c($1, new simple_spec_init_c($3, $6, locf(@3), locl(@5)), locloc(@$));}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2638
| identifier ':' prev_declared_simple_type_name {library_element_symtable.insert($1, prev_declared_simple_type_name_token);} ASSIGN constant
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2639
	{if (!get_preparse_state()) $$ = new simple_type_declaration_c($1, new simple_spec_init_c($3, $6, locf(@3), locl(@5)), locloc(@$));}
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2640
/* POST_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2641
/*  These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2642
| prev_declared_simple_type_name ':' simple_spec_init
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2643
	{$$ = new simple_type_declaration_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, locloc(@$));} // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2644
/* These three rules can now be safely replaced by the original rule abvoe!! */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2645
/*
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2646
| prev_declared_simple_type_name ':' simple_specification
734
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2647
	{$$ = new simple_type_declaration_c($1, $3, locloc(@$));}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2648
| prev_declared_simple_type_name ':' elementary_type_name           ASSIGN constant
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2649
	{$$ = new simple_type_declaration_c($1, new simple_spec_init_c($3, $5, locf(@3), locl(@5)), locloc(@$));}
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2650
| prev_declared_simple_type_name ':' prev_declared_simple_type_name ASSIGN constant
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2651
	{$$ = new simple_type_declaration_c($1, new simple_spec_init_c($3, $5, locf(@3), locl(@5)), locloc(@$));}
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2652
*/
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2653
/* ERROR_CHECK_BEGIN */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2654
| error ':' simple_spec_init
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2655
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid name defined for data type declaration.");yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2656
| identifier simple_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2657
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between data type name and specification in simple type declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2658
| identifier ':' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2659
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2660
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no specification defined in data type declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2661
	 else {print_err_msg(locf(@3), locl(@3), "invalid specification in data type declaration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2662
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2663
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2664
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2665
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2666
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2667
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2668
simple_spec_init:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2669
  simple_specification
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2670
  /* The following commented line was changed to the 
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2671
   * next two lines so that we wouldn't
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2672
   * have the first element of a simple_spec_init_c()
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2673
   * pointing to another simple_spec_init_c!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2674
   */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2675
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2676
| simple_specification ASSIGN constant
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2677
	{$$ = new simple_spec_init_c($1, $3);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2678
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2679
| elementary_type_name ASSIGN constant
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2680
	{$$ = new simple_spec_init_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2681
| prev_declared_simple_type_name ASSIGN constant
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2682
	{$$ = new simple_spec_init_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2683
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2684
| elementary_type_name constant
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2685
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' missing in specification with initialization."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2686
| prev_declared_simple_type_name constant
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2687
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' missing in specification with initialization."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2688
| elementary_type_name ASSIGN error
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2689
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2690
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no initial value defined in specification with initialization.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2691
	 else {print_err_msg(locf(@3), locl(@3), "invalid initial value in specification with initialization."); yyclearin;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2692
	 yyerrok;
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2693
	}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2694
| prev_declared_simple_type_name ASSIGN error
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2695
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2696
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no initial value defined in specification with initialization.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2697
	 else {print_err_msg(locf(@3), locl(@3), "invalid initial value in specification with initialization."); yyclearin;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2698
	 yyerrok;
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2699
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2700
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2701
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2702
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2703
/* When converting to C/C++, we need to know whether
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2704
 * the elementary_type_name is being used in a variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2705
 * declaration or elsewhere (ex. declaration of a derived
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2706
 * type), so the abstract syntax has the elementary_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2707
 * wrapped inside a simple_spec_init_c.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2708
 * The exact same thing occurs with prev_declared_simple_type_name.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2709
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2710
 * This is why in the definition of simple_spec_init,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2711
 * simple_specification was brocken up into its
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2712
 * constituent components...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2713
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2714
simple_specification:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2715
// elementary_type_name | simple_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2716
  elementary_type_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2717
	{$$ = new simple_spec_init_c($1, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2718
| prev_declared_simple_type_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2719
	{$$ = new simple_spec_init_c($1, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2720
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2721
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2722
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2723
subrange_type_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2724
/*  subrange_type_name ':' subrange_spec_init */
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2725
/* PRE_PARSING or SINGLE_PHASE_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2726
/*  The following rules will be run either by:
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2727
 *      - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2728
 *      - the standard single phase parser (when preparsing command line option is not chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2729
 */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2730
  identifier ':' subrange_spec_init	{library_element_symtable.insert($1, prev_declared_subrange_type_name_token);}
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2731
	{if (!get_preparse_state()) $$ = new subrange_type_declaration_c($1, $3, locloc(@$));}  
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2732
/* POST_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2733
/*  These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2734
| prev_declared_subrange_type_name ':' subrange_spec_init
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2735
	{$$ = new subrange_type_declaration_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, locloc(@$));} // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2736
/* ERROR_CHECK_BEGIN */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2737
| error ':' subrange_spec_init
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2738
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid name defined for subrange type declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2739
| identifier subrange_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2740
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between data type name and specification in subrange type declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2741
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2742
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2743
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2744
subrange_spec_init:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2745
  subrange_specification
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2746
	{$$ = new subrange_spec_init_c($1, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2747
| subrange_specification ASSIGN signed_integer
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2748
	{$$ = new subrange_spec_init_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2749
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2750
| subrange_specification signed_integer
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2751
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' missing in subrange specification with initialization."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2752
| subrange_specification ASSIGN error
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2753
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2754
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no initial value defined in subrange specification with initialization.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2755
	 else {print_err_msg(locf(@3), locl(@3), "invalid initial value in subrange specification with initialization."); yyclearin;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2756
	 yyerrok;
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2757
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2758
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2759
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2760
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2761
subrange_specification:
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2762
  integer_type_name '(' subrange ')'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2763
	{$$ = new subrange_specification_c($1, $3, locloc(@$));}
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2764
| prev_declared_subrange_type_name
98
d0cdf1d00b74 Adding support for derived data types.
lbessard
parents: 96
diff changeset
  2765
  {$$ = new subrange_specification_c($1, NULL, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2766
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2767
| integer_type_name '(' ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2768
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no subrange defined in subrange specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2769
| integer_type_name '(' error ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2770
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid subrange defined in subrange specification."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2771
| integer_type_name '(' subrange error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2772
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "')' missing after subrange defined in subrange specification."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2773
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2774
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2775
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2776
960
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2777
/* a non standard construct, used to allow the declaration of array subranges using a variable */
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2778
subrange_with_var:
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2779
  signed_integer DOTDOT signed_integer
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2780
	{$$ = new subrange_c($1, $3, locloc(@$));}
960
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2781
| any_identifier DOTDOT signed_integer
980
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2782
	{$$ = new subrange_c(new symbolic_constant_c($1, locloc(@1)), $3, locloc(@$));
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2783
	 if (!runtime_options.nonliteral_in_array_size) {
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2784
	   print_err_msg(locf(@1), locl(@1), "Use of variables in array size limits is not allowed in IEC 61131-3 (use -a option to activate support for this non-standard feature)."); 
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2785
	   yynerrs++;
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2786
	 }
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2787
	}
960
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2788
| signed_integer DOTDOT any_identifier
980
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2789
	{$$ = new subrange_c($1, new symbolic_constant_c($3, locloc(@3)), locloc(@$));
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2790
	 if (!runtime_options.nonliteral_in_array_size) {
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2791
	   print_err_msg(locf(@3), locl(@3), "Use of variables in array size limits is not allowed in IEC 61131-3 (use -a option to activate support for this non-standard feature)."); 
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2792
	   yynerrs++;
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2793
	 }
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2794
	}
960
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2795
| any_identifier DOTDOT any_identifier
980
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2796
	{$$ = new subrange_c(new symbolic_constant_c($1, locloc(@1)), new symbolic_constant_c($3, locloc(@3)), locloc(@$));
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2797
	 if (!runtime_options.nonliteral_in_array_size) {
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2798
	   print_err_msg(locf(@$), locl(@$), "Use of variables in array size limits is not allowed in IEC 61131-3 (use -a option to activate support for this non-standard feature)."); 
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2799
	   yynerrs++;
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2800
	 }
9ed5aff159db Make support for use of variables in array size declarations a command line option (off by default)
mjsousa
parents: 971
diff changeset
  2801
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2802
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2803
| signed_integer signed_integer
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2804
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'..' missing between bounds in subrange definition."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2805
| signed_integer DOTDOT error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2806
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2807
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for upper bound in subrange definition.");}
584
f95d6561d439 fix error message.
Mario de Sousa <msousa@fe.up.pt>
parents: 547
diff changeset
  2808
	 else {print_err_msg(locf(@3), locl(@3), "invalid value for upper bound in subrange definition."); yyclearin;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  2809
	 yyerrok;
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2810
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2811
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2812
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2813
960
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2814
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2815
subrange:
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2816
  signed_integer DOTDOT signed_integer
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2817
	{$$ = new subrange_c($1, $3, locloc(@$));}
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2818
/* ERROR_CHECK_BEGIN */
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2819
| signed_integer signed_integer
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2820
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'..' missing between bounds in subrange definition."); yynerrs++;}
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2821
| signed_integer DOTDOT error
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2822
	{$$ = NULL;
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2823
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for upper bound in subrange definition.");}
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2824
	 else {print_err_msg(locf(@3), locl(@3), "invalid value for upper bound in subrange definition."); yyclearin;}
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2825
	 yyerrok;
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2826
	}
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2827
/* ERROR_CHECK_END */
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2828
;
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2829
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  2830
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2831
enumerated_type_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2832
/*  enumerated_type_name ':' enumerated_spec_init */
734
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2833
/* NOTE: The 'identifier' used for the name of the new enumerated type is inserted early into the library_element_symtable so it may be used
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2834
 *       in defining the default initial value of this type, using the fully qualified enumerated constant syntax: type_name#enum_value
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2835
 *       In other words, this allows us to correclty parse the following IEC 61131-3 code:
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2836
 *           TYPE enum_t : (x1, x2, x3) := enum_t#x3; END_TYPE
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2837
 *                                         ^^^^^^^
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2838
 *
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2839
 *       However, we can only introduce it after we are sure we are parsing an enumerated_spec. For this reason, instead of using the
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2840
 *       symbol enumerated_spec_init in this rule, we decompose it here instead!
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2841
 *       
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2842
 *       If it were not for the above, we could use the rule
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2843
 *           identifier ':' enumerated_spec_init
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2844
 *       and include the library_element_symtable.insert(...) code in the rule actions!
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2845
 */
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2846
/* PRE_PARSING or SINGLE_PHASE_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2847
/*  The following rules will be run either by:
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2848
 *      - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2849
 *      - the standard single phase parser (when preparsing command line option is not chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2850
 */
734
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2851
  identifier ':' enumerated_specification {library_element_symtable.insert($1, prev_declared_enumerated_type_name_token);}
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2852
	{if (!get_preparse_state()) $$ = new enumerated_type_declaration_c($1, new enumerated_spec_init_c($3, NULL, locloc(@3)), locloc(@$));}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2853
| identifier ':' enumerated_specification {library_element_symtable.insert($1, prev_declared_enumerated_type_name_token);} ASSIGN enumerated_value
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2854
	{if (!get_preparse_state()) $$ = new enumerated_type_declaration_c($1, new enumerated_spec_init_c($3, $6, locf(@3), locl(@6)), locloc(@$));}
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2855
/* POST_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2856
/*  These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2857
/* Since the enumerated type name is placed in the library_element_symtable during preparsing, we can now safely use the single rule: */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2858
| prev_declared_enumerated_type_name ':' enumerated_spec_init 
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2859
	{$$ = new enumerated_type_declaration_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, locloc(@$));} // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2860
  /* These two rules are equivalent to the above rule */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2861
/*
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2862
| prev_declared_enumerated_type_name ':' enumerated_specification {library_element_symtable.insert($1, prev_declared_enumerated_type_name_token);}
756
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  2863
	{$$ = new enumerated_type_declaration_c($1, new enumerated_spec_init_c($3, NULL, locloc(@3)), locloc(@$));}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2864
| prev_declared_enumerated_type_name ':' enumerated_specification {library_element_symtable.insert($1, prev_declared_enumerated_type_name_token);} ASSIGN enumerated_value
734
49853bded539 Allow use of type#value syntax when defining default initial value inside a TYPE..END_TYPE declaration.
Mario de Sousa <msousa@fe.up.pt>
parents: 690
diff changeset
  2865
	{$$ = new enumerated_type_declaration_c($1, new enumerated_spec_init_c($3, $6, locf(@3), locl(@6)), locloc(@$));}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2866
*/
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2867
/* ERROR_CHECK_BEGIN */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2868
| error ':' enumerated_spec_init
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2869
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid name defined for enumerated type declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2870
| identifier enumerated_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2871
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between data type name and specification in enumerated type declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2872
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2873
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2874
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2875
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2876
enumerated_spec_init:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2877
  enumerated_specification
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2878
	{$$ = new enumerated_spec_init_c($1, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2879
| enumerated_specification ASSIGN enumerated_value
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2880
	{$$ = new enumerated_spec_init_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2881
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2882
| enumerated_specification enumerated_value
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2883
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' missing in enumerated specification with initialization."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2884
| enumerated_specification ASSIGN error
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2885
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2886
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined in enumerated specification with initialization.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2887
	 else {print_err_msg(locf(@3), locl(@3), "invalid value in enumerated specification with initialization."); yyclearin;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2888
	 yyerrok;
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2889
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2890
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2891
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2892
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2893
enumerated_specification:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2894
  '(' enumerated_value_list ')'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2895
	{$$ = $2;}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2896
| prev_declared_enumerated_type_name
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2897
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2898
| '(' ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2899
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no enumerated value list defined in enumerated specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2900
| '(' error ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2901
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid enumerated value list defined in enumerated specification.");yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2902
| '(' enumerated_value_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2903
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "')' missing at the end of enumerated specification."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2904
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2905
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2906
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2907
/* helper symbol for enumerated_specification */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2908
enumerated_value_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2909
  enumerated_value
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2910
	{$$ = new enumerated_value_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2911
| enumerated_value_list ',' enumerated_value
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2912
	{$$ = $1; $$->add_element($3);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2913
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2914
| enumerated_value_list enumerated_value
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2915
	{$$ = $1; print_err_msg(locl(@1), locf(@2), "',' missing in enumerated value list.");}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2916
| enumerated_value_list ',' error
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  2917
	{$$ = $1;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2918
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined in enumerated value list.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2919
	 else {print_err_msg(locf(@3), locl(@3), "invalid value in enumerated value list."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2920
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2921
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2922
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2923
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2924
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2925
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2926
enumerated_value:
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  2927
  identifier 
121
9e8ce092e169 Adding support for POU struct definition in POUS.h
lbessard
parents: 118
diff changeset
  2928
  {$$ = new enumerated_value_c(NULL, $1, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2929
| prev_declared_enumerated_type_name '#' any_identifier
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2930
	{$$ = new enumerated_value_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2931
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2932
| prev_declared_enumerated_type_name any_identifier
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2933
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between enumerated type name and value in enumerated literal."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2934
| prev_declared_enumerated_type_name '#' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2935
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2936
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for enumerated literal.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2937
	 else {print_err_msg(locf(@3), locl(@3), "invalid value for enumerated literal."); yyclearin;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2938
	 yyerrok;
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2939
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2940
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2941
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2942
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2943
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  2944
/*
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  2945
enumerated_value_without_identifier:
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  2946
  prev_declared_enumerated_type_name '#' any_identifier
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2947
	{$$ = new enumerated_value_c($1, $3, locloc(@$));}
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  2948
;
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  2949
*/
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  2950
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2951
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2952
array_type_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2953
/*  array_type_name ':' array_spec_init */
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2954
/* PRE_PARSING or SINGLE_PHASE_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2955
/*  The following rules will be run either by:
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2956
 *      - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2957
 *      - the standard single phase parser (when preparsing command line option is not chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2958
 */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2959
  identifier ':' array_spec_init   {library_element_symtable.insert($1, prev_declared_array_type_name_token);}
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  2960
	{if (!get_preparse_state()) $$ = new array_type_declaration_c($1, $3, locloc(@$));}
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2961
/* POST_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2962
/*  These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  2963
| prev_declared_array_type_name ':' array_spec_init
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  2964
	{$$ = new array_type_declaration_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, locloc(@$));} // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2965
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2966
| identifier array_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2967
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between data type name and specification in array type declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2968
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2969
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2970
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2971
array_spec_init:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2972
  array_specification
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2973
	{$$ = new array_spec_init_c($1, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2974
| array_specification ASSIGN array_initialization
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2975
	{$$ = new array_spec_init_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2976
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2977
| array_specification array_initialization
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2978
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' missing in array specification with initialization."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2979
| array_specification ASSIGN error
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2980
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2981
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no initial value defined in array specification with initialization.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2982
	 else {print_err_msg(locf(@3), locl(@3), "invalid initial value in array specification with initialization."); yyclearin;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  2983
	 yyerrok;
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2984
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  2985
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2986
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2987
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2988
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2989
array_specification:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2990
  prev_declared_array_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  2991
| ARRAY '[' array_subrange_list ']' OF non_generic_type_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  2992
	{$$ = new array_specification_c($3, $6, locloc(@$));}
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  2993
| ARRAY '[' array_subrange_list ']' OF ref_spec_non_recursive
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  2994
	/* non standard extension: Allow use of arrays storing REF_TO datatypes that are declared as 'ARRAY [1..3] OF REF_TO INT' */
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  2995
	/*                                                                                                            ^^^^^^      */
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  2996
	/* NOTE: We use ref_spec and not ref_spec_init as for the moment I do not want to allow direct specification of initial value.
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  2997
	 *       I (MJS) am not too sure whether this is currently supported in code generation, so leave it out for now.
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  2998
	 *       It also does not seem to be a very good idea to allow initial value specification when declaring the array,
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  2999
	 *       since the standard syntax does not allow it either for any other datatype!
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3000
	 * NOTE: We use ref_spec_non_recursive instead of ref_spec in order to remove a reduce/reduce conflict.
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3001
	 *       Note that non_generic_type_name that is used in the previous rule already include the prev_declared_ref_type_name.
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3002
	 *       which leads to the reduce/reduce conflict, as it is also included in ref_spec.
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3003
	 */
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3004
	{$$ = new array_specification_c($3, $6, locloc(@$));
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3005
	 if (!allow_ref_to_in_derived_datatypes) {
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3006
	   print_err_msg(locf(@$), locl(@$), "REF_TO may not be used in an ARRAY specification (use -R option to activate support for this non-standard syntax)."); 
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3007
	   yynerrs++;
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3008
	 }
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3009
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3010
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3011
| ARRAY array_subrange_list ']' OF non_generic_type_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3012
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'[' missing before subrange list in array specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3013
| ARRAY '[' ']' OF non_generic_type_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3014
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no subrange list defined in array specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3015
| ARRAY '[' error ']' OF non_generic_type_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3016
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid subrange list defined in array specification."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3017
| ARRAY OF non_generic_type_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3018
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no subrange list defined in array specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3019
| ARRAY error OF non_generic_type_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3020
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid subrange list defined in array specification."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3021
| ARRAY '[' array_subrange_list OF non_generic_type_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3022
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "']' missing after subrange list in array specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3023
| ARRAY '[' array_subrange_list ']' non_generic_type_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3024
	{$$ = NULL; print_err_msg(locl(@4), locf(@5), "'OF' missing between subrange list and item type name in array specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3025
| ARRAY '[' array_subrange_list ']' OF error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3026
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3027
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no item data type defined in array specification.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3028
	 else {print_err_msg(locf(@3), locl(@3), "invalid item data type in array specification."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3029
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3030
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3031
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3032
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3033
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3034
/* helper symbol for array_specification */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3035
array_subrange_list:
960
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  3036
/* the construct 'subrange' has been replaced with 'subrange_with_var' in order to support the declaration of array ranges using a varable: e.g. ARRAY [2..max] OF INT */
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  3037
  subrange_with_var
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3038
	{$$ = new array_subrange_list_c(locloc(@$)); $$->add_element($1);}
960
27063736913f Allow variables to be used when declaring the dimension of an array.
mjsousa
parents: 946
diff changeset
  3039
| array_subrange_list ',' subrange_with_var
98
d0cdf1d00b74 Adding support for derived data types.
lbessard
parents: 96
diff changeset
  3040
	{$$ = $1; $$->add_element($3);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3041
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3042
| array_subrange_list subrange
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3043
	{$$ = $1; print_err_msg(locl(@1), locf(@2), "',' missing in subrange list."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3044
| array_subrange_list ',' error
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  3045
	{$$ = $1;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3046
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no subrange defined in subrange list.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3047
	 else {print_err_msg(locf(@3), locl(@3), "invalid subrange in subrange list."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3048
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3049
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3050
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3051
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3052
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3053
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3054
array_initialization:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3055
  '[' array_initial_elements_list ']'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3056
	{$$ = $2;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3057
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3058
| '[' ']'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3059
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no initial values list defined in array initialization."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3060
| '[' error ']'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3061
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid initial values list defined in array initialization."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3062
| '[' array_initial_elements_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3063
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "']' missing at the end of array initialization."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3064
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3065
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3066
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3067
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3068
/* helper symbol for array_initialization */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3069
array_initial_elements_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3070
  array_initial_elements
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3071
	{$$ = new array_initial_elements_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3072
| array_initial_elements_list ',' array_initial_elements
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3073
	{$$ = $1; $$->add_element($3);}
547
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  3074
/* ERROR_CHECK_BEGIN */
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  3075
/* The following error checking rules have been commented out. Why? Was it a typo? 
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  3076
 * Lets keep them commented out for now...
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  3077
 */
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  3078
/*
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3079
| array_initial_elements_list ',' error
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  3080
	{$$ = $1;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3081
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no array initial value in array initial values list.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3082
	 else {print_err_msg(locf(@3), locl(@3), "invalid array initial value in array initial values list."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3083
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3084
	}
547
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  3085
*/
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3086
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3087
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3088
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3089
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3090
array_initial_elements:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3091
  array_initial_element
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3092
| integer '(' ')'
377
60b012b7793f Adding support for compiling direct array specification inside variable declaration
laurent
parents: 354
diff changeset
  3093
	{$$ = new array_initial_elements_c($1, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3094
| integer '(' array_initial_element ')'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3095
	{$$ = new array_initial_elements_c($1, $3, locloc(@$));}
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3096
/* ERROR_CHECK_BEGIN */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3097
| integer '(' error ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3098
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid array initial value in array initial values list."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3099
| integer '(' array_initial_element error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3100
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "')' missing at the end of array initial value in array initial values list."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3101
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3102
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3103
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3104
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3105
array_initial_element:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3106
  constant
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3107
| enumerated_value
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3108
| structure_initialization
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3109
| array_initialization
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3110
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3111
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3112
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3113
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3114
structure_type_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3115
/*  structure_type_name ':' structure_specification */
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3116
/* PRE_PARSING or SINGLE_PHASE_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3117
/*  The following rules will be run either by:
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3118
 *      - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3119
 *      - the standard single phase parser (when preparsing command line option is not chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3120
 */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  3121
  identifier ':' structure_specification  {library_element_symtable.insert($1, prev_declared_structure_type_name_token);}
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3122
	{if (!get_preparse_state()) $$ = new structure_type_declaration_c($1, $3, locloc(@$));}
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3123
/* POST_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3124
/*  These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  3125
| prev_declared_structure_type_name ':' structure_specification
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3126
	{$$ = new structure_type_declaration_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, locloc(@$));} // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3127
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3128
| identifier structure_specification
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3129
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between data type name and specification in structure type declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3130
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3131
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3132
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3133
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3134
structure_specification:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3135
  structure_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3136
| initialized_structure
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3137
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3138
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3139
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3140
initialized_structure:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3141
  prev_declared_structure_type_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3142
	{$$ = new initialized_structure_c($1, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3143
| prev_declared_structure_type_name ASSIGN structure_initialization
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3144
	{$$ = new initialized_structure_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3145
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3146
| prev_declared_structure_type_name structure_initialization
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3147
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' missing in structure specification with initialization."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3148
| prev_declared_structure_type_name ASSIGN error
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3149
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3150
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined in structure specification with initialization.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3151
	 else {print_err_msg(locf(@3), locl(@3), "invalid value in structure specification with initialization."); yyclearin;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3152
	 yyerrok;
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3153
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3154
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3155
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3156
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3157
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3158
structure_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3159
  STRUCT structure_element_declaration_list END_STRUCT
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3160
	{$$ = $2;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3161
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3162
| STRUCT END_STRUCT
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3163
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no structure element declared in structure type declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3164
| STRUCT error structure_element_declaration_list END_STRUCT
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3165
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'STRUCT' in structure type declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3166
| STRUCT structure_element_declaration_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3167
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed structure type declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3168
| STRUCT error END_STRUCT
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3169
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in structure type declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3170
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3171
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3172
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3173
/* helper symbol for structure_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3174
structure_element_declaration_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3175
  structure_element_declaration ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3176
	{$$ = new structure_element_declaration_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3177
| structure_element_declaration_list structure_element_declaration ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3178
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3179
/* ERROR_CHECK_BEGIN */
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  3180
| error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3181
	{$$ = new structure_element_declaration_list_c(locloc(@$)); print_err_msg(locf(@1), locl(@1), "invalid structure element declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3182
| structure_element_declaration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3183
	{$$ = new structure_element_declaration_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at end of structure element declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3184
| structure_element_declaration_list structure_element_declaration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3185
	{$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at end of structure element declaration."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  3186
| structure_element_declaration_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3187
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid structure element declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3188
| structure_element_declaration_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3189
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after structure element declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3190
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3191
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3192
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3193
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3194
structure_element_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3195
  structure_element_name ':' simple_spec_init
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3196
	{$$ = new structure_element_declaration_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3197
| structure_element_name ':' subrange_spec_init
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3198
	{$$ = new structure_element_declaration_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3199
| structure_element_name ':' enumerated_spec_init
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3200
	{$$ = new structure_element_declaration_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3201
| structure_element_name ':' array_spec_init
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3202
	{$$ = new structure_element_declaration_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3203
| structure_element_name ':' initialized_structure
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3204
	{$$ = new structure_element_declaration_c($1, $3, locloc(@$));}
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3205
| structure_element_name ':' ref_spec_init                              /* non standard extension: Allow use of struct elements storing REF_TO datatypes (either using REF_TO or a previosuly declared ref type) */
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3206
	{ $$ = new structure_element_declaration_c($1, $3, locloc(@$));
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3207
	  if (!allow_ref_to_in_derived_datatypes) {
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3208
	    print_err_msg(locf(@$), locl(@$), "REF_TO and reference datatypes may not be used in a STRUCT element (use -R option to activate support for this non-standard syntax)."); 
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3209
	    yynerrs++;
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3210
	  }
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3211
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3212
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3213
| structure_element_name simple_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3214
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between structure element name and simple specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3215
| structure_element_name subrange_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3216
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between structure element name and subrange specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3217
| structure_element_name enumerated_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3218
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between structure element name and enumerated specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3219
| structure_element_name array_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3220
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between structure element name and array specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3221
| structure_element_name initialized_structure
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3222
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between structure element name and structure specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3223
| structure_element_name ':' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3224
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3225
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no specification defined in structure element declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3226
	 else {print_err_msg(locf(@3), locl(@3), "invalid specification in structure element declaration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3227
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3228
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3229
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3230
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3231
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3232
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3233
structure_element_name: any_identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3234
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3235
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3236
structure_initialization:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3237
  '(' structure_element_initialization_list ')'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3238
	{$$ = $2;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3239
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3240
| '(' error ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3241
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid structure element initialization list in structure initialization."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3242
| '(' structure_element_initialization_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3243
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "expecting ')' at the end of structure element initialization list in structure initialization."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3244
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3245
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3246
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3247
/* helper symbol for structure_initialization */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3248
structure_element_initialization_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3249
  structure_element_initialization
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3250
	{$$ = new structure_element_initialization_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3251
| structure_element_initialization_list ',' structure_element_initialization
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3252
	{$$ = $1; $$->add_element($3);}
547
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  3253
/* ERROR_CHECK_BEGIN */
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  3254
/* The following error checking rules have been commented out. Why? Was it a typo? 
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  3255
 * Lets keep them commented out for now...
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  3256
 */
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  3257
/*
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3258
| structure_element_initialization_list structure_element_initialization
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3259
	{$$ = $1; print_err_msg(locl(@1), locf(@2), "',' missing in structure element initialization list in structure initialization."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3260
| structure_element_initialization_list ',' error
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  3261
	{$$ = $1;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3262
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no structure element initialization defined in structure initialization.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3263
	 else {print_err_msg(locf(@3), locl(@3), "invalid structure element initialization in structure initialization."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3264
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3265
	}
547
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  3266
*/
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3267
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3268
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3269
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3270
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3271
structure_element_initialization:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3272
  structure_element_name ASSIGN constant
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3273
	{$$ = new structure_element_initialization_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3274
| structure_element_name ASSIGN enumerated_value
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3275
	{$$ = new structure_element_initialization_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3276
| structure_element_name ASSIGN array_initialization
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3277
	{$$ = new structure_element_initialization_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3278
| structure_element_name ASSIGN structure_initialization
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3279
	{$$ = new structure_element_initialization_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3280
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3281
| structure_element_name constant
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3282
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' missing in structure element initialization."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3283
| structure_element_name enumerated_value
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3284
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' missing in enumerated structure element initialization."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3285
| structure_element_name array_initialization
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3286
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' missing in array structure element initialization."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3287
| structure_element_name structure_initialization
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3288
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' missing in structured structure element initialization."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3289
| structure_element_name ASSIGN error
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3290
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3291
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no initial value defined in structured structure element initialization.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3292
	 else {print_err_msg(locf(@3), locl(@3), "invalid initial value in structured structure element initialization."); yyclearin;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3293
	 yyerrok;
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3294
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3295
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3296
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3297
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3298
/* NOTE: in order to remove a reduce/reduce conflict,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3299
 *       all occurences of string_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3300
 *       have been replaced with identifier!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3301
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3302
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3303
string_type_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3304
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3305
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3306
string_type_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3307
/*  string_type_name ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init */
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3308
/* PRE_PARSING or SINGLE_PHASE_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3309
/*  The following rules will be run either by:
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3310
 *      - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3311
 *      - the standard single phase parser (when preparsing command line option is not chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3312
 */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  3313
  identifier ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init	{library_element_symtable.insert($1, prev_declared_string_type_name_token);}
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3314
	{if (!get_preparse_state()) $$ = new string_type_declaration_c($1, $3, $4, $5, locloc(@$));}
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3315
/* POST_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3316
/*  These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  3317
| prev_declared_string_type_name ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3318
	{$$ = new string_type_declaration_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, $4, $5, locloc(@$));} // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3319
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3320
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3321
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3322
/* helper symbol for string_type_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3323
string_type_declaration_size:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3324
  '[' integer ']'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3325
	{$$ = $2;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3326
/* REMOVED !! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3327
//|  /* empty */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3328
//	{$$ = NULL;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3329
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3330
/* The syntax contains a reduce/reduce conflict.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3331
 * The optional '[' <size> ']'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3332
 * has been changed to become mandatory to remove the conflict.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3333
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3334
 * The conflict arises because
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3335
 *  new_str_type : STRING := "hello!"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3336
 * may be reduced to a string_type_declaration OR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3337
 * a simple_type_declaration.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3338
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3339
 * Our change forces it to be reduced to a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3340
 * simple_type_declaration!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3341
 * We chose this option because changing the definition
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3342
 * of simple_spec_init would force us to change all the other
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3343
 * rules in which it appears. The change we made has no
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3344
 * side-effects!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3345
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3346
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3347
/* helper symbol for string_type_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3348
string_type_declaration_init:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3349
  /* empty */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3350
	{$$ = NULL;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3351
| ASSIGN character_string
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3352
	{$$ = $2;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3353
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3354
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3355
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3356
/* Taken fron IEC 61131-3 v3
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3357
 * // Table 14 - Reference operations
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3358
 * Ref_Type_Decl  : Ref_Type_Name ':' Ref_Spec_Init ;
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3359
 * Ref_Spec_Init  : Ref_Spec ( ':=' Ref_Value )? ;
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3360
 * Ref_Spec       : 'REF_TO' Non_Gen_Type_Name ;
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3361
 * Ref_Type_Name  : Identifier ;
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3362
 * Ref_Name       : Identifier ;
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3363
 * Ref_Value      : Ref_Addr | 'NULL' ;
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3364
 * Ref_Addr       : 'REF' '(' (Symbolic_Variable | FB_Name | Class_Instance_Name ) ')' ;
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3365
 * Ref_Assign     : Ref_Name ':=' (Ref_Name | Ref_Deref | Ref_Value ) ;
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3366
 * Ref_Deref      : 'DREF' '(' Ref_Name ')' ;
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3367
 */
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3368
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3369
/* NOTE: in IEC 61131-3 v3, the formal syntax definition does not define non_generic_type_name to include FB type names.
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3370
 *       However, in section "6.3.4.10 References", example 4 includes a  REF_TO a FB type!
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3371
 *       We have therefore explicitly added the "REF_TO function_block_type_name" to this rule!
923
0ad7843d3790 Add support for non standard REF_TO ANY (equivalent to void *)
mjsousa
parents: 919
diff changeset
  3372
 * NOTE: the REF_TO ANY is a non-standard extension to the standard. This is basically equivalent to a (void *)
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3373
 */
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3374
ref_spec_non_recursive: /* helper symbol, used to remove a reduce/reduce conflict in a non-standard syntax I (Mario) have added!! */
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3375
  REF_TO non_generic_type_name
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3376
	{$$ = new ref_spec_c($2, locloc(@$));}
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3377
| REF_TO function_block_type_name
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3378
	{$$ = new ref_spec_c($2, locloc(@$));}
923
0ad7843d3790 Add support for non standard REF_TO ANY (equivalent to void *)
mjsousa
parents: 919
diff changeset
  3379
| REF_TO ANY
924
9e824bb0c3d4 Make support for REF_TO ANY a command line option.
mjsousa
parents: 923
diff changeset
  3380
	{$$ = new ref_spec_c(new generic_type_any_c(locloc(@2)), locloc(@$));
9e824bb0c3d4 Make support for REF_TO ANY a command line option.
mjsousa
parents: 923
diff changeset
  3381
	 if (!allow_ref_to_any) {
9e824bb0c3d4 Make support for REF_TO ANY a command line option.
mjsousa
parents: 923
diff changeset
  3382
	   print_err_msg(locf(@$), locl(@$), "REF_TO ANY datatypes are not allowed (use -R option to activate support for this non-standard syntax)."); 
9e824bb0c3d4 Make support for REF_TO ANY a command line option.
mjsousa
parents: 923
diff changeset
  3383
	   yynerrs++;
9e824bb0c3d4 Make support for REF_TO ANY a command line option.
mjsousa
parents: 923
diff changeset
  3384
	 }
9e824bb0c3d4 Make support for REF_TO ANY a command line option.
mjsousa
parents: 923
diff changeset
  3385
	}
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3386
;
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3387
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3388
ref_spec: /* defined in IEC 61131-3 v3 */
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3389
  ref_spec_non_recursive
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3390
| prev_declared_ref_type_name 
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3391
;
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3392
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3393
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3394
/* The IEC 61131-3 v3 standard actually only defines the following syntax:
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3395
 * 
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3396
 *  Ref_Type_Decl: Ref_Type_Name ':' Ref_Spec_Init;
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3397
 *  Ref_Spec_Init: Ref_Spec ( ':=' Ref_Value )?;
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3398
 *  Ref_Spec     : 'REF_TO' + Data_Type_Access;
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3399
 *
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3400
 * Note that the above syntax it is not possible to define a REF_TO datatype as 
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3401
 * an alias to an already previously declared REF_TO datatype.
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3402
 *
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3403
 * I (Mario) believe that this is probably a bug in the IEC 61131-3 syntax, and I have therefore
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3404
 * changed that standard definition to...
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3405
 *
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3406
 *  Ref_Type_Decl: Ref_Type_Name ':' Ref_Spec_Init;
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3407
 *  Ref_Spec_Init: Ref_Spec ( ':=' Ref_Value )?;
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3408
 *  Ref_Spec     : ('REF_TO' + Data_Type_Access) | Ref_Type_Name;
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3409
 *  
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3410
 * For example:
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3411
 *       TYPE
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3412
 *          ref1_t: REF_TO INT;
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3413
 *          ref2_t: ref1_t;    <-- without the above changes, this would not be allowed!!
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3414
 *       END_TYPE
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3415
 *
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3416
 * This change also makes it possible to declare variables using a previously declared REF_TO datatype
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3417
 *  For example:
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3418
 *     VAR  refvar: ref1_t; END_VAR
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3419
 *
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3420
 * This change also makes it possible to declare arrays containing a previously declared ref type.
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3421
 *  For example:
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3422
 *     VAR  refvar: ARRAY [1..3] OF ref1_t;     END_VAR   <--- becomes OK
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3423
 *     VAR  refvar: ARRAY [1..3] OF REF_TO INT; END_VAR   <--- still not OK. (Only becomes OK with other non-standard rules in another location of this file!)
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3424
 *
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3425
 * Interestingly, this change does NOT make it possible to declare structure elements of a previously declared ref type.
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3426
 *  For example:
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3427
 *     TYPE struct_t: STRUCT elem1: ref1_t;     END_STRUCT; END_TYPE;    <--- still not OK. (Only becomes OK with other non-standard rules in another location of this file!)
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3428
 *     TYPE struct_t: STRUCT elem1: REF_TO INT; END_STRUCT; END_TYPE;    <--- still not OK. (Only becomes OK with other non-standard rules in another location of this file!)
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3429
 */
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3430
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3431
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3432
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3433
ref_spec_init: /* defined in IEC 61131-3 v3 */
909
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 894
diff changeset
  3434
  ref_spec
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 894
diff changeset
  3435
	{$$ = new ref_spec_init_c($1, NULL, locloc(@$));}
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 894
diff changeset
  3436
/*  For the moment, we do not support initialising reference data types...
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 894
diff changeset
  3437
| ref_spec ASSIGN ... 
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 894
diff changeset
  3438
	{$$ = new ref_spec_init_c($1, $3, locloc(@$));}
8b2a31dea131 Add support for REF_TO derived datatypes (along with datatype verification)
mjsousa
parents: 894
diff changeset
  3439
*/
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3440
;
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3441
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3442
ref_type_decl:  /* defined in IEC 61131-3 v3 */
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3443
/* PRE_PARSING or SINGLE_PHASE_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3444
/*  The following rules will be run either by:
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3445
 *      - the pre_parsing phase of two phase parsing (when preparsing command line option is chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3446
 *      - the standard single phase parser (when preparsing command line option is not chosen).
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3447
 */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  3448
  identifier ':' ref_spec_init  {library_element_symtable.insert($1, prev_declared_ref_type_name_token);}
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3449
	{if (!get_preparse_state()) $$ = new ref_type_decl_c($1, $3, locloc(@$));}
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3450
/* POST_PARSING */
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3451
/*  These rules will be run after the preparser phase of two phase parsing has finished (only gets to execute if preparsing command line option is chosen). */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  3452
| prev_declared_ref_type_name ':' ref_spec_init
954
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3453
	{$$ = new ref_type_decl_c(new identifier_c(((token_c *)$1)->value, locloc(@1)), $3, locloc(@$));}  // change the derived_datatype_identifier_c into an identifier_c, as it will be taking the place of an identifier!
a3f6039f1684 Fix AST generated by parsing with preparsing switched on, and allow parsing to work with preparsing off.
mjsousa
parents: 953
diff changeset
  3454
;
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3455
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3456
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3457
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3458
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3459
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  3460
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3461
/*********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3462
/* B 1.4 - Variables */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3463
/*********************/
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3464
/* NOTE: The standard is erroneous in it's definition of 'variable' because:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3465
 *         - The standard considers 'ENO' as a keyword...
315
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3466
 *         - ...=> which means that it may never be parsed as an 'identifier'...
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3467
 *         - ...=> and therefore may never be used as the name of a variable inside an expression.
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3468
 *         - However, a function/FB must be able to assign the ENO parameter
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3469
 *           it's value, doing it in an assignment statement, and therefore using the 'ENO'
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3470
 *           character sequence as an identifier!
315
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3471
 *        The obvious solution is to also allow the ENO keyword to be 
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3472
 *         used as the name of a variable. Note that this variable may be used
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3473
 *         even though it is not explicitly declared as a function/FB variable,
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3474
 *         as the standard requires us to define it implicitly in this case!
315
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3475
 *        There are three ways of achieving this:
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3476
 *          (i) simply not define EN and ENO as keywords in flex (lexical analyser)
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3477
 *              and let them be considered 'identifiers'. Aditionally, add some code
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3478
 *              so that if they are not explicitly declared, we add them automatically to
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3479
 *              the declaration of each Functions and FB, where they would then be parsed
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3480
 *              as a previously_declared_variable.
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3481
 *              This approach has the advantage the EN and ENO would automatically be valid
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3482
 *              in every location where it needs to be valid, namely in the explicit declaration 
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3483
 *              of these same variables, or when they are used within expressions.
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3484
 *              However, this approach has the drawback that 
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3485
 *              EN and ENO could then also be used anywhere a standard identifier is allowed,
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3486
 *              including in the naming of Functions, FBs, Programs, Configurations, Resources, 
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3487
 *              SFC Actions, SFC Steps, etc...
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3488
 *              This would mean that we would then have to add a lexical analysis check
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3489
 *              within the bison code (syntax analyser) to all the above constructs to make sure
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3490
 *              that the identifier being used is not EN or ENO.
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3491
 *         (ii) The other approach is to define EN and ENO as keywords / tokens in flex
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3492
 *              (lexical analyser) and then change the syntax in bison to acomodate 
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3493
 *              these tokens wherever they could correctly appear.
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3494
 *              This has the drawback that we need to do some changes to the synax defintion.
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3495
 *        (iii) Yet a another option is to mix the above two methods.
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3496
 *              Define EN and ENO as tokens in flex, but change (only) the syntax for
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3497
 *              variable declaration to allow these tokens to also be used in declaring variables.
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3498
 *              From this point onwards these tokens are then considered a previously_declared_variable,
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3499
 *              since flex will first check for this before even checking for tokens.
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3500
 *
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3501
 *              I (Mario) cuurretnly (2011) believe the cleanest method of achieving this goal
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3502
 *              is to use option (iii)
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3503
 *              However, considering that:
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3504
 *                - I have already previously implemented option (ii);
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3505
 *                - option (iii) requires that flex parse the previously_declared_variable
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3506
 *                   before parsing any token. We already support this (remeber that this is 
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3507
 *                   used mainly to allow some IL operators as well as PRIORITY, etc. tokens
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3508
 *                   to be used as identifiers, since the standard does not define them as keywords),
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3509
 *                   but this part of the code in flex is often commented out as usually people do not expect
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3510
 *                   us to follow the standard in the strict sense, but rather consider those
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3511
 *                   tokens as keywords;
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3512
 *                considering the above, we currently carry on using option (ii).
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3513
 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3514
variable:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3515
  symbolic_variable
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  3516
| prev_declared_direct_variable
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3517
| eno_identifier
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3518
	{$$ = new symbolic_variable_c($1, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3519
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3520
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3521
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3522
symbolic_variable:
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3523
/* NOTE: To be entirely correct, variable_name must be replacemed by
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3524
 *         prev_declared_variable_name | prev_declared_fb_name | prev_declared_global_var_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3525
 */
78
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  3526
  prev_declared_fb_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3527
	{$$ = new symbolic_variable_c($1, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3528
| prev_declared_global_var_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3529
	{$$ = new symbolic_variable_c($1, locloc(@$));}
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  3530
| prev_declared_variable_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3531
	{$$ = new symbolic_variable_c($1, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3532
| multi_element_variable
78
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  3533
/*
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  3534
| identifier
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  3535
	{$$ = new symbolic_variable_c($1, locloc(@$));}
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  3536
*/
933
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3537
| symbolic_variable '^'     
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3538
	/* Dereferencing operator defined in IEC 61131-3 v3. However, implemented here differently then how it is defined in the standard! See following note for explanation! */
936
0f7bcc160568 Fix bug: Add support for de-referencing pointers to struct (struct_ptr^.elem1) when used inside FB.
mjsousa
parents: 934
diff changeset
  3539
	{$$ = new deref_operator_c($1, locloc(@$));
934
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
  3540
	 if (!allow_ref_dereferencing) {
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
  3541
	   print_err_msg(locf(@$), locl(@$), "Derefencing REF_TO datatypes with '^' is not allowed (use -r option to activate support for this IEC 61131-3 v3 feature)."); 
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
  3542
	   yynerrs++;
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
  3543
	 }
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
  3544
}
933
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3545
;
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3546
/*
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3547
 * NOTE: The syntax defined in the v3 standard for the dereferencing operator '^' seems to me to be un-intentionally
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3548
 *       limited. For example
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3549
 *         ref_to_bool_var := REF(        array_of_bool [1] );   <---     Allowed!
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3550
 *         ref_to_bool_var := REF( ref_to_array_of_bool^[1] );   <---     Allowed!
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3551
 *         bool_var        := array_of_ref_to_bool[1]^;          <--- NOT Allowed!
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3552
 *         ref_to_array_of_bool^[1] := FALSE;                    <---     Allowed!
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3553
 *       I consider this a bug in the v3 standard!!
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3554
 *       I have therefore opted to implement this by simply adding a rule to symbolic_variable 
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3555
 *         symbolic_variable: 
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3556
 *                ...
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3557
 *           | symbolic_variable '^'
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3558
 *       This simple rule should be able to cover all the needed dereferencing syntax!
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3559
 *       I have also added a dereferencing expression for the DREF() operator.
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3560
 *       Since both of them do the exact same operation, they will both be translated to the exact same
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3561
 *       entry type in the abstract syntax tree (an deref_expression_c)
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  3562
 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3563
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3564
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3565
/* NOTE: in section B 1.7, when configuring a program, symbolic_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3566
 *       is used. Nevertheless, during the parsing of a configuration,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3567
 *       the variables in question are out of scope, so we should
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3568
 *       be allowing any_identifier instead of prev_declared_variable_name!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3569
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3570
 *       We therefore need a new any_symbolic_variable construct that
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3571
 *       allows the use of any_identifier instead of previously declared
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3572
 *       variables, function blocks, etc...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3573
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3574
any_symbolic_variable:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3575
// variable_name -> replaced by any_identifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3576
  any_identifier
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3577
	{$$ = new symbolic_variable_c($1, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3578
| any_multi_element_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3579
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3580
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3581
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3582
/* for yet undeclared variable names ! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3583
variable_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3584
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3585
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3586
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3587
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3588
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3589
/********************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3590
/* B.1.4.1   Directly Represented Variables */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3591
/********************************************/
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  3592
prev_declared_direct_variable: prev_declared_direct_variable_token	{$$ = new direct_variable_c($1, locloc(@$));};
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3593
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3594
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3595
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3596
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3597
/*************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3598
/* B.1.4.2   Multi-element Variables */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3599
/*************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3600
multi_element_variable:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3601
  array_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3602
| structured_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3603
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3604
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3605
/* please see note above any_symbolic_variable */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3606
any_multi_element_variable:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3607
  any_array_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3608
| any_structured_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3609
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3610
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3611
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3612
array_variable:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3613
  subscripted_variable '[' subscript_list ']'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3614
	{$$ = new array_variable_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3615
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3616
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3617
/* please see note above any_symbolic_variable */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3618
any_array_variable:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3619
  any_subscripted_variable '[' subscript_list ']'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3620
	{$$ = new array_variable_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3621
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3622
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3623
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3624
subscripted_variable:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3625
  symbolic_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3626
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3627
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3628
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3629
/* please see note above any_symbolic_variable */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3630
any_subscripted_variable:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3631
  any_symbolic_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3632
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3633
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3634
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3635
subscript_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3636
  subscript
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3637
	{$$ = new subscript_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3638
| subscript_list ',' subscript
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3639
	{$$ = $1; $$->add_element($3);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3640
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3641
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3642
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3643
subscript:  expression;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3644
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3645
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3646
structured_variable:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3647
  record_variable '.' field_selector
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3648
	{$$ = new structured_variable_c($1, $3, locloc(@$));}
382
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  3649
| record_variable '.' il_simple_operator_clash3
469
9fe6c4633ed6 Fix bug in building structured variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 453
diff changeset
  3650
    {$$ = new structured_variable_c($1, il_operator_c_2_identifier_c($3), locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3651
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3652
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3653
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3654
/* please see note above any_symbolic_variable */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3655
any_structured_variable:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3656
  any_record_variable '.' field_selector
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3657
	{$$ = new structured_variable_c($1, $3, locloc(@$));}
382
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  3658
| any_record_variable '.' il_simple_operator_clash3
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  3659
	{$$ = new structured_variable_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3660
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3661
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3662
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3663
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3664
record_variable:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3665
  symbolic_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3666
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3667
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3668
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3669
/* please see note above any_symbolic_variable */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3670
any_record_variable:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3671
  any_symbolic_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3672
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3673
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3674
315
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3675
field_selector: 
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3676
  any_identifier
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3677
| eno_identifier
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3678
;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3679
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3680
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3681
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3682
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3683
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3684
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3685
/******************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3686
/* B 1.4.3 - Declaration & Initialisation */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3687
/******************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3688
input_declarations:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3689
  VAR_INPUT            input_declaration_list END_VAR
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3690
	{$$ = new input_declarations_c(NULL, $2, new explicit_definition_c(), locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3691
| VAR_INPUT RETAIN     input_declaration_list END_VAR
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3692
	{$$ = new input_declarations_c(new retain_option_c(locloc(@2)), $3, new explicit_definition_c(), locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3693
| VAR_INPUT NON_RETAIN input_declaration_list END_VAR
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3694
	{$$ = new input_declarations_c(new non_retain_option_c(locloc(@2)), $3, new explicit_definition_c(), locloc(@$));}
95
b119b1db0a7a Changing format of error reporting.
mario
parents: 94
diff changeset
  3695
/* ERROR_CHECK_BEGIN */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3696
| VAR_INPUT END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3697
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no variable declared in input variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3698
| VAR_INPUT RETAIN END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3699
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable declared in retentive input variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3700
| VAR_INPUT NON_RETAIN END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3701
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable declared in non-retentive input variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3702
| VAR_INPUT error input_declaration_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3703
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'VAR_INPUT' in input variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3704
| VAR_INPUT RETAIN error input_declaration_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3705
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'RETAIN' in retentive input variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3706
| VAR_INPUT NON_RETAIN error input_declaration_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3707
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'NON_RETAIN' in non-retentive input variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3708
| VAR_INPUT input_declaration_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3709
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed input variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3710
| VAR_INPUT RETAIN input_declaration_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3711
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed retentive input variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3712
| VAR_INPUT NON_RETAIN input_declaration_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3713
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed non-retentive input variable(s) declaration."); yyerrok;}
95
b119b1db0a7a Changing format of error reporting.
mario
parents: 94
diff changeset
  3714
| VAR_INPUT error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3715
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in input variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3716
| VAR_INPUT RETAIN error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3717
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unknown error in retentive input variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3718
| VAR_INPUT NON_RETAIN error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3719
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unknown error in non-retentive input variable(s) declaration."); yyerrok;}
95
b119b1db0a7a Changing format of error reporting.
mario
parents: 94
diff changeset
  3720
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3721
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3722
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3723
/* helper symbol for input_declarations */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3724
input_declaration_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3725
  input_declaration ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3726
	{$$ = new input_declaration_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3727
| input_declaration_list input_declaration ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3728
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3729
/* ERROR_CHECK_BEGIN */
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  3730
| error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3731
	{$$ = new input_declaration_list_c(locloc(@$)); print_err_msg(locf(@1), locl(@1), "invalid input variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3732
| input_declaration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3733
	{$$ = new input_declaration_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at end of input variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3734
| input_declaration_list input_declaration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3735
	{$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at end of input variable(s) declaration."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  3736
| input_declaration_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3737
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid input variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3738
| input_declaration_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3739
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after input variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3740
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3741
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3742
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3743
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3744
/* NOTE: The formal definition of 'input_declaration' as defined in the standard is erroneous,
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3745
 *       as it does not allow a user defined 'EN' input parameter. However,
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3746
 *       The semantic description of the languages clearly states that this is allowed.
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3747
 *       We have added the 'en_param_declaration' clause to cover for this.
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3748
 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3749
input_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3750
  var_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3751
| edge_declaration
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3752
| en_param_declaration
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3753
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3754
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3755
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3756
edge_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3757
  var1_list ':' BOOL R_EDGE
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3758
	{$$ = new edge_declaration_c(new raising_edge_option_c(locloc(@3)), $1, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3759
| var1_list ':' BOOL F_EDGE
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3760
	{$$ = new edge_declaration_c(new falling_edge_option_c(locloc(@3)), $1, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3761
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3762
| var1_list BOOL R_EDGE
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3763
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and specification in edge declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3764
| var1_list BOOL F_EDGE
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3765
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and specification in edge declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3766
| var1_list ':' BOOL R_EDGE F_EDGE
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3767
	{$$ = NULL; print_err_msg(locl(@5), locf(@5), "'R_EDGE' and 'F_EDGE' can't be present at the same time in edge declaration."); yynerrs++;}
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3768
| var1_list ':' BOOL F_EDGE R_EDGE
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3769
	{$$ = NULL; print_err_msg(locl(@5), locf(@5), "'R_EDGE' and 'F_EDGE' can't be present at the same time in edge declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3770
| var1_list ':' R_EDGE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3771
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "'BOOL' missing in edge declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3772
| var1_list ':' F_EDGE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3773
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "'BOOL' missing in edge declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3774
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3775
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3776
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3777
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3778
/* NOTE: The formal definition of the standard is erroneous, as it simply does not
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3779
 *       consider the EN and ENO keywords!
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3780
 *       The semantic description of the languages clearly states that these may be
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3781
 *       used in several ways. One of them is to declare an EN input parameter.
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3782
 *       We have added the 'en_param_declaration' clause to cover for this.
315
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3783
 *
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  3784
 *       Please read the comment above the definition of 'variable' in section B1.4 for details.
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3785
 */
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3786
en_param_declaration:
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3787
  en_identifier ':' BOOL ASSIGN boolean_literal
805
b737cfc92614 Use simple_spec_init_c inside en_param_declaration_c (will reduce need to handle it as a special case in the future).
Mario de Sousa <msousa@fe.up.pt>
parents: 761
diff changeset
  3788
  {$$ = new en_param_declaration_c($1, new simple_spec_init_c(new bool_type_name_c(locloc(@3)), $5, locf(@3), locl(@5)), new explicit_definition_c(), locloc(@$));}
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3789
| en_identifier ':' BOOL ASSIGN integer
805
b737cfc92614 Use simple_spec_init_c inside en_param_declaration_c (will reduce need to handle it as a special case in the future).
Mario de Sousa <msousa@fe.up.pt>
parents: 761
diff changeset
  3790
  {$$ = new en_param_declaration_c($1, new simple_spec_init_c(new bool_type_name_c(locloc(@3)), $5, locf(@3), locl(@5)), new explicit_definition_c(), locloc(@$));}
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3791
/* ERROR_CHECK_BEGIN */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3792
| en_identifier BOOL ASSIGN boolean_literal
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3793
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and specification in EN declaration."); yynerrs++;}
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3794
| en_identifier BOOL ASSIGN integer
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3795
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and specification in EN declaration."); yynerrs++;}
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3796
| en_identifier ':' ASSIGN boolean_literal
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3797
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "'BOOL' missing in EN declaration."); yynerrs++;}
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3798
| en_identifier ':' ASSIGN integer
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3799
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "'BOOL' missing in EN declaration."); yynerrs++;}
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  3800
| en_identifier ':' BOOL ASSIGN error
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3801
	{$$ = NULL;
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3802
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no specification defined in EN declaration.");}
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3803
	 else {print_err_msg(locf(@3), locl(@3), "invalid specification in EN declaration."); yyclearin;}
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3804
	 yyerrok;
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3805
	}
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3806
/* ERROR_CHECK_END */
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  3807
;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3808
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3809
var_init_decl:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3810
  var1_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3811
| array_var_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3812
| structured_var_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3813
| fb_name_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3814
| string_var_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3815
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3816
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3817
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3818
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3819
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3820
var1_init_decl:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3821
  var1_list ':' simple_spec_init
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3822
	{$$ = new var1_init_decl_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3823
| var1_list ':' subrange_spec_init
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3824
	{$$ = new var1_init_decl_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3825
| var1_list ':' enumerated_spec_init
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3826
	{$$ = new var1_init_decl_c($1, $3, locloc(@$));}
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3827
| var1_list ':' ref_spec_init   /* defined in IEC 61131-3 v3   (REF_TO ...)*/
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  3828
	{$$ = new var1_init_decl_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3829
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3830
| var1_list simple_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3831
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and simple specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3832
| var1_list subrange_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3833
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and subrange specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3834
| var1_list enumerated_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3835
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and enumerated specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3836
| var1_list ':' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3837
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3838
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no specification defined in variable declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3839
	 else {print_err_msg(locf(@3), locl(@3), "invalid specification in variable declaration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3840
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3841
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3842
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3843
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3844
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3845
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3846
/* NOTE: 
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3847
 * The syntax 
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3848
 *    variable_name DOTDOT 
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3849
 * is an extension to the standard!!! 
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3850
 *
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3851
 * In order to be able to handle extensible standard functions
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3852
 * (i.e. standard functions that may have a variable number of
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3853
 * input parameters, such as AND(word#33, word#44, word#55, word#66),
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3854
 * we have extended the acceptable syntax to allow var_name '..'
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3855
 * in an input variable declaration.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3856
 *
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3857
 * This allows us to parse the declaration of standard
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3858
 * extensible functions and load their interface definition
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3859
 * into the abstract syntax tree just like we do to other 
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3860
 * user defined functions.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3861
 * This has the advantage that we can later do semantic
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3862
 * checking of calls to functions (be it a standard or user defined
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3863
 * function) in (almost) exactly the same way.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3864
 *
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3865
 * Of course, we have a flag that disables this syntax when parsing user
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3866
 * written code, so we only allow this extra syntax while parsing the 
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3867
 * 'header' file that declares all the standard IEC 61131-3 functions.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3868
 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3869
var1_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3870
  variable_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3871
	{$$ = new var1_list_c(locloc(@$)); $$->add_element($1);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3872
	 variable_name_symtable.insert($1, prev_declared_variable_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3873
	}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3874
| variable_name integer DOTDOT
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3875
	{$$ = new var1_list_c(locloc(@$)); $$->add_element(new extensible_input_parameter_c($1, $2, locloc(@$)));
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3876
	 variable_name_symtable.insert($1, prev_declared_variable_name_token);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3877
	 if (!allow_extensible_function_parameters) print_err_msg(locf(@1), locl(@2), "invalid syntax in variable name declaration.");
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3878
	}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3879
 | var1_list ',' variable_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3880
	{$$ = $1; $$->add_element($3);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3881
	 variable_name_symtable.insert($3, prev_declared_variable_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3882
	}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3883
 | var1_list ',' variable_name integer DOTDOT
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3884
	{$$ = $1; $$->add_element(new extensible_input_parameter_c($3, $4, locloc(@$)));
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3885
	 variable_name_symtable.insert($3, prev_declared_variable_name_token);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3886
	 if (!allow_extensible_function_parameters) print_err_msg(locf(@1), locl(@2), "invalid syntax in variable name declaration.");
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  3887
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3888
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3889
| var1_list variable_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3890
	{$$ = $1; print_err_msg(locl(@1), locf(@2), "',' missing in variable list."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3891
| var1_list ',' error
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  3892
	{$$ = $1;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3893
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no variable name defined in variable declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3894
	 else {print_err_msg(locf(@3), locl(@3), "invalid variable name in variable declaration."); yyclearin;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  3895
	 yyerrok;
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3896
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3897
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3898
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3899
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3900
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3901
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3902
array_var_init_decl:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3903
 var1_list ':' array_spec_init
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3904
	{$$ = new array_var_init_decl_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3905
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3906
| var1_list array_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3907
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and array specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3908
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3909
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3910
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3911
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3912
structured_var_init_decl:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3913
  var1_list ':' initialized_structure
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3914
	{$$ = new structured_var_init_decl_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3915
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3916
| var1_list initialized_structure
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3917
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and structured specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3918
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3919
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3920
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3921
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3922
/* NOTE: see notes above fb_name_list and var1_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3923
 *       for reason why ':' was removed from this rule!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3924
 *       In essence, to remove a shift/reduce conflict,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3925
 *       the ':' was moved to var1_list and fb_name_list!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3926
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3927
fb_name_decl:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3928
/*  fb_name_list ':' function_block_type_name */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3929
  fb_name_list_with_colon function_block_type_name
810
d9c48ad646f1 Add a new node to the abstract symtax tree, which will let us do datatype checking of FB variable declarations using the standard algorithm, and no special cases.
Mario de Sousa <msousa@fe.up.pt>
parents: 805
diff changeset
  3930
	{$$ = new fb_name_decl_c($1, new fb_spec_init_c($2, NULL,locloc(@2)), locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3931
/*| fb_name_list ':' function_block_type_name ASSIGN structure_initialization */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3932
| fb_name_list_with_colon function_block_type_name ASSIGN structure_initialization
810
d9c48ad646f1 Add a new node to the abstract symtax tree, which will let us do datatype checking of FB variable declarations using the standard algorithm, and no special cases.
Mario de Sousa <msousa@fe.up.pt>
parents: 805
diff changeset
  3933
	{$$ = new fb_name_decl_c($1, new fb_spec_init_c($2, $4, locf(@2), locl(@4)), locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3934
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3935
| fb_name_list_with_colon ASSIGN structure_initialization
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3936
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no function block type name defined in function block declaration with initialization."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3937
| fb_name_list_with_colon function_block_type_name structure_initialization
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3938
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "':=' missing in function block declaration with initialization."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3939
| fb_name_list_with_colon function_block_type_name ASSIGN error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3940
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3941
	 if (is_current_syntax_token()) {print_err_msg(locl(@3), locf(@4), "no initialization defined in function block declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  3942
	 else {print_err_msg(locf(@4), locl(@4), "invalid initialization in function block declaration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3943
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3944
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  3945
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3946
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3947
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3948
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3949
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3950
/* NOTE: In order to remove a reduce/reduce conflict between
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3951
 *       var1_list and fb_name_list, which are identical to each
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3952
 *       other, fb_name_list has been redefined to be a var1_list.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3953
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3954
 *        In order to remove a further shift/reduce conflict, var1_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3955
 *        is imediately transfomred into var1_list_with_colon
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3956
 *        (i.e. it includes the ':' following the list), which
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3957
 *        means that fb_name_list is built from a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3958
 *        var1_list_with_colon after all!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3959
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3960
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3961
fb_name_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3962
 (*  fb_name *)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3963
  identifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3964
	{$$ = new fb_name_list_c($1);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3965
	 variable_name_symtable.insert($1, prev_declared_fb_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3966
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3967
(* | fb_name_list ',' fb_name *)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3968
| fb_name_list ',' identifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3969
	{$$ = $1; $$->add_element($3);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3970
	 variable_name_symtable.insert($3, prev_declared_fb_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3971
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3972
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3973
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3974
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3975
fb_name_list_with_colon:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3976
  var1_list_with_colon
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  3977
	{$$ = new fb_name_list_c(locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3978
	 /* fill up the new fb_name_list_c object with the references
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3979
	  * contained in the var1_list_c object.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3980
	  */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3981
	 FOR_EACH_ELEMENT(elem, $1, {$$->add_element(elem);});
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3982
	 delete $1;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3983
	 /* change the tokens associated with the symbols stored in
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3984
	  * the variable name symbol table from prev_declared_variable_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3985
	  * to prev_declared_fb_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3986
	  */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3987
	 FOR_EACH_ELEMENT(elem, $$, {variable_name_symtable.set(elem, prev_declared_fb_name_token);});
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3988
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3989
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3990
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3991
/* helper symbol for fb_name_list_with_colon */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3992
var1_list_with_colon:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3993
  var1_list ':'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3994
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3995
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3996
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3997
// fb_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3998
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  3999
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4000
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4001
output_declarations:
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4002
  VAR_OUTPUT var_output_init_decl_list END_VAR
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4003
	{$$ = new output_declarations_c(NULL, $2, new explicit_definition_c(), locloc(@$));}
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4004
| VAR_OUTPUT RETAIN var_output_init_decl_list END_VAR
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4005
	{$$ = new output_declarations_c(new retain_option_c(locloc(@2)), $3, new explicit_definition_c(), locloc(@$));}
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4006
| VAR_OUTPUT NON_RETAIN var_output_init_decl_list END_VAR
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4007
	{$$ = new output_declarations_c(new non_retain_option_c(locloc(@2)), $3, new explicit_definition_c(), locloc(@$));}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4008
/* ERROR_CHECK_BEGIN */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4009
| VAR_OUTPUT END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4010
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no variable declared in output variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4011
| VAR_OUTPUT RETAIN END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4012
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable declared in retentive output variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4013
| VAR_OUTPUT NON_RETAIN END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4014
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable declared in non-retentive output variable(s) declaration."); yynerrs++;}
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4015
| VAR_OUTPUT error var_output_init_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4016
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'VAR_OUPUT' in output variable(s) declaration."); yyerrok;}
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4017
| VAR_OUTPUT RETAIN error var_output_init_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4018
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'RETAIN' in retentive output variable(s) declaration."); yyerrok;}
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4019
| VAR_OUTPUT NON_RETAIN error var_output_init_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4020
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'NON_RETAIN' in non-retentive output variable(s) declaration."); yyerrok;}
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4021
| VAR_OUTPUT var_output_init_decl_list error END_OF_INPUT
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4022
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed output variable(s) declaration."); yyerrok;}
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4023
| VAR_OUTPUT RETAIN var_output_init_decl_list error END_OF_INPUT
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4024
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed retentive output variable(s) declaration."); yyerrok;}
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4025
| VAR_OUTPUT NON_RETAIN var_output_init_decl_list error END_OF_INPUT
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4026
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed non-retentive output variable(s) declaration."); yyerrok;}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4027
| VAR_OUTPUT error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4028
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in output variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4029
| VAR_OUTPUT RETAIN error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4030
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unknown error in retentive output variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4031
| VAR_OUTPUT NON_RETAIN error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4032
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unknown error in non-retentive output variable(s) declaration."); yyerrok;}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4033
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4034
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4035
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4036
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4037
/* NOTE: The formal definition of 'var_output_init_decl' as defined in the standard is erroneous,
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4038
 *       as it does not allow a user defined 'ENO' output parameter. However,
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4039
 *       The semantic description of the languages clearly states that this is allowed.
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4040
 *       We have added the 'eno_param_declaration' clause to cover for this.
315
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  4041
 *
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  4042
 *       Please read the comment above the definition of 'variable' in section B1.4 for details.
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4043
 */
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4044
var_output_init_decl:
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4045
  var_init_decl
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4046
| eno_param_declaration
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4047
;
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4048
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4049
var_output_init_decl_list:
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4050
  var_output_init_decl ';'
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4051
	{$$ = new var_init_decl_list_c(locloc(@$)); $$->add_element($1);}
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4052
| var_output_init_decl_list var_output_init_decl ';'
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4053
	{$$ = $1; $$->add_element($2);}
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4054
/* ERROR_CHECK_BEGIN */
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4055
| var_output_init_decl_list var_output_init_decl error
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4056
	{$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at end of variable(s) declaration."); yyerrok;}
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4057
| var_output_init_decl_list error ';'
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4058
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid variable(s) declaration."); yyerrok;}
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4059
/* ERROR_CHECK_END */
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4060
;
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4061
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4062
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4063
/* NOTE: The formal definition of the standard is erroneous, as it simply does not
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4064
 *       consider the EN and ENO keywords!
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4065
 *       The semantic description of the languages clearly states that these may be
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4066
 *       used in several ways. One of them is to declare an ENO output parameter.
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4067
 *       We have added the 'eno_param_declaration' clause to cover for this.
315
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  4068
 *
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  4069
 *       Please read the comment above the definition of 'variable' in section B1.4 for details.
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4070
 */
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4071
eno_param_declaration:
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4072
  eno_identifier ':' BOOL
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4073
  /* NOTE We do _NOT_ include this variable in the previously_declared_variable symbol table!
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4074
   *      Please read the comment above the definition of 'variable' for the reason for this.
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4075
   */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4076
  {$$ = new eno_param_declaration_c($1, new bool_type_name_c(locloc(@$)), new explicit_definition_c(), locloc(@$));}
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4077
/* ERROR_CHECK_BEGIN */
207
56ee922d0112 Bug in eno_param_declaration error handle fixed
laurent
parents: 202
diff changeset
  4078
| eno_identifier BOOL
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  4079
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and specification in ENO declaration."); yynerrs++;}
207
56ee922d0112 Bug in eno_param_declaration error handle fixed
laurent
parents: 202
diff changeset
  4080
| eno_identifier ':' error
146
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4081
	{$$ = NULL;
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4082
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no specification defined in ENO declaration.");}
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4083
	 else {print_err_msg(locf(@3), locl(@3), "invalid specification in ENO declaration."); yyclearin;}
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4084
	 yyerrok;
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4085
	}
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4086
/* ERROR_CHECK_END */
eef5e62048c7 Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents: 143
diff changeset
  4087
;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4088
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4089
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4090
input_output_declarations:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4091
  VAR_IN_OUT var_declaration_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4092
	{$$ = new input_output_declarations_c($2, locloc(@$));}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4093
/* ERROR_CHECK_BEGIN */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4094
| VAR_IN_OUT END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4095
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no variable declared in in_out variable(s) declaration."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4096
| VAR_IN_OUT error var_declaration_list END_VAR
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4097
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'VAR_IN_OUT' in in_out variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4098
| VAR_IN_OUT var_declaration_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4099
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed in_out variable(s) declaration."); yyerrok;}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4100
| VAR_IN_OUT error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4101
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in in_out variable(s) declaration."); yyerrok;}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4102
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4103
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4104
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4105
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4106
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4107
/* helper symbol for input_output_declarations */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4108
var_declaration_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4109
  var_declaration ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4110
	{$$ = new var_declaration_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4111
| var_declaration_list var_declaration ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4112
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4113
/* ERROR_CHECK_BEGIN */
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  4114
| error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4115
	{$$ = new var_declaration_list_c(locloc(@$)); print_err_msg(locf(@1), locl(@1), "invalid variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4116
| var_declaration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4117
	{$$ = new var_declaration_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at end of variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4118
| var_declaration_list var_declaration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4119
	{$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at end of variable(s) declaration."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  4120
| var_declaration_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4121
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4122
| var_declaration_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4123
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4124
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4125
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4126
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4127
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4128
var_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4129
  temp_var_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4130
| fb_name_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4131
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4132
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4133
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4134
temp_var_decl:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4135
  var1_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4136
| array_var_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4137
| structured_var_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4138
| string_var_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4139
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4140
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4141
var1_declaration:
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  4142
  var1_list ':' simple_specification
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4143
	{$$ = new var1_init_decl_c($1, $3, locloc(@$));}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  4144
| var1_list ':' subrange_specification
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4145
	{$$ = new var1_init_decl_c($1, $3, locloc(@$));}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  4146
| var1_list ':' enumerated_specification
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4147
	{$$ = new var1_init_decl_c($1, $3, locloc(@$));}
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  4148
| var1_list ':' ref_spec   /* defined in IEC 61131-3 v3   (REF_TO ...)*/
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  4149
	{$$ = new var1_init_decl_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4150
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4151
| var1_list simple_specification
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4152
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and simple specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4153
| var1_list subrange_specification
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4154
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and subrange specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4155
| var1_list enumerated_specification
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4156
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and enumerated specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4157
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4158
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4159
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4160
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4161
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4162
array_var_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4163
  var1_list ':' array_specification
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4164
	{$$ = new array_var_declaration_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4165
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4166
| var1_list array_specification
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4167
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and array specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4168
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4169
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4170
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4171
structured_var_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4172
  var1_list ':' prev_declared_structure_type_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4173
	{$$ = new structured_var_declaration_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4174
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4175
| var1_list prev_declared_structure_type_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4176
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and structured specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4177
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4178
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4179
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4180
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4181
var_declarations:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4182
  VAR var_init_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4183
	{$$ = new var_declarations_c(NULL, $2, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4184
| VAR CONSTANT var_init_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4185
	{$$ = new var_declarations_c(new constant_option_c(locloc(@2)), $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4186
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4187
| VAR END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4188
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no variable declared in variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4189
| VAR CONSTANT END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4190
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable declared in constant variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4191
| VAR error var_init_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4192
	{$$ = NULL; print_err_msg(locl(@1), locf(@3), "unexpected token after 'VAR' in variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4193
| VAR CONSTANT error var_init_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4194
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'CONSTANT' in constant variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4195
| VAR var_init_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4196
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4197
| VAR CONSTANT var_init_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4198
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed constant variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4199
| VAR error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4200
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4201
| VAR CONSTANT error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4202
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unknown error in constant variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4203
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4204
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4205
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4206
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4207
retentive_var_declarations:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4208
  VAR RETAIN var_init_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4209
	{$$ = new retentive_var_declarations_c($3, locloc(@$));}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4210
/* ERROR_CHECK_BEGIN */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4211
| VAR RETAIN END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4212
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable declared in retentive variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4213
| VAR RETAIN error var_init_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4214
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'RETAIN' in retentive variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4215
| VAR RETAIN var_init_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4216
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed retentive variable(s) declaration."); yyerrok;}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4217
| VAR RETAIN error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4218
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unknown error in retentive variable(s) declaration."); yyerrok;}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4219
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4220
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4221
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4222
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4223
located_var_declarations:
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4224
  VAR located_var_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4225
	{$$ = new located_var_declarations_c(NULL, $2, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4226
| VAR CONSTANT located_var_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4227
	{$$ = new located_var_declarations_c(new constant_option_c(locloc(@2)), $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4228
| VAR RETAIN located_var_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4229
	{$$ = new located_var_declarations_c(new retain_option_c(locloc(@2)), $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4230
| VAR NON_RETAIN located_var_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4231
	{$$ = new located_var_declarations_c(new non_retain_option_c(locloc(@2)), $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4232
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4233
| VAR NON_RETAIN END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4234
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable declared in non-retentive located variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4235
| VAR error located_var_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4236
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'VAR' in located variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4237
| VAR CONSTANT error located_var_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4238
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'CONSTANT' in constant located variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4239
| VAR RETAIN error located_var_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4240
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'RETAIN' in retentive located variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4241
| VAR NON_RETAIN error located_var_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4242
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'NON_RETAIN' in non-retentive located variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4243
| VAR located_var_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4244
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed located variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4245
| VAR CONSTANT located_var_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4246
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed constant located variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4247
| VAR RETAIN located_var_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4248
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed retentive located variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4249
| VAR NON_RETAIN located_var_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4250
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed non-retentive located variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4251
| VAR NON_RETAIN error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4252
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unknown error in non retentive variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4253
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4254
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4255
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4256
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4257
/* helper symbol for located_var_declarations */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4258
located_var_decl_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4259
  located_var_decl ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4260
	{$$ = new located_var_decl_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4261
| located_var_decl_list located_var_decl ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4262
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4263
/* ERROR_CHECK_BEGIN */
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  4264
| error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4265
	{$$ = new located_var_decl_list_c(locloc(@$)); print_err_msg(locf(@1), locl(@1), "invalid located variable declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4266
| located_var_decl error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4267
	{$$ = new located_var_decl_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at end of located variable declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4268
| located_var_decl_list located_var_decl error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4269
	{$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at end of located variable declaration."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  4270
| located_var_decl_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4271
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid located variable declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4272
| located_var_decl_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4273
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after located variable declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4274
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4275
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4276
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4277
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4278
located_var_decl:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4279
  variable_name location ':' located_var_spec_init
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4280
	{$$ = new located_var_decl_c($1, $2, $4, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4281
	 variable_name_symtable.insert($1, prev_declared_variable_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4282
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4283
| location ':' located_var_spec_init
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4284
	{$$ = new located_var_decl_c(NULL, $1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4285
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4286
| variable_name location located_var_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4287
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between located variable location and specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4288
| location located_var_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4289
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between located variable location and specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4290
| variable_name location ':' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4291
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4292
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no specification defined in located variable declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4293
	 else {print_err_msg(locf(@3), locl(@3), "invalid specification in located variable declaration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4294
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4295
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4296
| location ':' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4297
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4298
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no specification defined in located variable declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4299
	 else {print_err_msg(locf(@3), locl(@3), "invalid specification in located variable declaration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4300
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4301
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4302
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4303
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4304
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4305
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4306
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4307
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4308
external_var_declarations:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4309
  VAR_EXTERNAL external_declaration_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4310
	{$$ = new external_var_declarations_c(NULL, $2, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4311
| VAR_EXTERNAL CONSTANT external_declaration_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4312
	{$$ = new external_var_declarations_c(new constant_option_c(locloc(@2)), $3, locloc(@$));}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4313
/* ERROR_CHECK_BEGIN */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4314
| VAR_EXTERNAL END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4315
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no variable declared in external variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4316
| VAR_EXTERNAL CONSTANT END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4317
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable declared in constant external variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4318
| VAR_EXTERNAL error external_declaration_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4319
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'VAR_EXTERNAL' in external variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4320
| VAR_EXTERNAL CONSTANT error external_declaration_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4321
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'CONSTANT' in constant external variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4322
| VAR_EXTERNAL external_declaration_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4323
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed external variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4324
| VAR_EXTERNAL CONSTANT external_declaration_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4325
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed constant external variable(s) declaration."); yyerrok;}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4326
| VAR_EXTERNAL error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4327
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in external variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4328
| VAR_EXTERNAL CONSTANT error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4329
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unknown error in constant external variable(s) declaration."); yyerrok;}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4330
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4331
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4332
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4333
/* helper symbol for external_var_declarations */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4334
external_declaration_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4335
  external_declaration ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4336
	{$$ = new external_declaration_list_c(locloc(@$)); $$->add_element($1);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4337
| external_declaration_list external_declaration ';'
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4338
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4339
/* ERROR_CHECK_BEGIN */
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  4340
| error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4341
	{$$ = new external_declaration_list_c(locloc(@$)); print_err_msg(locf(@1), locl(@1), "invalid external variable declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4342
| external_declaration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4343
	{$$ = new external_declaration_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at end of external variable declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4344
| external_declaration_list external_declaration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4345
	{$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at end of external variable declaration."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  4346
| external_declaration_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4347
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid external variable declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4348
| external_declaration_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4349
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after external variable declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4350
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4351
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4352
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4353
963
e3d4dca7520b Do constant folding of variable's initial value (allows correct C code generation with variables in the subrange of an array declaration: ARRAY [1..max] of INT).
mjsousa
parents: 961
diff changeset
  4354
e3d4dca7520b Do constant folding of variable's initial value (allows correct C code generation with variables in the subrange of an array declaration: ARRAY [1..max] of INT).
mjsousa
parents: 961
diff changeset
  4355
/* Warning: When handling VAR_EXTERNAL declarations, the constant folding algorithm may (depending on the command line parameters) 
e3d4dca7520b Do constant folding of variable's initial value (allows correct C code generation with variables in the subrange of an array declaration: ARRAY [1..max] of INT).
mjsousa
parents: 961
diff changeset
  4356
 *          set the symbol_c->const_value annotations on both the external_var_name as well as on its VAR_EXTERNAL datatype specification symbol.
e3d4dca7520b Do constant folding of variable's initial value (allows correct C code generation with variables in the subrange of an array declaration: ARRAY [1..max] of INT).
mjsousa
parents: 961
diff changeset
  4357
 *          Setting the const_value on the datatype specification symbol of a VAR_EXTERNAL declaration is only possible if the declaration of 
e3d4dca7520b Do constant folding of variable's initial value (allows correct C code generation with variables in the subrange of an array declaration: ARRAY [1..max] of INT).
mjsousa
parents: 961
diff changeset
  4358
 *          several external variables in a list is not allowed (as each variable could have a potentially distinct initial value).
e3d4dca7520b Do constant folding of variable's initial value (allows correct C code generation with variables in the subrange of an array declaration: ARRAY [1..max] of INT).
mjsousa
parents: 961
diff changeset
  4359
 *           VAR_EXTERNAL
e3d4dca7520b Do constant folding of variable's initial value (allows correct C code generation with variables in the subrange of an array declaration: ARRAY [1..max] of INT).
mjsousa
parents: 961
diff changeset
  4360
 *             a, b, c, d: INT;  (* incorrect syntax! *)
e3d4dca7520b Do constant folding of variable's initial value (allows correct C code generation with variables in the subrange of an array declaration: ARRAY [1..max] of INT).
mjsousa
parents: 961
diff changeset
  4361
 *           END_VAR
e3d4dca7520b Do constant folding of variable's initial value (allows correct C code generation with variables in the subrange of an array declaration: ARRAY [1..max] of INT).
mjsousa
parents: 961
diff changeset
  4362
 *          
e3d4dca7520b Do constant folding of variable's initial value (allows correct C code generation with variables in the subrange of an array declaration: ARRAY [1..max] of INT).
mjsousa
parents: 961
diff changeset
  4363
 *          If anybody considers extending this standard syntax to allow the above syntax (several variables in a list), then be sure to go
e3d4dca7520b Do constant folding of variable's initial value (allows correct C code generation with variables in the subrange of an array declaration: ARRAY [1..max] of INT).
mjsousa
parents: 961
diff changeset
  4364
 *          and fix the constant folding algorithm (more precisely, the constant_folding_c::handle_var_extern_global_pair() function.
e3d4dca7520b Do constant folding of variable's initial value (allows correct C code generation with variables in the subrange of an array declaration: ARRAY [1..max] of INT).
mjsousa
parents: 961
diff changeset
  4365
 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4366
external_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4367
  global_var_name ':' simple_specification
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4368
	{$$ = new external_declaration_c($1, $3, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4369
	 variable_name_symtable.insert($1, prev_declared_variable_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4370
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4371
| global_var_name ':' subrange_specification
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4372
	{$$ = new external_declaration_c($1, $3, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4373
	 variable_name_symtable.insert($1, prev_declared_variable_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4374
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4375
| global_var_name ':' enumerated_specification
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4376
	{$$ = new external_declaration_c($1, $3, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4377
	 variable_name_symtable.insert($1, prev_declared_variable_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4378
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4379
| global_var_name ':' array_specification
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4380
	{$$ = new external_declaration_c($1, $3, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4381
	 variable_name_symtable.insert($1, prev_declared_variable_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4382
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4383
| global_var_name ':' prev_declared_structure_type_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4384
	{$$ = new external_declaration_c($1, $3, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4385
	 variable_name_symtable.insert($1, prev_declared_variable_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4386
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4387
| global_var_name ':' function_block_type_name
810
d9c48ad646f1 Add a new node to the abstract symtax tree, which will let us do datatype checking of FB variable declarations using the standard algorithm, and no special cases.
Mario de Sousa <msousa@fe.up.pt>
parents: 805
diff changeset
  4388
	{$$ = new external_declaration_c($1, new fb_spec_init_c($3, NULL, locloc(@3)), locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4389
	 variable_name_symtable.insert($1, prev_declared_fb_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4390
	}
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  4391
| global_var_name ':' ref_spec /* defined in IEC 61131-3 v3   (REF_TO ...)*/
891
58109ca87903 Fix typo in as yet dormant code (related to REF_TO keyword, that is not yet active)
mjsousa
parents: 876
diff changeset
  4392
	{$$ = new external_declaration_c($1, $3, locloc(@$));
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  4393
	 variable_name_symtable.insert($1, prev_declared_fb_name_token);
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  4394
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4395
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4396
| global_var_name simple_specification
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4397
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between external variable name and simple specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4398
| global_var_name subrange_specification
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4399
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between external variable name and subrange specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4400
| global_var_name enumerated_specification
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4401
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between external variable name and enumerated specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4402
| global_var_name array_specification
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4403
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between external variable name and array specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4404
| global_var_name prev_declared_structure_type_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4405
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between external variable name and structured specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4406
| global_var_name function_block_type_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4407
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between external variable name and function block type specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4408
| global_var_name ':' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4409
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4410
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no specification defined in external variable declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4411
	 else {print_err_msg(locf(@3), locl(@3), "invalid specification in external variable declaration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4412
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4413
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4414
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4415
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4416
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4417
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4418
global_var_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4419
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4420
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4421
global_var_declarations:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4422
  VAR_GLOBAL global_var_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4423
	{$$ = new global_var_declarations_c(NULL, $2, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4424
| VAR_GLOBAL CONSTANT global_var_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4425
	{$$ = new global_var_declarations_c(new constant_option_c(locloc(@2)), $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4426
| VAR_GLOBAL RETAIN global_var_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4427
	{$$ = new global_var_declarations_c(new retain_option_c(locloc(@2)), $3, locloc(@$));}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4428
/* ERROR_CHECK_BEGIN */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4429
| VAR_GLOBAL END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4430
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no variable declared in global variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4431
| VAR_GLOBAL CONSTANT END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4432
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable declared in constant global variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4433
| VAR_GLOBAL RETAIN END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4434
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable declared in retentive global variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4435
| VAR_GLOBAL error global_var_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4436
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'VAR_GLOBAL' in global variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4437
| VAR_GLOBAL CONSTANT error global_var_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4438
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'CONSTANT' in constant global variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4439
| VAR_GLOBAL RETAIN error global_var_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4440
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'RETAIN' in retentive global variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4441
| VAR_GLOBAL global_var_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4442
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed global variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4443
| VAR_GLOBAL CONSTANT global_var_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4444
  {$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed constant global variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4445
| VAR_GLOBAL RETAIN global_var_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4446
  {$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed retentive global variable(s) declaration."); yyerrok;}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4447
| VAR_GLOBAL error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4448
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in global variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4449
| VAR_GLOBAL CONSTANT error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4450
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unknown error in constant global variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4451
| VAR_GLOBAL RETAIN error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4452
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unknown error in constant global variable(s) declaration."); yyerrok;}
96
23baa8821b58 Adding some basic error cheching.
mario
parents: 95
diff changeset
  4453
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4454
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4455
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4456
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4457
/* helper symbol for global_var_declarations */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4458
global_var_decl_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4459
  global_var_decl ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4460
	{$$ = new global_var_decl_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4461
| global_var_decl_list global_var_decl ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4462
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4463
/* ERROR_CHECK_BEGIN */
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  4464
| error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4465
	{$$ = new global_var_decl_list_c(locloc(@$)); print_err_msg(locf(@1), locl(@1), "invalid global variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4466
| global_var_decl error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4467
	{$$ = new global_var_decl_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at end of global variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4468
| global_var_decl_list global_var_decl error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4469
	{$$ = $1; print_err_msg(locl(@1), locf(@2), "';' missing at end of global variable(s) declaration."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  4470
| global_var_decl_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4471
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid global variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4472
| global_var_decl_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4473
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after global variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4474
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4475
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4476
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4477
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4478
global_var_decl:
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4479
/* NOTE : This possibility defined in standard has no sense and generate a conflict (disabled)
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4480
  global_var_spec ':'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4481
	{$$ = new global_var_decl_c($1, NULL, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4482
*/
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4483
  global_var_spec ':' located_var_spec_init
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4484
	{$$ = new global_var_decl_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4485
| global_var_spec ':' function_block_type_name
810
d9c48ad646f1 Add a new node to the abstract symtax tree, which will let us do datatype checking of FB variable declarations using the standard algorithm, and no special cases.
Mario de Sousa <msousa@fe.up.pt>
parents: 805
diff changeset
  4486
	{$$ = new global_var_decl_c($1, new fb_spec_init_c($3, NULL, locloc(@3)), locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4487
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4488
| global_var_list located_var_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4489
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between global variable list and type specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4490
| global_var_name location located_var_spec_init
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4491
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between global variable specification and type specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4492
| global_var_spec function_block_type_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4493
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between global variable specification and function block type specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4494
| global_var_spec ':' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4495
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4496
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no specification defined in global variable declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4497
	 else {print_err_msg(locf(@3), locl(@3), "invalid specification in global variable declaration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4498
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4499
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4500
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4501
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4502
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4503
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4504
global_var_spec:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4505
  global_var_list	{$$ = $1;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4506
| location
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4507
	{$$ = new global_var_spec_c(NULL, $1, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4508
| global_var_name location
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4509
	{$$ = new global_var_spec_c($1, $2, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4510
	 variable_name_symtable.insert($1, prev_declared_global_var_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4511
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4512
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4513
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4514
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4515
located_var_spec_init:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4516
  simple_spec_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4517
| subrange_spec_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4518
| enumerated_spec_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4519
| array_spec_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4520
| initialized_structure
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4521
| single_byte_string_spec
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4522
| double_byte_string_spec
876
e2c4f6f4abe2 Add support for parsing of REF_TO keyword (defined in IEC61131-3 v3). This support is currently inactive (in flex) until we get to add C code generation later on.
mjsousa
parents: 873
diff changeset
  4523
| ref_spec_init /* defined in IEC 61131-3 v3 (REF_TO ...) */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4524
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4525
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4526
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4527
location:
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  4528
  AT direct_variable_token
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  4529
	{$$ = new location_c(new direct_variable_c($2, locloc(@$)), locloc(@$));
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  4530
	 direct_variable_symtable.insert($2, prev_declared_direct_variable_token);
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  4531
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4532
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4533
| AT error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4534
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4535
	 if (is_current_syntax_token()) {print_err_msg(locl(@1), locf(@2), "no location defined in location declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4536
	 else {print_err_msg(locf(@2), locl(@2), "invalid location in global location declaration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4537
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4538
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4539
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4540
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4541
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4542
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4543
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4544
global_var_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4545
  global_var_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4546
	{$$ = new global_var_list_c(locloc(@$)); $$->add_element($1);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4547
	 variable_name_symtable.insert($1, prev_declared_global_var_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4548
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4549
| global_var_list ',' global_var_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4550
	{$$ = $1; $$->add_element($3);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4551
	 variable_name_symtable.insert($3, prev_declared_global_var_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4552
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4553
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4554
| global_var_list global_var_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4555
	{$$ = new global_var_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "',' missing in global variable list."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4556
| global_var_list ',' error
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  4557
	{$$ = $1;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4558
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no variable name defined in global variable declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4559
	 else {print_err_msg(locf(@3), locl(@3), "invalid variable name in global variable declaration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4560
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4561
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4562
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4563
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4564
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4565
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4566
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4567
string_var_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4568
  single_byte_string_var_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4569
| double_byte_string_var_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4570
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4571
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4572
single_byte_string_var_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4573
  var1_list ':' single_byte_string_spec
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4574
	{$$ = new single_byte_string_var_declaration_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4575
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4576
| var1_list single_byte_string_spec
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4577
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and string type specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4578
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4579
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4580
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4581
/* NOTE: The constructs
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4582
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4583
 *       [W]STRING
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4584
 *       and
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4585
 *       [W]STRING ASSIGN single_byte_character_string
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4586
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4587
 *       were removed as they are already contained
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4588
 *       within a other constructs.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4589
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4590
 *       single_byte_string_spec is used in:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4591
 *        - single_byte_string_var_declaration ->
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4592
 *           -> string_var_declaration ---> var_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4593
 *                                     |--> temp_var_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4594
 *                                     |--> var2_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4595
 *        - located_var_spec_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4596
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4597
 *       STRING [ASSIGN string_constant] -> elementary_string_type_name ->
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4598
 *        -> simple_spec -> simple_specification -> simple_spec_init ->
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4599
 *        -> located_var_spec_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4600
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4601
 *       STRING [ASSIGN string_constant] -> elementary_string_type_name ->
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4602
 *        -> simple_spec -> simple_specification -> simple_spec_init ->
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4603
 *        -> var1_init_decl -> var_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4604
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4605
 *       STRING [ASSIGN string_constant] -> elementary_string_type_name ->
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4606
 *        -> simple_spec -> simple_specification -> simple_spec_init ->
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4607
 *        -> var1_init_decl -> var2_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4608
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4609
 *       STRING [ASSIGN string_constant] -> elementary_string_type_name ->
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4610
 *        -> simple_spec -> simple_specification ->
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4611
 *        -> var1_declaration -> temp_var_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4612
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4613
single_byte_string_spec:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4614
/*  STRING
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4615
	{$$ = new single_byte_string_spec_c(NULL, NULL);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4616
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4617
  STRING '[' integer ']'
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4618
	{$$ = new single_byte_string_spec_c(new single_byte_limited_len_string_spec_c(new string_type_name_c(locloc(@1)), $3, locloc(@$)), NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4619
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4620
| STRING ASSIGN single_byte_character_string
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4621
	{$$ = new single_byte_string_spec_c($1, NULL, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4622
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4623
| STRING '[' integer ']' ASSIGN single_byte_character_string
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4624
	{$$ = new single_byte_string_spec_c(new single_byte_limited_len_string_spec_c(new string_type_name_c(locloc(@1)), $3, locloc(@$)), $6, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4625
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4626
| STRING '[' error ']'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4627
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid length value for limited string type specification."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4628
| STRING '[' error ']' ASSIGN single_byte_character_string
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4629
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid length value for limited string type specification."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4630
| STRING '[' ']'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4631
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "missing length value for limited string type specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4632
| STRING '[' ']' ASSIGN single_byte_character_string
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4633
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "missing length value for limited string type specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4634
| STRING '[' integer error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4635
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "expecting ']' after length definition for limited string type specification."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4636
| STRING '[' integer ']' single_byte_character_string
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4637
	{$$ = NULL; print_err_msg(locl(@4), locf(@5), "':=' missing before limited string type initialization."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4638
| STRING '[' integer ']' ASSIGN error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4639
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4640
	 if (is_current_syntax_token()) {print_err_msg(locl(@5), locf(@6), "no initial value defined in limited string type initialization.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4641
	 else {print_err_msg(locf(@6), locl(@6), "invalid initial value in limited string type initialization."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4642
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4643
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4644
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4645
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4646
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4647
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4648
double_byte_string_var_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4649
  var1_list ':' double_byte_string_spec
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4650
	{$$ = new double_byte_string_var_declaration_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4651
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4652
| var1_list double_byte_string_spec
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4653
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and double byte string type specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4654
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4655
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4656
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4657
double_byte_string_spec:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4658
/*  WSTRING
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4659
	{$$ = new double_byte_string_spec_c($1, NULL, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4660
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4661
  WSTRING '[' integer ']'
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4662
	{$$ = new double_byte_string_spec_c(new double_byte_limited_len_string_spec_c(new wstring_type_name_c(locloc(@1)), $3, locloc(@$)), NULL, locloc(@$));}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4663
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4664
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4665
| WSTRING ASSIGN double_byte_character_string
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4666
	{$$ = new double_byte_string_spec_c($1, NULL, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4667
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4668
| WSTRING '[' integer ']' ASSIGN double_byte_character_string
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4669
	{$$ = new double_byte_string_spec_c(new double_byte_limited_len_string_spec_c(new wstring_type_name_c(locloc(@1)), $3, locloc(@$)), $6, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4670
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4671
| WSTRING '[' error ']'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4672
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid length value for limited double byte string type specification."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4673
| WSTRING '[' error ']' ASSIGN single_byte_character_string
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4674
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid length value for limited double byte string type specification."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4675
| WSTRING '[' ']'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4676
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "missing length value for limited double byte string type specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4677
| WSTRING '[' ']' ASSIGN single_byte_character_string
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4678
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "missing length value for limited double byte string type specification."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4679
| WSTRING '[' integer error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4680
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "expecting ']' after length definition for limited double byte string type specification."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4681
| WSTRING '[' integer ']' single_byte_character_string
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4682
	{$$ = NULL; print_err_msg(locl(@4), locf(@5), "':=' missing before limited double byte string type initialization."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4683
| WSTRING '[' integer ']' ASSIGN error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4684
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4685
	 if (is_current_syntax_token()) {print_err_msg(locl(@5), locf(@6), "no initial value defined double byte in limited string type initialization.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4686
	 else {print_err_msg(locf(@6), locl(@6), "invalid initial value in limited double byte string type initialization."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4687
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4688
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4689
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4690
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4691
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4692
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4693
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4694
incompl_located_var_declarations:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4695
  VAR            incompl_located_var_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4696
	{$$ = new incompl_located_var_declarations_c(NULL, $2, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4697
| VAR     RETAIN incompl_located_var_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4698
	{$$ = new incompl_located_var_declarations_c(new retain_option_c(locloc(@2)), $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4699
| VAR NON_RETAIN incompl_located_var_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4700
	{$$ = new incompl_located_var_declarations_c(new non_retain_option_c(locloc(@2)), $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4701
/* ERROR_CHECK_BEGIN */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4702
| VAR incompl_located_var_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4703
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed incomplete located variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4704
| VAR RETAIN incompl_located_var_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4705
  {$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed incomplete retentive located variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4706
| VAR NON_RETAIN incompl_located_var_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4707
  {$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed incomplete non-retentive located variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4708
| VAR error incompl_located_var_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4709
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'VAR' in incomplete located variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4710
| VAR RETAIN error incompl_located_var_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4711
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'RETAIN' in retentive located variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4712
| VAR NON_RETAIN error incompl_located_var_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4713
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'NON_RETAIN' in non-retentive located variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4714
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4715
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4716
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4717
/* helper symbol for incompl_located_var_declarations */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4718
incompl_located_var_decl_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4719
  incompl_located_var_decl ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4720
	{$$ = new incompl_located_var_decl_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4721
| incompl_located_var_decl_list incompl_located_var_decl ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4722
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4723
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4724
| incompl_located_var_decl error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4725
	{$$ = new incompl_located_var_decl_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at end of incomplete located variable declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4726
| incompl_located_var_decl_list incompl_located_var_decl error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4727
	{$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at end of incomplete located variable declaration."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  4728
| incompl_located_var_decl_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4729
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid incomplete located variable declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4730
| incompl_located_var_decl_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4731
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after incomplete located variable declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4732
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4733
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4734
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4735
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4736
incompl_located_var_decl:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4737
  variable_name incompl_location ':' var_spec
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4738
	{$$ = new incompl_located_var_decl_c($1, $2, $4, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4739
/* ERROR_CHECK_BEGIN */
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  4740
| variable_name incompl_location var_spec
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4741
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between incomplete located variable and type specification."); yynerrs++;
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  4742
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4743
| variable_name incompl_location ':' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4744
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4745
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no specification defined in incomplete located variable declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4746
	 else {print_err_msg(locf(@3), locl(@3), "invalid specification in incomplete located variable declaration."); yyclearin;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  4747
	 yyerrok;
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4748
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4749
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4750
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4751
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4752
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4753
incompl_location:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4754
  AT incompl_location_token
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4755
	{$$ = new incompl_location_c($2, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4756
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4757
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4758
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4759
var_spec:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4760
  simple_specification
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4761
| subrange_specification
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4762
| enumerated_specification
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4763
| array_specification
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4764
| prev_declared_structure_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4765
| string_spec
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4766
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4767
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4768
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4769
/* helper symbol for var_spec */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4770
string_spec:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4771
/*  STRING
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4772
	{$$ = new single_byte_limited_len_string_spec_c($1, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4773
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4774
  STRING '[' integer ']'
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4775
	{$$ = new single_byte_limited_len_string_spec_c(new string_type_name_c(locloc(@1)), $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4776
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4777
| WSTRING
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4778
	{$$ = new double_byte_limited_len_string_spec_c($1, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4779
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4780
| WSTRING '[' integer ']'
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4781
	{$$ = new double_byte_limited_len_string_spec_c(new wstring_type_name_c(locloc(@1)), $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4782
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4783
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4784
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4785
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4786
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4787
/* intermediate helper symbol for:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4788
 *  - non_retentive_var_decls
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4789
 *  - var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4790
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4791
var_init_decl_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4792
  var_init_decl ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4793
	{$$ = new var_init_decl_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4794
| var_init_decl_list var_init_decl ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4795
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4796
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4797
| var_init_decl_list var_init_decl error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4798
	{$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at end of variable(s) declaration."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  4799
| var_init_decl_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  4800
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  4801
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4802
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4803
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4804
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4805
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4806
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4807
/***********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4808
/* B 1.5.1 - Functions */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4809
/***********************/
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4810
/*
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4811
function_name:
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4812
  prev_declared_derived_function_name
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4813
| standard_function_name 
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4814
;
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4815
*/
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  4816
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4817
/* The following rules should be set such as:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4818
 * function_name: function_name_no_clashes | function_name_simpleop_clashes | function_name_expression_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4819
 * function_name: function_name_no_NOT_clashes | function_name_NOT_clashes;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4820
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4821
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4822
function_name_no_clashes: prev_declared_derived_function_name | standard_function_name_no_clashes;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4823
function_name_simpleop_clashes: standard_function_name_simpleop_clashes;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4824
//function_name_expression_clashes: standard_function_name_expression_clashes;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4825
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4826
function_name_no_NOT_clashes: prev_declared_derived_function_name | standard_function_name_no_NOT_clashes;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4827
//function_name_NOT_clashes: standard_function_name_NOT_clashes;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4828
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4829
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4830
/* NOTE: The list of standard function names
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4831
 *       includes the standard functions MOD(), NOT()
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4832
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4833
 *       Strangely enough, MOD and NOT are reserved keywords,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4834
 *       so shouldn't be used for function names.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4835
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4836
 *       The specification contradicts itself!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4837
 *       Our workaround  is to treat MOD as a token,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4838
 *       but to include this token as a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4839
 *       standard_function_name.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4840
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4841
 *       The names of all other standard functions get
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4842
 *       preloaded into the library_element_symbol_table
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4843
 *       with the token value of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4844
 *       standard_function_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4845
 *       Actually, simply for completeness, MOD is also
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4846
 *       loaded into the library_element_symbol_table, but
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4847
 *       it is irrelevant since flex will catch MOD as a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4848
 *       token, before it interprets it as an identifier,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4849
 *       and looks in the library_element_symbol_table to check
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4850
 *       whether it has been previously declared.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4851
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4852
 * NOTE: The same as the above also occurs with the IL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4853
 *       operators NOT AND OR XOR ADD SUB MUL DIV MOD
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4854
 *       GT GE EQ LT LE NE.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4855
 *       Note that MOD is once again in the list!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4856
 *       Anyway, we give these the same treatement as
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4857
 *       MOD, since we are writing a parser for ST and
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4858
 *       IL simultaneously. If this were not the case,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4859
 *       the ST parser would not need the tokens NOT AND ...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4860
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4861
 * NOTE: Note that 'NOT' is special, as it conflicts
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4862
 *       with two operators: the  IL 'NOT' operator, and
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4863
 *       the unary operator 'NOT' in ST!!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4864
 *
78
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  4865
 * NOTE: The IL language is ambiguous, since using NOT, AND, ...
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4866
 *       may be interpreted as either an IL operator, or
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4867
 *       as a standard function call!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4868
 *       I (Mario) opted to interpret it as an IL operator.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4869
 *       This requires changing the syntax for IL language
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4870
 *       function   calling, to exclude all function with
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4871
 *       names that clash with IL operators. I therefore
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4872
 *       created the constructs
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4873
 *       function_name_without_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4874
 *       standard_function_name_without_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4875
 *       to include all function names, except those that clash
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4876
 *       with IL operators. These constructs are only used
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4877
 *       within the IL language!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4878
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4879
/* The following rules should be set such as:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4880
 * standard_function_name: standard_function_name_no_clashes | standard_function_name_simpleop_clashes | standard_function_name_expression_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4881
 * standard_function_name: standard_function_name_no_NOT_clashes | standard_function_name_NOT_clashes;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4882
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4883
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4884
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4885
standard_function_name:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4886
  standard_function_name_no_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4887
| standard_function_name_expression_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4888
| standard_function_name_NOT_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4889
//| standard_function_name_simpleop_only_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4890
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4891
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4892
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4893
standard_function_name_no_NOT_clashes:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4894
  standard_function_name_no_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4895
| standard_function_name_expression_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4896
//| standard_function_name_simpleop_only_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4897
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4898
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4899
/* standard_function_name_no_clashes is only used in function invocations, so we use the poutype_identifier_c class! */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4900
standard_function_name_no_clashes:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4901
  standard_function_name_token
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4902
	{$$ = new poutype_identifier_c($1, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4903
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4904
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4905
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4906
standard_function_name_simpleop_clashes:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4907
  standard_function_name_NOT_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4908
//| standard_function_name_simpleop_only_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4909
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4910
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4911
/* standard_function_name_NOT_clashes is only used in function invocations, so we use the poutype_identifier_c class! */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4912
standard_function_name_NOT_clashes:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4913
  NOT
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4914
	{$$ = new poutype_identifier_c(strdup("NOT"), locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4915
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4916
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4917
/* Add here any other IL simple operators that collide
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4918
 * with standard function names!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4919
 * Don't forget to uncomment the equivalent lines in
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4920
 *   - standard_function_name_simpleop_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4921
 *   - standard_function_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4922
 *   - standard_function_name_no_NOT_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4923
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4924
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4925
standard_function_name_simpleop_only_clashes:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4926
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4927
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4928
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4929
/* standard_function_name_expression_clashes is only used in function invocations, so we use the poutype_identifier_c class! */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4930
standard_function_name_expression_clashes:
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4931
  AND	{$$ = new poutype_identifier_c(strdup("AND"), locloc(@$));}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4932
| OR	{$$ = new poutype_identifier_c(strdup("OR"), locloc(@$));}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4933
| XOR	{$$ = new poutype_identifier_c(strdup("XOR"), locloc(@$));}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4934
| ADD	{$$ = new poutype_identifier_c(strdup("ADD"), locloc(@$));}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4935
| SUB	{$$ = new poutype_identifier_c(strdup("SUB"), locloc(@$));}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4936
| MUL	{$$ = new poutype_identifier_c(strdup("MUL"), locloc(@$));}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4937
| DIV	{$$ = new poutype_identifier_c(strdup("DIV"), locloc(@$));}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4938
| MOD	{$$ = new poutype_identifier_c(strdup("MOD"), locloc(@$));}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4939
| GT	{$$ = new poutype_identifier_c(strdup("GT"), locloc(@$));}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4940
| GE	{$$ = new poutype_identifier_c(strdup("GE"), locloc(@$));}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4941
| EQ	{$$ = new poutype_identifier_c(strdup("EQ"), locloc(@$));}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4942
| LT	{$$ = new poutype_identifier_c(strdup("LT"), locloc(@$));}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4943
| LE	{$$ = new poutype_identifier_c(strdup("LE"), locloc(@$));}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4944
| NE	{$$ = new poutype_identifier_c(strdup("NE"), locloc(@$));}
91
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  4945
/*
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4946
  AND_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4947
//NOTE: AND2 (corresponding to the source code string '&') does not clash
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4948
//      with a standard function name, so should be commented out!
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4949
//| AND2_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4950
| OR_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4951
| XOR_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4952
| ADD_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4953
| SUB_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4954
| MUL_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4955
| DIV_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4956
| MOD_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4957
| GT_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4958
| GE_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4959
| EQ_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4960
| LT_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4961
| LE_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4962
| NE_operator	{$$ = il_operator_c_2_poutype_identifier_c($1);}
91
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  4963
*/
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4964
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4965
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4966
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4967
derived_function_name:
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  4968
  identifier  /* will never occur during normal parsing, only needed for preparsing to change it to a prev_declared_derived_function_name! */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4969
| prev_declared_derived_function_name
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  4970
	{$$ = new identifier_c(((token_c *)$1)->value, locloc(@$)); // transform the poutype_identifier_c into an identifier_c
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  4971
	 if (get_preparse_state() && !allow_function_overloading) {print_err_msg(locloc(@$), "Function overloading not allowed. Invalid identifier.\n"); yynerrs++;}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4972
	}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4973
| AND
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4974
	{$$ = new identifier_c("AND", locloc(@$));
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  4975
	 if (!allow_function_overloading) {print_err_msg(locloc(@$), "Function overloading not allowed. Invalid identifier.\n"); yynerrs++;}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4976
	}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4977
| OR
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4978
	{$$ = new identifier_c("OR", locloc(@$));
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  4979
	 if (!allow_function_overloading) {print_err_msg(locloc(@$), "Function overloading not allowed. Invalid identifier.\n"); yynerrs++;}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4980
	}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4981
| XOR
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4982
	{$$ = new identifier_c("XOR", locloc(@$));
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  4983
	 if (!allow_function_overloading) {print_err_msg(locloc(@$), "Function overloading not allowed. Invalid identifier.\n"); yynerrs++;}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4984
	}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4985
| NOT
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4986
	{$$ = new identifier_c("NOT", locloc(@$));
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  4987
	 if (!allow_function_overloading) {print_err_msg(locloc(@$), "Function overloading not allowed. Invalid identifier.\n"); yynerrs++;}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4988
	}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4989
| MOD
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4990
	{$$ = new identifier_c("MOD", locloc(@$));
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  4991
	 if (!allow_function_overloading) {print_err_msg(locloc(@$), "Function overloading not allowed. Invalid identifier.\n"); yynerrs++;}
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  4992
	}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4993
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4994
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4995
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4996
function_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  4997
/*  FUNCTION derived_function_name ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  4998
/* PRE_PARSING: The rules expected to be applied by the preparser. */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  4999
  FUNCTION derived_function_name END_FUNCTION   /* rule that is only expected to be used during preparse state => MUST print an error if used outside preparse() state!! */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5000
	{$$ = NULL; 
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5001
	 if (get_preparse_state())    {library_element_symtable.insert($2, prev_declared_derived_function_name_token);}
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5002
	 else                         {print_err_msg(locl(@1), locf(@3), "FUNCTION with no variable declarations and no body."); yynerrs++;}
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5003
	 }
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  5004
/* POST_PARSING and STANDARD_PARSING: The rules expected to be applied after the preparser has finished. */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5005
| function_name_declaration ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5006
	{$$ = new function_declaration_c($1, $3, $4, $5, locloc(@$));
1011
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 980
diff changeset
  5007
	 if (!disable_implicit_en_eno) add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5008
	 variable_name_symtable.pop();
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  5009
	 direct_variable_symtable.pop();
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5010
	 library_element_symtable.insert($1, prev_declared_derived_function_name_token);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5011
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5012
/* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5013
| function_name_declaration ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5014
	{$$ = new function_declaration_c($1, $3, $4, $5, locloc(@$));
1011
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 980
diff changeset
  5015
	 if (!disable_implicit_en_eno) add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5016
	 variable_name_symtable.pop();
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  5017
	 direct_variable_symtable.pop();
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5018
	 library_element_symtable.insert($1, prev_declared_derived_function_name_token);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5019
	}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5020
/* ERROR_CHECK_BEGIN */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5021
| function_name_declaration elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5022
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing after function name in function declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5023
| function_name_declaration derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5024
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing after function name in function declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5025
| function_name_declaration ':' io_OR_function_var_declarations_list function_body END_FUNCTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5026
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no return type defined in function declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5027
| function_name_declaration ':' error io_OR_function_var_declarations_list function_body END_FUNCTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5028
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid return type defined in function declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5029
| function_name_declaration ':' elementary_type_name function_body END_FUNCTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5030
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "no variable(s) declared in function declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5031
| function_name_declaration ':' derived_type_name function_body END_FUNCTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5032
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "no variable(s) declared in function declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5033
| function_name_declaration ':' elementary_type_name io_OR_function_var_declarations_list END_FUNCTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5034
	{$$ = NULL; print_err_msg(locl(@4), locf(@5), "no body defined in function declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5035
| function_name_declaration ':' derived_type_name io_OR_function_var_declarations_list END_FUNCTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5036
	{$$ = NULL; print_err_msg(locl(@4), locf(@5), "no body defined in function declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5037
| function_name_declaration ':' elementary_type_name END_FUNCTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5038
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "no variable(s) declared and body defined in function declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5039
| function_name_declaration ':' derived_type_name END_FUNCTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5040
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "no variable(s) declared and body defined in function declaration."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5041
| function_name_declaration ':' elementary_type_name io_OR_function_var_declarations_list function_body END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5042
	{$$ = NULL; print_err_msg(locf(@1), locf(@3), "unclosed function declaration."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5043
| function_name_declaration ':' derived_type_name io_OR_function_var_declarations_list function_body END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5044
	{$$ = NULL; print_err_msg(locf(@1), locl(@3), "unclosed function declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5045
| function_name_declaration error END_FUNCTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5046
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in function declaration."); yyerrok;}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5047
/* ERROR_CHECK_END */
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5048
;
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5049
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5050
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5051
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5052
/* helper symbol for function_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5053
/* NOTE: due to reduce/reduce conflicts between identifiers
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5054
 *       being reduced to either a variable or an enumerator value,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5055
 *       we were forced to keep a symbol table of the names
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5056
 *       of all declared variables. Variables are no longer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5057
 *       created from simple identifier_token, but from
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5058
 *       prev_declared_variable_name_token.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5059
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5060
 *       BUT, in functions the function name itself may be used as
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5061
 *       a variable! In order to be able to parse this correctly,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5062
 *       the token parser (flex) must return a prev_declared_variable_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5063
 *       when it comes across the function name, while parsing
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5064
 *       the function itself.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5065
 *       We do this by inserting the function name into the variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5066
 *       symbol table, and having flex return a prev_declared_variable_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5067
 *       whenever it comes across it.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5068
 *       When we finish parsing the function the variable name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5069
 *       symbol table is cleared of all entries, and the function
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5070
 *       name is inserted into the library element symbol table. This
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5071
 *       means that from then onwards flex will return a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5072
 *       derived_function_name_token whenever it comes across the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5073
 *       function name.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5074
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5075
 *       In order to insert the function name into the variable_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5076
 *       symbol table BEFORE the function body gets parsed, we
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5077
 *       need the parser to reduce a construct that contains the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5078
 *       the function name. That is why we created this extra
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5079
 *       construct (function_name_declaration), i.e. to force
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5080
 *       the parser to reduce it, before parsing the function body!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5081
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5082
function_name_declaration:
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5083
  /* FUNCTION derived_function_name */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5084
  FUNCTION derived_function_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5085
	{$$ = $2;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5086
	 /* the function name functions as a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5087
	  * variable within the function itself!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5088
	  *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5089
	  * Remember that the variable_name_symtable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5090
	  * is cleared once the end of the function
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5091
	  * is parsed.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5092
	  */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5093
	 variable_name_symtable.insert($2, prev_declared_variable_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5094
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5095
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5096
| FUNCTION error 
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5097
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5098
	 if (is_current_syntax_token()) {print_err_msg(locl(@1), locf(@2), "no function name defined in function declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5099
	 else {print_err_msg(locf(@2), locl(@2), "invalid function name in function declaration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5100
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5101
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5102
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5103
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5104
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5105
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5106
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5107
/* intermediate helper symbol for function_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5108
io_OR_function_var_declarations_list:
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5109
  io_var_declarations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5110
  {$$ = new var_declarations_list_c(locloc(@1));$$->add_element($1);}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5111
| function_var_decls
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5112
	{$$ = new var_declarations_list_c(locloc(@1));$$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5113
| io_OR_function_var_declarations_list io_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5114
	{$$ = $1; $$->add_element($2);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5115
| io_OR_function_var_declarations_list function_var_decls
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5116
	{$$ = $1; $$->add_element($2);}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5117
/* ERROR_CHECK_BEGIN */
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5118
| io_OR_function_var_declarations_list retentive_var_declarations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5119
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected retentive variable(s) declaration in function declaration."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5120
| io_OR_function_var_declarations_list located_var_declarations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5121
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected located variable(s) declaration in function declaration."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5122
| io_OR_function_var_declarations_list external_var_declarations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5123
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected external variable(s) declaration in function declaration."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5124
| io_OR_function_var_declarations_list global_var_declarations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5125
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected global variable(s) declaration in function declaration."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5126
| io_OR_function_var_declarations_list incompl_located_var_declarations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5127
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected incomplete located variable(s) declaration in function declaration."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5128
| io_OR_function_var_declarations_list temp_var_decls
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5129
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected temporary located variable(s) declaration in function declaration."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5130
| io_OR_function_var_declarations_list non_retentive_var_decls
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5131
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected non-retentive variable(s) declaration in function declaration."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5132
/*| io_OR_function_var_declarations_list access_declarations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5133
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected access variable(s) declaration in function declaration."); yynerrs++;}*/
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5134
| io_OR_function_var_declarations_list instance_specific_initializations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5135
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected instance specific initialization(s) in function declaration."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5136
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5137
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5138
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5139
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5140
io_var_declarations:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5141
  input_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5142
| output_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5143
| input_output_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5144
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5145
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5146
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5147
function_var_decls:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5148
  VAR CONSTANT var2_init_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5149
	{$$ = new function_var_decls_c(new constant_option_c(locloc(@2)), $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5150
| VAR var2_init_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5151
	{$$ = new function_var_decls_c(NULL, $2, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5152
/* ERROR_CHECK_BEGIN */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5153
| VAR error var2_init_decl_list END_VAR
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5154
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'VAR' in function variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5155
| VAR CONSTANT error var2_init_decl_list END_VAR
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5156
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'CONSTANT' in constant function variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5157
| VAR var2_init_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5158
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed function variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5159
| VAR CONSTANT var2_init_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5160
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed constant function variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5161
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5162
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5163
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5164
/* intermediate helper symbol for function_var_decls */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5165
var2_init_decl_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5166
  var2_init_decl ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5167
	{$$ = new var2_init_decl_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5168
| var2_init_decl_list var2_init_decl ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5169
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5170
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5171
| var2_init_decl error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5172
	{$$ = new var2_init_decl_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at end of function variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5173
| var2_init_decl_list var2_init_decl error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5174
	{$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at end of function variable(s) declaration."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  5175
| var2_init_decl_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5176
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid function variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5177
| var2_init_decl_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5178
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after function variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5179
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5180
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5181
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5182
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5183
function_body:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5184
  statement_list	{$$ = $1;} /* if we leave it for the default action we get a type clash! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5185
| instruction_list	{$$ = $1;} /* if we leave it for the default action we get a type clash! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5186
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5187
| ladder_diagram
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5188
| function_block_diagram
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5189
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5190
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5191
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5192
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5193
var2_init_decl:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5194
  var1_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5195
| array_var_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5196
| structured_var_init_decl
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5197
| string_var_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5198
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5199
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5200
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5201
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5202
/*****************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5203
/* B 1.5.2 - Function Blocks */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5204
/*****************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5205
function_block_type_name:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5206
  prev_declared_derived_function_block_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5207
| standard_function_block_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5208
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5209
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5210
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5211
standard_function_block_name: standard_function_block_name_token {$$ = new identifier_c($1, locloc(@$));};
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5212
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5213
derived_function_block_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5214
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5215
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5216
function_block_declaration:
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5217
/* PRE_PARSING: The rules expected to be applied by the preparser. Will only run if pre-parsing command line option is ON. */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5218
  FUNCTION_BLOCK derived_function_block_name END_FUNCTION_BLOCK   /* rule that is only expected to be used during preparse state => MUST print an error if used outside preparse() state!! */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5219
	{$$ = NULL; 
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5220
	 if (get_preparse_state())    {library_element_symtable.insert($2, prev_declared_derived_function_block_name_token);}
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5221
	 else                         {print_err_msg(locl(@1), locf(@3), "FUNCTION_BLOCK with no variable declarations and no body."); yynerrs++;}
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5222
	 }
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5223
/* POST_PARSING: The rules expected to be applied after the preparser runs. Will only run if pre-parsing command line option is ON. */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5224
| FUNCTION_BLOCK prev_declared_derived_function_block_name io_OR_other_var_declarations_list function_block_body END_FUNCTION_BLOCK
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5225
	{$$ = new function_block_declaration_c($2, $3, $4, locloc(@$));
1011
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 980
diff changeset
  5226
	 if (!disable_implicit_en_eno) add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5227
	 /* Clear the variable_name_symtable. Since we have finished parsing the function block,
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5228
	  * the variable names are now out of scope, so are no longer valid!
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5229
	  */
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5230
	 variable_name_symtable.pop();
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5231
	 direct_variable_symtable.pop();
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5232
	}
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5233
/* STANDARD_PARSING: The rules expected to be applied in single-phase parsing. Will only run if pre-parsing command line option is OFF. */
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5234
| FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations_list function_block_body END_FUNCTION_BLOCK
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5235
	{$$ = new function_block_declaration_c($2, $3, $4, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5236
	 library_element_symtable.insert($2, prev_declared_derived_function_block_name_token);
1011
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 980
diff changeset
  5237
	 if (!disable_implicit_en_eno) add_en_eno_param_decl_c::add_to($$); /* add EN and ENO declarations, if not already there */
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5238
	 /* Clear the variable_name_symtable. Since we have finished parsing the function block,
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5239
	  * the variable names are now out of scope, so are no longer valid!
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5240
	  */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5241
	 variable_name_symtable.pop();
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  5242
	 direct_variable_symtable.pop();
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5243
	}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5244
/* ERROR_CHECK_BEGIN */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5245
| FUNCTION_BLOCK io_OR_other_var_declarations_list function_block_body END_FUNCTION_BLOCK
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5246
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no function block name defined in function block declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5247
| FUNCTION_BLOCK error io_OR_other_var_declarations_list function_block_body END_FUNCTION_BLOCK
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5248
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid function block name in function block declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5249
| FUNCTION_BLOCK derived_function_block_name function_block_body END_FUNCTION_BLOCK
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5250
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable(s) declared in function declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5251
| FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations_list END_FUNCTION_BLOCK
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5252
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "no body defined in function block declaration."); yynerrs++;}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5253
/*  Rule already covered by the rule to handle the preparse state!
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5254
| FUNCTION_BLOCK derived_function_block_name END_FUNCTION_BLOCK
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5255
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable(s) declared and body defined in function block declaration."); yynerrs++;}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5256
*/
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5257
| FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations_list function_block_body END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5258
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "no variable(s) declared and body defined in function block declaration."); yynerrs++;}	
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5259
| FUNCTION_BLOCK error END_FUNCTION_BLOCK
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5260
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in function block declaration."); yyerrok;}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5261
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5262
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5263
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5264
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5265
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5266
/* intermediate helper symbol for function_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5267
/*  { io_var_declarations | other_var_declarations }   */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5268
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5269
 * NOTE: we re-use the var_declarations_list_c
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5270
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5271
io_OR_other_var_declarations_list:
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5272
  io_var_declarations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5273
  {$$ = new var_declarations_list_c(locloc(@$));$$->add_element($1);}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5274
| other_var_declarations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5275
  {$$ = new var_declarations_list_c(locloc(@$));$$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5276
| io_OR_other_var_declarations_list io_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5277
	{$$ = $1; $$->add_element($2);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5278
| io_OR_other_var_declarations_list other_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5279
	{$$ = $1; $$->add_element($2);}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5280
/* ERROR_CHECK_BEGIN */
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5281
| io_OR_other_var_declarations_list located_var_declarations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5282
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected located variable(s) declaration in function block declaration."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5283
| io_OR_other_var_declarations_list global_var_declarations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5284
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected global variable(s) declaration in function block declaration."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5285
/*| io_OR_other_var_declarations_list access_declarations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5286
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected access variable(s) declaration in function block declaration."); yynerrs++;}*/
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5287
| io_OR_other_var_declarations_list instance_specific_initializations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5288
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected instance specific initialization(s) in function block declaration."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5289
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5290
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5291
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5292
/* NOTE:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5293
 *  The IEC specification gives the following definition:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5294
 *  other_var_declarations ::=
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5295
 *     external_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5296
 *   | var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5297
 *   | retentive_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5298
 *   | non_retentive_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5299
 *   | temp_var_decls
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5300
 *   | incompl_located_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5301
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5302
 *  Nvertheless, the symbol non_retentive_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5303
 *  is not defined in the spec. This seems to me (Mario)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5304
 *  to be a typo, so non_retentive_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5305
 *  has been replaced with non_retentive_var_decls
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5306
 *  in the following rule!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5307
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5308
other_var_declarations:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5309
  temp_var_decls
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5310
| non_retentive_var_decls
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5311
| external_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5312
| var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5313
| retentive_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5314
| incompl_located_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5315
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5316
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5317
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5318
temp_var_decls:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5319
  VAR_TEMP temp_var_decls_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5320
	{$$ = new temp_var_decls_c($2, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5321
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5322
| VAR_TEMP END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5323
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no variable declared in temporary variable(s) declaration."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5324
| VAR_TEMP temp_var_decls_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5325
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "unclosed temporary variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5326
| VAR_TEMP error temp_var_decls_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5327
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'VAR_TEMP' in function variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5328
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5329
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5330
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5331
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5332
/* intermediate helper symbol for temp_var_decls */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5333
temp_var_decls_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5334
  temp_var_decl ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5335
	{$$ = new temp_var_decls_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5336
| temp_var_decls_list temp_var_decl ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5337
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5338
/* ERROR_CHECK_BEGIN */
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5339
| error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5340
	{$$ = new temp_var_decls_list_c(locloc(@$)); print_err_msg(locf(@1), locl(@1), "invalid temporary variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5341
| temp_var_decl error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5342
	{$$ = new temp_var_decls_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at end of temporary variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5343
| temp_var_decls_list temp_var_decl error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5344
	{$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at end of temporary variable(s) declaration."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  5345
| temp_var_decls_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5346
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid temporary variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5347
| temp_var_decls_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5348
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after temporary variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5349
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5350
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5351
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5352
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5353
non_retentive_var_decls:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5354
  VAR NON_RETAIN var_init_decl_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5355
	{$$ = new non_retentive_var_decls_c($3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5356
/* ERROR_CHECK_BEGIN */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5357
| VAR NON_RETAIN var_init_decl_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5358
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unclosed non-retentive temporary variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5359
| VAR NON_RETAIN error var_init_decl_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5360
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'NON_RETAIN' in non-retentive temporary variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5361
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5362
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5363
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5364
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5365
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5366
function_block_body:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5367
  statement_list	{$$ = $1;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5368
| instruction_list	{$$ = $1;}
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5369
| sequential_function_chart	{$$ = $1;}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5370
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5371
| ladder_diagram
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5372
| function_block_diagram
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5373
| <other languages>
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5374
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5375
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5376
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5377
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5378
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5379
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5380
/**********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5381
/* B 1.5.3 - Programs */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5382
/**********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5383
program_type_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5384
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5385
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5386
program_declaration:
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5387
/* PRE_PARSING: The rules expected to be applied by the preparser. Will only run if pre-parsing command line option is ON. */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5388
  PROGRAM program_type_name END_PROGRAM   /* rule that is only expected to be used during preparse state => MUST print an error if used outside preparse() state!! */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5389
	{$$ = NULL; 
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5390
	 if (get_preparse_state())    {library_element_symtable.insert($2, prev_declared_program_type_name_token);}
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5391
	 else                         {print_err_msg(locl(@1), locf(@3), "PROGRAM with no variable declarations and no body."); yynerrs++;}
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5392
	 }
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5393
/* POST_PARSING: The rules expected to be applied after the preparser runs. Will only run if pre-parsing command line option is ON. */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5394
| PROGRAM prev_declared_program_type_name program_var_declarations_list function_block_body END_PROGRAM
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5395
	{$$ = new program_declaration_c($2, $3, $4, locloc(@$));
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5396
	 /* Clear the variable_name_symtable. Since we have finished parsing the program declaration,
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5397
	  * the variable names are now out of scope, so are no longer valid!
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5398
	  */
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5399
	 variable_name_symtable.pop();
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5400
	 direct_variable_symtable.pop();
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5401
	}
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5402
/* STANDARD_PARSING: The rules expected to be applied in single-phase parsing. Will only run if pre-parsing command line option is OFF. */
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5403
| PROGRAM program_type_name {library_element_symtable.insert($2, prev_declared_program_type_name_token);} program_var_declarations_list function_block_body END_PROGRAM
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5404
	{$$ = new program_declaration_c($2, $4, $5, locloc(@$));
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5405
	 /* Clear the variable_name_symtable. Since we have finished parsing the program declaration,
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5406
	  * the variable names are now out of scope, so are no longer valid!
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5407
	  */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5408
	 variable_name_symtable.pop();
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  5409
	 direct_variable_symtable.pop();
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5410
	}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5411
/* ERROR_CHECK_BEGIN */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5412
| PROGRAM program_var_declarations_list function_block_body END_PROGRAM
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5413
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no program name defined in program declaration.");}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5414
| PROGRAM error program_var_declarations_list function_block_body END_PROGRAM
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5415
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid program name in program declaration."); yyerrok;}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5416
| PROGRAM prev_declared_program_type_name function_block_body END_PROGRAM
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5417
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable(s) declared in program declaration."); yynerrs++;}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5418
| PROGRAM prev_declared_program_type_name program_var_declarations_list END_PROGRAM
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5419
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "no body defined in program declaration."); yynerrs++;}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5420
/*  Rule already covered by the rule to handle the preparse state!
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5421
| PROGRAM prev_declared_program_type_name END_PROGRAM 
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5422
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "no variable(s) declared and body defined in program declaration."); yynerrs++;}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5423
*/
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5424
| PROGRAM prev_declared_program_type_name program_var_declarations_list function_block_body END_OF_INPUT
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5425
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed program declaration."); yynerrs++;}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5426
| PROGRAM error END_PROGRAM
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5427
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in program declaration."); yyerrok;}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5428
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5429
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5430
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5431
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5432
/* helper symbol for program_declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5433
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5434
 * NOTE: we re-use the var_declarations_list_c
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5435
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5436
program_var_declarations_list:
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5437
  io_var_declarations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5438
	{$$ = new var_declarations_list_c(locloc(@$)); $$->add_element($1);}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5439
| other_var_declarations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5440
	{$$ = new var_declarations_list_c(locloc(@$)); $$->add_element($1);}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5441
| located_var_declarations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5442
	{$$ = new var_declarations_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5443
| program_var_declarations_list io_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5444
	{$$ = $1; $$->add_element($2);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5445
| program_var_declarations_list other_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5446
	{$$ = $1; $$->add_element($2);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5447
| program_var_declarations_list located_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5448
	{$$ = $1; $$->add_element($2);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5449
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5450
| program_var_declarations_list program_access_decls
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5451
	{$$ = $1; $$->add_element($2);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5452
*/
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5453
/* ERROR_CHECK_BEGIN */
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5454
| program_var_declarations_list global_var_declarations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5455
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected global variable(s) declaration in function block declaration."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5456
/*| program_var_declarations_list access_declarations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5457
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected access variable(s) declaration in function block declaration."); yynerrs++;}*/
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5458
| program_var_declarations_list instance_specific_initializations
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5459
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected instance specific initialization(s) in function block declaration."); yynerrs++;
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5460
	}
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5461
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5462
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5463
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5464
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5465
/* TODO ... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5466
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5467
program_access_decls:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5468
  VAR_ACCESS program_access_decl_list END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5469
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5470
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5471
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5472
/* helper symbol for program_access_decls */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5473
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5474
program_access_decl_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5475
  program_access_decl ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5476
| program_access_decl_list program_access_decl ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5477
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5478
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5479
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5480
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5481
program_access_decl:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5482
  access_name ':' symbolic_variable ':' non_generic_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5483
| access_name ':' symbolic_variable ':' non_generic_type_name direction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5484
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5485
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5486
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5487
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5488
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5489
/********************************************/
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5490
/* B 1.6 Sequential Function Chart elements *
3
38850ee685e6 ST and IL parsing added into flex-bison analyser
lbessard
parents: 1
diff changeset
  5491
/********************************************/
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5492
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5493
sequential_function_chart:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5494
  sfc_network
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5495
	{$$ = new sequential_function_chart_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5496
| sequential_function_chart sfc_network
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5497
	{$$ = $1; $$->add_element($2);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5498
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5499
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5500
sfc_network:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5501
  initial_step
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5502
	{$$ = new sfc_network_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5503
| sfc_network step
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5504
	{$$ = $1; $$->add_element($2);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5505
| sfc_network transition
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5506
	{$$ = $1; $$->add_element($2);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5507
| sfc_network action
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5508
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5509
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5510
| sfc_network error 
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5511
	{$$ = $1; print_err_msg(locl(@1), locf(@2), "unexpected token after SFC network in sequencial function chart."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5512
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5513
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5514
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5515
initial_step:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5516
  INITIAL_STEP step_name ':' action_association_list END_STEP
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  5517
//  INITIAL_STEP identifier ':' action_association_list END_STEP
616
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5518
	{$$ = new initial_step_c($2, $4, locloc(@$));
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5519
	 variable_name_symtable.insert($2, prev_declared_variable_name_token); // A step name may later be used as a structured variable!!
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5520
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5521
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5522
| INITIAL_STEP ':' action_association_list END_STEP
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5523
  {$$ = NULL; print_err_msg(locf(@1), locl(@2), "no step name defined in initial step declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5524
| INITIAL_STEP error ':' action_association_list END_STEP
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5525
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid step name defined in initial step declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5526
| INITIAL_STEP step_name action_association_list END_STEP
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5527
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "':' missing after step name in initial step declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5528
| INITIAL_STEP step_name ':' error END_STEP
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5529
	{$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid action association list in initial step declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5530
| INITIAL_STEP step_name ':' action_association_list END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5531
	{$$ = NULL; print_err_msg(locf(@1), locl(@3), "unclosed initial step declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5532
| INITIAL_STEP error END_STEP
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5533
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in initial step declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5534
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5535
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5536
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5537
step:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5538
  STEP step_name ':' action_association_list END_STEP
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  5539
//  STEP identifier ':' action_association_list END_STEP
616
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5540
	{$$ = new step_c($2, $4, locloc(@$));
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5541
	 variable_name_symtable.insert($2, prev_declared_variable_name_token); // A step name may later be used as a structured variable!!
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5542
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5543
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5544
| STEP ':' action_association_list END_STEP
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5545
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no step name defined in step declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5546
| STEP error ':' action_association_list END_STEP
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5547
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid step name defined in step declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5548
| STEP step_name action_association_list END_STEP
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5549
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "':' missing after step name in step declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5550
| STEP step_name ':' error END_STEP
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5551
	{$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid action association list in step declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5552
| STEP step_name ':' action_association_list END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5553
	{$$ = NULL; print_err_msg(locf(@1), locl(@3), "invalid action association list in step declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5554
| STEP error END_STEP
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5555
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in step declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5556
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5557
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5558
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5559
/* helper symbol for:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5560
 *  - initial_step
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5561
 *  - step
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5562
 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5563
action_association_list:
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5564
  /* empty */
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5565
	{$$ = new action_association_list_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5566
| action_association_list action_association ';'
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5567
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5568
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5569
| action_association_list action_association error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5570
	{$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at end of action association declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5571
| action_association_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5572
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after action association declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5573
/* ERROR_CHECK_END */
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5574
;
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5575
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5576
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  5577
// step_name: identifier;
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  5578
step_name: any_identifier;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5579
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5580
action_association:
295
e7ce7c6bbb5d Adding missing semicolons.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
  5581
  action_name '(' {cmd_goto_sfc_qualifier_state();} action_qualifier {cmd_pop_state();} indicator_name_list ')'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5582
	{$$ = new action_association_c($1, $4, $6, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5583
/* ERROR_CHECK_BEGIN */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5584
/*| action_name '(' error ')'
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5585
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid qualifier defined in action association."); yyerrok;}*/
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5586
/* ERROR_CHECK_END */
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5587
;
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5588
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5589
/* helper symbol for action_association */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5590
indicator_name_list:
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5591
  /* empty */
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5592
	{$$ = new indicator_name_list_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5593
| indicator_name_list ',' indicator_name
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5594
	{$$ = $1; $$->add_element($3);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5595
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5596
| indicator_name_list indicator_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5597
	{$$ = $1; print_err_msg(locl(@1), locf(@2), "',' missing at end of action association declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5598
| indicator_name_list ',' error
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5599
	{$$ = $1;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5600
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no indicator defined in indicator list.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5601
	 else {print_err_msg(locf(@3), locl(@3), "invalid indicator in indicator list."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5602
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5603
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5604
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5605
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5606
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  5607
// action_name: identifier;
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  5608
action_name: any_identifier;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5609
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5610
action_qualifier:
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5611
  /* empty */
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5612
	{$$ = NULL;}
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5613
| qualifier
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5614
	{$$ = new action_qualifier_c($1, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5615
| timed_qualifier ',' action_time
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5616
	{$$ = new action_qualifier_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5617
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5618
| timed_qualifier action_time
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5619
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "',' missing between timed qualifier and action time in action qualifier."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5620
| timed_qualifier ',' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5621
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5622
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no action time defined in action qualifier.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5623
	 else {print_err_msg(locf(@3), locl(@3), "invalid action time in action qualifier."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5624
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5625
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5626
/* ERROR_CHECK_END */
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5627
;
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5628
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5629
qualifier:
94
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  5630
  N		{$$ = new qualifier_c(strdup("N"), locloc(@$));}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5631
| R		{$$ = new qualifier_c(strdup("R"), locloc(@$));}
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5632
| S		{$$ = new qualifier_c(strdup("S"), locloc(@$));}
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5633
| P		{$$ = new qualifier_c(strdup("P"), locloc(@$));}
627
e7caa7d32ef5 Adding support for P0 and P1 qualifiers and fixing code generated for SL qualifier
Laurent Bessard
parents: 616
diff changeset
  5634
| P0	{$$ = new qualifier_c(strdup("P0"), locloc(@$));}
e7caa7d32ef5 Adding support for P0 and P1 qualifiers and fixing code generated for SL qualifier
Laurent Bessard
parents: 616
diff changeset
  5635
| P1	{$$ = new qualifier_c(strdup("P1"), locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5636
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5637
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5638
timed_qualifier:
94
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  5639
  L		{$$ = new timed_qualifier_c(strdup("L"), locloc(@$));}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5640
| D		{$$ = new timed_qualifier_c(strdup("D"), locloc(@$));}
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5641
| SD		{$$ = new timed_qualifier_c(strdup("SD"), locloc(@$));}
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5642
| DS		{$$ = new timed_qualifier_c(strdup("DS"), locloc(@$));}
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5643
| SL		{$$ = new timed_qualifier_c(strdup("SL"), locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5644
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5645
616
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5646
/* NOTE: A step_name may be used as a structured vaqriable, in order to access the status bit (e.g. Step1.X) 
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5647
 *       or the time it has been active (e.g. Step1.T). 
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5648
 *       In order to allow the step name to be used as a variable inside ST expressions (only ST expressions ??)
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5649
 *       when defining transitions, we need to add the step_name to the list of previously declared variables.
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5650
 *       This allows the step name to be used as a variable inside all transition expressions, as the user
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5651
 *       can clearly define the transition _after_ the step itself has been defined/declared, so the 
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5652
 *       'variable' is previously 'declared'.
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5653
 *
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5654
 *       However, when defining/declaring a step, a variable name can also be used to define a timed
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5655
 *       action association. In this case, we may have a circular reference:
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5656
 *        e.g.
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5657
 *            ...
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5658
 *             STEP step1:
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5659
 *                action1 (D,t#100ms);
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5660
 *             end_step
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5661
 *
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5662
 *             STEP step2:
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5663
 *                action1 (D,step3.T);  <---- forward reference to step3.T !!!!!!
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5664
 *             end_step
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5665
 *
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5666
 *             STEP step3:
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5667
 *                action1 (D,step2.T);  <---- back reference to step2.T
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5668
 *             end_step
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5669
 *
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5670
 *
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5671
 *         There is no way the user can always use the step3.T variable only after it has
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5672
 *         been 'declared'. So adding the steps to the list of previously declared variables 
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5673
 *         when the steps are declared is not a solution to the above situation.
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5674
 *
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5675
 *         Fortunately, the standard does not allow ST expressions in the above syntax
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5676
 *         (i.e. when defining the delay of a timed actions), but only either a 
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5677
 *         Time literal, or a variable.
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5678
 *         This is why we change the definition of action_time from
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5679
 *         action_time:
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5680
 *           duration
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5681
 *         | variable
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5682
 *         ;
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5683
 *
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5684
 *         to:
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5685
 *         action_time:
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5686
 *           duration
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5687
 *         | any_symbolic_variable
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5688
 *         ;
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5689
 *
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5690
 *       NOTE that this same problem does not occur with the 'indicator_name': it does not
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5691
 *       make sense to set/indicate a step1.X variable, as these variables are read-only!
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5692
 */     
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5693
    
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5694
action_time:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5695
  duration
616
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5696
//| variable
0c7663fdc8d3 Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 596
diff changeset
  5697
  | any_symbolic_variable
10
66f4f7f85d0a generate_iec completed
lbessard
parents: 5
diff changeset
  5698
;
66f4f7f85d0a generate_iec completed
lbessard
parents: 5
diff changeset
  5699
66f4f7f85d0a generate_iec completed
lbessard
parents: 5
diff changeset
  5700
indicator_name: variable;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5701
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  5702
// transition_name: identifier;
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  5703
transition_name: any_identifier;
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  5704
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5705
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5706
steps:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5707
  step_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5708
	{$$ = new steps_c($1, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5709
| '(' step_name_list ')'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5710
	{$$ = new steps_c(NULL, $2, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5711
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5712
| '(' step_name_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5713
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "expecting ')' at the end of step list in transition declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5714
| '(' error ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5715
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid step list in transition declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5716
/* ERROR_CHECK_END */
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5717
;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5718
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5719
step_name_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5720
  step_name ',' step_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5721
	{$$ = new step_name_list_c(locloc(@$)); $$->add_element($1); $$->add_element($3);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5722
| step_name_list ',' step_name
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5723
	{$$ = $1; $$->add_element($3);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5724
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5725
| step_name_list step_name
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5726
	{$$ = $1; print_err_msg(locl(@1), locf(@2), "',' missing in step list."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5727
| step_name_list ',' error
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5728
	{$$ = $1;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5729
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no step name defined in step list.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5730
	 else {print_err_msg(locf(@3), locl(@3), "invalid step name in step list."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5731
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5732
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5733
/* ERROR_CHECK_END */
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5734
;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5735
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  5736
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5737
/* NOTE: flex will automatically pop() out of body_state to previous state.
94
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  5738
 *       We do not need to give a command from bison to return to previous flex state,
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  5739
 *       after forcing flex to go to body_state.
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5740
 */
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5741
transition:
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5742
  TRANSITION transition_priority
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5743
    FROM steps TO steps 
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5744
    {cmd_goto_body_state();} transition_condition 
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5745
  END_TRANSITION 
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5746
	{$$ = new transition_c(NULL, $2, $4, $6, $8, locloc(@$));}
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5747
//| TRANSITION identifier FROM steps TO steps ... 
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5748
| TRANSITION transition_name transition_priority
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5749
    FROM steps TO steps 
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5750
    {cmd_goto_body_state();} transition_condition 
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5751
  END_TRANSITION 
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5752
	{$$ = new transition_c($2, $3, $5, $7, $9, locloc(@$));}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5753
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5754
| TRANSITION error transition_priority FROM steps TO steps {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5755
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid transition name defined in transition declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5756
| TRANSITION transition_name error FROM steps TO steps {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5757
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid transition priority defined in transition declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5758
| TRANSITION transition_priority FROM TO steps {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5759
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "no origin step(s) defined in transition declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5760
| TRANSITION transition_name transition_priority FROM TO steps {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5761
	{$$ = NULL; print_err_msg(locl(@4), locf(@5), "no origin step(s) defined in transition declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5762
| TRANSITION transition_priority FROM error TO steps {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5763
	{$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid origin step(s) defined in transition declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5764
| TRANSITION transition_name transition_priority FROM error TO steps {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5765
	{$$ = NULL; print_err_msg(locf(@5), locl(@5), "invalid origin step(s) defined in transition declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5766
| TRANSITION transition_priority FROM steps steps {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5767
	{$$ = NULL; print_err_msg(locl(@4), locf(@5), "'TO' missing between origin step(s) and destination step(s) in transition declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5768
| TRANSITION transition_name transition_priority FROM steps steps {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5769
	{$$ = NULL; print_err_msg(locl(@5), locf(@6), "'TO' missing between origin step(s) and destination step(s) in transition declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5770
| TRANSITION transition_priority FROM steps TO {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5771
	{$$ = NULL; print_err_msg(locl(@5), locf(@7), "no destination step(s) defined in transition declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5772
| TRANSITION transition_name transition_priority FROM steps TO {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5773
	{$$ = NULL; print_err_msg(locl(@6), locf(@8), "no destination step(s) defined in transition declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5774
| TRANSITION transition_priority FROM steps TO error {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5775
	{$$ = NULL; print_err_msg(locf(@6), locl(@6), "invalid destination step(s) defined in transition declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5776
| TRANSITION transition_name transition_priority FROM steps TO error {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5777
	{$$ = NULL; print_err_msg(locf(@7), locl(@7), "invalid destination step(s) defined in transition declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5778
| TRANSITION transition_priority {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5779
	{$$ = NULL; print_err_msg(locl(@2), locf(@4), "no origin and destination step(s) defined in transition declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5780
| TRANSITION transition_name transition_priority {cmd_goto_body_state();} transition_condition END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5781
	{$$ = NULL; print_err_msg(locl(@3), locf(@5), "no origin and destination step(s) defined in transition declaration."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5782
/*| TRANSITION transition_priority FROM steps TO steps {cmd_goto_body_state();} transition_condition error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5783
  {$$ = NULL; print_err_msg(locf(@1), locl(@6), "unclosed transition declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5784
| TRANSITION transition_name transition_priority FROM steps TO steps {cmd_goto_body_state();} transition_condition error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5785
  {$$ = NULL; print_err_msg(locf(@1), locl(@7), "unclosed transition declaration."); yyerrok;}*/
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5786
| TRANSITION error END_TRANSITION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5787
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in transition declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5788
/* ERROR_CHECK_END */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5789
;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5790
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5791
transition_priority:
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5792
  /* empty */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5793
  {$$ = NULL;}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5794
| '(' {cmd_goto_sfc_priority_state();} PRIORITY {cmd_pop_state();} ASSIGN integer ')'
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5795
	{$$ = $6;}
547
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  5796
/* ERROR_CHECK_BEGIN */
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  5797
/* The following error checking rules have been intentionally commented out. */
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  5798
/*
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5799
| '(' ASSIGN integer ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5800
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'PRIORITY' missing between '(' and ':=' in transition declaration with priority."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  5801
| '(' error ASSIGN integer ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5802
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "expecting 'PRIORITY' between '(' and ':=' in transition declaration with priority."); yyerrok;}
547
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  5803
*/
dab341e80664 Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents: 520
diff changeset
  5804
/* ERROR_CHECK_END */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5805
;
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5806
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5807
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5808
transition_condition:
10
66f4f7f85d0a generate_iec completed
lbessard
parents: 5
diff changeset
  5809
  ':' eol_list simple_instr_list
88
dab799d3d4a6 Adding location data to new transition_condition_c.
mario
parents: 87
diff changeset
  5810
	{$$ = new transition_condition_c($3, NULL, locloc(@$));}
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5811
| ASSIGN expression ';'
88
dab799d3d4a6 Adding location data to new transition_condition_c.
mario
parents: 87
diff changeset
  5812
	{$$ = new transition_condition_c(NULL, $2, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5813
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5814
| eol_list simple_instr_list
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5815
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing before IL condition in transition declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5816
| ':' eol_list error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5817
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5818
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no instructions defined in IL condition of transition declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5819
	 else {print_err_msg(locf(@3), locl(@3), "invalid instructions in IL condition of transition declaration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5820
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5821
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5822
| ASSIGN ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5823
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no expression defined in ST condition of transition declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5824
| ASSIGN error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5825
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid expression defined in ST condition of transition declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5826
| ASSIGN expression error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5827
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "expecting ';' after expression defined in ST condition of transition declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5828
/* ERROR_CHECK_END */
10
66f4f7f85d0a generate_iec completed
lbessard
parents: 5
diff changeset
  5829
;
3
38850ee685e6 ST and IL parsing added into flex-bison analyser
lbessard
parents: 1
diff changeset
  5830
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5831
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5832
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5833
action:
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5834
//  ACTION identifier ':' ... 
151
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5835
  ACTION action_name {cmd_goto_body_state();} action_body END_ACTION
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5836
	{$$ = new action_c($2, $4, locloc(@$));}
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5837
/* ERROR_CHECK_BEGIN */
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5838
| ACTION {cmd_goto_body_state();} action_body END_ACTION
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5839
  {$$ = NULL; print_err_msg(locl(@1), locf(@3), "no action name defined in action declaration."); yynerrs++;}
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5840
| ACTION error {cmd_goto_body_state();} action_body END_ACTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5841
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid action name defined in action declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5842
| ACTION action_name {cmd_goto_body_state();} function_block_body END_ACTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5843
	{$$ = NULL; print_err_msg(locl(@2), locf(@4), "':' missing after action name in action declaration."); yynerrs++;}
151
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5844
/*| ACTION action_name {cmd_goto_body_state();} action_body END_OF_INPUT
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5845
	{$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed action declaration."); yyerrok;}*/
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5846
| ACTION error END_ACTION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5847
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in action declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5848
/* ERROR_CHECK_END */
1
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5849
;
5d893a68be6e Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents: 0
diff changeset
  5850
151
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5851
action_body:
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5852
  ':' function_block_body
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5853
  {$$ = $2;}
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5854
/* ERROR_CHECK_BEGIN */
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5855
| ':' error
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5856
	{$$ = NULL;
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5857
	 if (is_current_syntax_token()) {print_err_msg(locl(@1), locf(@2), "no body defined in action declaration.");}
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5858
	 else {print_err_msg(locf(@2), locl(@2), "invalid body defined in action declaration."); yyclearin;}
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5859
	 yyerrok;
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5860
	}
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5861
/* ERROR_CHECK_END */
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5862
;
3b898fb11e73 Bug on language selection in SFC Action fixed
lbessard
parents: 147
diff changeset
  5863
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5864
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5865
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5866
/* B 1.7 Configuration elements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5867
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5868
/* NOTE:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5869
 * It is not clear from reading the specification to which namespace
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5870
 * the names of resources, tasks and programs belong to.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5871
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5872
 * The following syntax assumes that resource and program names belong to the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5873
 * same namespace as the variables defined within
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5874
 * the resource/configuration (i.e. VAR_GLOBAL).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5875
 * Task names belong to a namespace all of their own, since they don't
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5876
 * produce conflicts in the syntax parser, so we might just as well
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5877
 * leave them be! ;-)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5878
 * The above decision was made taking into
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5879
 * account that inside a VAR_CONFIG declaration global variables
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5880
 * may be referenced starting off from the resource name as:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5881
 *   resource_name.program_name.variable_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5882
 * Notice how resource names and program names are used in a very similar
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5883
 * manner as are variable names.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5884
 * Using a single namespace for all the above mentioned names
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5885
 * also makes it easier to write the syntax parser!! ;-) Using a private
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5886
 * namespace for each of the name types (resource names, program names,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5887
 * global varaiable names), i.e. letting the names be re-used across
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5888
 * each of the groups (resource, program, global variables), produces
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5889
 * reduce/reduce conflicts in the syntax parser. Actually, it is only
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5890
 * the resource names that need to be distinguished into a 
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5891
 * prev_declared_resource_name so as not to conflict with [gloabl] variable
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5892
 * names in the 'data' construct.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5893
 * The program names are only tracked to make sure that two programs do not
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5894
 * get the same name.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5895
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5896
 * Using a single namespace does have the drawback that the user will
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5897
 * not be able to re-use names for resources or programs if these
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5898
 * have already been used to name a variable!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5899
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5900
 * If it ever becomes necessary to change this interpretation of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5901
 * the syntax, then this section of the syntax parser must be updated!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5902
 */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5903
prev_declared_global_var_name:    prev_declared_global_var_name_token    {$$ = new identifier_c($1, locloc(@$));};
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5904
prev_declared_resource_name:      prev_declared_resource_name_token      {$$ = new identifier_c($1, locloc(@$));};
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5905
prev_declared_program_name:       prev_declared_program_name_token       {$$ = new identifier_c($1, locloc(@$));};
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5906
prev_declared_configuration_name: prev_declared_configuration_name_token {$$ = new identifier_c($1, locloc(@$));};
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5907
// prev_declared_task_name:       prev_declared_task_name_token          {$$ = new identifier_c($1, locloc(@$));};
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5908
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5909
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5910
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5911
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5912
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5913
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5914
configuration_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5915
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5916
/* NOTE: The specification states that valid resource type names
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5917
 *       are implementation defined, i.e. each implementaion will define
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5918
 *       what resource types it supports.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5919
 *       We are implementing this syntax parser to be used by any
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5920
 *       implementation, so at the moment we accept any identifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5921
 *       as a resource type name.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5922
 *       This implementation should probably be changed in the future. We
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5923
 *       should probably have a resource_type_name_token, and let the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5924
 *       implementation load the global symbol library with the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5925
 *       accepted resource type names before parsing the code.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5926
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5927
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5928
resource_type_name: any_identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5929
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5930
configuration_declaration:
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5931
/* PRE_PARSING: The rules expected to be applied by the preparser. Will only run if pre-parsing command line option is ON. */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5932
  CONFIGURATION configuration_name END_CONFIGURATION   /* rule that is only expected to be used during preparse state */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5933
	{$$ = NULL; 
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5934
	 if (get_preparse_state())    {library_element_symtable.insert($2, prev_declared_configuration_name_token);}
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5935
	 else                         {print_err_msg(locl(@1), locf(@3), "no resource(s) nor program(s) defined in configuration declaration."); yynerrs++;}
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5936
	 }
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5937
/* POST_PARSING: The rules expected to be applied after the preparser runs. Will only run if pre-parsing command line option is ON. */
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5938
| CONFIGURATION prev_declared_configuration_name
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  5939
   global_var_declarations_list
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5940
   single_resource_declaration
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  5941
   {variable_name_symtable.pop();
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  5942
    direct_variable_symtable.pop();}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5943
   optional_access_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5944
   optional_instance_specific_initializations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5945
  END_CONFIGURATION
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5946
	{$$ = new configuration_declaration_c($2, $3, $4, $6, $7, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5947
	 variable_name_symtable.pop();
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  5948
	 direct_variable_symtable.pop();
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5949
	}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  5950
| CONFIGURATION prev_declared_configuration_name
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  5951
   global_var_declarations_list
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5952
   resource_declaration_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5953
   optional_access_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5954
   optional_instance_specific_initializations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5955
 END_CONFIGURATION
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5956
	{$$ = new configuration_declaration_c($2, $3, $4, $5, $6, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5957
	 variable_name_symtable.pop();
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  5958
	 direct_variable_symtable.pop();
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5959
}
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5960
/* STANDARD_PARSING: The rules expected to be applied in single-phase parsing. Will only run if pre-parsing command line option is OFF. */
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5961
| CONFIGURATION configuration_name
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5962
   global_var_declarations_list
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5963
   single_resource_declaration
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5964
   {variable_name_symtable.pop();
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5965
    direct_variable_symtable.pop();}
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5966
   optional_access_declarations
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5967
   optional_instance_specific_initializations
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5968
  END_CONFIGURATION
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5969
	{$$ = new configuration_declaration_c($2, $3, $4, $6, $7, locloc(@$));
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5970
	 variable_name_symtable.pop();
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5971
	 direct_variable_symtable.pop();
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5972
	 library_element_symtable.insert($2, prev_declared_configuration_name_token);
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5973
	}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5974
| CONFIGURATION configuration_name
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  5975
   global_var_declarations_list
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5976
   resource_declaration_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5977
   optional_access_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5978
   optional_instance_specific_initializations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5979
 END_CONFIGURATION
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5980
	{$$ = new configuration_declaration_c($2, $3, $4, $5, $6, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  5981
	 variable_name_symtable.pop();
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  5982
	 direct_variable_symtable.pop();
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  5983
	 library_element_symtable.insert($2, prev_declared_configuration_name_token);
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  5984
}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  5985
/* ERROR_CHECK_BEGIN */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5986
| CONFIGURATION 
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  5987
   global_var_declarations_list
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5988
   single_resource_declaration
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  5989
   {variable_name_symtable.pop();
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  5990
    direct_variable_symtable.pop();}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5991
   optional_access_declarations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5992
   optional_instance_specific_initializations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5993
  END_CONFIGURATION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  5994
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no configuration name defined in configuration declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5995
| CONFIGURATION
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  5996
   global_var_declarations_list
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5997
   resource_declaration_list
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5998
   optional_access_declarations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  5999
   optional_instance_specific_initializations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6000
  END_CONFIGURATION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6001
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no configuration name defined in configuration declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6002
| CONFIGURATION error
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6003
   global_var_declarations_list
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6004
   single_resource_declaration
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  6005
   {variable_name_symtable.pop();
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  6006
    direct_variable_symtable.pop();}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6007
   optional_access_declarations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6008
   optional_instance_specific_initializations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6009
  END_CONFIGURATION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6010
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid configuration name defined in configuration declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6011
| CONFIGURATION error
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6012
   global_var_declarations_list
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6013
   resource_declaration_list
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6014
   optional_access_declarations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6015
   optional_instance_specific_initializations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6016
  END_CONFIGURATION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6017
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid configuration name defined in configuration declaration."); yyerrok;}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  6018
/*  Rule already covered by the rule to handle the preparse state!
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6019
| CONFIGURATION configuration_name
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6020
   global_var_declarations_list
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6021
   optional_access_declarations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6022
   optional_instance_specific_initializations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6023
  END_CONFIGURATION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6024
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "no resource(s) defined in configuration declaration."); yynerrs++;}
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  6025
*/
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6026
| CONFIGURATION configuration_name
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6027
   global_var_declarations_list
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6028
   error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6029
   optional_access_declarations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6030
   optional_instance_specific_initializations
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6031
  END_CONFIGURATION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6032
  {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid resource(s) defined in configuration declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6033
/*| CONFIGURATION configuration_name
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6034
   global_var_declarations_list
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6035
   single_resource_declaration
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  6036
   {variable_name_symtable.pop();
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  6037
    direct_variable_symtable.pop();}
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6038
   optional_access_declarations
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6039
   optional_instance_specific_initializations
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6040
  END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6041
  {$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed configuration declaration."); yyerrok;}*/
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6042
| CONFIGURATION configuration_name
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6043
   global_var_declarations_list
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6044
   resource_declaration_list
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6045
   optional_access_declarations
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6046
   optional_instance_specific_initializations
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6047
  END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6048
  {$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed configuration declaration."); yyerrok;}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6049
| CONFIGURATION error END_CONFIGURATION
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6050
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in configuration declaration."); yyerrok;}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6051
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6052
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6053
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6054
// helper symbol for
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6055
//  - configuration_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6056
//  - resource_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6057
//
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6058
/* NOTE: The IEC 61131-3 v2 standard defines this list as being: [global_var_declarations]
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6059
 *        e.g.:
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6060
 *          'CONFIGURATION' configuration_name  [global_var_declarations] ...
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6061
 *
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6062
 *       However, this means that a single VAR_GLOBAL ... END_VAR construct is allowed
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6063
 *       in each CONFIGURATION or RESOURCE declaration. If the user wishes to have global
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6064
 *       variables with distinct properties (e.g. some with RETAIN, others with CONSTANT,
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6065
 *       and yet other variables with none of these qualifiers), the syntax defined in the 
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6066
 *       standard does not allow this.
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6067
 *       Amazingly, IEC 61131-3 v3 also does not seem to allow it either!!
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6068
 *       Since this is most likely a bug in the standard, we are changing the syntax slightly
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6069
 *       to become:
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6070
 *          'CONFIGURATION' configuration_name  {global_var_declarations} ...
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6071
 *
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6072
 *       Remember that:
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6073
 *          {S}, closure, meaning zero or more concatenations of S.
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6074
 *          [S], option, meaning zero or one occurrence of S.
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6075
 */
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6076
global_var_declarations_list:
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6077
  // empty
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6078
	{$$ = new global_var_declarations_list_c(locloc(@$));}
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6079
| global_var_declarations_list global_var_declarations
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6080
	{$$ = $1; $$->add_element($2);}
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6081
;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6082
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6083
// helper symbol for configuration_declaration //
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6084
optional_access_declarations:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6085
  // empty
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6086
	{$$ = NULL;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6087
//| access_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6088
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6089
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6090
// helper symbol for configuration_declaration //
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6091
optional_instance_specific_initializations:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6092
  // empty
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6093
	{$$ = NULL;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6094
| instance_specific_initializations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6095
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6096
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6097
// helper symbol for configuration_declaration //
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6098
resource_declaration_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6099
  resource_declaration
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6100
	{$$ = new resource_declaration_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6101
| resource_declaration_list resource_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6102
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6103
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6104
| resource_declaration_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6105
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected token after resource declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6106
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6107
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6108
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6109
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6110
resource_declaration:
811
970c582885bf Allow variables declared inside resources to be referenced by res_name.var_name
Mario de Sousa <msousa@fe.up.pt>
parents: 810
diff changeset
  6111
  RESOURCE {variable_name_symtable.push();direct_variable_symtable.push();} resource_name {variable_name_symtable.insert($3, prev_declared_resource_name_token);} ON resource_type_name
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6112
   global_var_declarations_list
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6113
   single_resource_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6114
  END_RESOURCE
811
970c582885bf Allow variables declared inside resources to be referenced by res_name.var_name
Mario de Sousa <msousa@fe.up.pt>
parents: 810
diff changeset
  6115
	{$$ = new resource_declaration_c($3, $6, $7, $8, locloc(@$));
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  6116
	 variable_name_symtable.pop();
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  6117
	 direct_variable_symtable.pop();
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6118
	 variable_name_symtable.insert($3, prev_declared_resource_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6119
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6120
/* ERROR_CHECK_BEGIN */
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  6121
| RESOURCE {variable_name_symtable.push();direct_variable_symtable.push();} ON resource_type_name
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6122
   global_var_declarations_list
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6123
   single_resource_declaration
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6124
  END_RESOURCE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6125
  {$$ = NULL; print_err_msg(locl(@1), locf(@3), "no resource name defined in resource declaration."); yynerrs++;}
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  6126
/*|	RESOURCE {variable_name_symtable.push();direct_variable_symtable.push();} resource_name ON resource_type_name
862
2b6b1202f8a8 Fix bug in standard: standard does not allow multiple VAR_GLOBAL ... END_VAR constructs in configurations and resources. This is probably a bug, so we allow it.
mjsousa
parents: 823
diff changeset
  6127
   global_var_declarations_list
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6128
   single_resource_declaration
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6129
  END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6130
	{$$ = NULL; print_err_msg(locf(@1), locl(@5), "unclosed resource declaration."); yyerrok;}*/
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6131
| RESOURCE error END_RESOURCE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6132
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in resource declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6133
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6134
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6135
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6136
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6137
single_resource_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6138
 task_configuration_list program_configuration_list
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6139
	{$$ = new single_resource_declaration_c($1, $2, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6140
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6141
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6142
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6143
// helper symbol for single_resource_declaration //
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6144
task_configuration_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6145
  // empty
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6146
	{$$ = new task_configuration_list_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6147
| task_configuration_list task_configuration ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6148
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6149
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6150
| task_configuration_list task_configuration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6151
  {$$ = $1; print_err_msg(locl(@1), locf(@2), "';' missing at the end of task configuration in resource declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6152
| task_configuration_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6153
  {$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after task configuration in resource declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6154
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6155
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6156
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6157
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6158
// helper symbol for single_resource_declaration //
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6159
program_configuration_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6160
  program_configuration ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6161
	{$$ = new program_configuration_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6162
| program_configuration_list program_configuration ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6163
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6164
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6165
| program_configuration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6166
  {$$ = new program_configuration_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at the end of program configuration in resource declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6167
| program_configuration_list program_configuration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6168
  {$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at the end of program configuration in resource declaration."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  6169
| program_configuration_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6170
  {$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid program configuration in resource declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6171
| program_configuration_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6172
  {$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after program configuration in resource declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6173
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6174
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6175
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6176
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6177
resource_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6178
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6179
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6180
access_declarations:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6181
 VAR_ACCESS access_declaration_list END_VAR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6182
	{$$ = NULL;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6183
// ERROR_CHECK_BEGIN //
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6184
| VAR_ACCESS END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6185
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no variable declared in access variable(s) declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6186
| VAR_ACCESS error access_declaration_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6187
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'VAR_ACCESS' in access variable(s) declaration."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6188
| VAR_ACCESS access_declaration_list error END_VAR
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6189
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed access variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6190
| VAR_ACCESS error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6191
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in access variable(s) declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6192
// ERROR_CHECK_END //
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6193
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6194
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6195
// helper symbol for access_declarations //
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6196
access_declaration_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6197
  access_declaration ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6198
| access_declaration_list access_declaration ';'
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6199
// ERROR_CHECK_BEGIN //
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  6200
| error ';'
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  6201
  {$$ = // create a new list //;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6202
	 print_err_msg(locf(@1), locl(@1), "invalid access variable declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6203
| access_declaration error
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  6204
  {$$ = // create a new list //;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6205
	 print_err_msg(locl(@1), locf(@2), "';' missing at the end of access variable declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6206
| access_declaration_list access_declaration error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6207
  {$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at the end of access variable declaration."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  6208
| access_declaration_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6209
  {$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid access variable declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6210
| access_declaration_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6211
  {$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after access variable declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6212
// ERROR_CHECK_END //
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6213
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6214
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6215
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6216
access_declaration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6217
  access_name ':' access_path ':' non_generic_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6218
| access_name ':' access_path ':' non_generic_type_name direction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6219
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6220
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6221
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6222
access_path:
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  6223
  prev_declared_direct_variable
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  6224
| prev_declared_resource_name '.' prev_declared_direct_variable
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6225
| any_fb_name_list symbolic_variable
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6226
| prev_declared_resource_name '.' any_fb_name_list symbolic_variable
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6227
| prev_declared_program_name '.'  any_fb_name_list symbolic_variable
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6228
| prev_declared_resource_name '.' prev_declared_program_name '.' any_fb_name_list symbolic_variable
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6229
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6230
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6231
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6232
// helper symbol for
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6233
//  - access_path
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6234
//  - instance_specific_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6235
//
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6236
/* NOTE: The fb_name_list refers to funtion block variables
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6237
 *       that have been declared in a scope outside the one we are
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6238
 *       currently parsing, so we must accept them to be any_identifier!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6239
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6240
 *       Beware that other locations of this syntax parser also require
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6241
 *       a fb_name_list. In those locations the function blocks are being declared,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6242
 *       so only currently un-used identifiers (i.e. identifier) may be accepted.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6243
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6244
 *       In order to distinguish the two, here we use any_fb_name_list, while
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6245
 *       in the the locations we simply use fb_name_list!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6246
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6247
any_fb_name_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6248
  // empty
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6249
	{$$ = new any_fb_name_list_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6250
//| fb_name_list fb_name '.'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6251
| any_fb_name_list any_identifier '.'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6252
	{$$ = $1; $$->add_element($2);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6253
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6254
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6255
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6256
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6257
global_var_reference:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6258
//  [resource_name '.'] global_var_name ['.' structure_element_name] //
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6259
                                  prev_declared_global_var_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6260
	{$$ = new global_var_reference_c(NULL, $1, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6261
|                                 prev_declared_global_var_name '.' structure_element_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6262
	{$$ = new global_var_reference_c(NULL, $1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6263
| prev_declared_resource_name '.' prev_declared_global_var_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6264
	{$$ = new global_var_reference_c($1, $3, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6265
| prev_declared_resource_name '.' prev_declared_global_var_name '.' structure_element_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6266
	{$$ = new global_var_reference_c($1, $3, $5, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6267
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6268
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6269
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6270
//access_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6271
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6272
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6273
program_output_reference:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6274
/* NOTE:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6275
 * program_output_reference is merely used within data_source.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6276
 * data_source is merely used within task_initialization
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6277
 * task_initialization appears in a configuration declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6278
 * _before_ the programs are declared, so we cannot use
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6279
 * prev_declared_program_name, as what might seem correct at first.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6280
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6281
 * The semantic checker must later check whether the identifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6282
 * used really refers to a program declared after the task
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6283
 * initialization!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6284
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6285
//  prev_declared_program_name '.' symbolic_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6286
  program_name '.' symbolic_variable
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6287
	{$$ = new program_output_reference_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6288
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6289
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6290
program_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6291
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6292
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6293
direction:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6294
  READ_WRITE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6295
	{$$ = NULL;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6296
| READ_ONLY
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6297
	{$$ = NULL;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6298
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6299
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6300
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6301
task_configuration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6302
  TASK task_name task_initialization
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6303
	{$$ = new task_configuration_c($2, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6304
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6305
| TASK task_initialization
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6306
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no task name defined in task declaration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6307
| TASK error task_initialization
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6308
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid task name defined in task declaration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6309
| TASK task_name error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6310
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6311
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no task initialization defined in task declaration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6312
	 else {print_err_msg(locf(@3), locl(@3), "invalid task initialization in task declaration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6313
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6314
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6315
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6316
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6317
75
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  6318
/* NOTE: The specification does not mention the namespace to which task names
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6319
 *       should belong to. Unlike resource and program names, for the moment we
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6320
 *       let the task names belong to their own private namespace, as they do not
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6321
 *       produce any conflicts in the syntax parser.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6322
 *       If in the future our interpretation of the spec. turns out to be incorrect,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6323
 *       the definition of task_name may have to be changed!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6324
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6325
task_name: any_identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6326
74
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6327
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6328
task_initialization:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6329
//  '(' [SINGLE ASSIGN data_source ','] [INTERVAL ASSIGN data_source ','] PRIORITY ASSIGN integer ')' //
75
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  6330
  '(' {cmd_goto_task_init_state();} task_initialization_single task_initialization_interval task_initialization_priority ')'
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  6331
	{$$ = new task_initialization_c($3, $4, $5, locloc(@$));}
74
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6332
;
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6333
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6334
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6335
task_initialization_single:
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6336
// [SINGLE ASSIGN data_source ',']
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6337
  /* empty */
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6338
	{$$ = NULL;}
75
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  6339
| SINGLE ASSIGN {cmd_pop_state();} data_source ',' {cmd_goto_task_init_state();} 
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  6340
	{$$ = $4;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6341
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6342
| SINGLE {cmd_pop_state();} data_source ',' {cmd_goto_task_init_state();}
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6343
  {$$ = NULL; print_err_msg(locl(@1), locf(@3), "':=' missing after 'SINGLE' in task initialization."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6344
| SINGLE ASSIGN {cmd_pop_state();} ',' {cmd_goto_task_init_state();}
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6345
  {$$ = NULL; print_err_msg(locl(@2), locf(@4), "no data source defined in 'SINGLE' statement of task initialization."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6346
| SINGLE ASSIGN {cmd_pop_state();} error ',' {cmd_goto_task_init_state();}
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6347
  {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid data source defined in 'SINGLE' statement of task initialization."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6348
/* ERROR_CHECK_END */
74
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6349
;
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6350
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6351
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6352
task_initialization_interval:
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6353
// [INTERVAL ASSIGN data_source ','] 
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6354
  /* empty */
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6355
	{$$ = NULL;}
75
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  6356
| INTERVAL ASSIGN {cmd_pop_state();} data_source ',' {cmd_goto_task_init_state();}
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  6357
	{$$ = $4;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6358
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6359
| INTERVAL {cmd_pop_state();} data_source ',' {cmd_goto_task_init_state();}
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6360
  {$$ = NULL; print_err_msg(locl(@1), locf(@3), "':=' missing after 'INTERVAL' in task initialization.");}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6361
| INTERVAL ASSIGN {cmd_pop_state();} ',' {cmd_goto_task_init_state();}
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6362
  {$$ = NULL; print_err_msg(locl(@2), locf(@4), "no data source defined in 'INTERVAL' statement of task initialization."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6363
| INTERVAL ASSIGN {cmd_pop_state();} error ',' {cmd_goto_task_init_state();}
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6364
  {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid data source defined in 'INTERVAL' statement of task initialization."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6365
/* ERROR_CHECK_END */
75
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  6366
;
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  6367
74
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6368
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6369
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6370
task_initialization_priority:
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6371
// PRIORITY ASSIGN integer
75
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  6372
  PRIORITY ASSIGN {cmd_pop_state();} integer 
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  6373
	{$$ = $4;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6374
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6375
| PRIORITY {cmd_pop_state();} integer
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6376
  {$$ = NULL; print_err_msg(locl(@1), locf(@3), "':=' missing after 'PRIORITY' in task initialization."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6377
| PRIORITY ASSIGN {cmd_pop_state();} error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6378
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6379
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@4), "no priority number defined in 'PRIORITY' statement of task initialization.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6380
	 else {print_err_msg(locf(@4), locl(@4), "invalid priority number in 'PRIORITY' statement of task initialization."); yyclearin;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  6381
	 yyerrok;
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6382
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6383
/* ERROR_CHECK_END */
75
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  6384
;
0e381bdb8888 Fixing handling of task initialisation.
mario
parents: 74
diff changeset
  6385
74
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 73
diff changeset
  6386
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6387
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6388
data_source:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6389
  constant
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6390
| global_var_reference
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6391
| program_output_reference
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  6392
| prev_declared_direct_variable
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6393
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6394
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6395
program_configuration:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6396
//  PROGRAM [RETAIN | NON_RETAIN] program_name [WITH task_name] ':' program_type_name ['(' prog_conf_elements ')'] //
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6397
  PROGRAM program_name optional_task_name ':' prev_declared_program_type_name optional_prog_conf_elements
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6398
	{$$ = new program_configuration_c(NULL, $2, $3, $5, $6, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6399
	 variable_name_symtable.insert($2, prev_declared_program_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6400
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6401
| PROGRAM RETAIN program_name optional_task_name ':' prev_declared_program_type_name optional_prog_conf_elements
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6402
	{$$ = new program_configuration_c(new retain_option_c(locloc(@2)), $3, $4, $6, $7, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6403
	 variable_name_symtable.insert($3, prev_declared_program_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6404
	}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6405
| PROGRAM NON_RETAIN program_name optional_task_name ':' prev_declared_program_type_name optional_prog_conf_elements
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6406
	{$$ = new program_configuration_c(new non_retain_option_c(locloc(@2)), $3, $4, $6, $7, locloc(@$));
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6407
	 variable_name_symtable.insert($3, prev_declared_program_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6408
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6409
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6410
| PROGRAM program_name optional_task_name ':' identifier optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6411
  {$$ = NULL; print_err_msg(locf(@5), locl(@5), "invalid program type name after ':' in program configuration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6412
| PROGRAM RETAIN program_name optional_task_name ':' identifier optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6413
  {$$ = NULL; print_err_msg(locf(@6), locl(@6), "invalid program type name after ':' in program configuration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6414
| PROGRAM NON_RETAIN program_name optional_task_name ':' identifier optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6415
  {$$ = NULL; print_err_msg(locf(@6), locl(@6), "invalid program type name after ':' in program configuration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6416
| PROGRAM error program_name optional_task_name ':' prev_declared_program_type_name optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6417
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'PROGRAM' in program configuration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6418
| PROGRAM RETAIN error program_name optional_task_name ':' prev_declared_program_type_name optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6419
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'RETAIN' in retentive program configuration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6420
| PROGRAM NON_RETAIN error program_name optional_task_name ':' prev_declared_program_type_name optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6421
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "unexpected token after 'NON_RETAIN' in non-retentive program configuration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6422
| PROGRAM optional_task_name ':' prev_declared_program_type_name optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6423
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no program name defined in program configuration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6424
| PROGRAM RETAIN optional_task_name ':' prev_declared_program_type_name optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6425
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "no program name defined in retentive program configuration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6426
| PROGRAM NON_RETAIN optional_task_name ':' prev_declared_program_type_name optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6427
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "no program name defined in non-retentive program configuration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6428
| PROGRAM error optional_task_name ':' prev_declared_program_type_name optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6429
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid program name defined in program configuration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6430
| PROGRAM RETAIN error optional_task_name ':' prev_declared_program_type_name optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6431
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid program name defined in retentive program configuration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6432
| PROGRAM NON_RETAIN error optional_task_name ':' prev_declared_program_type_name optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6433
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid program name defined in non-retentive program configuration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6434
| PROGRAM program_name optional_task_name prev_declared_program_type_name optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6435
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "':' missing after program name or optional task name in program configuration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6436
| PROGRAM RETAIN program_name optional_task_name prev_declared_program_type_name optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6437
  {$$ = NULL; print_err_msg(locl(@4), locf(@5), "':' missing after program name or optional task name in retentive program configuration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6438
| PROGRAM NON_RETAIN program_name optional_task_name prev_declared_program_type_name optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6439
  {$$ = NULL; print_err_msg(locl(@4), locf(@5), "':' missing after program name or optional task name in non-retentive program configuration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6440
| PROGRAM program_name optional_task_name ':' optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6441
  {$$ = NULL; print_err_msg(locl(@4), locf(@5), "no program type defined in program configuration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6442
| PROGRAM RETAIN program_name optional_task_name ':' optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6443
  {$$ = NULL; print_err_msg(locl(@5), locf(@6), "no program type defined in retentive program configuration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6444
| PROGRAM NON_RETAIN program_name optional_task_name ':' optional_prog_conf_elements
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6445
  {$$ = NULL; print_err_msg(locl(@5), locf(@6), "no program type defined in non-retentive program configuration."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6446
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6447
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6448
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6449
// helper symbol for program_configuration //
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6450
optional_task_name:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6451
  // empty //
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6452
	{$$ = NULL;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6453
| WITH task_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6454
	{$$ = $2;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6455
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6456
| WITH error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6457
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6458
	 if (is_current_syntax_token()) {print_err_msg(locl(@1), locf(@2), "no task name defined in optional task name of program configuration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6459
	 else {print_err_msg(locf(@2), locl(@2), "invalid task name in optional task name of program configuration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6460
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6461
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6462
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6463
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6464
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6465
// helper symbol for program_configuration //
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6466
optional_prog_conf_elements:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6467
  // empty //
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6468
	{$$ = NULL;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6469
| '(' prog_conf_elements ')'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6470
	{$$ = $2;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6471
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6472
| '(' error ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6473
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid program configuration elements in program configuration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6474
| '(' prog_conf_elements error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6475
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "')' missing at the end of program configuration elements in program configuration."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6476
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6477
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6478
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6479
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6480
prog_conf_elements:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6481
  prog_conf_element
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6482
	{$$ = new prog_conf_elements_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6483
| prog_conf_elements ',' prog_conf_element
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6484
	{$$ = $1; $$->add_element($3);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6485
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6486
| prog_conf_elements prog_conf_element
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6487
  {$$ = $1; print_err_msg(locl(@1), locf(@2), "',' missing in program configuration elements list."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6488
| prog_conf_elements ',' error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6489
  {$$ = $1;
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6490
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for program configuration element in program configuration list.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6491
	 else {print_err_msg(locf(@3), locl(@3), "invalid value for program configuration element in program configuration list."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6492
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6493
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6494
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6495
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6496
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6497
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6498
prog_conf_element:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6499
  fb_task
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6500
| prog_cnxn
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6501
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6502
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6503
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6504
fb_task:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6505
  // fb_name WITH task_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6506
/* NOTE: The fb_name refers to funtion block variables
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6507
 *       that have been declared in a scope outside the one we are
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6508
 *       currently parsing, so we must accept them to be any_identifier!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6509
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6510
  any_identifier WITH task_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6511
	{$$ = new fb_task_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6512
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6513
| any_identifier WITH error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6514
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6515
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no task name defined in function block configuration.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6516
	 else {print_err_msg(locf(@3), locl(@3), "invalid task name in function block configuration."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6517
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6518
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6519
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6520
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6521
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6522
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6523
/* NOTE:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6524
 *  The semantics of configuring a program are rather confusing, so here is
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6525
 *  my (Mario) understanding on the issue...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6526
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6527
 *  A function/program may have as its input variables a simple variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6528
 *  (BYTE, WORD, etc...), an array (ARRAY [1 .. 3] OF BYTE, ...) , or a structure.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6529
 *  Nevertheless, when calling this function from within a st or il language statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6530
 *  it is not possible to allocate a value to a single element of the array or structure
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6531
 *  typed input variable, as the accepted syntax is simply '(' variable_name ':=' variable ')'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6532
 *  Notice how the variable_name does not include things such as 'a.elem1' or 'a[1]'!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6533
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6534
 *  Nevertheless, when configuring a program from within a configuration,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6535
 *  it becomes possible to allocate values to individual elements of the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6536
 *  array or structured type input variable, as the syntax is now
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6537
 *  '(' symbolic_variable ':=' data_sink|prog_data_source ')'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6538
 *  Notice how the symbolic_variable _does_ include things such as 'a.elem1' or 'a[1]'!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6539
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6540
 *  Conclusion: Unlike other locations in the syntax where SENDTO appears,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6541
 *  here it is not valid to replace symbolic_variable with any_identifier!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6542
 *  Nevertheless, it is also not correct to leave symbolic_variable as it is,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6543
 *  as we have defined it to only include previously declared variables,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6544
 *  which is not the case in this situation. Here symbolic_variable is refering
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6545
 *  to variables that were defined within the scope of the program that is being
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6546
 *  called, and _not_ within the scope of the configuration that is calling the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6547
 *  program, so the variables in question are not declared in the current scope!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6548
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6549
 *  We therefore need to define a new symbolic_variable, that accepts any_identifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6550
 *  instead of previosuly declared variable names, to be used in the definition of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6551
 *  prog_cnxn!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6552
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6553
prog_cnxn:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6554
  any_symbolic_variable ASSIGN prog_data_source
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6555
	{$$ = new prog_cnxn_assign_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6556
| any_symbolic_variable SENDTO data_sink
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6557
	{$$ = new prog_cnxn_sendto_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6558
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6559
| any_symbolic_variable constant
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6560
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' missing between parameter and value in program configuration element."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6561
| any_symbolic_variable enumerated_value
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6562
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' missing between parameter and value in program configuration element."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6563
| any_symbolic_variable data_sink
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6564
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' or '=>' missing between parameter and variable in program configuration element."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6565
| any_symbolic_variable ASSIGN error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6566
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6567
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value or variable defined in program configuration assignment element.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6568
	 else {print_err_msg(locf(@3), locl(@3), "invalid value or variable in program configuration assignment element."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6569
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6570
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6571
| any_symbolic_variable SENDTO error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6572
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6573
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no variable defined in program configuration sendto element.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6574
	 else {print_err_msg(locf(@3), locl(@3), "invalid variable in program configuration sendto element."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6575
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6576
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6577
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6578
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6579
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6580
prog_data_source:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6581
  constant
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6582
| enumerated_value
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6583
| global_var_reference
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  6584
| prev_declared_direct_variable
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6585
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6586
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6587
data_sink:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6588
  global_var_reference
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 151
diff changeset
  6589
| prev_declared_direct_variable
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6590
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6591
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6592
instance_specific_initializations:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6593
 VAR_CONFIG instance_specific_init_list END_VAR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6594
	{$$ = new instance_specific_initializations_c($2, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6595
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6596
| VAR_CONFIG END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6597
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "no variable declared in configuration variable(s) initialization."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6598
| VAR_CONFIG error instance_specific_init_list END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6599
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unexpected token after 'VAR_CONFIG' in configuration variable(s) initialization."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6600
| VAR_CONFIG instance_specific_init_list error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6601
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed configuration variable(s) initialization."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6602
| VAR_CONFIG error END_VAR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6603
	{$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in configuration variable(s) initialization."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6604
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6605
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6606
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6607
// helper symbol for instance_specific_initializations //
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6608
instance_specific_init_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6609
  instance_specific_init ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6610
	{$$ = new instance_specific_init_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6611
| instance_specific_init_list instance_specific_init ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6612
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6613
/* ERROR_CHECK_BEGIN */
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  6614
| error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6615
  {$$ = new instance_specific_init_list_c(locloc(@$)); print_err_msg(locf(@1), locl(@1), "invalid configuration variable initialization."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6616
| instance_specific_init error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6617
  {$$ = new instance_specific_init_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at the end of configuration variable initialization."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6618
| instance_specific_init_list instance_specific_init error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6619
  {$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at the end of configuration variable initialization."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  6620
| instance_specific_init_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6621
  {$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid configuration variable initialization."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6622
| instance_specific_init_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6623
  {$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after configuration variable initialization."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6624
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6625
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6626
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6627
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6628
instance_specific_init:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6629
//
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6630
//  resource_name '.' program_name '.' {fb_name '.'}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6631
//  ((variable_name [location] ':' located_var_spec_init) | (fb_name ':' function_block_type_name ':=' structure_initialization))
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6632
//
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6633
//  prev_declared_resource_name '.' prev_declared_program_name '.' any_fb_name_list variable_name ':' located_var_spec_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6634
/* NOTE: variable_name has been changed to any_identifier (and not simply identifier) because the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6635
 *       variables being referenced have been declared outside the scope currently being parsed!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6636
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6637
/* NOTE: program_name has not been changed to prev_declared_program_name because the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6638
 *       programs being referenced have been declared outside the scope currently being parsed!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6639
 *       The programs are only kept inside the scope of the resource in which they are defined.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6640
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6641
  prev_declared_resource_name '.' program_name '.' any_fb_name_list any_identifier ':' located_var_spec_init
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6642
	{$$ = new instance_specific_init_c($1, $3, $5, $6, NULL, $8, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6643
| prev_declared_resource_name '.' program_name '.' any_fb_name_list any_identifier location ':' located_var_spec_init
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6644
	{$$ = new instance_specific_init_c($1, $3, $5, $6, $7, $9, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6645
| prev_declared_resource_name '.' program_name '.' any_fb_name_list any_identifier ':' fb_initialization
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6646
	{$5->add_element($6); $$ = new instance_specific_init_c($1, $3, $5, NULL, NULL, $8, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6647
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6648
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6649
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6650
/* helper symbol for instance_specific_init */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6651
fb_initialization:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6652
  function_block_type_name ASSIGN structure_initialization
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6653
	{$$ = new fb_initialization_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6654
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6655
| function_block_type_name structure_initialization
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6656
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':=' missing between function block name and initialization in function block initialization."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6657
| function_block_type_name ASSIGN error
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6658
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6659
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no initial value defined in function block initialization.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6660
	 else {print_err_msg(locf(@3), locl(@3), "invalid initial value in function block initialization."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6661
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6662
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6663
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6664
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6665
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6666
/***********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6667
/* B 2.1 Instructions and Operands */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6668
/***********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6669
/* helper symbol for many IL instructions, etc... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6670
/* eat up any extra EOL tokens... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6671
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6672
eol_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6673
  EOL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6674
| eol_list EOL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6675
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6676
94
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  6677
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6678
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6679
instruction_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6680
  il_instruction
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6681
	{$$ = new instruction_list_c(locloc(@$)); $$->add_element($1);}
267
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  6682
| any_pragma eol_list
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  6683
	{$$ = new instruction_list_c(locloc(@1)); $$->add_element($1);} /* locloc(@1) is not a bug! We ignore trailing EOLs when determining symbol location! */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6684
| instruction_list il_instruction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6685
	{$$ = $1; $$->add_element($2);}
267
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  6686
| instruction_list any_pragma
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6687
	{$$ = $1; $$->add_element($2);}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6688
;
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6689
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6690
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6691
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6692
il_instruction:
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6693
  il_incomplete_instruction eol_list
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  6694
	{$$ = new il_instruction_c(NULL, $1, locloc(@1));} /* locloc(@1) is not a bug! We ignore trailing EOLs when determining symbol location! */
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6695
| label ':' il_incomplete_instruction eol_list
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  6696
	{$$ = new il_instruction_c($1, $3, locf(@1), locl(@3));} /* locf(@1), locl(@3) is not a bug! We ignore trailing EOLs when determining symbol location! */
311
8fcea60029de Allow [EOL] after a label in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 295
diff changeset
  6697
| label ':' eol_list
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  6698
	{$$ = new il_instruction_c($1, NULL, locf(@1), locl(@2));} /* locf(@1), locl(@2) is not a bug! We ignore trailing EOLs when determining symbol location! */
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6699
/* ERROR_CHECK_BEGIN */
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6700
| error eol_list
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6701
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid IL instruction."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6702
| il_incomplete_instruction error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6703
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "EOL missing at the end of IL instruction."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6704
| error ':' il_incomplete_instruction eol_list
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6705
	{$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid label in IL instruction."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6706
| label il_incomplete_instruction eol_list
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6707
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing after label in IL instruction."); yynerrs++;}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6708
| label ':' error eol_list
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6709
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid IL instruction."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6710
| label ':' il_incomplete_instruction error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6711
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "EOL missing at the end of IL instruction."); yyerrok;}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6712
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6713
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6714
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6715
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6716
/* helper symbol for il_instruction */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6717
il_incomplete_instruction:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6718
  il_simple_operation
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6719
| il_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6720
| il_jump_operation
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6721
| il_fb_call
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6722
| il_formal_funct_call
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6723
| il_return_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6724
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6725
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6726
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6727
label: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6728
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6729
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6730
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6731
il_simple_operation:
94
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  6732
// (il_simple_operator [il_operand]) | (function_name [il_operand_list])
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6733
  il_simple_operator
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6734
	{$$ = new il_simple_operation_c($1, NULL, locloc(@$));}
93
284ef59bb133 Cleaning up comments.
mario
parents: 92
diff changeset
  6735
/*
284ef59bb133 Cleaning up comments.
mario
parents: 92
diff changeset
  6736
 * Note: Bison is getting confused with the following rule,
94
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  6737
 *       i.e. it is finding conflicts where there seemingly are really none.
93
284ef59bb133 Cleaning up comments.
mario
parents: 92
diff changeset
  6738
 *       The rule was therefore replaced by the equivalent following
284ef59bb133 Cleaning up comments.
mario
parents: 92
diff changeset
  6739
 *       two rules.
284ef59bb133 Cleaning up comments.
mario
parents: 92
diff changeset
  6740
 */
284ef59bb133 Cleaning up comments.
mario
parents: 92
diff changeset
  6741
/*
284ef59bb133 Cleaning up comments.
mario
parents: 92
diff changeset
  6742
| il_simple_operator il_operand
284ef59bb133 Cleaning up comments.
mario
parents: 92
diff changeset
  6743
	{$$ = new il_simple_operation_c($1, $2, locloc(@$));}
284ef59bb133 Cleaning up comments.
mario
parents: 92
diff changeset
  6744
*/
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6745
| il_simple_operator_noclash il_operand
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6746
	{$$ = new il_simple_operation_c($1, $2, locloc(@$));}
91
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  6747
| il_simple_operator_clash il_operand
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  6748
	{$$ = new il_simple_operation_c($1, $2, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6749
/* NOTE: the line
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6750
 *         | il_simple_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6751
 *       already contains the 'NOT' operator, as well as all the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6752
 *       expression operators ('MOD', 'AND', etc...), all of which
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6753
 *       may also be a function name! This means that these operators/functions,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6754
 *       without any operands, could be reduced to either an operator or a
89
5b2ec5c057fa Cleaning up comments.
mario
parents: 88
diff changeset
  6755
 *       function call. 
5b2ec5c057fa Cleaning up comments.
mario
parents: 88
diff changeset
  6756
 *
5b2ec5c057fa Cleaning up comments.
mario
parents: 88
diff changeset
  6757
 *       I (Mario) have chosen to reduce it to an operator.
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6758
 *       In order to do this, we must remove from the syntax that defines
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6759
 *       function calls all the functions whose names clash with the IL operators.
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6760
 *
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6761
 *       The line
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6762
 *         | function_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6763
 *       has been replaced with the lines
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6764
 *         | function_name_no_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6765
 *       in order to include all possible function names except
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6766
 *       those whose names coincide with operators !!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6767
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6768
| function_name_no_clashes
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  6769
	{$$ = new il_function_call_c($1, NULL, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6770
/* NOTE: the line
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6771
 *         | il_simple_operator il_operand
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6772
 *       already contains the 'NOT', 'MOD', etc. operators, followed by a single il_operand.
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6773
 *       However, this same code (MOD x) may also be reduced to a function call to the MOD
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6774
 *       function. This means that (MOD, AND,...) could be interpret as a function name
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6775
 *       or as an IL operator! This would lead us to a reduce/reduce conflict!
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6776
 *
89
5b2ec5c057fa Cleaning up comments.
mario
parents: 88
diff changeset
  6777
 *       I (Mario) have chosen to reduce it to an operand, rather than a function call.
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6778
 *       In order to do this, we must remove from the syntax that defines
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6779
 *       function calls all the functions whose names clash with the IL operators.
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6780
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6781
 *       The line
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6782
 *         | function_name il_operand_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6783
 *       has been replaced with the line
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6784
 *         | function_name_no_clashes il_operand_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6785
 *       in order to include all possible function names except
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6786
 *       for the function names which clash with expression and simple operators.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6787
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6788
 *       Note that:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6789
 *       this alternative syntax does not cover the possibility of
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6790
 *       the function 'NOT', 'MOD', etc... being called with more than one il_operand,
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6791
 *       in which case it is always a function call, and not an IL instruction.
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6792
 *       We therefore need to include an extra rule where the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6793
 *       function_name_expression_clashes and function_name_simpleop_clashes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6794
 *       are followed by a il_operand_list with __two__ or more il_operands!!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6795
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6796
| function_name_no_clashes il_operand_list
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  6797
	{$$ = new il_function_call_c($1, $2, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
91
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  6798
| il_simple_operator_clash il_operand_list2
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  6799
	{$$ = new il_function_call_c(il_operator_c_2_poutype_identifier_c($1), $2, locloc(@$));}
93
284ef59bb133 Cleaning up comments.
mario
parents: 92
diff changeset
  6800
;
284ef59bb133 Cleaning up comments.
mario
parents: 92
diff changeset
  6801
91
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  6802
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6803
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6804
il_expression:
94
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  6805
// il_expr_operator '(' [il_operand] EOL {EOL} [simple_instr_list] ')'
690
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6806
/* IMPORTANT NOTE:
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6807
 *  When the <il_operand> exists, and to make it easier to handle the <il_operand> as a general case (i.e. without C++ code handling this as a special case), 
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6808
 *  we will create an equivalent LD <il_operand> IL instruction, and prepend it into the <simple_instr_list>. 
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6809
 *  The remainder of the compiler may from now on assume that the code being compiled does not contain any IL code like
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6810
 *     LD 1
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6811
 *     ADD ( 2
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6812
 *        SUB 3
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6813
 *        )
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6814
 *
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6815
 * but instead, the equivalent code
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6816
 *     LD 1
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6817
 *     ADD ( 
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6818
 *        LD  2
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6819
 *        SUB 3
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6820
 *        )
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6821
 *
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6822
 * Note, however, that in the first case, we still store in the il_expression_c a pointer to the <il_operand> (the literal '2' in the above example), in case
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6823
 * somewhere further on in the compiler we really want to handle it as a special case. To handle it as a special case, it should be easy to simply delete the first
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6824
 * artificial entry in <simple_instr_list> with il_expression->simple_instr_list->remove_element(0)  !!
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6825
 */
94
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  6826
/*
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  6827
 * Note: Bison is getting confused with the use of il_expr_operator,
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  6828
 *       i.e. it is finding conflicts where there seemingly are really none.
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  6829
 *       il_expr_operator was therefore replaced by the equivalent 
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  6830
 *       il_expr_operator_noclash | il_expr_operator_clash.
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  6831
 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6832
  il_expr_operator_noclash '(' eol_list ')'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6833
	{$$ = new il_expression_c($1, NULL, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6834
| il_expr_operator_noclash '(' il_operand eol_list ')'
690
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6835
	{ simple_instr_list_c *tmp_simple_instr_list = new simple_instr_list_c(locloc(@3));
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6836
	  tmp_simple_instr_list ->insert_element(new il_simple_instruction_c(new il_simple_operation_c(new LD_operator_c(locloc(@3)), $3, locloc(@3)), locloc(@3)), 0);
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6837
	  $$ = new il_expression_c($1, $3, tmp_simple_instr_list, locloc(@$));
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6838
	}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6839
| il_expr_operator_noclash '(' eol_list simple_instr_list ')'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6840
	{$$ = new il_expression_c($1, NULL, $4, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6841
| il_expr_operator_noclash '(' il_operand eol_list simple_instr_list ')'
690
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6842
	{ simple_instr_list_c *tmp_simple_instr_list = dynamic_cast <simple_instr_list_c *> $5;
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6843
	  tmp_simple_instr_list ->insert_element(new il_simple_instruction_c(new il_simple_operation_c(new LD_operator_c(locloc(@3)), $3, locloc(@3)), locloc(@3)), 0);
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6844
	  $$ = new il_expression_c($1, $3, $5, locloc(@$));
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6845
	}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6846
| il_expr_operator_clash '(' eol_list ')'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6847
	{$$ = new il_expression_c($1, NULL, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6848
| il_expr_operator_clash '(' il_operand eol_list ')'
690
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6849
	{ simple_instr_list_c *tmp_simple_instr_list = new simple_instr_list_c(locloc(@3));
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6850
	  tmp_simple_instr_list ->insert_element(new il_simple_instruction_c(new il_simple_operation_c(new LD_operator_c(locloc(@3)), $3, locloc(@3)), locloc(@3)), 0);
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6851
	  $$ = new il_expression_c($1, $3, tmp_simple_instr_list, locloc(@$));
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6852
	}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6853
| il_expr_operator_clash '(' il_operand eol_list simple_instr_list ')'
690
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6854
	{ simple_instr_list_c *tmp_simple_instr_list = dynamic_cast <simple_instr_list_c *> $5;
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6855
	  tmp_simple_instr_list ->insert_element(new il_simple_instruction_c(new il_simple_operation_c(new LD_operator_c(locloc(@3)), $3, locloc(@3)), locloc(@3)), 0);
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6856
	  $$ = new il_expression_c($1, $3, $5, locloc(@$));
6156ee2b4e32 Correctly generate C code for IL expressions, i.e. IL instructions inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 667
diff changeset
  6857
	}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6858
| il_expr_operator_clash_eol_list simple_instr_list ')'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6859
	{$$ = new il_expression_c($1, NULL, $2, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6860
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6861
| il_expr_operator_noclash '(' eol_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6862
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "')' missing at the end of IL expression."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6863
| il_expr_operator_noclash '(' il_operand eol_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6864
  {$$ = NULL; print_err_msg(locl(@4), locf(@5), "')' missing at the end of IL expression."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6865
| il_expr_operator_noclash '(' eol_list simple_instr_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6866
  {$$ = NULL; print_err_msg(locl(@4), locf(@5), "')' missing at the end of IL expression."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6867
| il_expr_operator_noclash '(' il_operand eol_list simple_instr_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6868
  {$$ = NULL; print_err_msg(locl(@5), locf(@6), "')' missing at the end of IL expression."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6869
| il_expr_operator_clash '(' il_operand eol_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6870
  {$$ = NULL; print_err_msg(locl(@4), locf(@5), "')' missing at the end of IL expression."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6871
| il_expr_operator_clash '(' il_operand eol_list simple_instr_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6872
  {$$ = NULL; print_err_msg(locl(@5), locf(@6), "')' missing at the end of IL expression."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6873
| il_expr_operator_clash_eol_list simple_instr_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6874
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "')' missing at the end of IL expression."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6875
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6876
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6877
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6878
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6879
il_jump_operation:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6880
  il_jump_operator label
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6881
	{$$ = new il_jump_operation_c($1, $2, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6882
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6883
| il_jump_operator error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6884
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid label defined in IL jump operation."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6885
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6886
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6887
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6888
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6889
il_fb_call:
94
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  6890
// il_call_operator fb_name ['(' (EOL {EOL} [il_param_list]) | [il_operand_list] ')']
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6891
  il_call_operator prev_declared_fb_name
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6892
	{$$ = new il_fb_call_c($1, $2, NULL, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6893
| il_call_operator prev_declared_fb_name '(' ')'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6894
	{$$ = new il_fb_call_c($1, $2, NULL, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6895
| il_call_operator prev_declared_fb_name '(' eol_list ')'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6896
	{$$ = new il_fb_call_c($1, $2, NULL, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6897
| il_call_operator prev_declared_fb_name '(' il_operand_list ')'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6898
	{$$ = new il_fb_call_c($1, $2, $4, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6899
| il_call_operator prev_declared_fb_name '(' eol_list il_param_list ')'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6900
	{$$ = new il_fb_call_c($1, $2, NULL, $5, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6901
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6902
| il_call_operator error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6903
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6904
	 if (is_current_syntax_token()) {print_err_msg(locl(@1), locf(@2), "no function block name defined in IL function block call.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6905
	 else {print_err_msg(locf(@2), locl(@2), "invalid function block name in IL function block call."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6906
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6907
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6908
| il_call_operator '(' ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6909
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no function block name defined in IL function block call."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6910
| il_call_operator '(' eol_list ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6911
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no function block name defined in IL function block call."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6912
| il_call_operator '(' il_operand_list ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6913
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no function block name defined in IL function block call."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6914
| il_call_operator '(' eol_list il_param_list ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6915
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no function block name defined in IL function block call."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6916
| il_call_operator error '(' ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6917
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid function block name defined in IL function block call."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6918
| il_call_operator error '(' eol_list ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6919
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid function block name defined in IL function block call."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6920
| il_call_operator error '(' il_operand_list ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6921
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid function block name defined in IL function block call."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6922
| il_call_operator error '(' eol_list il_param_list ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6923
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid function block name defined in IL function block call."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6924
| il_call_operator prev_declared_fb_name ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6925
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "'(' missing after function block name defined in IL function block call."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6926
| il_call_operator prev_declared_fb_name il_operand_list ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6927
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "'(' missing after function block name defined in IL function block call."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6928
| il_call_operator prev_declared_fb_name '(' error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6929
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "')' missing at the end of IL function block call."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6930
| il_call_operator prev_declared_fb_name '(' eol_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6931
  {$$ = NULL; print_err_msg(locl(@4), locf(@5), "')' missing at the end of IL function block call."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6932
| il_call_operator prev_declared_fb_name '(' il_operand_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  6933
  {$$ = NULL; print_err_msg(locl(@4), locf(@5), "')' missing at the end of IL function block call."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  6934
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6935
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6936
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6937
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6938
/* NOTE: Please read note above the definition of function_name_without_clashes */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6939
il_formal_funct_call:
94
40288323acc0 Fixing some more comments.
mario
parents: 93
diff changeset
  6940
// function_name '(' EOL {EOL} [il_param_list] ')'
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6941
/*  function_name '(' eol_list ')'  */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6942
/* NOTE: il_formal_funct_call is only used in the definition of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6943
 *         - il_incomplete_instruction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6944
 *         - il_simple_instruction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6945
 *       In both of the above, il_expression also
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6946
 *       shows up as another option. This means that the functions whose
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6947
 *       names clash with expressions, followed by '(' eol_list ')', are
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6948
 *       already included. We must therefore leave them out in this
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6949
 *       definition in order to remove reduce/reduce conflicts.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6950
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6951
 *       In summary: 'MOD' '(' eol_list ')', and all other functions whose
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6952
 *       names clash with expressions may be interpreted by the syntax by
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6953
 *       two different routes. I (Mario) chose to interpret them
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6954
 *       as operators, rather than as function calls!
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6955
 *       (AND MOD OR XOR ADD DIV EQ GT GE LT LE MUL NE SUB)
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6956
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6957
  function_name_no_clashes '(' eol_list ')'
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  6958
	{$$ = new il_formal_funct_call_c($1, NULL, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6959
| function_name_simpleop_clashes '(' eol_list ')'
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  6960
	{$$ = new il_formal_funct_call_c($1, NULL, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6961
/* | function_name '(' eol_list il_param_list ')' */
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6962
/* For the above syntax, we no longer have two ways of interpreting the
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6963
 * same syntax. The above is always a function call!
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6964
 * However, some of the functions that we may be calling
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6965
 * may have the same name as an IL operator. This means that
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6966
 * flex will be parsing them and handing them over to bison as
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6967
 * IL operator tokens, and not as function name tokens.
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6968
 * (when parsing ST, flex no longer recognizes IL operators,
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6969
 * so will always return the correct function name, unless that
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6970
 * name also coincides with an operator used in ST -> XOR, OR, MOD, AND, NOT)
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6971
 *
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6972
 * We must therefore interpret the IL operators as function names!
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6973
 */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6974
| function_name_no_clashes '(' eol_list il_param_list ')'
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  6975
	{$$ = new il_formal_funct_call_c($1, $4, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6976
| function_name_simpleop_clashes '(' eol_list il_param_list ')'
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  6977
	{$$ = new il_formal_funct_call_c($1, $4, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6978
/* The following line should read:
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6979
 *
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6980
 * | function_name_expression_clashes '(' eol_list il_param_list ')'
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6981
 *
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  6982
 * but the function_name_expression_clashes had to be first reduced to
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6983
 * an intermediary symbol in order to remove a reduce/reduce conflict.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6984
 * In essence, the syntax requires more than one look ahead token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6985
 * in order to be parsed. We resolve this by reducing a collection of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6986
 * symbols into a temporary symbol (il_expr_operator_clash_eol_list), that
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6987
 * will later be replaced by the correct symbol. The correct symbol will
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6988
 * now be determined by a single look ahead token, as all the common
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6989
 * symbols have been reduced to the temporary symbol
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6990
 * il_expr_operator_clash_eol_list !
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6991
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6992
 * Unfortunately, this work around results in the wrong symbol
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6993
 * being created for the abstract syntax tree.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6994
 * We need to figure out which symbol was created, destroy it,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6995
 * and create the correct symbol for our case.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6996
 * This is a lot of work, so I put it in a function
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  6997
 * at the end of this file... il_operator_c_2_poutype_identifier_c()
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6998
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  6999
| il_expr_operator_clash_eol_list il_param_list ')'
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  7000
	{$$ = new il_formal_funct_call_c(il_operator_c_2_poutype_identifier_c($1), $2, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7001
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7002
| function_name_no_clashes '(' eol_list error ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7003
  {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid parameter list defined in IL formal function call."); yyerrok;} 
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7004
| function_name_simpleop_clashes '(' eol_list error ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7005
  {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid parameter list defined in IL formal function call."); yyerrok;} 
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7006
| il_expr_operator_clash_eol_list error ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7007
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid parameter list defined in IL formal function call."); yyerrok;} 
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7008
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7009
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7010
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7011
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7012
il_expr_operator_clash_eol_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7013
  il_expr_operator_clash '(' eol_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7014
	{$$ = $1;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7015
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7016
| il_expr_operator_clash '(' error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7017
  {$$ = $1; print_err_msg(locl(@2), locf(@3), "EOL missing after '(' in IL instruction."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7018
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7019
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7020
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7021
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7022
il_operand:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7023
  variable
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7024
| enumerated_value
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7025
| constant
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7026
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7027
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7028
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7029
il_operand_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7030
  il_operand
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7031
	{$$ = new il_operand_list_c(locloc(@$)); $$->add_element($1);}
91
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  7032
| il_operand_list2
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  7033
;
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  7034
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  7035
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  7036
/* List with 2 or more il_operands */ 
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  7037
il_operand_list2:
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  7038
  il_operand ',' il_operand 
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  7039
	{$$ = new il_operand_list_c(locloc(@$)); $$->add_element($1); $$->add_element($3);}
ac119a256fc0 Cleaning up some bison rules.
mario
parents: 90
diff changeset
  7040
| il_operand_list2 ',' il_operand
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7041
	{$$ = $1; $$->add_element($3);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7042
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7043
| il_operand_list2 il_operand
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7044
  {$$ = $1; print_err_msg(locl(@1), locf(@2), "',' missing in IL operand list."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7045
| il_operand ',' error
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7046
  {$$ = new il_operand_list_c(locloc(@$));
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7047
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no operand defined in IL operand list.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7048
	 else {print_err_msg(locf(@3), locl(@3), "invalid operand name in IL operand list."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7049
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7050
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7051
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7052
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7053
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7054
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7055
simple_instr_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7056
  il_simple_instruction
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7057
	{$$ = new simple_instr_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7058
| simple_instr_list il_simple_instruction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7059
	{$$ = $1; $$->add_element($2);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7060
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7061
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7062
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7063
il_simple_instruction:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7064
  il_simple_operation eol_list
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  7065
	{$$ = new il_simple_instruction_c($1, locloc(@1));} /* locloc(@1) is not a bug! We ignore trailing EOLs when determining symbol location! */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7066
| il_expression eol_list
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  7067
	{$$ = new il_simple_instruction_c($1, locloc(@1));} /* locloc(@1) is not a bug! We ignore trailing EOLs when determining symbol location! */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7068
| il_formal_funct_call eol_list
520
fb381d2cd25b Ignore trailing EOLs when determining symbol location.
Mario de Sousa <msousa@fe.up.pt>
parents: 516
diff changeset
  7069
	{$$ = new il_simple_instruction_c($1, locloc(@1));} /* locloc(@1) is not a bug! We ignore trailing EOLs when determining symbol location! */
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7070
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7071
| il_expression error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7072
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "EOL missing after expression IL instruction."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7073
| il_formal_funct_call error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7074
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "EOL missing after formal function call IL instruction."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7075
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7076
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7077
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7078
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7079
/* NOTE: the correct definition of il_param_list is
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7080
 * il_param_list ::= {il_param_instruction} il_param_last_instruction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7081
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7082
 * where {...} denotes zero or many il_param_instruction's.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7083
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7084
 * We could do this by defining the following:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7085
 * il_param_list: il_param_instruction_list il_param_last_instruction;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7086
 * il_param_instruction_list : ** empty ** | il_param_instruction_list il_param_instruction;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7087
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7088
 * Unfortunately, the above leads to reduce/reduce conflicts.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7089
 * The chosen alternative (as follows) does not have any conflicts!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7090
 * il_param_list: il_param_last_instruction | il_param_instruction_list il_param_last_instruction;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7091
 * il_param_instruction_list : il_param_instruction_list | il_param_instruction_list il_param_instruction;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7092
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7093
il_param_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7094
  il_param_instruction_list il_param_last_instruction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7095
	{$$ = $1; $$->add_element($2);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7096
| il_param_last_instruction
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7097
	{$$ = new il_param_list_c(locloc(@$)); $$->add_element($1);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7098
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7099
| il_param_instruction_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7100
  {$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid parameter assignment in parameter assignment list."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7101
| il_param_last_instruction il_param_last_instruction
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7102
  {$$ = new il_param_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "',' missing at the end of parameter assignment in parameter assignment list."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7103
| il_param_instruction_list il_param_last_instruction il_param_last_instruction
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7104
  {$$ = $1; print_err_msg(locl(@2), locf(@3), "',' missing at the end of parameter assignment in parameter assignment list."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7105
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7106
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7107
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7108
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7109
/* Helper symbol for il_param_list */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7110
il_param_instruction_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7111
  il_param_instruction
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7112
	{$$ = new il_param_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7113
| il_param_instruction_list il_param_instruction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7114
	{$$ = $1; $$->add_element($2);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7115
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7116
| il_param_last_instruction il_param_instruction
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7117
  {$$ = new il_param_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "',' missing at the end of parameter assignment in parameter assignment list."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7118
| il_param_instruction_list il_param_last_instruction il_param_instruction
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7119
  {$$ = $1; print_err_msg(locl(@2), locf(@3), "',' missing at the end of parameter assignment in parameter assignment list."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7120
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7121
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7122
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7123
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7124
il_param_instruction:
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7125
  il_param_assignment ',' eol_list 
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7126
| il_param_out_assignment ',' eol_list
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7127
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7128
| il_param_assignment ',' error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7129
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "EOL missing at the end of parameter assignment in parameter assignment list."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7130
| il_param_out_assignment ',' error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7131
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "EOL missing at the end of parameter out assignment in parameter assignment list."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7132
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7133
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7134
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7135
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7136
il_param_last_instruction:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7137
  il_param_assignment eol_list
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7138
| il_param_out_assignment eol_list
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7139
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7140
| il_param_assignment error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7141
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "EOL missing at the end of last parameter assignment in parameter assignment list."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7142
| il_param_out_assignment error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7143
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "EOL missing at the end of last parameter out assignment in parameter assignment list."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7144
/* ERROR_CHECK_END */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7145
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7146
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7147
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7148
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7149
il_param_assignment:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7150
  il_assign_operator il_operand
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7151
	{$$ = new il_param_assignment_c($1, $2, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7152
| il_assign_operator '(' eol_list simple_instr_list ')'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7153
	{$$ = new il_param_assignment_c($1, NULL, $4, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7154
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7155
| error il_operand
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7156
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid operator in parameter assignment."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7157
| error '(' eol_list simple_instr_list ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7158
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid operator in parameter assignment."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7159
| il_assign_operator error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7160
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7161
	 if (is_current_syntax_token()) {print_err_msg(locl(@1), locf(@2), "no operand defined in parameter assignment.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7162
	 else {print_err_msg(locf(@2), locl(@2), "invalid operand in parameter assignment."); yyclearin;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  7163
	 yyerrok;
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  7164
	}
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  7165
| il_assign_operator '(' eol_list ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7166
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "no instruction list defined in parameter assignment."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  7167
| il_assign_operator '(' eol_list error ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7168
  {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid instruction list defined in parameter assignment."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7169
| il_assign_operator '(' eol_list simple_instr_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7170
  {$$ = NULL; print_err_msg(locl(@4), locf(@5), "')' missing at the end of instruction list defined in parameter assignment."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7171
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7172
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7173
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7174
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7175
il_param_out_assignment:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7176
  il_assign_out_operator variable
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7177
	{$$ = new il_param_out_assignment_c($1, $2, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7178
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7179
| il_assign_out_operator error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7180
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7181
	 if (is_current_syntax_token()) {print_err_msg(locl(@1), locf(@2), "no variable defined in IL operand list.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7182
	 else {print_err_msg(locf(@2), locl(@2), "invalid variable in IL operand list."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7183
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7184
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7185
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7186
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7187
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7188
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7189
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7190
/*******************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7191
/* B 2.2 Operators */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7192
/*******************/
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7193
sendto_identifier: sendto_identifier_token {$$ = new identifier_c($1, locloc(@$));};
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7194
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7195
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7196
/* NOTE:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7197
 *  The spec includes the operator 'EQ '
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7198
 * Note that EQ is followed by a space.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7199
 * I am considering this a typo, and defining the operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7200
 * as 'EQ'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7201
 * (Mario)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7202
 */
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7203
LD_operator: 		LD 	{$$ = new LD_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7204
LDN_operator: 		LDN 	{$$ = new LDN_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7205
ST_operator: 		ST 	{$$ = new ST_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7206
STN_operator: 		STN 	{$$ = new STN_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7207
NOT_operator: 		NOT 	{$$ = new NOT_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7208
S_operator: 		S 	{$$ = new S_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7209
R_operator: 		R 	{$$ = new R_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7210
S1_operator: 		S1 	{$$ = new S1_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7211
R1_operator: 		R1 	{$$ = new R1_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7212
CLK_operator: 		CLK 	{$$ = new CLK_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7213
CU_operator: 		CU 	{$$ = new CU_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7214
CD_operator: 		CD 	{$$ = new CD_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7215
PV_operator: 		PV 	{$$ = new PV_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7216
IN_operator: 		IN 	{$$ = new IN_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7217
PT_operator: 		PT 	{$$ = new PT_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7218
AND_operator: 		AND 	{$$ = new AND_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7219
AND2_operator: 		AND2 	{$$ = new AND_operator_c(locloc(@$));}; /* '&' in the source code! */
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7220
OR_operator: 		OR 	{$$ = new OR_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7221
XOR_operator: 		XOR 	{$$ = new XOR_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7222
ANDN_operator: 		ANDN 	{$$ = new ANDN_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7223
ANDN2_operator:		ANDN2 	{$$ = new ANDN_operator_c(locloc(@$));}; /* '&N' in the source code! */
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7224
ORN_operator: 		ORN 	{$$ = new ORN_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7225
XORN_operator: 		XORN 	{$$ = new XORN_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7226
ADD_operator: 		ADD 	{$$ = new ADD_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7227
SUB_operator: 		SUB 	{$$ = new SUB_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7228
MUL_operator: 		MUL 	{$$ = new MUL_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7229
DIV_operator: 		DIV 	{$$ = new DIV_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7230
MOD_operator: 		MOD 	{$$ = new MOD_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7231
GT_operator: 		GT 	{$$ = new GT_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7232
GE_operator: 		GE 	{$$ = new GE_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7233
EQ_operator: 		EQ 	{$$ = new EQ_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7234
LT_operator: 		LT 	{$$ = new LT_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7235
LE_operator: 		LE 	{$$ = new LE_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7236
NE_operator: 		NE 	{$$ = new NE_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7237
CAL_operator: 		CAL 	{$$ = new CAL_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7238
CALC_operator: 		CALC 	{$$ = new CALC_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7239
CALCN_operator: 	CALCN 	{$$ = new CALCN_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7240
RET_operator: 		RET 	{$$ = new RET_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7241
RETC_operator: 		RETC 	{$$ = new RETC_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7242
RETCN_operator: 	RETCN 	{$$ = new RETCN_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7243
JMP_operator: 		JMP 	{$$ = new JMP_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7244
JMPC_operator: 		JMPC 	{$$ = new JMPC_operator_c(locloc(@$));};
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7245
JMPCN_operator: 	JMPCN 	{$$ = new JMPCN_operator_c(locloc(@$));};
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7246
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7247
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7248
il_simple_operator:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7249
  il_simple_operator_clash
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7250
| il_simple_operator_noclash
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7251
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7252
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7253
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7254
il_simple_operator_noclash:
382
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7255
  LDN_operator
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7256
| ST_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7257
| STN_operator
382
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7258
| il_expr_operator_noclash
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7259
;
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7260
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7261
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7262
il_simple_operator_clash:
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7263
  il_simple_operator_clash1
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7264
| il_simple_operator_clash2
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7265
| il_simple_operator_clash3
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7266
;
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7267
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7268
il_simple_operator_clash1:
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7269
  NOT_operator
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7270
;
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7271
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7272
il_simple_operator_clash2:
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7273
  il_expr_operator_clash
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7274
;
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7275
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7276
il_simple_operator_clash3:
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7277
  LD_operator
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7278
| S_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7279
| R_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7280
| S1_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7281
| R1_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7282
| CLK_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7283
| CU_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7284
| CD_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7285
| PV_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7286
| IN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7287
| PT_operator
382
ac6dfec701c9 Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents: 377
diff changeset
  7288
;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7289
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7290
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7291
il_expr_operator:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7292
  il_expr_operator_noclash
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7293
| il_expr_operator_clash
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7294
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7295
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7296
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7297
il_expr_operator_clash:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7298
  AND_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7299
| OR_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7300
| XOR_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7301
| ADD_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7302
| SUB_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7303
| MUL_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7304
| DIV_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7305
| MOD_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7306
| GT_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7307
| GE_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7308
| EQ_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7309
| LT_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7310
| LE_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7311
| NE_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7312
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7313
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7314
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7315
il_expr_operator_noclash:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7316
  ANDN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7317
| ANDN2_operator  /* string '&N' in source code! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7318
| AND2_operator  /* string '&' in source code! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7319
| ORN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7320
| XORN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7321
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7322
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7323
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7324
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7325
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7326
il_assign_operator:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7327
/*  variable_name ASSIGN */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7328
  any_identifier ASSIGN
143
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  7329
	{$$ = new il_assign_operator_c($1, locloc(@$));}
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  7330
| en_identifier ASSIGN
143
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  7331
	{$$ = new il_assign_operator_c($1, locloc(@$));}
239
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7332
| S1_operator ASSIGN
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7333
	{$$ = new il_assign_operator_c(il_operator_c_2_identifier_c($1), locloc(@$));}
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7334
| R1_operator ASSIGN
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7335
	{$$ = new il_assign_operator_c(il_operator_c_2_identifier_c($1), locloc(@$));}
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7336
| CLK_operator ASSIGN
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7337
	{$$ = new il_assign_operator_c(il_operator_c_2_identifier_c($1), locloc(@$));}
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7338
| CU_operator ASSIGN
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7339
	{$$ = new il_assign_operator_c(il_operator_c_2_identifier_c($1), locloc(@$));}
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7340
| CD_operator ASSIGN
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7341
	{$$ = new il_assign_operator_c(il_operator_c_2_identifier_c($1), locloc(@$));}
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7342
| PV_operator ASSIGN
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7343
	{$$ = new il_assign_operator_c(il_operator_c_2_identifier_c($1), locloc(@$));}
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7344
| IN_operator ASSIGN
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7345
	{$$ = new il_assign_operator_c(il_operator_c_2_identifier_c($1), locloc(@$));}
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7346
| PT_operator ASSIGN
b3063ca418c1 Bug when parsing standard function block call in IL
laurent
parents: 207
diff changeset
  7347
	{$$ = new il_assign_operator_c(il_operator_c_2_identifier_c($1), locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7348
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7349
| error ASSIGN
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7350
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid parameter defined in parameter assignment."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7351
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7352
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7353
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7354
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7355
il_assign_out_operator:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7356
/*  variable_name SENDTO */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7357
/*  any_identifier SENDTO */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7358
  sendto_identifier SENDTO
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7359
	{$$ = new il_assign_out_operator_c(NULL, $1, locloc(@$));}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7360
/* The following is not required, as the sendto_identifier_token returned by flex will 
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7361
 * also include the 'ENO' identifier.
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7362
 * The resulting abstract syntax tree is identical with or without this following rule,
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7363
 * as both the eno_identifier and the sendto_identifier are stored as
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7364
 * an identifier_c !!
315
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  7365
 *
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  7366
 * To understand why we must even explicitly consider the use of ENO here,  
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  7367
 * please read the comment above the definition of 'variable' in section B1.4 for details.
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7368
 */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7369
/*
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  7370
| eno_identifier SENDTO
143
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  7371
	{$$ = new il_assign_out_operator_c(NULL, $1, locloc(@$));}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7372
*/
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7373
/*| NOT variable_name SENDTO */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7374
| NOT sendto_identifier SENDTO
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7375
	{$$ = new il_assign_out_operator_c(new not_paramassign_c(locloc(@1)), $2, locloc(@$));}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7376
/* The following is not required, as the sendto_identifier_token returned by flex will 
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7377
 * also include the 'ENO' identifier.
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7378
 * The resulting abstract syntax tree is identical with or without this following rule,
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7379
 * as both the eno_identifier and the sendto_identifier are stored as
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7380
 * an identifier_c !!
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7381
 *
315
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  7382
 * To understand why we must even explicitly consider the use of ENO here,  
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  7383
 * please read the comment above the definition of 'variable' in section B1.4 for details.
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  7384
 *
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7385
 * NOTE: Removing the following rule also removes a shift/reduce conflict from the parser.
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7386
 *       This conflict is not really an error/ambiguity in the syntax, but rather
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7387
 *       due to the fact that more than a single look-ahead token would be required
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7388
 *       to correctly parse the syntax, something that bison does not support.
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7389
 *
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7390
 *       The shift/reduce conflict arises because bison does not know whether
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7391
 *       to parse the 'NOT ENO' in the following code
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7392
 *         LD 1
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7393
 *         funct_name (
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7394
 *                      NOT ENO => bool_var,
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7395
 *                      EN := TRUE
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7396
 *                    )
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7397
 *        as either a il_param_assignment (wrong!) or an il_param_out_assignment.(correct).
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7398
 *        The '=>' delimiter (known as SEND_TO in this iec.y file) is a dead giveaway that 
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7399
 *        it should be parsed as an il_param_out_assignment, but still, bison gets confused!
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7400
 *        Bison considers the possibility of reducing the 'NOT ENO' as an NOT_operator with
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7401
 *        the 'ENO' operand
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7402
 *        (NOT_operator -> il_simple_operator -> il_simple_operation -> il_simple_instruction ->
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7403
 *          -> simple_instr_list -> il_param_assignment)
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7404
 *        instead of reducing it to an il_param_out_operator.
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7405
 *        ( il_param_out_operator -> il_param_out_assignment)
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7406
 *
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7407
 *        Note that the shift/reduce conflict only manifests itself in the il_formal_funct_call,
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7408
 *        where both the il_param_out_assignment and il_param_assignment are used!
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7409
 * 
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7410
 *          il_param_out_assignment --+--> il_param_instruction -> il_param_instruction_list --+
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7411
 *                                    |                                                        |
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7412
 *          il_param_assignment     --+                                                        |
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7413
 *                                                                                             |
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7414
 *                                                     il_formal_funct_call <- il_param_list <-+
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7415
 *
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7416
 */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7417
/*
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  7418
| NOT eno_identifier SENDTO
143
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  7419
	{$$ = new il_assign_out_operator_c(new not_paramassign_c(locloc(@1)), $2, locloc(@$));}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7420
*/
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7421
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7422
| error SENDTO
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7423
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid parameter defined in parameter out assignment."); yyerrok;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  7424
| NOT SENDTO
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7425
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no parameter defined in parameter out assignment."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  7426
| NOT error SENDTO
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7427
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid parameter defined in parameter out assignment."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7428
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7429
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7430
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7431
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7432
il_call_operator:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7433
  CAL_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7434
| CALC_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7435
| CALCN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7436
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7437
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7438
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7439
il_return_operator:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7440
  RET_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7441
| RETC_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7442
| RETCN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7443
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7444
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7445
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7446
il_jump_operator:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7447
  JMP_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7448
| JMPC_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7449
| JMPCN_operator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7450
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7451
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7452
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7453
/***********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7454
/* B 3.1 - Expressions */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7455
/***********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7456
expression:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7457
  xor_expression
933
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  7458
| ref_expression    /* an extension to the IEC 61131-3 v2 standard, based on the IEC 61131-3 v3 standard */ 
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  7459
| deref_expression  /* an extension to the IEC 61131-3 v2 standard, based on the IEC 61131-3 v3 standard */ 
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7460
| expression OR xor_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7461
	{$$ = new or_expression_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7462
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7463
| expression OR error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7464
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7465
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after 'OR' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7466
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after 'OR' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7467
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7468
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7469
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7470
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7471
873
dea39ef02847 Add limited support for the REF() operator (defined in v3 of IEC 61131-3)
mjsousa
parents: 862
diff changeset
  7472
/*  REF(var_name) */
dea39ef02847 Add limited support for the REF() operator (defined in v3 of IEC 61131-3)
mjsousa
parents: 862
diff changeset
  7473
/*  This is an extension to the IEC 61131-3 standard. It is actually defined in the IEC 61131-3 v3 standard */
dea39ef02847 Add limited support for the REF() operator (defined in v3 of IEC 61131-3)
mjsousa
parents: 862
diff changeset
  7474
/*  The REF() operator returns the adrress of the variable. Basically, it returns a pointer to the variable */
dea39ef02847 Add limited support for the REF() operator (defined in v3 of IEC 61131-3)
mjsousa
parents: 862
diff changeset
  7475
ref_expression:
dea39ef02847 Add limited support for the REF() operator (defined in v3 of IEC 61131-3)
mjsousa
parents: 862
diff changeset
  7476
  REF '(' symbolic_variable ')'
dea39ef02847 Add limited support for the REF() operator (defined in v3 of IEC 61131-3)
mjsousa
parents: 862
diff changeset
  7477
	{$$ = new ref_expression_c($3, locloc(@$));}
dea39ef02847 Add limited support for the REF() operator (defined in v3 of IEC 61131-3)
mjsousa
parents: 862
diff changeset
  7478
;
dea39ef02847 Add limited support for the REF() operator (defined in v3 of IEC 61131-3)
mjsousa
parents: 862
diff changeset
  7479
933
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  7480
/*  DREF(var_name) */
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  7481
/*  This is an extension to the IEC 61131-3 standard. It is actually defined in the IEC 61131-3 v3 standard */
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  7482
/*  The DREF() operator accesses the variable stored in the specified address. Basically, it dereferences a pointer to the variable */
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  7483
deref_expression:
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  7484
  DREF '(' symbolic_variable ')'
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  7485
	{$$ = new deref_expression_c($3, locloc(@$));}
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  7486
;
76324f461aed Add support for de-referencing of REF_TO datatypes (Note: dereferencing of arrays and structs not yet supported!)
mjsousa
parents: 932
diff changeset
  7487
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7488
xor_expression:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7489
  and_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7490
| xor_expression XOR and_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7491
	{$$ = new xor_expression_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7492
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7493
| xor_expression XOR error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7494
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7495
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after 'XOR' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7496
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after 'XOR' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7497
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7498
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7499
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7500
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7501
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7502
and_expression:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7503
  comparison
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7504
| and_expression '&' comparison
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7505
	{$$ = new and_expression_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7506
| and_expression AND comparison
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7507
	{$$ = new and_expression_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7508
/* NOTE: The lexical parser never returns the token '&'.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7509
 *       The '&' string is interpreted by the lexcial parser as the token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7510
 *       AND2!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7511
 *       This means that the first rule with '&' is actually not required,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7512
 *       but we leave it in nevertheless just in case we later decide
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7513
 *       to remove the AND2 token...
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7514
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7515
| and_expression AND2 comparison
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7516
	{$$ = new and_expression_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7517
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7518
| and_expression '&' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7519
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7520
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after '&' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7521
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after '&' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7522
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7523
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7524
| and_expression AND error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7525
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7526
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after 'AND' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7527
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after 'AND' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7528
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7529
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7530
| and_expression AND2 error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7531
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7532
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after '&' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7533
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after '&' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7534
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7535
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7536
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7537
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7538
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7539
comparison:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7540
  equ_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7541
| comparison '=' equ_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7542
	{$$ = new equ_expression_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7543
| comparison OPER_NE equ_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7544
	{$$ = new notequ_expression_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7545
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7546
| comparison '=' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7547
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7548
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after '=' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7549
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after '=' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7550
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7551
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7552
| comparison OPER_NE error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7553
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7554
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after '<>' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7555
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after '<>' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7556
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7557
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7558
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7559
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7560
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7561
equ_expression:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7562
  add_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7563
| equ_expression '<' add_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7564
	{$$ = new lt_expression_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7565
| equ_expression '>' add_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7566
	{$$ = new gt_expression_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7567
| equ_expression OPER_LE add_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7568
	{$$ = new le_expression_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7569
| equ_expression OPER_GE add_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7570
	{$$ = new ge_expression_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7571
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7572
| equ_expression '<' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7573
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7574
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after '<' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7575
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after '<' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7576
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7577
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7578
| equ_expression '>' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7579
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7580
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after '>' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7581
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after '>' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7582
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7583
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7584
| equ_expression OPER_LE error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7585
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7586
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after '<=' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7587
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after '<=' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7588
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7589
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7590
| equ_expression OPER_GE error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7591
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7592
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after '>=' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7593
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after '>=' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7594
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7595
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7596
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7597
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7598
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7599
/* Not required...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7600
comparison_operator: '<' | '>' | '>=' '<='
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7601
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7602
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7603
add_expression:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7604
  term
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7605
| add_expression '+' term
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7606
	{$$ = new add_expression_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7607
| add_expression '-' term
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7608
	{$$ = new sub_expression_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7609
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7610
| add_expression '+' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7611
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7612
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after '+' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7613
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after '+' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7614
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7615
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7616
| add_expression '-' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7617
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7618
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after '-' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7619
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after '-' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7620
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7621
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7622
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7623
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7624
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7625
/* Not required...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7626
add_operator: '+' | '-'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7627
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7628
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7629
term:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7630
  power_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7631
| term '*' power_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7632
	{$$ = new mul_expression_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7633
| term '/' power_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7634
	{$$ = new div_expression_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7635
| term MOD power_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7636
	{$$ = new mod_expression_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7637
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7638
| term '*' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7639
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7640
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after '*' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7641
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after '*' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7642
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7643
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7644
| term '/' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7645
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7646
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after '/' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7647
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after '/' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7648
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7649
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7650
| term MOD error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7651
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7652
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after 'MOD' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7653
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after 'MOD' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7654
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7655
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7656
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7657
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7658
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7659
/* Not required...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7660
multiply_operator: '*' | '/' | 'MOD'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7661
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7662
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7663
power_expression:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7664
  unary_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7665
| power_expression OPER_EXP unary_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7666
	{$$ = new power_expression_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7667
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7668
| power_expression OPER_EXP error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7669
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7670
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after '**' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7671
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after '**' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7672
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7673
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7674
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7675
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7676
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7677
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7678
unary_expression:
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7679
  primary_expression
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7680
| '-' non_int_or_real_primary_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7681
	{$$ = new neg_expression_c($2, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7682
| NOT primary_expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7683
	{$$ = new not_expression_c($2, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7684
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7685
| '-' error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7686
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7687
	 if (is_current_syntax_token()) {print_err_msg(locl(@1), locf(@2), "no expression defined after '-' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7688
	 else {print_err_msg(locf(@2), locl(@2), "invalid expression after '-' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7689
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7690
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7691
| NOT error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7692
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7693
	 if (is_current_syntax_token()) {print_err_msg(locl(@1), locf(@2), "no expression defined after 'NOT' in ST expression.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7694
	 else {print_err_msg(locf(@2), locl(@2), "invalid expression after 'NOT' in ST expression."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7695
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7696
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7697
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7698
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7699
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7700
/* Not required...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7701
unary_operator: '-' | 'NOT'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7702
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7703
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7704
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7705
/* NOTE: using constant as a possible symbol for primary_expression
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7706
 *       leads to a reduce/reduce conflict.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7707
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7708
 *       The text '-9' may be parsed as either a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7709
 *       expression<-primary_expression<-constant<-signed_integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7710
 *       (i.e. the constant 9 negative)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7711
 *       OR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7712
 *       expression<-unary_expression<-constant<-integer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7713
 *       (i.e. the constant 9, preceded by a unary negation)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7714
 *
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7715
 *       To remove the conflict, we only allow constants without
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7716
 *       integer or reals that are not preceded by a sign 
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7717
 *       (i.e. a '-' or '+' character) to be used in primary_expression
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7718
 *       (i.e. as a parameter to the unary negation operator)
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7719
 *
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7720
 *       e.g.  '-42', '+54', '42', '54' are all allowed in primary expression
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7721
 *       according to the standard. However, we will allow only '-42' and '+54'
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7722
 *       to be used as an argument to the negation operator ('-').
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7723
 */
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7724
/* NOTE: Notice that the standard considers the following syntax correct:
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7725
 *         VAR intv: INT; END_VAR
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7726
 *         intv :=      42;         <----- OK
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7727
 *         intv :=     -42;         <----- OK
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7728
 *         intv :=     +42;         <----- OK
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7729
 *         intv :=    --42;         <----- OK!!
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7730
 *         intv :=    -+42;         <----- OK!!
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7731
 *         intv :=  -(--42);        <----- OK!!
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7732
 *         intv :=  -(-+42);        <----- OK!!
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7733
 *         intv :=-(-(--42));       <----- OK!!
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7734
 *         intv :=-(-(-+42));       <----- OK!!
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7735
 *     but does NOT allow the following syntax:
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7736
 *         VAR intv: INT; END_VAR
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7737
 *         intv :=   ---42;       <----- ERROR!!
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7738
 *         intv :=   --+42;       <----- ERROR!!
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7739
 *         intv :=  ----42;       <----- ERROR!!
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7740
 *         intv :=  ---+42;       <----- ERROR!!
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7741
 *
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7742
 *    Although strange, we follow the standard to the letter, and do exactly
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7743
 *    as stated above!!
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7744
 */
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  7745
/* NOTE: We use enumerated_value_without_identifier instead of enumerated_value
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  7746
 *       in order to remove a reduce/reduce conflict between reducing an
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  7747
 *       identifier to a variable or an enumerated_value.
78
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  7748
 *
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  7749
 *       This change follows the IEC specification. The specification seems to
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7750
 *       imply (by introducing syntax that allows to unambiguosly reference an
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7751
 *       enumerated value - enum_type#enum_value) that in case the same identifier is used
78
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  7752
 *       for a variable and an enumerated value, then the variable shall be
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7753
 *       considered.
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  7754
 */
643
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7755
non_int_or_real_primary_expression:
1cc0e1ca2aad Fix constant folding: now handles INT_MIN and neg_integer_c correctly.
Mario de Sousa <msousa@fe.up.pt>
parents: 616
diff changeset
  7756
  non_int_or_real_constant
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7757
//| enumerated_value_without_identifier
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7758
| enumerated_value
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7759
| variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7760
| '(' expression ')'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7761
	{$$ = $2;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7762
|  function_invocation
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7763
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7764
| '(' expression error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7765
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "')' missing at the end of expression in ST expression."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7766
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7767
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7768
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7769
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7770
primary_expression:
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7771
  constant
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7772
//| enumerated_value_without_identifier
328
66cd5d9893dd Add support for finding type of a constant enumerated value and managing conflict between same identifiers defined in different enumerated data types
laurent
parents: 315
diff changeset
  7773
| enumerated_value
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7774
| variable
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7775
| '(' expression ')'
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7776
	{$$ = $2;}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7777
|  function_invocation
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7778
/* ERROR_CHECK_BEGIN */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7779
| '(' expression error
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7780
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "')' missing at the end of expression in ST expression."); yyerrok;}
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7781
/* ERROR_CHECK_END */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7782
;
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7783
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7784
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  7785
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7786
/* intermediate helper symbol for primary_expression */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7787
/* NOTE: function_name includes the standard function name 'NOT' !
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7788
 *       This introduces a reduce/reduce conflict, as NOT(var)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7789
 *       may be parsed as either a function_invocation, or a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7790
 *       unary_expression.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7791
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7792
 *       I (Mario) have opted to remove the possible reduction
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7793
 *       to function invocation, which means replacing the rule
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7794
 *           function_name '(' param_assignment_list ')'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7795
 *       with
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7796
 *           function_name_no_NOT_clashes '(' param_assignment_list ')'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7797
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7798
 *       Notice how the new rule does not include the situation where
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7799
 *       the function NOT is called with more than one parameter, which
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7800
 *       the original rule does include! Callinf the NOT function with more
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7801
 *       than one argument is probably a semantic error anyway, so it
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7802
 *       doesn't make much sense to take it into account.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7803
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7804
 *       Nevertheless, if we were to to it entirely correctly,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7805
 *       leaving the semantic checks for the next compiler stage,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7806
 *       this syntax parser would need to include such a possibility.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7807
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7808
 *       We will leave this out for now. No need to complicate the syntax
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7809
 *       more than the specification does by contradicting itself, and
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7810
 *       letting names clash!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7811
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7812
function_invocation:
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7813
/*  function_name '(' [param_assignment_list] ')' */
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7814
  function_name_no_NOT_clashes '(' param_assignment_formal_list ')'
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  7815
	{$$ = new function_invocation_c($1, $3, NULL, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7816
| function_name_no_NOT_clashes '(' param_assignment_nonformal_list ')'
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  7817
	{$$ = new function_invocation_c($1, NULL, $3, locloc(@$)); if (NULL == dynamic_cast<poutype_identifier_c*>($1)) ERROR;} // $1 should be a poutype_identifier_c
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7818
/* ERROR_CHECK_BEGIN */ 
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7819
| function_name_no_NOT_clashes param_assignment_formal_list ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7820
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'(' missing after function name in ST expression."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7821
| function_name_no_NOT_clashes '(' ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7822
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "no parameter defined in function invocation of ST expression."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7823
| function_name_no_NOT_clashes '(' error ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7824
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid parameter(s) defined in function invocation of ST expression."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7825
| function_name_no_NOT_clashes '(' param_assignment_formal_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7826
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "')' missing at the end of function invocation in ST expression."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7827
| function_name_no_NOT_clashes '(' param_assignment_nonformal_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7828
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "')' missing at the end of function invocation in ST expression."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7829
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7830
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7831
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7832
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7833
/********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7834
/* B 3.2 Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7835
/********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7836
statement_list:
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  7837
  statement ';'
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7838
	{$$ = new statement_list_c(locloc(@$)); $$->add_element($1);}
267
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  7839
| any_pragma
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7840
	{$$ = new statement_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7841
| statement_list statement ';'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7842
	{$$ = $1; $$->add_element($2);}
267
0a1204bcc9af starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents: 264
diff changeset
  7843
| statement_list any_pragma
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7844
	{$$ = $1; $$->add_element($2);}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7845
/* ERROR_CHECK_BEGIN */
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  7846
| statement error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7847
	{$$ = new statement_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at the end of statement in ST statement."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  7848
| statement_list statement error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7849
	{$$ = $1; print_err_msg(locl(@2), locf(@3), "';' missing at the end of statement in ST statement."); yyerrok;}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7850
| statement_list error ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7851
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "invalid statement in ST statement."); yyerrok;}
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  7852
| statement_list ';'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7853
	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unexpected ';' after statement in ST statement."); yynerrs++;}
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7854
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7855
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7856
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7857
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7858
statement:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7859
  assignment_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7860
| subprogram_control_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7861
| selection_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7862
| iteration_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7863
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7864
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7865
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7866
/*********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7867
/* B 3.2.1 Assignment Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7868
/*********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7869
assignment_statement:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7870
  variable ASSIGN expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7871
	{$$ = new assignment_statement_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7872
/* ERROR_CHECK_BEGIN */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7873
| error ASSIGN expression
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7874
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid variable before ':=' in ST assignment statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7875
| variable ASSIGN error
133
fff75b8283be Some bugs on syntax checking tests fixed
lbessard
parents: 131
diff changeset
  7876
	{$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7877
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined after ':=' in ST assignment statement.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7878
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression after ':=' in ST assignment statement."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7879
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7880
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7881
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7882
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7883
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7884
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7885
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7886
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7887
/*****************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7888
/* B 3.2.2 Subprogram Control Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7889
/*****************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7890
subprogram_control_statement:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7891
  fb_invocation
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7892
| return_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7893
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7894
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7895
return_statement:
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7896
  RETURN	{$$ = new return_statement_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7897
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7898
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7899
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7900
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7901
fb_invocation:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7902
  prev_declared_fb_name '(' ')'
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  7903
	{$$ = new fb_invocation_c($1, NULL, NULL, locloc(@$));	}
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7904
| prev_declared_fb_name '(' param_assignment_formal_list ')'
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  7905
	{$$ = new fb_invocation_c($1, $3, NULL, locloc(@$));}
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7906
| prev_declared_fb_name '(' param_assignment_nonformal_list ')'
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  7907
	{$$ = new fb_invocation_c($1, NULL, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7908
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7909
| prev_declared_fb_name ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7910
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'(' missing after function block name in ST statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7911
| prev_declared_fb_name param_assignment_formal_list ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7912
	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "'(' missing after function block name in ST statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7913
| prev_declared_fb_name '(' error ')'
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7914
	{$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid parameter list in function block invocation in ST statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7915
| prev_declared_fb_name '(' error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7916
	{$$ = NULL; print_err_msg(locl(@2), locf(@3), "')' missing after parameter list of function block invocation in ST statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7917
| prev_declared_fb_name '(' param_assignment_formal_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7918
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "')' missing after parameter list of function block invocation in ST statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7919
| prev_declared_fb_name '(' param_assignment_nonformal_list error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7920
	{$$ = NULL; print_err_msg(locl(@3), locf(@4), "')' missing after parameter list of function block invocation in ST statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7921
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7922
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7923
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7924
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7925
/* helper symbol for
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7926
 * - fb_invocation
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7927
 * - function_invocation
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7928
 */
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7929
param_assignment_formal_list:
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7930
  param_assignment_formal
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7931
	{$$ = new param_assignment_list_c(locloc(@$)); $$->add_element($1);}
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7932
| param_assignment_formal_list ',' param_assignment_formal
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7933
	{$$ = $1; $$->add_element($3);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7934
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7935
| param_assignment_formal_list ',' error
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  7936
  {$$ = $1;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7937
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no parameter assignment defined in ST parameter assignment list.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7938
	 else {print_err_msg(locf(@3), locl(@3), "invalid parameter assignment in ST parameter assignment list."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7939
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7940
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7941
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7942
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7943
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7944
/* helper symbol for
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7945
 * - fb_invocation
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7946
 * - function_invocation
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7947
 */
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7948
param_assignment_nonformal_list:
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7949
  param_assignment_nonformal
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7950
	{$$ = new param_assignment_list_c(locloc(@$)); $$->add_element($1);}
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7951
| param_assignment_nonformal_list ',' param_assignment_nonformal
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7952
	{$$ = $1; $$->add_element($3);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7953
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7954
| param_assignment_nonformal_list ',' error
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  7955
  {$$ = $1;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7956
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no parameter assignment defined in ST parameter assignment list.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  7957
	 else {print_err_msg(locf(@3), locl(@3), "invalid parameter assignment in ST parameter assignment list."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7958
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7959
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  7960
/* ERROR_CHECK_END */
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7961
;
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7962
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7963
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7964
/* NOTE: According to the IEC 61131-3 standard, there are two possible
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7965
 *       syntaxes for calling function blocks within ST.
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7966
 *       The formal method has the form:
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7967
 *        fb ( invar := x, inoutvar := var1, outvar => var2);
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7968
 *       The non-formal method has the form:
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7969
 *        fb (x, var1, var2);
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7970
 *       In the text of IEC 61131-3 (where the semantics are defined),
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7971
 *       it is obvious that mixing the two syntaxes is considered incorrect.
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7972
 *       The following should therefore be incorrect: 
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7973
 *        fb ( invar := x, var1, var2);
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7974
 *       However, according to the syntax definition, as defined in IEC 61131-3,
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7975
 *       mixing the formal and non-formal methods of invocation is allowed.
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7976
 *       We have two alternatives:
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7977
 *        (a) implement the syntax here in iec.y according to the standard,
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7978
 *            and leave it to the semantic analyser stage to find this error
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7979
 *        (b) or implement the syntax in iec.y correctly, not allowing 
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7980
 *            the mixing of formal and non-formal invocation syntaxes.
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7981
 *       Considering that this is a syntax issue, and not semantic issue,
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7982
 *       I (Mario) have decided to go with alternative (a).
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7983
 *       In other words, in iec.y we do not follow the syntax as defined in
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7984
 *       Annex B of the IEC 61131-3 standard, but rather implement
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7985
 *       the syntax also taking into account the textual part of the standard too.
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7986
 */
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7987
/*
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7988
param_assignment:
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7989
  variable_name ASSIGN expression 
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7990
*/
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7991
param_assignment_nonformal:
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7992
  expression
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7993
;
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7994
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7995
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  7996
param_assignment_formal:
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  7997
  any_identifier ASSIGN expression
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  7998
	{$$ = new input_variable_param_assignment_c($1, $3, locloc(@$));}
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  7999
| en_identifier ASSIGN expression
143
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8000
	{$$ = new input_variable_param_assignment_c($1, $3, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8001
/*| variable_name SENDTO variable */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8002
/*| any_identifier SENDTO variable */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8003
| sendto_identifier SENDTO variable
143
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8004
	{$$ = new output_variable_param_assignment_c(NULL, $1, $3, locloc(@$));}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8005
/* The following is not required, as the sendto_identifier_token returned by flex will 
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8006
 * also include the 'ENO' identifier.
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8007
 * The resulting abstract syntax tree is identical with or without this following rule,
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8008
 * as both the eno_identifier and the sendto_identifier are stored as
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8009
 * an identifier_c !!
315
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  8010
 *
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  8011
 * To understand why we must even explicitly consider the use of ENO here,  
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  8012
 * please read the comment above the definition of 'variable' in section B1.4 for details.
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8013
 */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8014
/*
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8015
| eno_identifier SENDTO variable
143
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8016
	{$$ = new output_variable_param_assignment_c(NULL, $1, $3, locloc(@$));}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8017
*/
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  8018
/*| NOT variable_name SENDTO variable */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8019
/*| NOT any_identifier SENDTO variable*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8020
| NOT sendto_identifier SENDTO variable
143
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8021
	{$$ = new output_variable_param_assignment_c(new not_paramassign_c(locloc(@$)), $2, $4, locloc(@$));}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8022
/* The following is not required, as the sendto_identifier_token returned by flex will 
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8023
 * also include the 'ENO' identifier.
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8024
 * The resulting abstract syntax tree is identical with or without this following rule,
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8025
 * as both the eno_identifier and the sendto_identifier are stored as
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8026
 * an identifier_c !!
315
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  8027
 *
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  8028
 * To understand why we must even explicitly consider the use of ENO here,  
c62a4078f269 Allow use of ENO keyword in structured variable field selector.
Mario de Sousa <msousa@fe.up.pt>
parents: 311
diff changeset
  8029
 * please read the comment above the definition of 'variable' in section B1.4 for details.
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8030
 */
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8031
/*
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8032
| NOT eno_identifier SENDTO variable
143
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8033
	{$$ = new output_variable_param_assignment_c(new not_paramassign_c(locloc(@$)), $2, $4, locloc(@$));}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8034
*/
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8035
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8036
| any_identifier ASSIGN error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8037
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8038
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined in ST formal parameter assignment.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8039
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression in ST formal parameter assignment."); yyclearin;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8040
	 yyerrok;
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8041
	}
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8042
| en_identifier ASSIGN error
143
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8043
  {$$ = NULL;
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8044
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined in ST formal parameter assignment.");}
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8045
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression in ST formal parameter assignment."); yyclearin;}
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8046
	 yyerrok;
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8047
	}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8048
| sendto_identifier SENDTO error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8049
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8050
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined in ST formal parameter out assignment.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8051
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression in ST formal parameter out assignment."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8052
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8053
	}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8054
/*
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8055
| eno_identifier SENDTO error
143
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8056
  {$$ = NULL;
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8057
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined in ST formal parameter out assignment.");}
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8058
	 else {print_err_msg(locf(@3), locl(@3), "invalid expression in ST formal parameter out assignment."); yyclearin;}
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8059
	 yyerrok;
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8060
	}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8061
*/
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8062
| NOT SENDTO variable
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8063
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no parameter name defined in ST formal parameter out negated assignment."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8064
| NOT error SENDTO variable
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8065
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid parameter name defined in ST formal parameter out negated assignment."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8066
| NOT sendto_identifier SENDTO error
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8067
  {$$ = NULL;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8068
	 if (is_current_syntax_token()) {print_err_msg(locl(@3), locf(@4), "no expression defined in ST formal parameter out negated assignment.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8069
	 else {print_err_msg(locf(@4), locl(@4), "invalid expression in ST formal parameter out negated assignment."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8070
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8071
	}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8072
/*
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8073
| NOT eno_identifier SENDTO error
143
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8074
  {$$ = NULL;
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8075
	 if (is_current_syntax_token()) {print_err_msg(locl(@3), locf(@4), "no expression defined in ST formal parameter out negated assignment.");}
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8076
	 else {print_err_msg(locf(@4), locl(@4), "invalid expression in ST formal parameter out negated assignment."); yyclearin;}
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8077
	 yyerrok;
73372bdeeffb Adding support for EN/ENO parameters in bison rules
lbessard
parents: 142
diff changeset
  8078
	}
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8079
*/
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8080
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8081
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8082
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8083
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8084
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8085
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8086
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8087
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8088
/* B 3.2.3 Selection Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8089
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8090
selection_statement:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8091
  if_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8092
| case_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8093
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8094
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8095
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8096
if_statement:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8097
  IF expression THEN statement_list elseif_statement_list END_IF
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8098
	{$$ = new if_statement_c($2, $4, $5, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8099
| IF expression THEN statement_list elseif_statement_list ELSE statement_list END_IF
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8100
	{$$ = new if_statement_c($2, $4, $5, $7, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8101
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8102
| IF THEN statement_list elseif_statement_list END_IF
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8103
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no test expression defined in ST 'IF' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8104
| IF THEN statement_list elseif_statement_list ELSE statement_list END_IF
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8105
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no test expression defined in ST 'IF' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8106
| IF error THEN statement_list elseif_statement_list END_IF
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8107
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid test expression defined for ST 'IF' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8108
| IF error THEN statement_list elseif_statement_list ELSE statement_list END_IF
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8109
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid test expression defined for ST 'IF' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8110
| IF expression error statement_list elseif_statement_list END_IF
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8111
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "expecting 'THEN' after test expression in ST 'IF' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8112
| IF expression error statement_list elseif_statement_list ELSE statement_list END_IF
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8113
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "expecting 'THEN' after test expression in ST 'IF' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8114
| IF expression THEN elseif_statement_list END_IF
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8115
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "no statement defined after 'THEN' in ST 'IF' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8116
| IF expression THEN elseif_statement_list ELSE statement_list END_IF
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8117
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "no statement defined after 'THEN' in ST 'IF' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8118
| IF expression THEN statement_list elseif_statement_list ELSE END_IF
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8119
  {$$ = NULL; print_err_msg(locl(@6), locf(@7), "no statement defined after 'ELSE' in ST 'IF' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8120
| IF expression THEN statement_list elseif_statement_list ELSE error END_IF
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8121
  {$$ = NULL; print_err_msg(locf(@7), locl(@7), "invalid statement defined after 'ELSE' in ST 'IF' statement."); yynerrs++; yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8122
| IF expression error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8123
  {$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed 'IF' statement in ST."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8124
| IF expression THEN statement_list elseif_statement_list END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8125
  {$$ = NULL; print_err_msg(locf(@1), locl(@3), "unclosed 'IF' statement in ST."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8126
| IF expression THEN statement_list elseif_statement_list ELSE statement_list END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8127
  {$$ = NULL; print_err_msg(locf(@1), locl(@3), "unclosed 'IF' statement in ST."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8128
| IF error END_IF
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8129
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in ST 'IF' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8130
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8131
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8132
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8133
/* helper symbol for if_statement */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8134
elseif_statement_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8135
  /* empty */
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8136
	{$$ = new elseif_statement_list_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8137
| elseif_statement_list elseif_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8138
	{$$ = $1; $$->add_element($2);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8139
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8140
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8141
/* helper symbol for elseif_statement_list */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8142
elseif_statement:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8143
  ELSIF expression THEN statement_list
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8144
	{$$ = new elseif_statement_c($2, $4, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8145
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8146
| ELSIF THEN statement_list
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8147
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no test expression defined for 'ELSEIF' statement in ST 'IF' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8148
| ELSIF error THEN statement_list
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8149
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid test expression defined for 'ELSEIF' statement in ST 'IF' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8150
| ELSIF expression error statement_list
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8151
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "expecting 'THEN' after test expression in 'ELSEIF' statement of ST 'IF' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8152
| ELSIF expression THEN error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8153
  {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid statement list in 'ELSEIF' statement of ST 'IF' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8154
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8155
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8156
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8157
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8158
case_statement:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8159
  CASE expression OF case_element_list END_CASE
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8160
	{$$ = new case_statement_c($2, $4, NULL, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8161
| CASE expression OF case_element_list ELSE statement_list END_CASE
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8162
	{$$ = new case_statement_c($2, $4, $6, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8163
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8164
| CASE OF case_element_list END_CASE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8165
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no test expression defined in ST 'CASE' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8166
| CASE OF case_element_list ELSE statement_list END_CASE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8167
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no test expression defined in ST 'CASE' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8168
| CASE error OF case_element_list END_CASE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8169
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid test expression defined for ST 'CASE' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8170
| CASE error OF case_element_list ELSE statement_list END_CASE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8171
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid test expression defined for ST 'CASE' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8172
| CASE expression error case_element_list END_CASE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8173
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "expecting 'OF' after test expression in ST 'CASE' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8174
| CASE expression error case_element_list ELSE statement_list END_CASE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8175
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "expecting 'OF' after test expression in ST 'CASE' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8176
| CASE expression OF END_CASE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8177
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "no case element(s) defined after 'OF' in ST 'CASE' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8178
| CASE expression OF ELSE statement_list END_CASE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8179
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "no case element(s) defined after 'OF' in ST 'CASE' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8180
| CASE expression OF error END_CASE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8181
  {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid case element(s) defined after 'OF' in ST 'CASE' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8182
| CASE expression OF error ELSE statement_list END_CASE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8183
  {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid case element(s) defined after 'OF' in ST 'CASE' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8184
| CASE expression OF case_element_list ELSE END_CASE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8185
  {$$ = NULL; print_err_msg(locl(@5), locf(@6), "no statement defined after 'ELSE' in ST 'CASE' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8186
| CASE expression OF case_element_list ELSE error END_CASE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8187
  {$$ = NULL; print_err_msg(locf(@6), locl(@6), "invalid statement defined after 'ELSE' in ST 'CASE' statement."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8188
| CASE expression error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8189
  {$$ = NULL; print_err_msg(locf(@1), locl(@2), "unclosed 'CASE' statement in ST."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8190
| CASE expression OF case_element_list END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8191
  {$$ = NULL; print_err_msg(locf(@1), locl(@3), "unclosed 'CASE' statement in ST."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8192
| CASE expression OF case_element_list ELSE statement_list END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8193
  {$$ = NULL; print_err_msg(locf(@1), locl(@3), "unclosed 'CASE' statement in ST."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8194
| CASE error END_CASE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8195
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in ST 'CASE' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8196
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8197
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8198
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8199
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8200
/* helper symbol for case_statement */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8201
case_element_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8202
  case_element
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8203
	{$$ = new case_element_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8204
| case_element_list case_element
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8205
	{$$ = $1; $$->add_element($2);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8206
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8207
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8208
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8209
case_element:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8210
  case_list ':' statement_list
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8211
	{$$ = new case_element_c($1, $3, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8212
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8213
| case_list statement_list
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8214
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing after case list in ST 'CASE' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8215
| case_list ':' error
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8216
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "invalid statement in case element of ST 'CASE' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8217
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8218
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8219
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8220
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8221
case_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8222
  case_list_element
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8223
	{$$ = new case_list_c(locloc(@$)); $$->add_element($1);}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8224
| case_list ',' case_list_element
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8225
	{$$ = $1; $$->add_element($3);}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8226
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8227
| case_list ',' error
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  8228
  {$$ = $1;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8229
	 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no case defined in case list of ST parameter assignment list.");}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8230
	 else {print_err_msg(locf(@3), locl(@3), "invalid case in case list of ST parameter assignment list."); yyclearin;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8231
	 yyerrok;
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8232
	}
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8233
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8234
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8235
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8236
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8237
case_list_element:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8238
  signed_integer
78
aead91ec37cd removing 'identifier' from definition of symbolic_variable
mario
parents: 77
diff changeset
  8239
| subrange
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8240
| enumerated_value
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8241
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8242
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8243
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8244
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8245
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8246
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8247
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8248
/* B 3.2.4 Iteration Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8249
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8250
iteration_statement:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8251
  for_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8252
| while_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8253
| repeat_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8254
| exit_statement
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8255
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8256
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8257
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8258
for_statement:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8259
  FOR control_variable ASSIGN expression TO expression BY expression DO statement_list END_FOR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8260
	{$$ = new for_statement_c($2, $4, $6, $8, $10, locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8261
| FOR control_variable ASSIGN expression TO expression DO statement_list END_FOR
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8262
	{$$ = new for_statement_c($2, $4, $6, NULL, $8, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8263
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8264
| FOR ASSIGN expression TO expression BY expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8265
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no control variable defined in ST 'FOR' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8266
| FOR ASSIGN expression TO expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8267
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no control variable defined in ST 'FOR' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8268
| FOR error ASSIGN expression TO expression BY expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8269
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid control variable defined for ST 'FOR' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8270
| FOR error ASSIGN expression TO expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8271
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid control variable defined for ST 'FOR' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8272
| FOR control_variable expression TO expression BY expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8273
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "':=' missing between control variable and start expression in ST 'FOR' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8274
| FOR control_variable expression TO expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8275
  {$$ = NULL; print_err_msg(locl(@2), locf(@3), "':=' missing between control variable and start expression in ST 'FOR' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8276
| FOR control_variable error expression TO expression BY expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8277
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "expecting ':=' between control variable and start expression in ST 'FOR' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8278
| FOR control_variable error expression TO expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8279
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "expecting ':=' between control variable and start expression in ST 'FOR' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8280
| FOR control_variable ASSIGN TO expression BY expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8281
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "no start expression defined in ST 'FOR' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8282
| FOR control_variable ASSIGN TO expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8283
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "no start expression defined in ST 'FOR' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8284
| FOR control_variable ASSIGN error TO expression BY expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8285
  {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid start expression defined in ST 'FOR' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8286
| FOR control_variable ASSIGN error TO expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8287
  {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid start expression in ST 'FOR' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8288
| FOR control_variable ASSIGN expression error expression BY expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8289
  {$$ = NULL; print_err_msg(locf(@5), locl(@5), "expecting 'TO' between start expression and end expression in ST 'FOR' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8290
| FOR control_variable ASSIGN expression error expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8291
  {$$ = NULL; print_err_msg(locf(@5), locl(@5), "expecting 'TO' between start expression and end expression in ST 'FOR' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8292
| FOR control_variable ASSIGN expression TO expression error expression DO statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8293
  {$$ = NULL; print_err_msg(locf(@7), locl(@7), "expecting 'BY' between end expression and step expression in ST 'FOR' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8294
| FOR control_variable ASSIGN expression TO expression BY expression error statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8295
  {$$ = NULL; print_err_msg(locf(@9), locl(@9), "expecting 'DO' after step expression in ST 'FOR' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8296
| FOR control_variable ASSIGN expression TO expression error statement_list END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8297
  {$$ = NULL; print_err_msg(locf(@7), locl(@7), "expecting 'DO' after end expression in ST 'FOR' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8298
| FOR control_variable ASSIGN expression TO expression BY expression DO END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8299
  {$$ = NULL; print_err_msg(locl(@9), locf(@10), "no statement(s) defined after 'DO' in ST 'FOR' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8300
| FOR control_variable ASSIGN expression TO expression DO END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8301
  {$$ = NULL; print_err_msg(locl(@7), locf(@8), "no statement(s) defined after 'DO' in ST 'FOR' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8302
| FOR control_variable ASSIGN expression TO expression BY expression DO error END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8303
  {$$ = NULL; print_err_msg(locf(@10), locl(@10), "invalid statement(s) defined after 'DO' in ST 'FOR' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8304
| FOR control_variable ASSIGN expression TO expression DO error END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8305
  {$$ = NULL; print_err_msg(locf(@8), locl(@8), "invalid statement(s) defined after 'DO' in ST 'FOR' statement."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8306
| FOR control_variable error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8307
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed 'FOR' statement in ST."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8308
| FOR control_variable ASSIGN expression error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8309
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed 'FOR' statement in ST."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8310
| FOR control_variable ASSIGN expression TO expression DO statement_list END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8311
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed 'FOR' statement in ST."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8312
| FOR control_variable ASSIGN expression TO expression BY expression error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8313
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed 'FOR' statement in ST."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8314
| FOR control_variable ASSIGN expression TO expression BY expression DO statement_list END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8315
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed 'FOR' statement in ST."); yynerrs++;}
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  8316
| FOR error END_FOR
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8317
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in ST 'FOR' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8318
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8319
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8320
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8321
/* The spec has the syntax
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8322
 * control_variable: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8323
 * but then defines the semantics of control_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8324
 * (Section 3.3.2.4) as being of an integer type
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8325
 * (e.g., SINT, INT, or DINT).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8326
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8327
 * Obviously this presuposes that the control_variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8328
 * must have been declared in some VAR .. END_VAR
79
7417b346e5a3 fixing buf in FOR control variable.
mario
parents: 78
diff changeset
  8329
 * We must therefore change the syntax to read
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8330
 * control_variable: prev_declared_variable_name;
13
77174ccc5471 Many major changes to support SFC!
mario
parents: 10
diff changeset
  8331
 * 
79
7417b346e5a3 fixing buf in FOR control variable.
mario
parents: 78
diff changeset
  8332
 * If we don't, then the correct use of any previosuly declared 
7417b346e5a3 fixing buf in FOR control variable.
mario
parents: 78
diff changeset
  8333
 * variable would result in an incorrect syntax error
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8334
*/
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8335
control_variable: 
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8336
  prev_declared_variable_name 
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8337
	{$$ = new symbolic_variable_c($1,locloc(@$));};
79
7417b346e5a3 fixing buf in FOR control variable.
mario
parents: 78
diff changeset
  8338
// control_variable: identifier {$$ = $1;};
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8339
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8340
/* Integrated directly into for_statement */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8341
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8342
for_list:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8343
  expression TO expression [BY expression]
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8344
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8345
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8346
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8347
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8348
while_statement:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8349
  WHILE expression DO statement_list END_WHILE
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8350
	{$$ = new while_statement_c($2, $4, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8351
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8352
| WHILE DO statement_list END_WHILE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8353
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no test expression defined in ST 'WHILE' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8354
| WHILE error DO statement_list END_WHILE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8355
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid test expression defined for ST 'WHILE' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8356
| WHILE expression error statement_list END_WHILE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8357
  {$$ = NULL; print_err_msg(locf(@3), locl(@3), "expecting 'DO' after test expression in ST 'WHILE' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8358
| WHILE expression DO END_WHILE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8359
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "no statement(s) defined after 'DO' in ST 'WHILE' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8360
| WHILE expression DO error END_WHILE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8361
  {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid statement(s) defined after 'DO' in ST 'WHILE' statement."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8362
| WHILE expression error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8363
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed 'WHILE' statement in ST."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8364
| WHILE expression DO statement_list END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8365
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed 'WHILE' statement in ST."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8366
| WHILE error END_WHILE
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8367
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in ST 'WHILE' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8368
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8369
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8370
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8371
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8372
repeat_statement:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8373
  REPEAT statement_list UNTIL expression END_REPEAT
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8374
	{$$ = new repeat_statement_c($2, $4, locloc(@$));}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8375
/* ERROR_CHECK_BEGIN */
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8376
| REPEAT UNTIL expression END_REPEAT
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8377
  {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no statement(s) defined after 'REPEAT' in ST 'REPEAT' statement."); yynerrs++;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8378
| REPEAT error UNTIL expression END_REPEAT
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8379
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid statement(s) defined after 'REPEAT' for ST 'REPEAT' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8380
| REPEAT statement_list UNTIL END_REPEAT
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8381
  {$$ = NULL; print_err_msg(locl(@3), locf(@4), "no test expression defined after 'UNTIL' in ST 'REPEAT' statement.");}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8382
| REPEAT statement_list UNTIL error END_REPEAT
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8383
  {$$ = NULL; print_err_msg(locf(@4), locl(@4), "invalid test expression defined after 'UNTIL' in ST 'REPEAT' statement."); yyerrok;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8384
| REPEAT statement_list END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8385
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed 'REPEAT' statement in ST."); yynerrs++;}
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8386
| REPEAT statement_list UNTIL expression error END_OF_INPUT
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8387
  {$$ = NULL; print_err_msg(locf(@1), locl(@1), "unclosed 'REPEAT' statement in ST."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8388
| REPEAT error END_REPEAT
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8389
  {$$ = NULL; print_err_msg(locf(@2), locl(@2), "unknown error in ST 'REPEAT' statement."); yyerrok;}
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8390
/* ERROR_CHECK_END */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8391
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8392
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8393
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8394
exit_statement:
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8395
  EXIT	{$$ = new exit_statement_c(locloc(@$));}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8396
;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8397
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8398
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8399
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8400
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8401
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8402
%%
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8403
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8404
#include <stdio.h>	/* required for printf() */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8405
#include <errno.h>
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8406
#include "../util/symtable.hh"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8407
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  8408
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8409
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8410
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8411
/*************************************************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8412
/* NOTE: These variables are really parameters we would like the stage2__ function to pass       */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8413
/*       to the yyparse() function. However, the yyparse() function is created automatically     */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8414
/*       by bison, so we cannot add parameters to this function. The only other                  */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8415
/*       option is to use global variables! yuck!                                                */ 
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8416
/*************************************************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8417
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  8418
/* A global flag used to tell the parser if overloaded funtions should be allowed.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  8419
 * The IEC 61131-3 standard allows overloaded funtions in the standard library,
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  8420
 * but disallows them in user code...
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8421
 *
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8422
 * In essence, a parameter we would like to pass to the yyparse() function but
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8423
 * have to do it using a global variable, as the yyparse() prototype is fixed by bison.
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  8424
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  8425
bool allow_function_overloading = false;
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  8426
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8427
/* | [var1_list ','] variable_name '..' */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8428
/* NOTE: This is an extension to the standard!!! */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8429
/* In order to be able to handle extensible standard functions
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8430
 * (i.e. standard functions that may have a variable number of
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8431
 * input parameters, such as AND(word#33, word#44, word#55, word#66),
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8432
 * we have extended the acceptable syntax to allow var_name '..'
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8433
 * in an input variable declaration.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8434
 *
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8435
 * This allows us to parse the declaration of standard
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8436
 * extensible functions and load their interface definition
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8437
 * into the abstract syntax tree just like we do to other 
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8438
 * user defined functions.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8439
 * This has the advantage that we can later do semantic
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8440
 * checking of calls to functions (be it a standard or user defined
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8441
 * function) in (almost) exactly the same way.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8442
 *
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8443
 * Of course, we have a flag that disables this syntax when parsing user
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8444
 * written code, so we only allow this extra syntax while parsing the 
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8445
 * 'header' file that declares all the standard IEC 61131-3 functions.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8446
 */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8447
bool allow_extensible_function_parameters = false;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8448
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  8449
/* A global flag indicating whether to include the full variable location when printing out error messages... */
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8450
bool full_token_loc;
934
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
  8451
/* A global flag used to tell the parser whether to generate conversion function for enumerated data types. */
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
  8452
bool conversion_functions = false;
1011
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 980
diff changeset
  8453
/* A global flag used to tell the parser whether to disable generation of implicit EN and ENO parameters. */
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 980
diff changeset
  8454
bool disable_implicit_en_eno;
934
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
  8455
/* A global flag used to tell the parser whether to allow use of DREF and '^' operators (defined in IEC 61131-3 v3) */
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 933
diff changeset
  8456
bool allow_ref_dereferencing;
924
9e824bb0c3d4 Make support for REF_TO ANY a command line option.
mjsousa
parents: 923
diff changeset
  8457
/* A global flag used to tell the parser whether to allow use of REF_TO ANY datatypes (non-standard extension) */
9e824bb0c3d4 Make support for REF_TO ANY a command line option.
mjsousa
parents: 923
diff changeset
  8458
bool allow_ref_to_any = false;
932
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  8459
/* A global flag used to tell the parser whether to allow use of REF_TO as a struct or array element (non-standard extension) */
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  8460
bool allow_ref_to_in_derived_datatypes = false;
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  8461
061824c45a5b Add support for REF_TO inside arrays and structs (a non-standard feature!)
mjsousa
parents: 924
diff changeset
  8462
/* A pointer to the root of the parsing tree that will be generated by bison. */
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  8463
symbol_c *tree_root;
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  8464
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  8465
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents: 13
diff changeset
  8466
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8467
/* The following function is called automatically by bison whenever it comes across
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8468
 * an error. Unfortunately it calls this function before executing the code that handles
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8469
 * the error itself, so we cannot print out the correct line numbers of the error location
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8470
 * over here.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8471
 * Our solution is to store the current error message in a global variable, and have all
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8472
 * error action handlers call the function print_err_msg() after setting the location
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8473
 * (line number) variable correctly.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8474
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8475
const char *current_error_msg;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8476
void yyerror (const char *error_msg) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8477
  current_error_msg = error_msg;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8478
/* fprintf(stderr, "error %d: %s\n", yynerrs // global variable //, error_msg); */
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8479
/*  print_include_stack(); */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8480
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8481
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8482
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8483
/* ERROR_CHECK_BEGIN */
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8484
bool is_current_syntax_token() {
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8485
  switch (yychar) {
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8486
    case ';':
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8487
    case ',':
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8488
    case ')':
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8489
    case ']':
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8490
    case '+':
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8491
    case '*':
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8492
    case '-':
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8493
    case '/':
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8494
    case '<':
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8495
    case '>':
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8496
    case '=':
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8497
    case '&':
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8498
    case OR:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8499
    case XOR:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8500
    case AND:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8501
    case AND2:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8502
    case OPER_NE:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8503
    case OPER_LE:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8504
    case OPER_GE:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8505
    case MOD:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8506
    case OPER_EXP:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8507
    case NOT:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8508
      return true;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8509
    default:
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8510
     return false;
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8511
  }
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8512
}
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8513
/* ERROR_CHECK_END */
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8514
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8515
32bd7ef40897 Adding some improvements:
lbessard
parents: 134
diff changeset
  8516
void print_err_msg(int first_line,
95
b119b1db0a7a Changing format of error reporting.
mario
parents: 94
diff changeset
  8517
                   int first_column,
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8518
                   const char *first_filename,
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
  8519
                   long int first_order,
95
b119b1db0a7a Changing format of error reporting.
mario
parents: 94
diff changeset
  8520
                   int last_line,
b119b1db0a7a Changing format of error reporting.
mario
parents: 94
diff changeset
  8521
                   int last_column,
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8522
                   const char *last_filename,
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
  8523
                   long int last_order,
95
b119b1db0a7a Changing format of error reporting.
mario
parents: 94
diff changeset
  8524
                   const char *additional_error_msg) {
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8525
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8526
  const char *unknown_file = "<unknown_file>";
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8527
  if (first_filename == NULL) first_filename = unknown_file;
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8528
  if ( last_filename == NULL)  last_filename = unknown_file;
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8529
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8530
  if (full_token_loc) {
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8531
    if (first_filename == last_filename)
516
8591746fa134 Produce similar error messages in stage2 and stage3.
Mario de Sousa <msousa@fe.up.pt>
parents: 469
diff changeset
  8532
      fprintf(stderr, "%s:%d-%d..%d-%d: error: %s\n", first_filename, first_line, first_column, last_line, last_column, additional_error_msg);
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8533
    else
516
8591746fa134 Produce similar error messages in stage2 and stage3.
Mario de Sousa <msousa@fe.up.pt>
parents: 469
diff changeset
  8534
      fprintf(stderr, "%s:%d-%d..%s:%d-%d: error: %s\n", first_filename, first_line, first_column, last_filename, last_line, last_column, additional_error_msg);
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8535
  } else {
516
8591746fa134 Produce similar error messages in stage2 and stage3.
Mario de Sousa <msousa@fe.up.pt>
parents: 469
diff changeset
  8536
      fprintf(stderr, "%s:%d: error: %s\n", first_filename, first_line, additional_error_msg);
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8537
  }
131
f55ef301e14c Adding some human-readable error messages
lbessard
parents: 121
diff changeset
  8538
  //fprintf(stderr, "error %d: %s\n", yynerrs /* a global variable */, additional_error_msg);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8539
  print_include_stack();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8540
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8541
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8542
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8543
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8544
/* If function overloading is on, we allow several functions with the same name.
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8545
 *
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8546
 * However, to support standard functions, we also allow functions named
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8547
 *   AND, MOD, NOT, OR, XOR, ADD, ...
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8548
 */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8549
/*
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8550
identifier_c *token_2_identifier_c(char *value, ) {
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8551
  identifier_c tmp = new identifier_c(value, locloc(@$));
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8552
	 if (!allow_function_overloading) {
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8553
	   fprintf(stderr, "Function overloading not allowed. Invalid identifier %s\n", ((token_c *)($$))->value);
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8554
	   ERROR;
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8555
	 }
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8556
	}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8557
}
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8558
*/
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8559
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8560
/* convert between an il_operator to a function name */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8561
/* This a kludge!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8562
 * It is required because our language requires more than one
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8563
 * look ahead token, and bison only works with one!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8564
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8565
#define op_2_str(op, str) {\
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8566
  op ## _operator_c *ptr = dynamic_cast<op ## _operator_c *>(il_operator); \
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8567
  if (ptr != NULL) name = str; \
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8568
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8569
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8570
/* NOTE: this code is very ugly and un-eficient, but I (Mario) have many
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8571
 *       more things to worry about right now, so just let it be...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8572
 */
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8573
poutype_identifier_c *il_operator_c_2_poutype_identifier_c(symbol_c *il_operator) {
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8574
  identifier_c         *    id = il_operator_c_2_identifier_c(il_operator);
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8575
  poutype_identifier_c *pou_id = new poutype_identifier_c(strdup(id->value));
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8576
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8577
  *(symbol_c *)pou_id = *(symbol_c *)id;
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8578
  delete id;
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8579
  return pou_id;
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8580
}
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8581
  
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8582
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8583
identifier_c *il_operator_c_2_identifier_c(symbol_c *il_operator) {
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8584
  const char *name = NULL;
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8585
  identifier_c *res;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8586
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8587
  op_2_str(NOT,   "NOT");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8588
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8589
  op_2_str(AND,   "AND");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8590
  op_2_str(OR,    "OR");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8591
  op_2_str(XOR,   "XOR");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8592
  op_2_str(ADD,   "ADD");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8593
  op_2_str(SUB,   "SUB");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8594
  op_2_str(MUL,   "MUL");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8595
  op_2_str(DIV,   "DIV");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8596
  op_2_str(MOD,   "MOD");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8597
  op_2_str(GT,    "GT");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8598
  op_2_str(GE,    "GE");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8599
  op_2_str(EQ,    "EQ");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8600
  op_2_str(LT,    "LT");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8601
  op_2_str(LE,    "LE");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8602
  op_2_str(NE,    "NE");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8603
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8604
  op_2_str(LD,    "LD");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8605
  op_2_str(LDN,   "LDN");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8606
  op_2_str(ST,    "ST");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8607
  op_2_str(STN,   "STN");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8608
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8609
  op_2_str(S,     "S");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8610
  op_2_str(R,     "R");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8611
  op_2_str(S1,    "S1");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8612
  op_2_str(R1,    "R1");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8613
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8614
  op_2_str(CLK,   "CLK");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8615
  op_2_str(CU,    "CU");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8616
  op_2_str(CD,    "CD");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8617
  op_2_str(PV,    "PV");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8618
  op_2_str(IN,    "IN");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8619
  op_2_str(PT,    "PT");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8620
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8621
  op_2_str(ANDN,  "ANDN");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8622
  op_2_str(ORN,   "ORN");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8623
  op_2_str(XORN,  "XORN");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8624
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8625
  op_2_str(ADD,   "ADD");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8626
  op_2_str(SUB,   "SUB");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8627
  op_2_str(MUL,   "MUL");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8628
  op_2_str(DIV,   "DIV");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8629
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8630
  op_2_str(GT,    "GT");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8631
  op_2_str(GE,    "GE");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8632
  op_2_str(EQ,    "EQ");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8633
  op_2_str(LT,    "LT");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8634
  op_2_str(LE,    "LE");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8635
  op_2_str(NE,    "NE");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8636
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8637
  op_2_str(CAL,   "CAL");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8638
  op_2_str(CALC,  "CALC");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8639
  op_2_str(CALCN, "CALCN");
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8640
  op_2_str(RET,   "RET");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8641
  op_2_str(RETC,  "RETC");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8642
  op_2_str(RETCN, "RETCN");
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8643
  op_2_str(JMP,   "JMP");
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 193
diff changeset
  8644
  op_2_str(JMPC,  "JMPC");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8645
  op_2_str(JMPCN, "JMPCN");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8646
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8647
  if (name == NULL)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8648
    ERROR;
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8649
/*
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8650
  res = new identifier_c(strdup(name), 
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8651
                         il_operator->first_line,
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8652
                         il_operator->first_column,
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8653
                         il_operator->first_file,
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
  8654
                         il_operator->first_order,
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8655
                         il_operator->last_line,
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
  8656
                         il_operator->last_column,
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
  8657
                         il_operator->last_file,
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
  8658
                         il_operator->last_order
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8659
                        );
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8660
  free(il_operator);
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8661
*/
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8662
  res = new identifier_c(strdup(name));
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8663
  *(symbol_c *)res = *(symbol_c *)il_operator;
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8664
  delete il_operator;
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 956
diff changeset
  8665
  
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8666
  return res;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8667
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8668
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8669
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents: 28
diff changeset
  8670
#include "standard_function_names.c"
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8671
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8672
const char *standard_function_block_names[] = {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8673
// 2.5.2.3.1  Bistable elements
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8674
//   Table 34 - Standard bistable function blocks
73
0e623bbdee95 fixing infinite error loops at library level, and ...
mario
parents: 68
diff changeset
  8675
"SR","RS",
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8676
// 2.5.2.3.2  Edge detection
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8677
//   Table 35 - Standard edge detection function blocks
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8678
"R_TRIG","F_TRIG",
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8679
// 2.5.2.3.3  Counters
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8680
//   Table 36 - Standard counter function blocks
68
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8681
"CTU","CTU_DINT","CTU_LINT","CTU_UDINT","CTU_ULINT",
b0a43002dcac Adding basic error checking.
mario
parents: 52
diff changeset
  8682
"CTD","CTD_DINT","CTD_LINT","CTD_UDINT","CTD_ULINT",
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8683
"CTUD","CTUD_DINT","CTUD_LINT","CTUD_ULINT",
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8684
// 2.5.2.3.4  Timers
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8685
//   Table 37 - Standard timer function blocks
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8686
"TP","TON","TOF",
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8687
/* end of array marker! Do not remove! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8688
NULL
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8689
};
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8690
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8691
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8692
#define LIBFILE "ieclib.txt"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8693
#define DEF_LIBFILENAME LIBDIRECTORY "/" LIBFILE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8694
40
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents: 28
diff changeset
  8695
extern const char *INCLUDE_DIRECTORIES[];
873a5b60a7ea Fixed -I library include path behavior + removed old lib implementation + added generated lib func names to stage 1_2 + added Makefile.Linux
etisserant
parents: 28
diff changeset
  8696
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
  8697
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8698
static int parse_files(const char *libfilename, const char *filename) {
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8699
  /* first parse the standard library file... */  
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8700
  /*   Do not debug the standard library, even if debug flag is set!
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8701
  #if YYDEBUG
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8702
    yydebug = 1;
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8703
  #endif
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8704
  */
761
7b52623a2f37 Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents: 759
diff changeset
  8705
  FILE *libfile = NULL;
7b52623a2f37 Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents: 759
diff changeset
  8706
  if((libfile = parse_file(libfilename)) == NULL) {
757
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8707
    char *errmsg = strdup2("Error opening library file ", libfilename);
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8708
    perror(errmsg);
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8709
    free(errmsg);
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8710
    /* we give up... */
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8711
    return -1;
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8712
  }
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8713
924
9e824bb0c3d4 Make support for REF_TO ANY a command line option.
mjsousa
parents: 923
diff changeset
  8714
  allow_function_overloading           = true;
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8715
  allow_extensible_function_parameters = true;
946
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
  8716
  full_token_loc                       = runtime_options.full_token_loc;
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
  8717
  conversion_functions                 = runtime_options.conversion_functions;
1011
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 980
diff changeset
  8718
  disable_implicit_en_eno              = runtime_options.disable_implicit_en_eno;
946
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
  8719
  allow_ref_dereferencing              = runtime_options.ref_standard_extensions;
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
  8720
  allow_ref_to_any                     = runtime_options.ref_nonstand_extensions;
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
  8721
  allow_ref_to_in_derived_datatypes    = runtime_options.ref_nonstand_extensions;
955
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  8722
  if (yyparse() != 0) {
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  8723
    fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors in standard library. Bailing out!\n");
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  8724
    exit(EXIT_FAILURE);
5e2e7707f770 Fix AST generated by parsing with preparsing switched OFF (typo in array datatypes, and fix parsing of POUs).
mjsousa
parents: 954
diff changeset
  8725
  }
761
7b52623a2f37 Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents: 759
diff changeset
  8726
  fclose(libfile);
7b52623a2f37 Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents: 759
diff changeset
  8727
      
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8728
  if (yynerrs > 0) {  /* NOTE: yynerrs is a global variable */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8729
    /* Hopefully the libraries do not contain any errors, so this should not occur! */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8730
    fprintf (stderr, "\n%d error(s) found in %s. Bailing out!\n", yynerrs, libfilename);
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8731
    return -2;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8732
  }
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8733
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8734
  /* if by any chance the library is not complete, we now add the missing reserved keywords to the list!!!  */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8735
  for(int i = 0; standard_function_block_names[i] != NULL; i++)
971
8aee27d46208 Change symbtable_c -> use design pattern used by C++ standard library (STL)
mjsousa
parents: 963
diff changeset
  8736
    if (library_element_symtable.find(standard_function_block_names[i]) ==
8aee27d46208 Change symbtable_c -> use design pattern used by C++ standard library (STL)
mjsousa
parents: 963
diff changeset
  8737
        library_element_symtable.end())
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8738
      library_element_symtable.insert(standard_function_block_names[i], standard_function_block_name_token);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8739
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8740
  /* now parse the input file... */
257
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8741
  #if YYDEBUG
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8742
    yydebug = 1;
90782e241346 Huge change.
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
  8743
  #endif
761
7b52623a2f37 Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents: 759
diff changeset
  8744
  FILE *mainfile = NULL;
7b52623a2f37 Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents: 759
diff changeset
  8745
  if ((mainfile = parse_file(filename)) == NULL) {
757
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8746
    char *errmsg = strdup2("Error opening main file ", filename);
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8747
    perror(errmsg);
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8748
    free(errmsg);
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8749
    return -3;
757
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8750
  }
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8751
924
9e824bb0c3d4 Make support for REF_TO ANY a command line option.
mjsousa
parents: 923
diff changeset
  8752
  allow_function_overloading           = false;
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 328
diff changeset
  8753
  allow_extensible_function_parameters = false;
946
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
  8754
  full_token_loc                       = runtime_options.full_token_loc;
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
  8755
  conversion_functions                 = runtime_options.conversion_functions;
1011
76175defb87b Add option to not add the EN and ENO parameters to every function and FB (generated C code becomes smaller, and uses less memory for function invocations)
mjsousa
parents: 980
diff changeset
  8756
  disable_implicit_en_eno              = runtime_options.disable_implicit_en_eno;
946
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
  8757
  allow_ref_dereferencing              = runtime_options.ref_standard_extensions;
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
  8758
  allow_ref_to_any                     = runtime_options.ref_nonstand_extensions;
c012a64dc2fa Make the relaxed datatype model a runtime option (off by default)
mjsousa
parents: 945
diff changeset
  8759
  allow_ref_to_in_derived_datatypes    = runtime_options.ref_nonstand_extensions;
924
9e824bb0c3d4 Make support for REF_TO ANY a command line option.
mjsousa
parents: 923
diff changeset
  8760
  //allow_ref_to_any = false;    /* we only allow REF_TO ANY in library functions/FBs, no matter what the user asks for in the command line */
757
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8761
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8762
  if (yyparse() != 0) {
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8763
    fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors. Bailing out!\n");
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
  8764
    exit(EXIT_FAILURE);
85
a6e651ba55c2 Fixing handling of enumeration values;
mario
parents: 79
diff changeset
  8765
  }
761
7b52623a2f37 Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents: 759
diff changeset
  8766
  fclose(mainfile);
7b52623a2f37 Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents: 759
diff changeset
  8767
  
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8768
  if (yynerrs > 0) {
516
8591746fa134 Produce similar error messages in stage2 and stage3.
Mario de Sousa <msousa@fe.up.pt>
parents: 469
diff changeset
  8769
    fprintf (stderr, "\n%d error(s) found. Bailing out!\n", yynerrs /* global variable */);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8770
    exit(EXIT_FAILURE);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8771
  }
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8772
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8773
  return 0;
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8774
}  
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8775
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8776
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8777
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8778
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8779
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8780
/* We parse the input source code twice!!
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8781
 *  1st pass -->  Pre-parsing
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8782
 *  -------------------------
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8783
 *  The intention of the first pass is to fill up the library_element_symtable with the names of all
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8784
 *  the POUs (Functions, FBs, Programs and Configurations), as well as all the Derived Datatypes.
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8785
 * 
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8786
 *  During this pass POUs are only parsed until their name is obtained, and the remaining source
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8787
 *  code (variable declarations and body) is completely thrown away by flex. Datatype declarations
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8788
 *  however are parsed normally!
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8789
 *
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8790
 *  At the end of the pre-parsing, the AST will contain only the derived datatype declarations,
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8791
 *  and this tree will be trown away (by simply resetting tree_root = NULL).
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8792
 *  More importantly, the library_element_symtable will contain the names of all the POUs and 
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8793
 *  derived datatypes.
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8794
 *
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8795
 *  2st pass -->  Normal parsing
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8796
 *  ----------------------------
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8797
 *  In this second parse the whole source code is parsed correctly, and the AST is generated
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8798
 *  completely.
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8799
 *
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8800
 *  However, if the pre-parsing has been done before this normal parsing, the POUs may appear
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8801
 *  in the source code in any order, as calling a POU (e.g. calling a function) that has not yet
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8802
 *  been declared will no longer generate a parsing error because the name of the function being 
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8803
 *  called is already in the library_element_symtable.
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8804
 *
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8805
 *  Declaring variables of datatypes that have not yet been declared will also be possible, as the
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8806
 *  datatypes will also already be in the library_element_symtable!
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8807
 */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8808
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8809
int stage2__(const char *filename, 
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8810
             symbol_c **tree_root_ref
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8811
            ) {             
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8812
  char *libfilename = NULL;
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8813
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8814
  /* Determine the full path name of the standard library file... */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8815
  if (runtime_options.includedir != NULL)
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8816
    INCLUDE_DIRECTORIES[0] = runtime_options.includedir;
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8817
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8818
  if ((libfilename = strdup3(INCLUDE_DIRECTORIES[0], "/", LIBFILE)) == NULL) {
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8819
    fprintf (stderr, "Out of memory. Bailing out!\n");
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8820
    exit(EXIT_FAILURE);
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8821
  }
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8822
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8823
  /*******************************/
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8824
  /* Do the  PRE parsing run...! */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8825
  /*******************************/
956
513809fbfaf9 Make use of pre-parser a command line option.
mjsousa
parents: 955
diff changeset
  8826
  if (runtime_options.pre_parsing) {
513809fbfaf9 Make use of pre-parser a command line option.
mjsousa
parents: 955
diff changeset
  8827
    // fprintf (stderr, "----> Starting pre-parsing!\n");
513809fbfaf9 Make use of pre-parser a command line option.
mjsousa
parents: 955
diff changeset
  8828
    tree_root = NULL;
513809fbfaf9 Make use of pre-parser a command line option.
mjsousa
parents: 955
diff changeset
  8829
    set_preparse_state();
513809fbfaf9 Make use of pre-parser a command line option.
mjsousa
parents: 955
diff changeset
  8830
    if (parse_files(libfilename, filename) < 0)
513809fbfaf9 Make use of pre-parser a command line option.
mjsousa
parents: 955
diff changeset
  8831
      exit(EXIT_FAILURE);
513809fbfaf9 Make use of pre-parser a command line option.
mjsousa
parents: 955
diff changeset
  8832
    // TODO: delete the current AST. For the moment, we leave all the objects in memory (not much of an issue in a program that always runs to completion).
513809fbfaf9 Make use of pre-parser a command line option.
mjsousa
parents: 955
diff changeset
  8833
  }
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8834
  /*******************************/
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8835
  /* Do the main parsing run...! */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8836
  /*******************************/
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8837
  // fprintf (stderr, "----> Starting normal parsing!\n");
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8838
  tree_root = NULL;
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8839
  rst_preparse_state();
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8840
  if (parse_files(libfilename, filename) < 0)
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8841
    exit(EXIT_FAILURE);
134
0e43c556cd2d Fixed some uncatched errors and error bounds in error messages
lbessard
parents: 133
diff changeset
  8842
  
952
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8843
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8844
  /* Final clean-up... */
e984cfdf3b10 Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents: 946
diff changeset
  8845
  free(libfilename);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8846
  if (tree_root_ref != NULL)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8847
    *tree_root_ref = tree_root;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8848
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8849
  return 0;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8850
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  8851
756
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  8852
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  8853
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  8854
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  8855
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  8856
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  8857
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  8858
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  8859
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  8860
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  8861
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  8862
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  8863
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 749
diff changeset
  8864