author | Paul Beltyukov <beltyukov.p.a@gmail.com> |
Tue, 09 May 2017 21:46:44 +0100 | |
changeset 1051 | e483512edbeb |
parent 1050 | bdc21971f95d |
child 1055 | ce7b65e24676 |
permissions | -rw-r--r-- |
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:
257
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:
257
diff
changeset
|
3 |
* |
6facabd9c2cd
Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
4 |
* Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) |
6facabd9c2cd
Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
5 |
* |
6facabd9c2cd
Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
6 |
* 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:
257
diff
changeset
|
7 |
* it under the terms of the GNU General Public License as published by |
866 | 8 |
* the Free Software Foundation, either version 3 of thest_whitespaceLicense, or |
264
6facabd9c2cd
Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
9 |
* (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:
257
diff
changeset
|
10 |
* |
6facabd9c2cd
Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
11 |
* 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:
257
diff
changeset
|
12 |
* 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:
257
diff
changeset
|
13 |
* 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:
257
diff
changeset
|
14 |
* 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:
257
diff
changeset
|
15 |
* |
6facabd9c2cd
Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
16 |
* 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:
257
diff
changeset
|
17 |
* 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:
257
diff
changeset
|
18 |
* |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
19 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
20 |
* 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
|
21 |
* 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
|
22 |
*/ |
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 |
/* |
264
6facabd9c2cd
Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
257
diff
changeset
|
25 |
* 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
|
26 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
27 |
* 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
|
28 |
* 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
|
29 |
* |
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 |
* Stage 1 |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
34 |
* ======= |
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 |
* This file contains the lexical tokens definitions, from which |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
37 |
* the flex utility will generate a lexical parser function. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
38 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
39 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
40 |
|
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 |
/* Lexical Parser Options... */ |
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 |
/* The lexical analyser will never work in interactive mode, |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
48 |
* i.e., it will only process programs saved to files, and never |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
49 |
* programs being written inter-actively by the user. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
50 |
* This option saves the resulting parser from 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
|
51 |
* isatty() function, that seems to be generating some compile |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
52 |
* errors under some (older?) versions of flex. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
53 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
54 |
%option never-interactive |
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 |
/* Have the lexical analyser use a 'char *yytext' instead of an |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
57 |
* array of char 'char yytext[??]' to store the lexical token. |
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 |
%pointer |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
60 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
61 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
62 |
/* Have the lexical analyser ignore the case of letters. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
63 |
* This will occur for all the tokens and keywords, but |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
64 |
* the resulting text handed up to 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
|
65 |
* will not be changed, and keep the original case |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
66 |
* of the letters in the input file. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
67 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
68 |
%option case-insensitive |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
69 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
70 |
/* Have the generated lexical analyser keep track 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
|
71 |
* line number it is currently analysing. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
72 |
* This is used to pass up to 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
|
73 |
* the number of the line on which the current |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
74 |
* token was found. It will enable 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
|
75 |
* to generate more informatve error messages... |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
76 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
77 |
%option yylineno |
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 |
/* required for the use of the yy_pop_state() and |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
80 |
* yy_push_state() functions |
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 |
%option stack |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
83 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
84 |
/* The '%option stack' also requests the inclusion of |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
85 |
* the yy_top_state(), however this function is not |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
86 |
* currently being used. This means that the compiler |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
87 |
* is complaining about the existance of this function. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
88 |
* The following option removes the yy_top_state() |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
89 |
* function from the resulting c code, so the compiler |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
90 |
* no longer complains. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
91 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
92 |
%option noyy_top_state |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
93 |
|
547
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
94 |
/* We will be using unput() in our flex code, so we cannot set the following option!... */ |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
95 |
/* |
267
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
96 |
%option nounput |
547
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
97 |
*/ |
267
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
98 |
|
1050
bdc21971f95d
Add comment stating how to enable debug option in flex.
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1031
diff
changeset
|
99 |
/* The '%option debug' makes the generated scanner run in |
bdc21971f95d
Add comment stating how to enable debug option in flex.
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1031
diff
changeset
|
100 |
* debug mode. |
bdc21971f95d
Add comment stating how to enable debug option in flex.
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1031
diff
changeset
|
101 |
%option debug |
bdc21971f95d
Add comment stating how to enable debug option in flex.
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1031
diff
changeset
|
102 |
*/ |
bdc21971f95d
Add comment stating how to enable debug option in flex.
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1031
diff
changeset
|
103 |
|
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 |
/**************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
105 |
/* External Variable and Function declarations... */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
106 |
/**************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
107 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
108 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
109 |
%{ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
110 |
/* Define TEST_MAIN to include a main() function. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
111 |
* Useful for testing the 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
|
112 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
113 |
/* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
114 |
#define TEST_MAIN |
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 |
/* If lexical parser is compiled by itself, we need to define 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
|
117 |
* constant to some string. Under normal circumstances LIBDIRECTORY is set |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
118 |
* in the syntax parser header file... |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
119 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
120 |
#ifdef TEST_MAIN |
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:
15
diff
changeset
|
121 |
#define DEFAULT_LIBDIR "just_testing" |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
122 |
#endif |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
123 |
|
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 |
/* 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
|
127 |
#include <string.h> |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
128 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
129 |
/* Required only for the declaration of abstract syntax classes |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
130 |
* (class symbol_c; class token_c; class 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
|
131 |
* These will not be used in flex, but the token type union defined |
822 | 132 |
* in iec_bison.hh contains pointers to these classes, so we must include |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
133 |
* it here. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
134 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
135 |
#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
|
136 |
|
15
0b472e25eb16
Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
13
diff
changeset
|
137 |
|
822 | 138 |
/* iec_bison.hh is generated by bison. |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
139 |
* Contains the definition of the token constants, and the |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
140 |
* token value type YYSTYPE (in our case, a 'const char *') |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
141 |
*/ |
822 | 142 |
#include "iec_bison.hh" |
15
0b472e25eb16
Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
13
diff
changeset
|
143 |
#include "stage1_2_priv.hh" |
0b472e25eb16
Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
13
diff
changeset
|
144 |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
145 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
146 |
/* Variable defined by the bison parser, |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
147 |
* where the value of the tokens will be stored |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
148 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
149 |
extern YYSTYPE yylval; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
150 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
151 |
/* The name of the file 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
|
152 |
* Note that flex accesses and updates this global variable |
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
153 |
* apropriately whenever it comes across an (*#include <filename> *) directive... |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
154 |
*/ |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
155 |
const char *current_filename = NULL; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
156 |
|
15
0b472e25eb16
Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
13
diff
changeset
|
157 |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
158 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
159 |
/* Variable defined by the bison parser. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
160 |
* It must be initialised with 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
|
161 |
* of the token 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
|
162 |
* This is only needed if we want to keep |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
163 |
* track of the locations, in order to give |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
164 |
* more meaningful error messages! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
165 |
*/ |
415 | 166 |
/* |
167 |
*extern YYLTYPE yylloc; |
|
168 |
b*/ |
|
136 | 169 |
#define YY_INPUT(buf,result,max_size) {\ |
170 |
result = GetNextChar(buf, max_size);\ |
|
171 |
if ( result <= 0 )\ |
|
172 |
result = YY_NULL;\ |
|
173 |
} |
|
174 |
||
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
|
175 |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
176 |
/* Macro that is executed for every action. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
177 |
* We use it to pass the location of 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
|
178 |
* back to the bison parser... |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
179 |
*/ |
136 | 180 |
#define YY_USER_ACTION {\ |
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
|
181 |
yylloc.first_line = current_tracking->lineNumber; \ |
9df7fcb9bde5
Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents:
286
diff
changeset
|
182 |
yylloc.first_column = current_tracking->currentTokenStart; \ |
9df7fcb9bde5
Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents:
286
diff
changeset
|
183 |
yylloc.first_file = current_filename; \ |
9df7fcb9bde5
Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents:
286
diff
changeset
|
184 |
yylloc.first_order = current_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
|
185 |
yylloc.last_line = current_tracking->lineNumber; \ |
9df7fcb9bde5
Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents:
286
diff
changeset
|
186 |
yylloc.last_column = current_tracking->currentChar - 1; \ |
9df7fcb9bde5
Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents:
286
diff
changeset
|
187 |
yylloc.last_file = current_filename; \ |
9df7fcb9bde5
Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents:
286
diff
changeset
|
188 |
yylloc.last_order = current_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
|
189 |
current_tracking->currentTokenStart = current_tracking->currentChar; \ |
9df7fcb9bde5
Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents:
286
diff
changeset
|
190 |
current_order++; \ |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
191 |
} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
192 |
|
879 | 193 |
|
194 |
||
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
195 |
/* Since this lexical parser we defined only works in ASCII based |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
196 |
* systems, we might as well make sure it is being compiled on |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
197 |
* one... |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
198 |
* Lets check a few random characters... |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
199 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
200 |
#if (('a' != 0x61) || ('A' != 0x41) || ('z' != 0x7A) || ('Z' != 0x5A) || \ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
201 |
('0' != 0x30) || ('9' != 0x39) || ('(' != 0x28) || ('[' != 0x5B)) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
202 |
#error This lexical analyser is not portable to a non ASCII based system. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
203 |
#endif |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
204 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
205 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
206 |
/* Function only called from within flex, but defined |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
207 |
* in iec.y! |
3 | 208 |
* We declare it here... |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
209 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
210 |
* Search for a symbol in either of the two symbol tables |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
211 |
* and return the token id of the first symbol found. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
212 |
* Searches first in the variables, and only if not found |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
213 |
* does it continue searching in the library elements |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
214 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
215 |
//token_id_t get_identifier_token(const char *identifier_str); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
216 |
int get_identifier_token(const char *identifier_str); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
217 |
%} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
218 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
219 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
220 |
/***************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
221 |
/* Forward Declaration of functions defined later. */ |
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 |
/* return all the text in the current token back to the input stream. */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
226 |
void unput_text(unsigned int n); |
547
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
227 |
/* return all the text in the current token back to the input stream, |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
228 |
* but first return to the stream an additional character to mark the end of the token. |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
229 |
*/ |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
230 |
void unput_and_mark(const char c); |
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:
737
diff
changeset
|
231 |
|
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:
737
diff
changeset
|
232 |
void include_file(const char *include_filename); |
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
233 |
|
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
234 |
/* The body_state tries to find a ';' before a END_PROGRAM, END_FUNCTION or END_FUNCTION_BLOCK or END_ACTION |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
235 |
* To do so, it must ignore comments and pragmas. This means that we cannot do this in a signle lex rule. |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
236 |
* However, we must store any text we consume in every rule, so we can push it back into the buffer |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
237 |
* once we have decided if we are parsing ST or IL code. The following functions manage that buffer used by |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
238 |
* the body_state. |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
239 |
*/ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
240 |
void append_bodystate_buffer(const char *yytext); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
241 |
void unput_bodystate_buffer(void); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
242 |
int isempty_bodystate_buffer(void); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
243 |
|
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
244 |
int GetNextChar(char *b, int maxBuffer); |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
245 |
%} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
246 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
247 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
248 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
249 |
/****************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
250 |
/* Lexical Parser States... */ |
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 |
/* NOTE: Our psrser can parse st or il code, intermixed |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
254 |
* within the same file. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
255 |
* With IL we come across the issue of the EOL (end of line) token. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
256 |
* ST, and the declaration parts of IL do not use 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
|
257 |
* If the lexical analyser were to issue this token during ST |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
258 |
* language parsing, or during the declaration of 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
|
259 |
* function headers, etc. in IL, the syntax parser would crash. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
260 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
261 |
* We can solve this issue using one of three methods: |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
262 |
* (1) Augment all the syntax that does not accept the EOL |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
263 |
* token to simply ignore it. This makes 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
|
264 |
* definition (in iec.y) very cluttered! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
265 |
* (2) Let the lexical parser figure out which language |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
266 |
* it is parsing, and decide whether or not to issue |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
267 |
* the EOL token. This requires 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
|
268 |
* to have knowledge of the syntax!, making for a poor |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
269 |
* overall organisation of the code. It would also make it |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
270 |
* very difficult to understand the lexical parser as it |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
271 |
* would use several states, and a state machine to transition |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
272 |
* between the states. The state transitions would be |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
273 |
* intermingled with the lexical parser defintion! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
274 |
* (3) Use a mixture of (1) and (2). The lexical analyser |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
275 |
* merely distinguishes between function headers and function |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
276 |
* bodies, but no longer makes a distinction between il and |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
277 |
* st language bodies. When parsing a body, it will return |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
278 |
* the EOL token. In other states '\n' will be ignored as |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
279 |
* whitespace. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
280 |
* The ST language syntax has been augmented 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
|
281 |
* parser configuration to ignore any EOL tokens that it may |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
282 |
* come across! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
283 |
* This option has both drawbacks of option (1) and (2), but |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
284 |
* much less intensely. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
285 |
* The syntax that gets cluttered is limited to the ST statements |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
286 |
* (which is rather limited, compared to the function headers and |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
287 |
* data type declarations, etc...), while the state machine in |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
288 |
* the lexical parser becomes very simple. All state transitions |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
289 |
* can be handled within the lexical parser by itself, and can be |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
290 |
* easily identified. Thus knowledge of the syntax required by |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
291 |
* the lexical parser is very limited! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
292 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
293 |
* Amazingly enough, I (Mario) got to implement option (3) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
294 |
* at first, requiring two basic states, decl and body. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
295 |
* The lexical parser will enter the body state when |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
296 |
* it is parsing the body of a function/program/function block. The |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
297 |
* state transition is done when we find a VAR_END that is not followed |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
298 |
* by a VAR! This is the syntax knowledge that gets included 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
|
299 |
* lexical analyser with this option! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
300 |
* Unfortunately, getting the st syntax parser to ignore EOL anywhere |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
301 |
* where they might appear leads to conflicts. This is 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
|
302 |
* that the syntax parser uses the single look-ahead token 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
|
303 |
* possible conflicts. When we insert a possible EOL, the single |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
304 |
* look ahead token becomes the EOL, which means the potential conflicts |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
305 |
* could no longer be resolved. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
306 |
* Removing these conflicts would make the st syntax parser very convoluted, |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
307 |
* and adding the extraneous EOL would make it very cluttered. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
308 |
* This option was therefore dropped in favour of another! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
309 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
310 |
* I ended up implementing (2). Unfortunately the lexical analyser can |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
311 |
* not easily distinguish between il and st code, since function |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
312 |
* calls in il are very similar to function block calls 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
|
313 |
* We therefore use an extra 'body' state. When 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
|
314 |
* finds that last END_VAR, it enters the body state. This state |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
315 |
* must figure out what language is being parsed from the first few |
68 | 316 |
* tokens, and switch to the correct state (st, il or sfc) according to the |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
317 |
* language. This means that we insert quite a bit of knowledge 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
|
318 |
* syntax of the languages into the lexical parser. This is ugly, but it |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
319 |
* works, and at least it is possible to keep all the state changes together |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
320 |
* to make it easier to remove them later on if need be. |
68 | 321 |
* Once the language being parsed has been identified, |
322 |
* the body state returns any matched text back to the buffer with unput(), |
|
323 |
* to be later matched correctly by the apropriate language parser (st, il or sfc). |
|
324 |
* |
|
325 |
* Aditionally, in sfc state it may further recursively enter the body state |
|
326 |
* once again. This is because an sfc body may contain ACTIONS, which are then |
|
327 |
* written in one of the three languages (ST, IL or SFC), so once again we need |
|
328 |
* to figure out which language the ACTION in the SFC was written in. We already |
|
329 |
* ahve all that done in the body state, so we recursively transition to the body |
|
330 |
* state once again. |
|
331 |
* Note that in this case, when coming out of the st/il state (whichever language |
|
332 |
* the action was written in) the sfc state will become active again. This is done by |
|
333 |
* pushing and poping the previously active state! |
|
334 |
* |
|
335 |
* The sfc_qualifier_state is required because when parsing actions within an |
|
336 |
* sfc, we will be expecting action qualifiers (N, P, R, S, DS, SD, ...). In order |
|
337 |
* to bison to work correctly, these qualifiers must be returned as tokens. However, |
|
338 |
* these tokens are not reserved keywords, which means it should be possible to |
|
339 |
* define variables/functions/FBs with any of these names (including |
|
340 |
* S and R which are special because they are also IL operators). So, when we are not |
|
341 |
* expecting any action qualifiers, flex does not return these tokens, and is free |
|
342 |
* to interpret them as previously defined variables/functions/... as the case may be. |
|
343 |
* |
|
547
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
344 |
* The time_literal_state is required because TIME# literals are decomposed into |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
345 |
* portions, and wewant to send these portions one by one to bison. Each poertion will |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
346 |
* represent the value in days/hours/minutes/seconds/ms. |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
347 |
* Unfortunately, some of these portions may also be lexically analysed as an identifier. So, |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
348 |
* we need to disable lexical identification of identifiers while parsing TIME# literals! |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
349 |
* e.g.: TIME#55d_4h_56m |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
350 |
* We would like to return to bison the tokens 'TIME' '#' '55d' '_' '4h' '_' '56m' |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
351 |
* Unfortunately, flex will join '_' and '4h' to create a legal {identifier} '_4h', |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
352 |
* and return that identifier instead! So, we added this state! |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
353 |
* |
952
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
354 |
* The ignore_pou_state state is only used when bison says it is doing the 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:
948
diff
changeset
|
355 |
* During pre-parsing, the main state machine will only transition between |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
356 |
* INITIAL and ignore_pou_state, and from here back to INITIAL. All other |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
357 |
* transitions are inhibited. This inhibition is actually just enforced by making |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
358 |
* sure that the INITIAL ---> ignore_pou_state transition is tested before all other |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
359 |
* transitions coming out of INITIAL state. All other transitions are unaffected, as they |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
360 |
* never get a chance to be evaluated when bison is doing 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:
948
diff
changeset
|
361 |
* Pre-parsing is a first quick scan through the whole input source code simply |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
362 |
* to determine the list of POUs and datatypes that will be defined in that |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
363 |
* code. Basically, the objective is to fill up the previously_declared_xxxxx |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
364 |
* maps, without processing the code itself. Once these maps have been filled up, |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
365 |
* bison will throw away the AST (abstract syntax tree) created up to that point, |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
366 |
* and scan through the same source code again, but this time creating a correct AST. |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
367 |
* This pre-scan allows the source code to reference POUs and datatypes that are |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
368 |
* only declared after they are used! |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
369 |
* |
952
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
370 |
* |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
371 |
* Here is a main state machine... |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
372 |
* --+ |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
373 |
* | these states are |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
374 |
* +------------> get_pou_name_state ----> ignore_pou_state | only active |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
375 |
* | | | when bison is |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
376 |
* | ------------------------------------------+ | doing the |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
377 |
* | | | 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:
948
diff
changeset
|
378 |
* | v --+ |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
379 |
* +---> INITIAL <-------> config |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
380 |
* | \ |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
381 |
* | V |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
382 |
* | header_state |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
383 |
* | | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
384 |
* | V |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
385 |
* vardecl_list_state <------> var_decl |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
386 |
* ^ | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
387 |
* | | [using push()] |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
388 |
* | | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
389 |
* | V |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
390 |
* | body, |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
391 |
* | | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
392 |
* | | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
393 |
* | ------------------- |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
394 |
* | | | | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
395 |
* | v v v |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
396 |
* | st il sfc |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
397 |
* | | | | [using pop() when leaving st/il/sfc => goes to vardecl_list_state] |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
398 |
* | | | | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
399 |
* ----------------------- |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
400 |
* |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
401 |
* NOTE:- When inside sfc, and an action or transition in ST/IL is found, then |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
402 |
* we also push() to the body state. This means that sometimes, when pop()ing |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
403 |
* from st and il, the state machine may return to the sfc state! |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
404 |
* - The transitions form sfc to body will be decided by bison, which will |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
405 |
* tell flex to do the transition by calling cmd_goto_body_state(). |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
406 |
* |
866 | 407 |
* |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
408 |
* Possible state changes are: |
952
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
409 |
* INITIAL -> goto(ignore_pou_state) |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
410 |
* (This transition state is only used when bison says it is doing the 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:
948
diff
changeset
|
411 |
* (This transition takes precedence over all other transitions!) |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
412 |
* (when a FUNCTION, FUNCTION_BLOCK, PROGRAM or CONFIGURATION is found) |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
413 |
* |
68 | 414 |
* INITIAL -> goto(config_state) |
415 |
* (when a CONFIGURATION is found) |
|
866 | 416 |
* |
417 |
* INITIAL -> goto(header_state) |
|
418 |
* (when a FUNCTION, FUNCTION_BLOCK, or PROGRAM is found) |
|
952
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
419 |
* |
866 | 420 |
* header_state -> goto(vardecl_list_state) |
421 |
* (When the first VAR token is found, i.e. at begining of first VAR .. END_VAR declaration) |
|
422 |
* |
|
423 |
* vardecl_list_state -> push current state (vardecl_list_state), and goto(vardecl_state) |
|
424 |
* (when a VAR token is found) |
|
425 |
* vardecl_state -> pop() to (vardecl_list_state) |
|
426 |
* (when a END_VAR token is found) |
|
427 |
* |
|
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
428 |
* vardecl_list_state -> push current state (vardecl_list_state), and goto(body_state) |
866 | 429 |
* (when the last END_VAR is found!) |
430 |
* |
|
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
431 |
* body_state -> goto(sfc_state) |
68 | 432 |
* (when it figures out it is parsing sfc language) |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
433 |
* body_state -> goto(st_state) |
68 | 434 |
* (when it figures out it is parsing st language) |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
435 |
* body_state -> goto(il_state) |
68 | 436 |
* (when it figures out it is parsing il language) |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
437 |
* st_state -> pop() to vardecl_list_state |
68 | 438 |
* (when a END_FUNCTION, END_FUNCTION_BLOCK, END_PROGRAM, |
439 |
* END_ACTION or END_TRANSITION is found) |
|
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
440 |
* il_state -> pop() to vardecl_list_state |
68 | 441 |
* (when a END_FUNCTION, END_FUNCTION_BLOCK, END_PROGRAM, |
442 |
* END_ACTION or END_TRANSITION is found) |
|
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
443 |
* sfc_state -> pop() to vardecl_list_state |
68 | 444 |
* (when a END_FUNCTION, END_FUNCTION_BLOCK, or END_PROGRAM is found) |
866 | 445 |
* |
952
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
446 |
* ignore_pou_state -> goto(INITIAL) |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
447 |
* (when a END_FUNCTION, END_FUNCTION_BLOCK, END_PROGRAM or END_CONFIGURATION is found) |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
448 |
* vardecl_list_state -> goto(INITIAL) |
952
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
449 |
* (when a END_FUNCTION, END_FUNCTION_BLOCK, or END_PROGRAM is found) |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
450 |
* config_state -> goto(INITIAL) |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
451 |
* (when a END_CONFIGURATION is found) |
866 | 452 |
* |
453 |
* |
|
454 |
* sfc_state -> push current state(sfc_state); goto(body_state) |
|
68 | 455 |
* (when parsing an action. This transition is requested by bison) |
866 | 456 |
* sfc_state -> push current state(sfc_state); goto(sfc_qualifier_state) |
68 | 457 |
* (when expecting an action qualifier. This transition is requested by bison) |
866 | 458 |
* sfc_qualifier_state -> pop() to sfc_state |
68 | 459 |
* (when no longer expecting an action qualifier. This transition is requested by bison) |
866 | 460 |
* |
74
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
461 |
* config_state -> push(config_state); goto(task_init_state) |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
462 |
* (when parsing a task initialisation. This transition is requested by bison) |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
463 |
* task_init_state -> pop() |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
464 |
* (when no longer parsing task initialisation parameters. This transition is requested by bison) |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
465 |
* |
866 | 466 |
* |
467 |
* There is another secondary state machine for parsing comments, another for file_includes, |
|
468 |
* and yet another for time literals. |
|
74
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
469 |
*/ |
68 | 470 |
|
471 |
||
952
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
472 |
/* Bison is in the pre-parsing stage, and we are parsing a POU. Ignore everything up to the end of the POU! */ |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
473 |
%x ignore_pou_state |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
474 |
%x get_pou_name_state |
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
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 |
/* we are parsing a configuration. */ |
3 | 477 |
%s config_state |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
478 |
|
74
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
479 |
/* Inside a configuration, we are parsing a task initialisation parameters */ |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
480 |
/* This means that PRIORITY, SINGLE and INTERVAL must be handled as |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
481 |
* tokens, and not as possible identifiers. Note that the above words |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
482 |
* are not keywords. |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
483 |
*/ |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
484 |
%s task_init_state |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
485 |
|
866 | 486 |
/* we are looking for the first VAR inside a function's, program's or function block's declaration */ |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
487 |
/* This is not exclusive (%x) as we must be able to parse the identifier and data types of a function/FB */ |
866 | 488 |
%s header_state |
489 |
||
490 |
/* we are parsing a function, program or function block sequence of VAR..END_VAR delcarations */ |
|
491 |
%x vardecl_list_state |
|
492 |
/* a substate of the vardecl_list_state: we are inside a specific VAR .. END_VAR */ |
|
493 |
%s vardecl_state |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
494 |
|
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
495 |
/* we will be parsing a function body/action/transition. Whether il/st/sfc remains to be determined */ |
68 | 496 |
%x body_state |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
497 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
498 |
/* we are parsing il code -> flex must return the EOL tokens! */ |
3 | 499 |
%s il_state |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
500 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
501 |
/* we are parsing st code -> flex must not return the EOL tokens! */ |
3 | 502 |
%s st_state |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
503 |
|
68 | 504 |
/* we are parsing sfc code -> flex must not return the EOL tokens! */ |
3 | 505 |
%s sfc_state |
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 |
|
68 | 507 |
/* we are parsing sfc code, and expecting an action qualifier. */ |
508 |
%s sfc_qualifier_state |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
509 |
|
86
1988bf1634da
Adding support for use of PRIORITY as identifier inside SFC.
mario
parents:
84
diff
changeset
|
510 |
/* we are parsing sfc code, and expecting the priority token. */ |
1988bf1634da
Adding support for use of PRIORITY as identifier inside SFC.
mario
parents:
84
diff
changeset
|
511 |
%s sfc_priority_state |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
512 |
|
547
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
513 |
/* we are parsing a TIME# literal. We must not return any {identifier} tokens. */ |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
514 |
%x time_literal_state |
75 | 515 |
|
866 | 516 |
/* we are parsing a comment. */ |
517 |
%x comment_state |
|
518 |
||
75 | 519 |
|
0
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 |
/* File #include's */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
522 |
/*******************/ |
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 |
/* We extend the IEC 61131-3 standard syntax to allow inclusion |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
525 |
* of other files, using the IEC 61131-3 pragma directive... |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
526 |
* The accepted syntax is: |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
527 |
* {#include "<filename>"} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
528 |
*/ |
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 |
/* the "include" states are used for picking up the name of an include file */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
531 |
%x include_beg |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
532 |
%x include_filename |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
533 |
%x include_end |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
534 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
535 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
536 |
file_include_pragma_filename [^\"]* |
866 | 537 |
file_include_pragma_beg "{#include"{st_whitespace}\" |
538 |
file_include_pragma_end \"{st_whitespace}"}" |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
539 |
file_include_pragma {file_include_pragma_beg}{file_include_pragma_filename}{file_include_pragma_end} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
540 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
541 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
542 |
%{ |
879 | 543 |
|
544 |
/* A counter to track the order by which each token is processed. |
|
545 |
* NOTE: This counter is not exactly linear (i.e., it does not get incremented by 1 for each token). |
|
546 |
* i.e.. it may get incremented by more than one between two consecutive tokens. |
|
547 |
* This is due to the fact that the counter gets incremented every 'user action' in flex, |
|
548 |
* however not every user action will result in a token being passed to bison. |
|
549 |
* Nevertheless this is still OK, as we are only interested in the relative |
|
550 |
* ordering of tokens... |
|
551 |
*/ |
|
552 |
static long int current_order = 0; |
|
553 |
||
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
554 |
typedef struct { |
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
555 |
int eof; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
556 |
int lineNumber; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
557 |
int currentChar; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
558 |
int lineLength; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
559 |
int currentTokenStart; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
560 |
char *buffer; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
561 |
FILE *in_file; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
562 |
} tracking_t; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
563 |
|
879 | 564 |
/* A forward declaration of a function defined at the end of this file. */ |
565 |
void FreeTracking(tracking_t *tracking); |
|
566 |
||
567 |
||
568 |
#define MAX_INCLUDE_DEPTH 16 |
|
569 |
||
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
570 |
typedef struct { |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
571 |
YY_BUFFER_STATE buffer_state; |
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
572 |
tracking_t *env; |
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 |
const char *filename; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
574 |
} include_stack_t; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
575 |
|
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
576 |
tracking_t *current_tracking = NULL; |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
577 |
include_stack_t include_stack[MAX_INCLUDE_DEPTH]; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
578 |
int include_stack_ptr = 0; |
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 |
const char *INCLUDE_DIRECTORIES[] = { |
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:
15
diff
changeset
|
581 |
DEFAULT_LIBDIR, |
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:
15
diff
changeset
|
582 |
".", |
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:
15
diff
changeset
|
583 |
"/lib", |
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:
15
diff
changeset
|
584 |
"/usr/lib", |
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:
15
diff
changeset
|
585 |
"/usr/lib/iec", |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
586 |
NULL /* must end with NULL!! */ |
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 |
%} |
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 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
591 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
592 |
/*****************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
593 |
/* Prelimenary constructs... */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
594 |
/*****************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
595 |
|
866 | 596 |
/* PRAGMAS */ |
597 |
/* ======= */ |
|
267
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
598 |
/* In order to allow the declaration of POU prototypes (Function, FB, Program, ...), |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
599 |
* especially the prototypes of Functions and FBs defined in the standard |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
600 |
* (i.e. standard functions and FBs), we extend the IEC 61131-3 standard syntax |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
601 |
* with two pragmas to indicate that the code is to be parsed (going through the |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
602 |
* lexical, syntactical, and semantic analysers), but no code is to be generated. |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
603 |
* |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
604 |
* The accepted syntax is: |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
605 |
* {no_code_generation begin} |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
606 |
* ... prototypes ... |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
607 |
* {no_code_generation end} |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
608 |
* |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
609 |
* When parsing these prototypes the abstract syntax tree will be populated as usual, |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
610 |
* allowing the semantic analyser to correctly analyse the semantics of calls to these |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
611 |
* functions/FBs. However, stage4 will simply ignore all IEC61131-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
|
612 |
* between the above two pragmas. |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
613 |
*/ |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
614 |
|
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
615 |
disable_code_generation_pragma "{disable code generation}" |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
616 |
enable_code_generation_pragma "{enable code generation}" |
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
617 |
|
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
618 |
|
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
619 |
/* Any other pragma... */ |
869 | 620 |
pragma ("{"[^}]*"}")|("{{"([^}]|"}"[^}])*"}}") |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
621 |
|
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
622 |
|
866 | 623 |
|
624 |
/* COMMENTS */ |
|
625 |
/* ======== */ |
|
626 |
||
627 |
/* In order to allow nested comments, comments are handled by a specific comment_state state */ |
|
628 |
/* Whenever a "(*" is found, we push the current state onto the stack, and enter a new instance of the comment_state state. |
|
629 |
* Whenever a "*)" is found, we pop a state off the stack |
|
630 |
*/ |
|
631 |
||
632 |
/* comments... */ |
|
633 |
comment_beg "(*" |
|
634 |
comment_end "*)" |
|
635 |
||
636 |
/* However, bison has a shift/reduce conflict in bison, when parsing formal function/FB |
|
637 |
* invocations with the 'NOT <variable_name> =>' syntax (which needs two look ahead |
|
638 |
* tokens to be parsed correctly - and bison being LALR(1) only supports one). |
|
639 |
* The current work around requires flex to completely parse the '<variable_name> =>' |
|
640 |
* sequence. This sequence includes whitespace and/or comments between the |
|
641 |
* <variable_name> and the "=>" token. |
|
642 |
* |
|
643 |
* This flex rule (sendto_identifier_token) uses the whitespace/comment as trailing context, |
|
644 |
* which means we can not use the comment_state method of specifying/finding and ignoring |
|
645 |
* comments. |
|
646 |
* |
|
647 |
* For this reason only, we must also define what a complete comment looks like, so |
|
648 |
* it may be used in this rule. Since the rule uses the whitespace_or_comment |
|
649 |
* construct as trailing context, this definition of comment must not use any |
|
650 |
* trailing context either. |
|
651 |
* |
|
652 |
* Aditionally, it is not possible to define nested comments in flex without the use of |
|
653 |
* states, so for this particular location, we do NOT support nested comments. |
|
654 |
*/ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
655 |
/* NOTE: this seemingly unnecessary complex definition is required |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
656 |
* to be able to eat up comments 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
|
657 |
* '(* Testing... ! ***** ******)' |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
658 |
* without using the trailing context command in flex (/{context}) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
659 |
* since {comment} itself will later be used with |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
660 |
* trailing context ({comment}/{context}) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
661 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
662 |
not_asterisk [^*] |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
663 |
not_close_parenthesis_nor_asterisk [^*)] |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
664 |
asterisk "*" |
866 | 665 |
comment_text ({not_asterisk})|(({asterisk}+){not_close_parenthesis_nor_asterisk}) |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
666 |
comment "(*"({comment_text}*)({asterisk}+)")" |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
667 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
668 |
|
866 | 669 |
|
670 |
/* 3.1 Whitespace */ |
|
671 |
/* ============== */ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
672 |
/* |
866 | 673 |
* Whitespace is clearly defined (see IEC 61131-3 v2, section 2.1.4) |
674 |
* |
|
675 |
* Whitespace definition includes the newline character. |
|
676 |
* |
|
677 |
* However, the standard is inconsistent in that in IL the newline character |
|
678 |
* is considered a token (EOL - end of line). |
|
679 |
* In our implementation we therefore have two definitions of whitespace |
|
680 |
* - one for ST, that includes the newline character |
|
681 |
* - one for IL without the newline character. |
|
682 |
* Additionally, when parsing IL, the newline character is treated as the EOL token. |
|
683 |
* This requires the use of a state machine in the lexical parser that needs at least |
|
684 |
* some knowledge of the syntax itself. |
|
685 |
* |
|
686 |
* NOTE: Our definition of whitespace will only work in ASCII! |
|
687 |
* |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
688 |
* NOTE: 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
|
689 |
* st_whitespace [:space:]* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
690 |
* since we use {st_whitespace} as trailing context. In 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
|
691 |
* this would not constitute "dangerous trailing context", but the |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
692 |
* lexical generator (i.e. flex) does not know this (since it does |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
693 |
* not know which characters belong to the set [:space:]), and will |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
694 |
* generate a "dangerous trailing context" warning! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
695 |
* We use this alternative just to stop the flex utility from |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
696 |
* generating the invalid (in this case) warning... |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
697 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
698 |
|
866 | 699 |
st_whitespace [ \f\n\r\t\v]* |
700 |
il_whitespace [ \f\r\t\v]* |
|
701 |
||
702 |
st_whitespace_or_pragma_or_commentX ({st_whitespace})|({pragma})|({comment}) |
|
703 |
il_whitespace_or_pragma_or_commentX ({il_whitespace})|({pragma})|({comment}) |
|
704 |
||
705 |
st_whitespace_or_pragma_or_comment {st_whitespace_or_pragma_or_commentX}* |
|
706 |
il_whitespace_or_pragma_or_comment {il_whitespace_or_pragma_or_commentX}* |
|
707 |
||
708 |
||
709 |
||
710 |
qualified_identifier {identifier}(\.{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
|
711 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
712 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
713 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
714 |
/*****************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
715 |
/* 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
|
716 |
/*****************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
717 |
/* NOTE: The following definitions only work if the host computer |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
718 |
* is using the ASCII maping. For e.g., with EBCDIC [A-Z] |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
719 |
* contains non-alphabetic characters! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
720 |
* The correct way of doing it would be to use |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
721 |
* the [:upper:] etc... definitions. |
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 |
* Unfortunately, further on we need all printable |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
724 |
* characters (i.e. [:print:]), but excluding '$'. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
725 |
* Flex does not allow sets to be composed by excluding |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
726 |
* elements. Sets may only be constructed by adding new |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
727 |
* elements, which means that we have to revert to |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
728 |
* [\x20\x21\x23\x25\x26\x28-x7E] for 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
|
729 |
* of the printable characters with the required exceptions. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
730 |
* The above also implies the use of ASCII, but now we have |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
731 |
* no way to work around it| |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
732 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
733 |
* The conclusion is that our parser is limited to ASCII |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
734 |
* based host computers!! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
735 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
736 |
letter [A-Za-z] |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
737 |
digit [0-9] |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
738 |
octal_digit [0-7] |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
739 |
hex_digit {digit}|[A-F] |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
740 |
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
|
741 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
742 |
/*******************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
743 |
/* 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
|
744 |
/*******************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
745 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
746 |
/******************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
747 |
/* 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
|
748 |
/******************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
749 |
integer {digit}((_?{digit})*) |
547
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
750 |
|
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
751 |
/* Some helper symbols for parsing TIME literals... */ |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
752 |
integer_0_59 (0(_?))*([0-5](_?))?{digit} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
753 |
integer_0_19 (0(_?))*([0-1](_?))?{digit} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
754 |
integer_20_23 (0(_?))*2(_?)[0-3] |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
755 |
integer_0_23 {integer_0_19}|{integer_20_23} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
756 |
integer_0_999 {digit}((_?{digit})?)((_?{digit})?) |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
757 |
|
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
758 |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
759 |
binary_integer 2#{bit}((_?{bit})*) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
760 |
bit [0-1] |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
761 |
octal_integer 8#{octal_digit}((_?{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
|
762 |
hex_integer 16#{hex_digit}((_?{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
|
763 |
exponent [Ee]([+-]?){integer} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
764 |
/* The correct definition for real would be: |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
765 |
* 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
|
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 |
* Unfortunately, the spec also defines fixed_point (B 1.2.3.1) as: |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
768 |
* 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
|
769 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
770 |
* This means that {integer}\.{integer} could be interpreted |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
771 |
* as either a fixed_point or a real. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
772 |
* I have opted to interpret {integer}\.{integer} as 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
|
773 |
* In order to do this, the definition of real has been changed to: |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
774 |
* 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
|
775 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
776 |
* This means that the syntax parser now needs to define a real 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
|
777 |
* either a real_token or a 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
|
778 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
779 |
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
|
780 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
781 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
782 |
/*******************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
783 |
/* 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
|
784 |
/*******************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
785 |
/* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
786 |
common_character_representation := |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
787 |
<any printable character except '$', '"' or "'"> |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
788 |
|'$$' |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
789 |
|'$L'|'$N'|'$P'|'$R'|'$T' |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
790 |
|'$l'|'$n'|'$p'|'$r'|'$t' |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
791 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
792 |
NOTE: $ = 0x24 |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
793 |
" = 0x22 |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
794 |
' = 0x27 |
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 |
printable chars in ASCII: 0x20-0x7E |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
797 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
798 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
799 |
esc_char_u $L|$N|$P|$R|$T |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
800 |
esc_char_l $l|$n|$p|$r|$t |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
801 |
esc_char $$|{esc_char_u}|{esc_char_l} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
802 |
double_byte_char (${hex_digit}{hex_digit}{hex_digit}{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
|
803 |
single_byte_char (${hex_digit}{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
|
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 |
/* WARNING: |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
806 |
* This definition is only valid in ASCII... |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
807 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
808 |
* Flex includes the function print_char() that defines |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
809 |
* all printable characters portably (i.e. whatever character |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
810 |
* encoding is currently being used , ASCII, EBCDIC, etc...) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
811 |
* Unfortunately, we cannot generate 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
|
812 |
* common_character_representation portably, since flex |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
813 |
* does not allow definition of sets by subtracting |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
814 |
* elements in one set from another set. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
815 |
* This means we must build up the defintion of |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
816 |
* common_character_representation using only set addition, |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
817 |
* which leaves us with the only choice of defining the |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
818 |
* characters non-portably... |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
819 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
820 |
common_character_representation [\x20\x21\x23\x25\x26\x28-\x7E]|{esc_char} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
821 |
double_byte_character_representation $\"|'|{double_byte_char}|{common_character_representation} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
822 |
single_byte_character_representation $'|\"|{single_byte_char}|{common_character_representation} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
823 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
824 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
825 |
double_byte_character_string \"({double_byte_character_representation}*)\" |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
826 |
single_byte_character_string '({single_byte_character_representation}*)' |
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 |
|
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 |
/* 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
|
831 |
/************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
832 |
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
|
833 |
|
547
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
834 |
|
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
835 |
/* NOTE: The IEC 61131-3 v2 standard has an incorrect formal syntax definition of duration, |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
836 |
* as its definition does not match the standard's text. |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
837 |
* IEC 61131-3 v3 (committee draft) seems to have this fixed, so we use that |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
838 |
* definition instead! |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
839 |
* |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
840 |
* duration::= ('T' | 'TIME') '#' ['+'|'-'] interval |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
841 |
* interval::= days | hours | minutes | seconds | milliseconds |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
842 |
* fixed_point ::= integer [ '.' integer] |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
843 |
* days ::= fixed_point 'd' | integer 'd' ['_'] [ hours ] |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
844 |
* hours ::= fixed_point 'h' | integer 'h' ['_'] [ minutes ] |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
845 |
* minutes ::= fixed_point 'm' | integer 'm' ['_'] [ seconds ] |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
846 |
* seconds ::= fixed_point 's' | integer 's' ['_'] [ milliseconds ] |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
847 |
* milliseconds ::= fixed_point 'ms' |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
848 |
* |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
849 |
* |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
850 |
* The original IEC 61131-3 v2 definition is: |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
851 |
* duration ::= ('T' | 'TIME') '#' ['-'] interval |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
852 |
* interval ::= days | hours | minutes | seconds | milliseconds |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
853 |
* fixed_point ::= integer [ '.' integer] |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
854 |
* days ::= fixed_point 'd' | integer 'd' ['_'] hours |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
855 |
* hours ::= fixed_point 'h' | integer 'h' ['_'] minutes |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
856 |
* minutes ::= fixed_point 'm' | integer 'm' ['_'] seconds |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
857 |
* seconds ::= fixed_point 's' | integer 's' ['_'] milliseconds |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
858 |
* milliseconds ::= fixed_point 'ms' |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
859 |
*/ |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
860 |
|
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
861 |
interval_ms_X ({integer_0_999}(\.{integer})?)ms |
686
9b87606d4c07
Fix processing of TIME literals (submited by Andreas)
Mario de Sousa <msousa@fe.up.pt>
parents:
627
diff
changeset
|
862 |
interval_s_X {integer_0_59}s(_?{interval_ms_X})?|({integer_0_59}(\.{integer})?s) |
9b87606d4c07
Fix processing of TIME literals (submited by Andreas)
Mario de Sousa <msousa@fe.up.pt>
parents:
627
diff
changeset
|
863 |
interval_m_X {integer_0_59}m(_?{interval_s_X})?|({integer_0_59}(\.{integer})?m) |
9b87606d4c07
Fix processing of TIME literals (submited by Andreas)
Mario de Sousa <msousa@fe.up.pt>
parents:
627
diff
changeset
|
864 |
interval_h_X {integer_0_23}h(_?{interval_m_X})?|({integer_0_23}(\.{integer})?h) |
547
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
865 |
|
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
866 |
interval_ms {integer}ms|({fixed_point}ms) |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
867 |
interval_s {integer}s(_?{interval_ms_X})?|({fixed_point}s) |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
868 |
interval_m {integer}m(_?{interval_s_X})?|({fixed_point}m) |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
869 |
interval_h {integer}h(_?{interval_m_X})?|({fixed_point}h) |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
870 |
interval_d {integer}d(_?{interval_h_X})?|({fixed_point}d) |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
871 |
|
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
872 |
interval {interval_ms}|{interval_s}|{interval_m}|{interval_h}|{interval_d} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
873 |
|
686
9b87606d4c07
Fix processing of TIME literals (submited by Andreas)
Mario de Sousa <msousa@fe.up.pt>
parents:
627
diff
changeset
|
874 |
|
547
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
875 |
/* to help provide nice error messages, we also parse an incorrect but plausible interval... */ |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
876 |
/* NOTE that this erroneous interval will be parsed outside the time_literal_state, so must not |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
877 |
* be able to parse any other legal lexcial construct (besides a legal interval, but that |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
878 |
* is OK as this rule will appear _after_ the rule to parse legal intervals!). |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
879 |
*/ |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
880 |
fixed_point_or_integer {fixed_point}|{integer} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
881 |
erroneous_interval ({fixed_point_or_integer}d_?)?({fixed_point_or_integer}h_?)?({fixed_point_or_integer}m_?)?({fixed_point_or_integer}s_?)?({fixed_point_or_integer}ms)? |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
882 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
883 |
/********************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
884 |
/* 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
|
885 |
/********************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
886 |
/* The correct definition, if the standard were to be followed... */ |
11 | 887 |
|
888 |
location_prefix [IQM] |
|
889 |
size_prefix [XBWDL] |
|
890 |
direct_variable_standard %{location_prefix}({size_prefix}?){integer}((.{integer})*) |
|
891 |
||
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
892 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
893 |
/* For the MatPLC, we will accept %<identifier> |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
894 |
* as a direct variable, this being mapped onto the MatPLC point |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
895 |
* named <identifier> |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
896 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
897 |
/* TODO: we should not restrict it to only the accepted syntax |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
898 |
* of <identifier> as specified by the standard. MatPLC point names |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
899 |
* have a more permissive syntax. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
900 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
901 |
* e.g. "P__234" |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
902 |
* Is a valid MatPLC point name, but not a valid <identifier> !! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
903 |
* The same happens with names such as "333", "349+23", etc... |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
904 |
* How can we handle these more expressive names in 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
|
905 |
* Remember that some direct variable may remain anonymous, with |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
906 |
* declarations 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
|
907 |
* VAR |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
908 |
* AT %I3 : BYTE := 255; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
909 |
* END_VAR |
11 | 910 |
* in which case we are currently using "%I3" as the variable |
911 |
* name. |
|
912 |
*/ |
|
547
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
913 |
/* direct_variable_matplc %{identifier} */ |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
914 |
/* direct_variable {direct_variable_standard}|{direct_variable_matplc} */ |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
915 |
direct_variable {direct_variable_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
|
916 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
917 |
/******************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
918 |
/* 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
|
919 |
/******************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
920 |
incompl_location %[IQM]\* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
921 |
|
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 |
|
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 |
%% |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
926 |
/* fprintf(stderr, "flex: state %d\n", YY_START); */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
927 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
928 |
/*****************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
929 |
/*****************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
930 |
/*****************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
931 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
932 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
933 |
/***** F I R S T T H I N G S F I R S T *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
934 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
935 |
/***** *****/ |
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 |
|
68 | 940 |
/***********************************************************/ |
941 |
/* Handle requests sent by bison for flex to change state. */ |
|
942 |
/***********************************************************/ |
|
13 | 943 |
if (get_goto_body_state()) { |
68 | 944 |
yy_push_state(body_state); |
13 | 945 |
rst_goto_body_state(); |
6 | 946 |
} |
3 | 947 |
|
68 | 948 |
if (get_goto_sfc_qualifier_state()) { |
949 |
yy_push_state(sfc_qualifier_state); |
|
950 |
rst_goto_sfc_qualifier_state(); |
|
951 |
} |
|
952 |
||
86
1988bf1634da
Adding support for use of PRIORITY as identifier inside SFC.
mario
parents:
84
diff
changeset
|
953 |
if (get_goto_sfc_priority_state()) { |
1988bf1634da
Adding support for use of PRIORITY as identifier inside SFC.
mario
parents:
84
diff
changeset
|
954 |
yy_push_state(sfc_priority_state); |
1988bf1634da
Adding support for use of PRIORITY as identifier inside SFC.
mario
parents:
84
diff
changeset
|
955 |
rst_goto_sfc_priority_state(); |
1988bf1634da
Adding support for use of PRIORITY as identifier inside SFC.
mario
parents:
84
diff
changeset
|
956 |
} |
1988bf1634da
Adding support for use of PRIORITY as identifier inside SFC.
mario
parents:
84
diff
changeset
|
957 |
|
74
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
958 |
if (get_goto_task_init_state()) { |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
959 |
yy_push_state(task_init_state); |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
960 |
rst_goto_task_init_state(); |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
961 |
} |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
962 |
|
68 | 963 |
if (get_pop_state()) { |
964 |
yy_pop_state(); |
|
965 |
rst_pop_state(); |
|
966 |
} |
|
967 |
||
968 |
/***************************/ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
969 |
/* Handle the pragmas! */ |
68 | 970 |
/***************************/ |
0
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 |
/* We start off by searching for the pragmas we handle 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
|
973 |
<INITIAL>{file_include_pragma} unput_text(0); yy_push_state(include_beg); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
974 |
|
267
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
975 |
/* Pragmas sent to syntax analyser (bison) */ |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
976 |
/* NOTE: In the vardecl_list_state we only process the pragmas between two consecutive VAR .. END_VAR blocks. |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
977 |
* We do not process any pragmas trailing after the last END_VAR. We leave that to the body_state. |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
978 |
* This is because the pragmas are stored in a statement_list or instruction_list (in bison), |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
979 |
* but these lists must start with the special tokens start_IL_body_token/start_ST_body_token. |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
980 |
* This means that these special tokens must be generated (by the body_state) before processing |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
981 |
* the pragme => we cannot process the trailing pragmas in the vardecl_list_state state. |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
982 |
*/ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
983 |
{disable_code_generation_pragma} return disable_code_generation_pragma_token; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
984 |
{enable_code_generation_pragma} return enable_code_generation_pragma_token; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
985 |
<vardecl_list_state>{disable_code_generation_pragma}/(VAR) return disable_code_generation_pragma_token; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
986 |
<vardecl_list_state>{enable_code_generation_pragma}/(VAR) return enable_code_generation_pragma_token; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
987 |
<body_state>{disable_code_generation_pragma} append_bodystate_buffer(yytext); /* in body state we do not process any tokens, we simply store them for later processing! */ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
988 |
<body_state>{enable_code_generation_pragma} append_bodystate_buffer(yytext); /* in body state we do not process any tokens, we simply store them for later processing! */ |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
989 |
/* Any other pragma we find, we just pass it up to the syntax parser... */ |
68 | 990 |
/* Note that the <body_state> state is exclusive, so we have to include it here too. */ |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
991 |
<body_state>{pragma} append_bodystate_buffer(yytext); /* in body state we do not process any tokens, we simply store them for later processing! */ |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
992 |
{pragma} {/* return the pragmma without the enclosing '{' and '}' */ |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
993 |
int cut = yytext[1]=='{'?2:1; |
634
736b36a83548
Added double curly braces for pragma (kept single curly braces for compatibility). Added macro def and undef surrounding pragma to simplify user code. Moved useless comment from generated code back to code generator.
Edouard Tisserant
parents:
627
diff
changeset
|
994 |
yytext[strlen(yytext)-cut] = '\0'; |
736b36a83548
Added double curly braces for pragma (kept single curly braces for compatibility). Added macro def and undef surrounding pragma to simplify user code. Moved useless comment from generated code back to code generator.
Edouard Tisserant
parents:
627
diff
changeset
|
995 |
yylval.ID=strdup(yytext+cut); |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
996 |
return 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
|
997 |
} |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
998 |
<vardecl_list_state>{pragma}/(VAR) {/* return the pragmma without the enclosing '{' and '}' */ |
701
562c01f82afb
Fix pragma with double bracket token stripping
Laurent Bessard
parents:
637
diff
changeset
|
999 |
int cut = yytext[1]=='{'?2:1; |
866 | 1000 |
yytext[strlen(yytext)-cut] = '\0'; |
701
562c01f82afb
Fix pragma with double bracket token stripping
Laurent Bessard
parents:
637
diff
changeset
|
1001 |
yylval.ID=strdup(yytext+cut); |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1002 |
return 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
|
1003 |
} |
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 |
/* Handle the file includes! */ |
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 |
<include_beg>{file_include_pragma_beg} BEGIN(include_filename); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1010 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1011 |
<include_filename>{file_include_pragma_filename} { |
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:
737
diff
changeset
|
1012 |
/* set the internal state variables of lexical analyser to process a new include file */ |
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:
737
diff
changeset
|
1013 |
include_file(yytext); |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1014 |
/* switch to whatever state was active before the include file */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1015 |
yy_pop_state(); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1016 |
/* now process the new file... */ |
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 |
|
761
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1020 |
<<EOF>> { /* NOTE: Currently bison is incorrectly using END_OF_INPUT in many rules |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1021 |
* when checking for syntax errors in the input source code. |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1022 |
* This means that in reality flex will be asked to carry on reading the input |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1023 |
* even after it has reached the end of all (including the main) input files. |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1024 |
* In other owrds, we will be called to return more tokens, even after we have |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1025 |
* already returned an END_OF_INPUT token. In this case, we must carry on returning |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1026 |
* more END_OF_INPUT tokens. |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1027 |
* |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1028 |
* However, in the above case we will be asked to carry on reading more tokens |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1029 |
* from the main input file, after we have reached the end. For this to work |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1030 |
* correctly, we cannot close the main input file! |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1031 |
* |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1032 |
* This is why we WILL be called with include_stack_ptr == 0 multiple times, |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1033 |
* and why we must handle it as a special case |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1034 |
* that leaves the include_stack_ptr unchanged, and returns END_OF_INPUT once again. |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1035 |
* |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1036 |
* As a corollory, flex can never safely close the main input file, and we must ask |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1037 |
* bison to close it! |
76
ec7799ec929b
fixing include bug (only ocured for includes in main program file).
mario
parents:
75
diff
changeset
|
1038 |
*/ |
ec7799ec929b
fixing include bug (only ocured for includes in main program file).
mario
parents:
75
diff
changeset
|
1039 |
if (include_stack_ptr == 0) { |
761
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1040 |
// fclose(yyin); // Must not do this!! |
879 | 1041 |
// FreeTracking(current_tracking); // Must not do this!! |
73 | 1042 |
/* yyterminate() terminates the scanner and returns a 0 to the |
1043 |
* scanner's caller, indicating "all done". |
|
1044 |
* |
|
1045 |
* Our syntax parser (written with bison) has the token |
|
1046 |
* END_OF_INPUT associated to the value 0, so even though |
|
1047 |
* we don't explicitly return the token END_OF_INPUT |
|
1048 |
* calling yyterminate() is equivalent to doing that. |
|
1049 |
*/ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1050 |
yyterminate(); |
737
f6bc5230aadd
Fix comments and code alignment
Mario de Sousa <msousa@fe.up.pt>
parents:
686
diff
changeset
|
1051 |
} else { |
761
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
1052 |
fclose(yyin); |
879 | 1053 |
FreeTracking(current_tracking); |
136 | 1054 |
--include_stack_ptr; |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1055 |
yy_delete_buffer(YY_CURRENT_BUFFER); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1056 |
yy_switch_to_buffer((include_stack[include_stack_ptr]).buffer_state); |
136 | 1057 |
current_tracking = include_stack[include_stack_ptr].env; |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1058 |
/* removing constness of char *. This is safe actually, |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1059 |
* since the only real const char * that is stored on the stack is |
1
5d893a68be6e
Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents:
0
diff
changeset
|
1060 |
* the first one (i.e. the one that gets stored in include_stack[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
|
1061 |
* which is never free'd! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1062 |
*/ |
286
a4f4990d5c66
Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents:
267
diff
changeset
|
1063 |
/* NOTE: We do __NOT__ free the malloc()'d memory since |
a4f4990d5c66
Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents:
267
diff
changeset
|
1064 |
* pointers to this filename will be kept by many objects |
a4f4990d5c66
Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents:
267
diff
changeset
|
1065 |
* in the abstract syntax tree. |
a4f4990d5c66
Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents:
267
diff
changeset
|
1066 |
* This will later be used to provide correct error |
a4f4990d5c66
Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents:
267
diff
changeset
|
1067 |
* messages during semantic analysis (stage 3) |
a4f4990d5c66
Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents:
267
diff
changeset
|
1068 |
*/ |
a4f4990d5c66
Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents:
267
diff
changeset
|
1069 |
/* free((char *)current_filename); */ |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1070 |
current_filename = include_stack[include_stack_ptr].filename; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1071 |
yy_push_state(include_end); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1072 |
} |
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 |
<include_end>{file_include_pragma_end} yy_pop_state(); |
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:
737
diff
changeset
|
1076 |
/* handle the artificial file includes created by include_string(), which do not end with a '}' */ |
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:
737
diff
changeset
|
1077 |
<include_end>. unput_text(0); yy_pop_state(); |
0
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 |
/* Handle all the state changes! */ |
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 |
|
866 | 1084 |
/* INITIAL -> header_state */ |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1085 |
<INITIAL>{ |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1086 |
FUNCTION{st_whitespace} if (get_preparse_state()) BEGIN(get_pou_name_state); else {BEGIN(header_state);/* printf("\nChanging to header_state\n"); */} return FUNCTION; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1087 |
FUNCTION_BLOCK{st_whitespace} if (get_preparse_state()) BEGIN(get_pou_name_state); else {BEGIN(header_state);/* printf("\nChanging to header_state\n"); */} return FUNCTION_BLOCK; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1088 |
PROGRAM{st_whitespace} if (get_preparse_state()) BEGIN(get_pou_name_state); else {BEGIN(header_state);/* printf("\nChanging to header_state\n"); */} return PROGRAM; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1089 |
CONFIGURATION{st_whitespace} if (get_preparse_state()) BEGIN(get_pou_name_state); else {BEGIN(config_state);/* printf("\nChanging to config_state\n"); */} return CONFIGURATION; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1090 |
} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1091 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1092 |
<get_pou_name_state>{ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1093 |
{identifier} BEGIN(ignore_pou_state); yylval.ID=strdup(yytext); return identifier_token; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1094 |
. BEGIN(ignore_pou_state); unput_text(0); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1095 |
} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1096 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1097 |
<ignore_pou_state>{ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1098 |
END_FUNCTION unput_text(0); BEGIN(INITIAL); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1099 |
END_FUNCTION_BLOCK unput_text(0); BEGIN(INITIAL); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1100 |
END_PROGRAM unput_text(0); BEGIN(INITIAL); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1101 |
END_CONFIGURATION unput_text(0); BEGIN(INITIAL); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1102 |
.|\n {}/* Ignore text inside POU! (including the '\n' character!)) */ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1103 |
} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1104 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1105 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1106 |
/* header_state -> (vardecl_list_state) */ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1107 |
/* NOTE: This transition assumes that all POUs with code (Function, FB, and Program) will always contain |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1108 |
* at least one VAR_XXX block. |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1109 |
* How about functions that do not declare variables, and go directly to the body_state??? |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1110 |
* - According to Section 2.5.1.3 (Function Declaration), item 2 in the list, a FUNCTION |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1111 |
* must have at least one input argument, so a correct declaration will have at least |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1112 |
* one VAR_INPUT ... VAR_END construct! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1113 |
* - According to Section 2.5.2.2 (Function Block Declaration), a 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
|
1114 |
* must have at least one input argument, so a correct declaration will have at least |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1115 |
* one VAR_INPUT ... VAR_END construct! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1116 |
* - According to Section 2.5.3 (Programs), a PROGRAM must have at least one input |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1117 |
* argument, so a correct declaration will have at least one VAR_INPUT ... VAR_END |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1118 |
* construct! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1119 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1120 |
* All the above means that we needn't worry about PROGRAMs, FUNCTIONs or |
68 | 1121 |
* FUNCTION_BLOCKs that do not have at least one VAR_END before the body_state. |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1122 |
* If the code has an error, and no VAR_END before the body, we will simply |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1123 |
* continue in the <vardecl_state> state, until the end of the FUNCTION, FUNCTION_BLOCK |
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 |
* or PROGAM. |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1125 |
* |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1126 |
* WARNING: From 2016-05 (May 2016) onwards, matiec supports a non-standard option in which a Function |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1127 |
* may be declared with no Input, Output or IN_OUT variables. This means that the above |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1128 |
* assumption is no longer valid. |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1129 |
* To make things simpler (i.e. so we do not need to change the transition conditions in the flex state machine), |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1130 |
* when using this non-standard extension matiec requires that Functions must include at least one |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1131 |
* VAR .. END_VAR block. This implies that the above assumption remains valid! |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1132 |
* This limitation of requiring a VAR .. END_VAR block is not really very limiting, as a function |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1133 |
* with no input and output parameters will probably need to do some 'work', and for that it will |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1134 |
* probably need some local variables declared in a VAR .. END_VAR block. |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1135 |
* Note however that in the extreme it might make sense to have a function with no variables whatsoever |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1136 |
* (e.g.: a function that only calls other functions that all return VOID - another non standard extension!). |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1137 |
* For now we do not consider this!! |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1138 |
*/ |
866 | 1139 |
<header_state>{ |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1140 |
VAR | /* execute the next rule's action, i.e. fall-through! */ |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1141 |
VAR_INPUT | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1142 |
VAR_OUTPUT | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1143 |
VAR_IN_OUT | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1144 |
VAR_EXTERNAL | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1145 |
VAR_GLOBAL | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1146 |
VAR_TEMP | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1147 |
VAR_CONFIG | |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1148 |
VAR_ACCESS unput_text(0); /* printf("\nChanging to vardecl_list_state\n") */; BEGIN(vardecl_list_state); |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1149 |
} |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1150 |
|
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1151 |
|
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1152 |
/* vardecl_list_state -> (vardecl_state | body_state | INITIAL) */ |
866 | 1153 |
<vardecl_list_state>{ |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1154 |
VAR_INPUT | /* execute the next rule's action, i.e. fall-through! */ |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1155 |
VAR_OUTPUT | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1156 |
VAR_IN_OUT | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1157 |
VAR_EXTERNAL | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1158 |
VAR_GLOBAL | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1159 |
VAR_TEMP | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1160 |
VAR_CONFIG | |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1161 |
VAR_ACCESS | |
866 | 1162 |
VAR unput_text(0); yy_push_state(vardecl_state); |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1163 |
|
1010
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1164 |
END_FUNCTION unput_text(0); BEGIN(INITIAL); |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1165 |
END_FUNCTION_BLOCK unput_text(0); BEGIN(INITIAL); |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1166 |
END_PROGRAM unput_text(0); BEGIN(INITIAL); |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1167 |
|
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1168 |
. unput_text(0); yy_push_state(body_state); //printf("\nChanging to body_state\n");/* anything else, just change to body_state! */ |
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1169 |
} |
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1170 |
|
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1171 |
|
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1172 |
/* vardecl_list_state -> pop to $previous_state (vardecl_list_state) */ |
866 | 1173 |
<vardecl_state>{ |
948
543f8319bdf8
Fix main state machine in flex (states were being pushed without being poped from the stack)
mjsousa
parents:
934
diff
changeset
|
1174 |
END_VAR yy_pop_state(); return END_VAR; /* pop back to vardecl_list_state */ |
866 | 1175 |
} |
1176 |
||
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1177 |
|
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1178 |
/* body_state -> (il_state | st_state | sfc_state) */ |
68 | 1179 |
<body_state>{ |
1020
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1180 |
{st_whitespace} {/* In body state we do not process any tokens, |
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1181 |
* we simply store them for later processing! |
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1182 |
* NOTE: all whitespace in the begining |
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1183 |
* of body_state must be removed so we can |
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1184 |
* detect ':=' in the beginning of TRANSACTION |
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1185 |
* conditions preceded by whitespace. |
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1186 |
* => only add to bodystate_buffer when not in beginning. |
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1187 |
*/ |
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1188 |
if (!isempty_bodystate_buffer()) |
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1189 |
append_bodystate_buffer(yytext); |
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1190 |
} |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1191 |
/* 'INITIAL_STEP' always used in beginning of SFCs !! */ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1192 |
INITIAL_STEP { if (isempty_bodystate_buffer()) {unput_text(0); BEGIN(sfc_state);} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1193 |
else {append_bodystate_buffer(yytext);} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1194 |
} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1195 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1196 |
/* ':=', at the very beginning of a 'body', occurs only in transitions and not Function, FB, or Program bodies! */ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1197 |
:= { if (isempty_bodystate_buffer()) {unput_text(0); BEGIN(st_state);} /* We do _not_ return a start_ST_body_token here, as bison does not expect it! */ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1198 |
else {append_bodystate_buffer(yytext);} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1199 |
} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1200 |
|
1031
ce026aee03e0
fix compilation of SFC transitions written in IL (compiler was entering endless loop)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1020
diff
changeset
|
1201 |
/* check if ';' occurs before an END_FUNCTION, END_FUNCTION_BLOCK, END_PROGRAM, END_ACTION or END_TRANSITION. (If true => we are parsing ST; If false => parsing IL). */ |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1202 |
END_ACTION | /* execute the next rule's action, i.e. fall-through! */ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1203 |
END_FUNCTION | |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1204 |
END_FUNCTION_BLOCK | |
1031
ce026aee03e0
fix compilation of SFC transitions written in IL (compiler was entering endless loop)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1020
diff
changeset
|
1205 |
END_TRANSITION | |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1206 |
END_PROGRAM { append_bodystate_buffer(yytext); unput_bodystate_buffer(); BEGIN(il_state); /*printf("returning start_IL_body_token\n");*/ return start_IL_body_token;} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1207 |
.|\n { append_bodystate_buffer(yytext); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1208 |
if (strcmp(yytext, ";") == 0) |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1209 |
{unput_bodystate_buffer(); BEGIN(st_state); /*printf("returning start_ST_body_token\n");*/ return start_ST_body_token;} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1210 |
} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1211 |
/* The following rules are not really necessary. They just make compilation faster in case the ST Statement List starts with one fot he following... */ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1212 |
RETURN | /* execute the next rule's action, i.e. fall-through! */ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1213 |
IF | |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1214 |
CASE | |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1215 |
FOR | |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1216 |
WHILE | |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1217 |
EXIT | |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1218 |
REPEAT { if (isempty_bodystate_buffer()) {unput_text(0); BEGIN(st_state); return start_ST_body_token;} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1219 |
else {append_bodystate_buffer(yytext);} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1220 |
} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1221 |
|
68 | 1222 |
} /* end of body_state lexical parser */ |
3 | 1223 |
|
866 | 1224 |
|
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1225 |
/* (il_state | st_state) -> pop to $previous_state (vardecl_list_state or sfc_state) */ |
3 | 1226 |
<il_state,st_state>{ |
1227 |
END_FUNCTION yy_pop_state(); unput_text(0); |
|
1228 |
END_FUNCTION_BLOCK yy_pop_state(); unput_text(0); |
|
1229 |
END_PROGRAM yy_pop_state(); unput_text(0); |
|
1230 |
END_TRANSITION yy_pop_state(); unput_text(0); |
|
6 | 1231 |
END_ACTION yy_pop_state(); unput_text(0); |
3 | 1232 |
} |
1233 |
||
868
23f271534a7c
Fix the state machine that became broken 2 commits ago (when adding support for nested comments)
mjsousa
parents:
867
diff
changeset
|
1234 |
/* sfc_state -> pop to $previous_state (vardecl_list_state or sfc_state) */ |
4 | 1235 |
<sfc_state>{ |
1236 |
END_FUNCTION yy_pop_state(); unput_text(0); |
|
1237 |
END_FUNCTION_BLOCK yy_pop_state(); unput_text(0); |
|
1238 |
END_PROGRAM yy_pop_state(); unput_text(0); |
|
1239 |
} |
|
1240 |
||
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1241 |
/* config -> INITIAL */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1242 |
END_CONFIGURATION BEGIN(INITIAL); return 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
|
1243 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1244 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1245 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1246 |
/***************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1247 |
/* Next is to to remove all whitespace */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1248 |
/***************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1249 |
/* NOTE: pragmas are handled right at the beginning... */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1250 |
|
866 | 1251 |
/* The whitespace */ |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1252 |
<INITIAL,header_state,config_state,vardecl_list_state,vardecl_state,st_state,sfc_state,task_init_state,sfc_qualifier_state>{st_whitespace} /* Eat any whitespace */ |
866 | 1253 |
<il_state>{il_whitespace} /* Eat any whitespace */ |
1020
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1254 |
/* NOTE: Due to the need of having the following rule have higher priority, |
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1255 |
* the following rule was moved to an earlier position in this file. |
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1256 |
<body_state>{st_whitespace} {...} |
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
1257 |
*/ |
866 | 1258 |
|
1259 |
/* The comments */ |
|
952
e984cfdf3b10
Add a pre-parsing phase to stage1_2 (allows source code that references POUs and datatypes before they are declared)
mjsousa
parents:
948
diff
changeset
|
1260 |
<get_pou_name_state,ignore_pou_state,body_state,vardecl_list_state>{comment_beg} yy_push_state(comment_state); |
867
a435684a5223
Add option to control support for nested comments (default is off, as defined in IEC 61131-3 v2)
mjsousa
parents:
866
diff
changeset
|
1261 |
{comment_beg} yy_push_state(comment_state); |
866 | 1262 |
<comment_state>{ |
867
a435684a5223
Add option to control support for nested comments (default is off, as defined in IEC 61131-3 v2)
mjsousa
parents:
866
diff
changeset
|
1263 |
{comment_beg} {if (get_opt_nested_comments()) yy_push_state(comment_state);} |
a435684a5223
Add option to control support for nested comments (default is off, as defined in IEC 61131-3 v2)
mjsousa
parents:
866
diff
changeset
|
1264 |
{comment_end} yy_pop_state(); |
a435684a5223
Add option to control support for nested comments (default is off, as defined in IEC 61131-3 v2)
mjsousa
parents:
866
diff
changeset
|
1265 |
. /* Ignore text inside comment! */ |
a435684a5223
Add option to control support for nested comments (default is off, as defined in IEC 61131-3 v2)
mjsousa
parents:
866
diff
changeset
|
1266 |
\n /* Ignore text inside comment! */ |
866 | 1267 |
} |
267
0a1204bcc9af
starting to add proper header file with declaration of standard functions
Mario de Sousa <msousa@fe.up.pt>
parents:
264
diff
changeset
|
1268 |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1269 |
/*****************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1270 |
/* 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
|
1271 |
/*****************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1272 |
/* NOTE: 'R1', 'IN', etc... are IL operators, and therefore tokens |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1273 |
* On the other hand, the spec does not define them as keywords, |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1274 |
* which means they may be re-used for variable names, etc...! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1275 |
* The syntax parser already caters for the possibility of these |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1276 |
* tokens being used for variable names in their declarations. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1277 |
* When they are declared, they will be added to the variable 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
|
1278 |
* Further appearances of these tokens must no longer be parsed |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1279 |
* as R1_tokens etc..., but rather as variable_name_tokens! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1280 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1281 |
* That is why the first thing we do with identifiers, even before |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1282 |
* checking whether they may be a 'keyword', is to check whether |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1283 |
* they have been previously declared as a 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
|
1284 |
* |
13 | 1285 |
* However, we have a dilema! Should we here also check for |
1286 |
* prev_declared_derived_function_name_token? |
|
1287 |
* If we do, then the 'MOD' default library function (defined in |
|
1288 |
* the standard) will always be returned as a function name, and |
|
1289 |
* it will therefore not be possible to use it as an operator as |
|
1290 |
* in the following ST expression 'X := Y MOD Z;' ! |
|
1291 |
* If we don't, then even it will not be possible to use 'MOD' |
|
1292 |
* as a funtion as in 'X := MOD(Y, Z);' |
|
1293 |
* We solve this by NOT testing for function names here, and |
|
1294 |
* handling this function and keyword clash in bison! |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1295 |
*/ |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1296 |
/* NOTE: The following code has been commented out as most users do not want matiec |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1297 |
* to allow the use of 'R1', 'IN' ... IL operators as identifiers, |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1298 |
* even though a literal reading of the standard allows this. |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1299 |
* We could add this as a commadnd line option, but it is not yet done. |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1300 |
* For now we just comment out the code, but leave it the commented code |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1301 |
* in so we can re-activate quickly (without having to go through old commits |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1302 |
* in the mercurial repository to figure out the missing code! |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1303 |
*/ |
83
aeb7e0e53855
commenting out code no longer required. To be deleted later.
mario
parents:
82
diff
changeset
|
1304 |
/* |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1305 |
{identifier} {int token = get_identifier_token(yytext); |
81
de518eb7bc74
removing debug messages left by mistake in previous commit.
mario
parents:
80
diff
changeset
|
1306 |
// fprintf(stderr, "flex: analysing identifier '%s'...", yytext); |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1307 |
if ((token == prev_declared_variable_name_token) || |
13 | 1308 |
// (token == prev_declared_derived_function_name_token) || // DO NOT add this 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
|
1309 |
(token == prev_declared_fb_name_token)) { |
83
aeb7e0e53855
commenting out code no longer required. To be deleted later.
mario
parents:
82
diff
changeset
|
1310 |
// if (token != identifier_token) |
aeb7e0e53855
commenting out code no longer required. To be deleted later.
mario
parents:
82
diff
changeset
|
1311 |
// * NOTE: if we replace the above uncommented conditions with |
13 | 1312 |
* the simple test of (token != identifier_token), then |
1313 |
* 'MOD' et al must be removed from the |
|
1314 |
* library_symbol_table as a default function name! |
|
83
aeb7e0e53855
commenting out code no longer required. To be deleted later.
mario
parents:
82
diff
changeset
|
1315 |
* // |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1316 |
yylval.ID=strdup(yytext); |
81
de518eb7bc74
removing debug messages left by mistake in previous commit.
mario
parents:
80
diff
changeset
|
1317 |
// fprintf(stderr, "returning token %d\n", 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
|
1318 |
return token; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1319 |
} |
83
aeb7e0e53855
commenting out code no longer required. To be deleted later.
mario
parents:
82
diff
changeset
|
1320 |
// otherwise, leave it for the other lexical parser rules... |
81
de518eb7bc74
removing debug messages left by mistake in previous commit.
mario
parents:
80
diff
changeset
|
1321 |
// fprintf(stderr, "rejecting\n"); |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1322 |
REJECT; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1323 |
} |
83
aeb7e0e53855
commenting out code no longer required. To be deleted later.
mario
parents:
82
diff
changeset
|
1324 |
*/ |
0
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 |
/******************************************************/ |
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 |
/******************************************************/ |
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 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1331 |
/***** N O W D O T H E K E Y W O R D S *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1332 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1333 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1334 |
/******************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1335 |
/******************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1336 |
/******************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1337 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1338 |
|
934
2a42a68f4b59
Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents:
933
diff
changeset
|
1339 |
REF {if (get_opt_ref_standard_extensions()) return REF; else{REJECT;}} /* Keyword in IEC 61131-3 v3 */ |
2a42a68f4b59
Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents:
933
diff
changeset
|
1340 |
DREF {if (get_opt_ref_standard_extensions()) return DREF; else{REJECT;}} /* Keyword in IEC 61131-3 v3 */ |
2a42a68f4b59
Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents:
933
diff
changeset
|
1341 |
REF_TO {if (get_opt_ref_standard_extensions()) return REF_TO; else{REJECT;}} /* Keyword in IEC 61131-3 v3 */ |
2a42a68f4b59
Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents:
933
diff
changeset
|
1342 |
NULL {if (get_opt_ref_standard_extensions()) return NULL_token; else{REJECT;}} /* Keyword in IEC 61131-3 v3 */ |
873
dea39ef02847
Add limited support for the REF() operator (defined in v3 of IEC 61131-3)
mjsousa
parents:
869
diff
changeset
|
1343 |
|
82 | 1344 |
EN return EN; /* Keyword */ |
1345 |
ENO return ENO; /* Keyword */ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1346 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1347 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1348 |
/******************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1349 |
/* 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
|
1350 |
/******************************/ |
82 | 1351 |
TRUE return TRUE; /* Keyword */ |
257 | 1352 |
BOOL#1 return boolean_true_literal_token; |
1353 |
BOOL#TRUE return boolean_true_literal_token; |
|
1354 |
SAFEBOOL#1 {if (get_opt_safe_extensions()) {return safeboolean_true_literal_token;} else{REJECT;}} /* Keyword (Data Type) */ |
|
1355 |
SAFEBOOL#TRUE {if (get_opt_safe_extensions()) {return safeboolean_true_literal_token;} else{REJECT;}} /* Keyword (Data Type) */ |
|
1356 |
||
82 | 1357 |
FALSE return FALSE; /* Keyword */ |
257 | 1358 |
BOOL#0 return boolean_false_literal_token; |
1359 |
BOOL#FALSE return boolean_false_literal_token; |
|
1360 |
SAFEBOOL#0 {if (get_opt_safe_extensions()) {return safeboolean_false_literal_token;} else{REJECT;}} /* Keyword (Data Type) */ |
|
1361 |
SAFEBOOL#FALSE {if (get_opt_safe_extensions()) {return safeboolean_false_literal_token;} else{REJECT;}} /* Keyword (Data Type) */ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1362 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1363 |
|
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 |
/* 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
|
1366 |
/************************/ |
82 | 1367 |
t# return T_SHARP; /* Delimiter */ |
1368 |
T# return T_SHARP; /* Delimiter */ |
|
1369 |
TIME return TIME; /* Keyword (Data Type) */ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1370 |
|
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 |
/* 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
|
1374 |
/************************************/ |
82 | 1375 |
TIME_OF_DAY return TIME_OF_DAY; /* Keyword (Data Type) */ |
1376 |
TOD return TIME_OF_DAY; /* Keyword (Data Type) */ |
|
1377 |
DATE return DATE; /* Keyword (Data Type) */ |
|
1378 |
d# return D_SHARP; /* Delimiter */ |
|
1379 |
D# return D_SHARP; /* Delimiter */ |
|
1380 |
DATE_AND_TIME return DATE_AND_TIME; /* Keyword (Data Type) */ |
|
1381 |
DT return DATE_AND_TIME; /* Keyword (Data Type) */ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1382 |
|
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 |
/***********************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1385 |
/* 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
|
1386 |
/***********************************/ |
257 | 1387 |
BOOL return BOOL; /* Keyword (Data Type) */ |
1388 |
||
82 | 1389 |
BYTE return BYTE; /* Keyword (Data Type) */ |
1390 |
WORD return WORD; /* Keyword (Data Type) */ |
|
1391 |
DWORD return DWORD; /* Keyword (Data Type) */ |
|
1392 |
LWORD return LWORD; /* Keyword (Data Type) */ |
|
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 |
|
257 | 1394 |
SINT return SINT; /* Keyword (Data Type) */ |
1395 |
INT return INT; /* Keyword (Data Type) */ |
|
1396 |
DINT return DINT; /* Keyword (Data Type) */ |
|
1397 |
LINT return LINT; /* Keyword (Data Type) */ |
|
1398 |
||
1399 |
USINT return USINT; /* Keyword (Data Type) */ |
|
1400 |
UINT return UINT; /* Keyword (Data Type) */ |
|
1401 |
UDINT return UDINT; /* Keyword (Data Type) */ |
|
1402 |
ULINT return ULINT; /* Keyword (Data Type) */ |
|
1403 |
||
1404 |
REAL return REAL; /* Keyword (Data Type) */ |
|
1405 |
LREAL return LREAL; /* Keyword (Data Type) */ |
|
1406 |
||
1407 |
WSTRING return WSTRING; /* Keyword (Data Type) */ |
|
1408 |
STRING return STRING; /* Keyword (Data Type) */ |
|
1409 |
||
1410 |
TIME return TIME; /* Keyword (Data Type) */ |
|
1411 |
DATE return DATE; /* Keyword (Data Type) */ |
|
1412 |
DT return DT; /* Keyword (Data Type) */ |
|
1413 |
TOD return TOD; /* Keyword (Data Type) */ |
|
1414 |
DATE_AND_TIME return DATE_AND_TIME; /* Keyword (Data Type) */ |
|
1415 |
TIME_OF_DAY return TIME_OF_DAY; /* Keyword (Data Type) */ |
|
1416 |
||
1014
a61f8f58f612
Add support for non-standard VOID datatype. May ony be used to define functions returning VOID.
mjsousa
parents:
1013
diff
changeset
|
1417 |
/* A non-standard extension! */ |
a61f8f58f612
Add support for non-standard VOID datatype. May ony be used to define functions returning VOID.
mjsousa
parents:
1013
diff
changeset
|
1418 |
VOID {if (runtime_options.allow_void_datatype) {return VOID;} else {REJECT;}} |
a61f8f58f612
Add support for non-standard VOID datatype. May ony be used to define functions returning VOID.
mjsousa
parents:
1013
diff
changeset
|
1419 |
|
a61f8f58f612
Add support for non-standard VOID datatype. May ony be used to define functions returning VOID.
mjsousa
parents:
1013
diff
changeset
|
1420 |
|
257 | 1421 |
/*****************************************************************/ |
1422 |
/* Keywords defined in "Safety Software Technical Specification" */ |
|
1423 |
/*****************************************************************/ |
|
1424 |
/* |
|
1425 |
* NOTE: The following keywords are define in |
|
1426 |
* "Safety Software Technical Specification, |
|
1427 |
* Part 1: Concepts and Function Blocks, |
|
1428 |
* Version 1.0 – Official Release" |
|
1429 |
* written by PLCopen - Technical Committee 5 |
|
1430 |
* |
|
1431 |
* We only support these extensions and keywords |
|
1432 |
* if the apropriate command line option is given. |
|
1433 |
*/ |
|
1434 |
SAFEBOOL {if (get_opt_safe_extensions()) {return SAFEBOOL;} else {REJECT;}} |
|
1435 |
||
1436 |
SAFEBYTE {if (get_opt_safe_extensions()) {return SAFEBYTE;} else {REJECT;}} |
|
1437 |
SAFEWORD {if (get_opt_safe_extensions()) {return SAFEWORD;} else {REJECT;}} |
|
1438 |
SAFEDWORD {if (get_opt_safe_extensions()) {return SAFEDWORD;} else{REJECT;}} |
|
1439 |
SAFELWORD {if (get_opt_safe_extensions()) {return SAFELWORD;} else{REJECT;}} |
|
1440 |
||
1441 |
SAFEREAL {if (get_opt_safe_extensions()) {return SAFESINT;} else{REJECT;}} |
|
1442 |
SAFELREAL {if (get_opt_safe_extensions()) {return SAFELREAL;} else{REJECT;}} |
|
1443 |
||
1444 |
SAFESINT {if (get_opt_safe_extensions()) {return SAFESINT;} else{REJECT;}} |
|
1445 |
SAFEINT {if (get_opt_safe_extensions()) {return SAFEINT;} else{REJECT;}} |
|
1446 |
SAFEDINT {if (get_opt_safe_extensions()) {return SAFEDINT;} else{REJECT;}} |
|
1447 |
SAFELINT {if (get_opt_safe_extensions()) {return SAFELINT;} else{REJECT;}} |
|
1448 |
||
1449 |
SAFEUSINT {if (get_opt_safe_extensions()) {return SAFEUSINT;} else{REJECT;}} |
|
1450 |
SAFEUINT {if (get_opt_safe_extensions()) {return SAFEUINT;} else{REJECT;}} |
|
1451 |
SAFEUDINT {if (get_opt_safe_extensions()) {return SAFEUDINT;} else{REJECT;}} |
|
1452 |
SAFEULINT {if (get_opt_safe_extensions()) {return SAFEULINT;} else{REJECT;}} |
|
1453 |
||
1454 |
/* SAFESTRING and SAFEWSTRING are not yet supported, i.e. checked correctly, in the semantic analyser (stage 3) */ |
|
1455 |
/* so it is best not to support them at all... */ |
|
1456 |
/* |
|
1457 |
SAFEWSTRING {if (get_opt_safe_extensions()) {return SAFEWSTRING;} else{REJECT;}} |
|
1458 |
SAFESTRING {if (get_opt_safe_extensions()) {return SAFESTRING;} else{REJECT;}} |
|
1459 |
*/ |
|
1460 |
||
1461 |
SAFETIME {if (get_opt_safe_extensions()) {return SAFETIME;} else{REJECT;}} |
|
1462 |
SAFEDATE {if (get_opt_safe_extensions()) {return SAFEDATE;} else{REJECT;}} |
|
1463 |
SAFEDT {if (get_opt_safe_extensions()) {return SAFEDT;} else{REJECT;}} |
|
1464 |
SAFETOD {if (get_opt_safe_extensions()) {return SAFETOD;} else{REJECT;}} |
|
1465 |
SAFEDATE_AND_TIME {if (get_opt_safe_extensions()) {return SAFEDATE_AND_TIME;} else{REJECT;}} |
|
1466 |
SAFETIME_OF_DAY {if (get_opt_safe_extensions()) {return SAFETIME_OF_DAY;} else{REJECT;}} |
|
0
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 |
/* 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
|
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 |
/* Strangely, the following symbols do not 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
|
1472 |
/* But we include them so they become reserved words, and 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
|
1473 |
* get passed up to bison 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
|
1474 |
*/ |
82 | 1475 |
ANY return ANY; /* Keyword (Data Type) */ |
1476 |
ANY_DERIVED return ANY_DERIVED; /* Keyword (Data Type) */ |
|
1477 |
ANY_ELEMENTARY return ANY_ELEMENTARY; /* Keyword (Data Type) */ |
|
1478 |
ANY_MAGNITUDE return ANY_MAGNITUDE; /* Keyword (Data Type) */ |
|
1479 |
ANY_NUM return ANY_NUM; /* Keyword (Data Type) */ |
|
1480 |
ANY_REAL return ANY_REAL; /* Keyword (Data Type) */ |
|
1481 |
ANY_INT return ANY_INT; /* Keyword (Data Type) */ |
|
1482 |
ANY_BIT return ANY_BIT; /* Keyword (Data Type) */ |
|
1483 |
ANY_STRING return ANY_STRING; /* Keyword (Data Type) */ |
|
1484 |
ANY_DATE return ANY_DATE; /* Keyword (Data Type) */ |
|
0
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 |
/* 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
|
1489 |
/********************************/ |
82 | 1490 |
":=" return ASSIGN; /* Delimiter */ |
1491 |
".." return DOTDOT; /* Delimiter */ |
|
1492 |
TYPE return TYPE; /* Keyword */ |
|
1493 |
END_TYPE return END_TYPE; /* Keyword */ |
|
1494 |
ARRAY return ARRAY; /* Keyword */ |
|
1495 |
OF return OF; /* Keyword */ |
|
1496 |
STRUCT return STRUCT; /* Keyword */ |
|
1497 |
END_STRUCT return END_STRUCT; /* Keyword */ |
|
0
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 |
/* 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
|
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 |
/* 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
|
1506 |
/******************************************/ |
82 | 1507 |
VAR_INPUT return VAR_INPUT; /* Keyword */ |
1508 |
VAR_OUTPUT return VAR_OUTPUT; /* Keyword */ |
|
1509 |
VAR_IN_OUT return VAR_IN_OUT; /* Keyword */ |
|
1510 |
VAR_EXTERNAL return VAR_EXTERNAL; /* Keyword */ |
|
1511 |
VAR_GLOBAL return VAR_GLOBAL; /* Keyword */ |
|
1512 |
END_VAR return END_VAR; /* Keyword */ |
|
1513 |
RETAIN return RETAIN; /* Keyword */ |
|
1514 |
NON_RETAIN return NON_RETAIN; /* Keyword */ |
|
1515 |
R_EDGE return R_EDGE; /* Keyword */ |
|
1516 |
F_EDGE return F_EDGE; /* Keyword */ |
|
1517 |
AT return AT; /* Keyword */ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1518 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1519 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1520 |
/***********************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1521 |
/* 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
|
1522 |
/***********************/ |
1010
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1523 |
/* Note: The following END_FUNCTION rule includes a BEGIN(INITIAL); command. |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1524 |
* This is necessary in case the input program being parsed has syntax errors that force |
1010
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1525 |
* flex's main state machine to never change to the il_state or the st_state |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1526 |
* after changing to the body_state. |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1527 |
* Ths BEGIN(INITIAL) command forces the flex state machine to re-synchronise with |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1528 |
* the input stream even in the presence of buggy code! |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1529 |
*/ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1530 |
FUNCTION return FUNCTION; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1531 |
END_FUNCTION BEGIN(INITIAL); return END_FUNCTION; /* Keyword */ /* see Note above */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1532 |
VAR return VAR; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1533 |
CONSTANT return CONSTANT; /* Keyword */ |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1534 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1535 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1536 |
/*****************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1537 |
/* 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
|
1538 |
/*****************************/ |
1010
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1539 |
/* Note: The following END_FUNCTION_BLOCK rule includes a BEGIN(INITIAL); command. |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1540 |
* This is necessary in case the input program being parsed has syntax errors that force |
1010
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1541 |
* flex's main state machine to never change to the il_state or the st_state |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1542 |
* after changing to the body_state. |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1543 |
* Ths BEGIN(INITIAL) command forces the flex state machine to re-synchronise with |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1544 |
* the input stream even in the presence of buggy code! |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1545 |
*/ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1546 |
FUNCTION_BLOCK return FUNCTION_BLOCK; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1547 |
END_FUNCTION_BLOCK BEGIN(INITIAL); return END_FUNCTION_BLOCK; /* Keyword */ /* see Note above */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1548 |
VAR_TEMP return VAR_TEMP; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1549 |
VAR return VAR; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1550 |
NON_RETAIN return NON_RETAIN; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1551 |
END_VAR return END_VAR; /* Keyword */ |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1552 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1553 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1554 |
/**********************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1555 |
/* 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
|
1556 |
/**********************/ |
1010
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1557 |
/* Note: The following END_PROGRAM rule includes a BEGIN(INITIAL); command. |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
1558 |
* This is necessary in case the input program being parsed has syntax errors that force |
1010
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1559 |
* flex's main state machine to never change to the il_state or the st_state |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1560 |
* after changing to the body_state. |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1561 |
* Ths BEGIN(INITIAL) command forces the flex state machine to re-synchronise with |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1562 |
* the input stream even in the presence of buggy code! |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1563 |
*/ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1564 |
PROGRAM return PROGRAM; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1565 |
END_PROGRAM BEGIN(INITIAL); return END_PROGRAM; /* Keyword */ /* see Note 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
|
1566 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1567 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1568 |
/********************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1569 |
/* 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
|
1570 |
/********************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1571 |
/* NOTE: the following identifiers/tokens clash with the R and S IL operators, 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
|
1572 |
.* as other identifiers that may be used as variable names inside IL and ST programs. |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1573 |
* They will have to be handled when we include parsing of SFC... For now, simply |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1574 |
* ignore them! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1575 |
*/ |
1
5d893a68be6e
Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents:
0
diff
changeset
|
1576 |
|
82 | 1577 |
ACTION return ACTION; /* Keyword */ |
1578 |
END_ACTION return END_ACTION; /* Keyword */ |
|
1579 |
||
1580 |
TRANSITION return TRANSITION; /* Keyword */ |
|
1581 |
END_TRANSITION return END_TRANSITION; /* Keyword */ |
|
1582 |
FROM return FROM; /* Keyword */ |
|
1583 |
TO return TO; /* Keyword */ |
|
1584 |
||
1585 |
INITIAL_STEP return INITIAL_STEP; /* Keyword */ |
|
1586 |
STEP return STEP; /* Keyword */ |
|
1587 |
END_STEP return END_STEP; /* Keyword */ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1588 |
|
74
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
1589 |
/* PRIORITY is not a keyword, so we only return it when |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
1590 |
* it is explicitly required and we are not expecting any identifiers |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
1591 |
* that could also use the same letter sequence (i.e. an identifier: piority) |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
1592 |
*/ |
86
1988bf1634da
Adding support for use of PRIORITY as identifier inside SFC.
mario
parents:
84
diff
changeset
|
1593 |
<sfc_priority_state>PRIORITY return PRIORITY; |
74
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
1594 |
|
68 | 1595 |
<sfc_qualifier_state>{ |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1596 |
L return L; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1597 |
D return D; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1598 |
SD return SD; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1599 |
DS return DS; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1600 |
SL return SL; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1601 |
N return N; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1602 |
P return P; |
627
e7caa7d32ef5
Adding support for P0 and P1 qualifiers and fixing code generated for SL qualifier
Laurent Bessard
parents:
616
diff
changeset
|
1603 |
P0 return P0; |
e7caa7d32ef5
Adding support for P0 and P1 qualifiers and fixing code generated for SL qualifier
Laurent Bessard
parents:
616
diff
changeset
|
1604 |
P1 return 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
|
1605 |
R return R; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1606 |
S return S; |
1
5d893a68be6e
Changes made since Mario visit at LOLITECH. Thanks again !
etisserant
parents:
0
diff
changeset
|
1607 |
} |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1608 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1609 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1610 |
/********************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1611 |
/* 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
|
1612 |
/********************************/ |
1010
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1613 |
/* Note: The following END_CONFIGURATION rule will never get to be used, as we have |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1614 |
* another identical rule above (closer to the rules handling the transitions |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1615 |
* of the main state machine) that will always execute before this one. |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1616 |
* Note: The following END_CONFIGURATION rule includes a BEGIN(INITIAL); command. |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1617 |
* This is nt strictly necessary, but I place it here so it follwos the same |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1618 |
* pattern used in END_FUNCTION, END_PROGRAM, and END_FUNCTION_BLOCK |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1619 |
*/ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1620 |
CONFIGURATION return CONFIGURATION; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1621 |
END_CONFIGURATION BEGIN(INITIAL); return END_CONFIGURATION; /* Keyword */ /* see 2 Notes above! */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1622 |
TASK return TASK; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1623 |
RESOURCE return RESOURCE; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1624 |
ON return ON; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1625 |
END_RESOURCE return END_RESOURCE; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1626 |
VAR_CONFIG return VAR_CONFIG; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1627 |
VAR_ACCESS return VAR_ACCESS; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1628 |
END_VAR return END_VAR; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1629 |
WITH return WITH; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1630 |
PROGRAM return PROGRAM; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1631 |
RETAIN return RETAIN; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1632 |
NON_RETAIN return NON_RETAIN; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1633 |
READ_WRITE return READ_WRITE; /* Keyword */ |
242907849850
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
mjsousa
parents:
952
diff
changeset
|
1634 |
READ_ONLY return READ_ONLY; /* Keyword */ |
74
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
1635 |
|
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
1636 |
/* PRIORITY, SINGLE and INTERVAL are not a keywords, so we only return them when |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
1637 |
* it is explicitly required and we are not expecting any identifiers |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
1638 |
* that could also use the same letter sequence (i.e. an identifier: piority, ...) |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
1639 |
*/ |
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
1640 |
<task_init_state>{ |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1641 |
PRIORITY return PRIORITY; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1642 |
SINGLE return SINGLE; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1643 |
INTERVAL return INTERVAL; |
74
85af9521bf63
fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents:
73
diff
changeset
|
1644 |
} |
0
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 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
|
1648 |
/***********************************/ |
3 | 1649 |
<il_state>\n return EOL; |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1650 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1651 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1652 |
/*******************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1653 |
/* 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
|
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 |
/* NOTE: we can't have flex return the same token for |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1656 |
* ANDN and &N, neither for AND and &, since |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1657 |
* AND and ANDN are considered valid variable |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1658 |
* function or functionblock 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
|
1659 |
* This means that the parser may decide that the |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1660 |
* AND or ANDN strings found 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
|
1661 |
* are being used as 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
|
1662 |
* and not as operators, and will therefore transform |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1663 |
* these tokens into indentifier tokens! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1664 |
* We can't have the parser thinking that the source |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1665 |
* code contained the string AND (which may be interpreted |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1666 |
* as a vairable name) when in reality 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
|
1667 |
* merely contained the character &, so we use two |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1668 |
* different tokens for & and AND (and similarly |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1669 |
* ANDN and &N)! |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1670 |
*/ |
68 | 1671 |
/* The following tokens clash with ST expression operators and Standard Functions */ |
73 | 1672 |
/* They are also keywords! */ |
82 | 1673 |
AND return AND; /* Keyword */ |
1674 |
MOD return MOD; /* Keyword */ |
|
1675 |
OR return OR; /* Keyword */ |
|
1676 |
XOR return XOR; /* Keyword */ |
|
1677 |
NOT return NOT; /* Keyword */ |
|
68 | 1678 |
|
1679 |
/* The following tokens clash with Standard Functions */ |
|
82 | 1680 |
/* They are keywords because they are a function name */ |
73 | 1681 |
<il_state>{ |
82 | 1682 |
ADD return ADD; /* Keyword (Standard Function) */ |
1683 |
DIV return DIV; /* Keyword (Standard Function) */ |
|
1684 |
EQ return EQ; /* Keyword (Standard Function) */ |
|
1685 |
GE return GE; /* Keyword (Standard Function) */ |
|
1686 |
GT return GT; /* Keyword (Standard Function) */ |
|
1687 |
LE return LE; /* Keyword (Standard Function) */ |
|
1688 |
LT return LT; /* Keyword (Standard Function) */ |
|
1689 |
MUL return MUL; /* Keyword (Standard Function) */ |
|
1690 |
NE return NE; /* Keyword (Standard Function) */ |
|
1691 |
SUB return SUB; /* Keyword (Standard Function) */ |
|
73 | 1692 |
} |
68 | 1693 |
|
1694 |
/* The following tokens clash with SFC action qualifiers */ |
|
82 | 1695 |
/* They are not keywords! */ |
73 | 1696 |
<il_state>{ |
68 | 1697 |
S return S; |
1698 |
R return R; |
|
73 | 1699 |
} |
68 | 1700 |
|
1701 |
/* The following tokens clash with ST expression operators */ |
|
82 | 1702 |
& return AND2; /* NOT a Delimiter! */ |
68 | 1703 |
|
1704 |
/* The following tokens have no clashes */ |
|
82 | 1705 |
/* They are not keywords! */ |
73 | 1706 |
<il_state>{ |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1707 |
LD return LD; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1708 |
LDN return LDN; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1709 |
ST return ST; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1710 |
STN return STN; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1711 |
S1 return S1; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1712 |
R1 return R1; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1713 |
CLK return CLK; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1714 |
CU return CU; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1715 |
CD return CD; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1716 |
PV return PV; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1717 |
IN return IN; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1718 |
PT return PT; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1719 |
ANDN return ANDN; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1720 |
&N return ANDN2; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1721 |
ORN return ORN; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1722 |
XORN return XORN; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1723 |
CAL return CAL; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1724 |
CALC return CALC; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1725 |
CALCN return CALCN; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1726 |
RET return RET; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1727 |
RETC return RETC; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1728 |
RETCN return RETCN; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1729 |
JMP return JMP; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1730 |
JMPC return JMPC; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1731 |
JMPCN return JMPCN; |
73 | 1732 |
} |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1733 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1734 |
/***********************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1735 |
/* 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
|
1736 |
/***********************/ |
82 | 1737 |
"**" return OPER_EXP; /* NOT a Delimiter! */ |
1738 |
"<>" return OPER_NE; /* NOT a Delimiter! */ |
|
1739 |
">=" return OPER_GE; /* NOT a Delimiter! */ |
|
1740 |
"<=" return OPER_LE; /* NOT a Delimiter! */ |
|
1741 |
& return AND2; /* NOT a Delimiter! */ |
|
1742 |
AND return AND; /* Keyword */ |
|
1743 |
XOR return XOR; /* Keyword */ |
|
1744 |
OR return OR; /* Keyword */ |
|
1745 |
NOT return NOT; /* Keyword */ |
|
1746 |
MOD return MOD; /* Keyword */ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1747 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1748 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1749 |
/*****************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1750 |
/* 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
|
1751 |
/*****************************************/ |
82 | 1752 |
:= return ASSIGN; /* Delimiter */ |
1753 |
=> return SENDTO; /* Delimiter */ |
|
1754 |
RETURN return RETURN; /* Keyword */ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1755 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1756 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1757 |
/********************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1758 |
/* 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
|
1759 |
/********************************/ |
82 | 1760 |
IF return IF; /* Keyword */ |
1761 |
THEN return THEN; /* Keyword */ |
|
1762 |
ELSIF return ELSIF; /* Keyword */ |
|
1763 |
ELSE return ELSE; /* Keyword */ |
|
1764 |
END_IF return END_IF; /* Keyword */ |
|
1765 |
||
1766 |
CASE return CASE; /* Keyword */ |
|
1767 |
OF return OF; /* Keyword */ |
|
1768 |
ELSE return ELSE; /* Keyword */ |
|
1769 |
END_CASE return END_CASE; /* Keyword */ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1770 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1771 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1772 |
/********************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1773 |
/* 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
|
1774 |
/********************************/ |
82 | 1775 |
FOR return FOR; /* Keyword */ |
1776 |
TO return TO; /* Keyword */ |
|
1777 |
BY return BY; /* Keyword */ |
|
1778 |
DO return DO; /* Keyword */ |
|
1779 |
END_FOR return END_FOR; /* Keyword */ |
|
1780 |
||
1781 |
WHILE return WHILE; /* Keyword */ |
|
1782 |
DO return DO; /* Keyword */ |
|
1783 |
END_WHILE return END_WHILE; /* Keyword */ |
|
1784 |
||
1785 |
REPEAT return REPEAT; /* Keyword */ |
|
1786 |
UNTIL return UNTIL; /* Keyword */ |
|
1787 |
END_REPEAT return END_REPEAT; /* Keyword */ |
|
1788 |
||
1789 |
EXIT return EXIT; /* Keyword */ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1790 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1791 |
|
257 | 1792 |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1793 |
|
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 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1796 |
/********************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1797 |
/********************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1798 |
/********************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1799 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1800 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1801 |
/***** N O W W O R K W I T H V A L U E S *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1802 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1803 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1804 |
/********************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1805 |
/********************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1806 |
/********************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1807 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1808 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1809 |
/********************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1810 |
/* 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
|
1811 |
/********************************************/ |
175
dadda1b5401e
Adding support for checking direct variable declared before using
lbessard
parents:
152
diff
changeset
|
1812 |
{direct_variable} {yylval.ID=strdup(yytext); return get_direct_variable_token(yytext);} |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1813 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1814 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1815 |
/******************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1816 |
/* 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
|
1817 |
/******************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1818 |
{incompl_location} {yylval.ID=strdup(yytext); return 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
|
1819 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1820 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1821 |
/************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1822 |
/* 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
|
1823 |
/************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1824 |
{fixed_point} {yylval.ID=strdup(yytext); return fixed_point_token;} |
547
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1825 |
{interval} {/*fprintf(stderr, "entering time_literal_state ##%s##\n", yytext);*/ unput_and_mark('#'); yy_push_state(time_literal_state);} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1826 |
{erroneous_interval} {return erroneous_interval_token;} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1827 |
|
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1828 |
<time_literal_state>{ |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1829 |
{integer}d {yylval.ID=strdup(yytext); yylval.ID[yyleng-1] = '\0'; return integer_d_token;} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1830 |
{integer}h {yylval.ID=strdup(yytext); yylval.ID[yyleng-1] = '\0'; return integer_h_token;} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1831 |
{integer}m {yylval.ID=strdup(yytext); yylval.ID[yyleng-1] = '\0'; return integer_m_token;} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1832 |
{integer}s {yylval.ID=strdup(yytext); yylval.ID[yyleng-1] = '\0'; return integer_s_token;} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1833 |
{integer}ms {yylval.ID=strdup(yytext); yylval.ID[yyleng-2] = '\0'; return integer_ms_token;} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1834 |
{fixed_point}d {yylval.ID=strdup(yytext); yylval.ID[yyleng-1] = '\0'; return fixed_point_d_token;} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1835 |
{fixed_point}h {yylval.ID=strdup(yytext); yylval.ID[yyleng-1] = '\0'; return fixed_point_h_token;} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1836 |
{fixed_point}m {yylval.ID=strdup(yytext); yylval.ID[yyleng-1] = '\0'; return fixed_point_m_token;} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1837 |
{fixed_point}s {yylval.ID=strdup(yytext); yylval.ID[yyleng-1] = '\0'; return fixed_point_s_token;} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1838 |
{fixed_point}ms {yylval.ID=strdup(yytext); yylval.ID[yyleng-2] = '\0'; return fixed_point_ms_token;} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1839 |
|
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1840 |
_ /* do nothing - eat it up!*/ |
616
0c7663fdc8d3
Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents:
547
diff
changeset
|
1841 |
\# {/*fprintf(stderr, "popping from time_literal_state (###)\n");*/ yy_pop_state(); return end_interval_token;} |
0c7663fdc8d3
Aloow use of SFC STEPs as variables.
Mario de Sousa <msousa@fe.up.pt>
parents:
547
diff
changeset
|
1842 |
. {/*fprintf(stderr, "time_literal_state: found invalid character '%s'. Aborting!\n", yytext);*/ ERROR;} |
547
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1843 |
\n {ERROR;} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
1844 |
} |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1845 |
/*******************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1846 |
/* 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
|
1847 |
/*******************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1848 |
{double_byte_character_string} {yylval.ID=strdup(yytext); return 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
|
1849 |
{single_byte_character_string} {yylval.ID=strdup(yytext); return 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
|
1850 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1851 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1852 |
/******************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1853 |
/* 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
|
1854 |
/******************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1855 |
{integer} {yylval.ID=strdup(yytext); return 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
|
1856 |
{real} {yylval.ID=strdup(yytext); return 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
|
1857 |
{binary_integer} {yylval.ID=strdup(yytext); return 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
|
1858 |
{octal_integer} {yylval.ID=strdup(yytext); return 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
|
1859 |
{hex_integer} {yylval.ID=strdup(yytext); return 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
|
1860 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1861 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1862 |
/*****************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1863 |
/* 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
|
1864 |
/*****************************************/ |
866 | 1865 |
<st_state>{identifier}/({st_whitespace_or_pragma_or_comment})"=>" {yylval.ID=strdup(yytext); return sendto_identifier_token;} |
1866 |
<il_state>{identifier}/({il_whitespace_or_pragma_or_comment})"=>" {yylval.ID=strdup(yytext); return sendto_identifier_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
|
1867 |
{identifier} {yylval.ID=strdup(yytext); |
75 | 1868 |
// printf("returning identifier...: %s, %d\n", yytext, get_identifier_token(yytext)); |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1869 |
return get_identifier_token(yytext);} |
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 |
|
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 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1874 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1875 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1876 |
/************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1877 |
/************************************************/ |
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 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1880 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1881 |
/***** T H E L E F T O V E R S . . . *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1882 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1883 |
/***** *****/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1884 |
/************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1885 |
/************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1886 |
/************************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1887 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1888 |
/* do the single character tokens... |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1889 |
* |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1890 |
* e.g.: ':' '(' ')' '+' '*' ... |
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 |
. {return yytext[0];} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1893 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1894 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1895 |
%% |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1896 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1897 |
|
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1898 |
/*************************/ |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1899 |
/* Tracking Functions... */ |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1900 |
/*************************/ |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1901 |
|
880
599e88d12f9a
Track of line number correctly when input file has code with very long lines.
mjsousa
parents:
879
diff
changeset
|
1902 |
#define MAX_LINE_LENGTH 1024 |
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1903 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1904 |
tracking_t *GetNewTracking(FILE* in_file) { |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1905 |
tracking_t* new_env = new tracking_t; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1906 |
new_env->eof = 0; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1907 |
new_env->lineNumber = 0; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1908 |
new_env->currentChar = 0; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1909 |
new_env->lineLength = 0; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1910 |
new_env->currentTokenStart = 0; |
879 | 1911 |
new_env->buffer = (char*)malloc(MAX_LINE_LENGTH); |
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1912 |
new_env->in_file = in_file; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1913 |
return new_env; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1914 |
} |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1915 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1916 |
|
879 | 1917 |
void FreeTracking(tracking_t *tracking) { |
1918 |
free(tracking->buffer); |
|
1919 |
delete tracking; |
|
1920 |
} |
|
1921 |
||
1922 |
||
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1923 |
/* GetNextChar: reads a character from input */ |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1924 |
int GetNextChar(char *b, int maxBuffer) { |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1925 |
char *p; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1926 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1927 |
if ( current_tracking->eof ) |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1928 |
return 0; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1929 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1930 |
while ( current_tracking->currentChar >= current_tracking->lineLength ) { |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1931 |
current_tracking->currentChar = 0; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1932 |
current_tracking->currentTokenStart = 1; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1933 |
current_tracking->eof = false; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1934 |
|
879 | 1935 |
p = fgets(current_tracking->buffer, MAX_LINE_LENGTH, current_tracking->in_file); |
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1936 |
if ( p == NULL ) { |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1937 |
if ( ferror(current_tracking->in_file) ) |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1938 |
return 0; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1939 |
current_tracking->eof = true; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1940 |
return 0; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1941 |
} |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1942 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1943 |
current_tracking->lineLength = strlen(current_tracking->buffer); |
880
599e88d12f9a
Track of line number correctly when input file has code with very long lines.
mjsousa
parents:
879
diff
changeset
|
1944 |
|
599e88d12f9a
Track of line number correctly when input file has code with very long lines.
mjsousa
parents:
879
diff
changeset
|
1945 |
/* only increment line number if the buffer was big enough to read the whole line! */ |
599e88d12f9a
Track of line number correctly when input file has code with very long lines.
mjsousa
parents:
879
diff
changeset
|
1946 |
char last_char = current_tracking->buffer[current_tracking->lineLength - 1]; |
599e88d12f9a
Track of line number correctly when input file has code with very long lines.
mjsousa
parents:
879
diff
changeset
|
1947 |
if (('\n' == last_char) || ('\r' == last_char)) // '\r' ---> CR, '\n' ---> LF |
599e88d12f9a
Track of line number correctly when input file has code with very long lines.
mjsousa
parents:
879
diff
changeset
|
1948 |
current_tracking->lineNumber++; |
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1949 |
} |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1950 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1951 |
b[0] = current_tracking->buffer[current_tracking->currentChar]; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1952 |
if (b[0] == ' ' || b[0] == '\t') |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1953 |
current_tracking->currentTokenStart++; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1954 |
current_tracking->currentChar++; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1955 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1956 |
return b[0]==0?0:1; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1957 |
} |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1958 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1959 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1960 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
1961 |
|
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 |
/***********************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1963 |
/* Utility function definitions... */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1964 |
/***********************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1965 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1966 |
/* print the include file stack to stderr... */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1967 |
void print_include_stack(void) { |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1968 |
int i; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1969 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1970 |
if ((include_stack_ptr - 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
|
1971 |
fprintf (stderr, "in file "); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1972 |
for (i = include_stack_ptr - 1; i >= 0; i--) |
136 | 1973 |
fprintf (stderr, "included from file %s:%d\n", include_stack[i].filename, include_stack[i].env->lineNumber); |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1974 |
} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1975 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
1976 |
|
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:
737
diff
changeset
|
1977 |
|
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:
737
diff
changeset
|
1978 |
/* set the internal state variables of lexical analyser to process a new include file */ |
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:
737
diff
changeset
|
1979 |
void handle_include_file_(FILE *filehandle, const char *filename) { |
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:
737
diff
changeset
|
1980 |
if (include_stack_ptr >= MAX_INCLUDE_DEPTH) { |
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:
737
diff
changeset
|
1981 |
fprintf(stderr, "Includes nested too deeply\n"); |
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:
737
diff
changeset
|
1982 |
exit( 1 ); |
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:
737
diff
changeset
|
1983 |
} |
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:
737
diff
changeset
|
1984 |
|
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:
737
diff
changeset
|
1985 |
yyin = filehandle; |
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:
737
diff
changeset
|
1986 |
|
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:
737
diff
changeset
|
1987 |
include_stack[include_stack_ptr].buffer_state = YY_CURRENT_BUFFER; |
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:
737
diff
changeset
|
1988 |
include_stack[include_stack_ptr].env = current_tracking; |
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:
737
diff
changeset
|
1989 |
include_stack[include_stack_ptr].filename = current_filename; |
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:
737
diff
changeset
|
1990 |
|
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:
737
diff
changeset
|
1991 |
current_filename = strdup(filename); |
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:
737
diff
changeset
|
1992 |
current_tracking = GetNewTracking(yyin); |
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:
737
diff
changeset
|
1993 |
include_stack_ptr++; |
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:
737
diff
changeset
|
1994 |
|
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:
737
diff
changeset
|
1995 |
/* switch input buffer to new file... */ |
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:
737
diff
changeset
|
1996 |
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); |
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:
737
diff
changeset
|
1997 |
} |
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:
737
diff
changeset
|
1998 |
|
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:
737
diff
changeset
|
1999 |
|
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:
737
diff
changeset
|
2000 |
|
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:
737
diff
changeset
|
2001 |
/* insert the code (in <source_code>) into the source code we are parsing. |
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:
737
diff
changeset
|
2002 |
* This is done by creating an artificial file with that new source code, and then 'including' the file |
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:
737
diff
changeset
|
2003 |
*/ |
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2004 |
void include_string_(const char *source_code) { |
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:
737
diff
changeset
|
2005 |
FILE *tmp_file = tmpfile(); |
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:
737
diff
changeset
|
2006 |
|
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:
737
diff
changeset
|
2007 |
if(tmp_file == NULL) { |
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:
737
diff
changeset
|
2008 |
perror("Error creating temp file."); |
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:
737
diff
changeset
|
2009 |
exit(EXIT_FAILURE); |
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:
737
diff
changeset
|
2010 |
} |
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:
737
diff
changeset
|
2011 |
|
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:
737
diff
changeset
|
2012 |
fwrite((void *)source_code, 1, strlen(source_code), tmp_file); |
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:
737
diff
changeset
|
2013 |
rewind(tmp_file); |
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:
737
diff
changeset
|
2014 |
|
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:
737
diff
changeset
|
2015 |
/* now parse the tmp file, by asking flex to handle it as if it had been included with the (*#include ... *) pragma... */ |
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:
737
diff
changeset
|
2016 |
handle_include_file_(tmp_file, ""); |
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:
737
diff
changeset
|
2017 |
//fclose(tmp_file); /* do NOT close file. It must only be closed when we finish reading from it! */ |
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:
737
diff
changeset
|
2018 |
} |
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:
737
diff
changeset
|
2019 |
|
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:
737
diff
changeset
|
2020 |
|
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:
737
diff
changeset
|
2021 |
|
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:
737
diff
changeset
|
2022 |
/* Open an include file, and set the internal state variables of lexical analyser to process a new include file */ |
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:
737
diff
changeset
|
2023 |
void include_file(const char *filename) { |
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:
737
diff
changeset
|
2024 |
FILE *filehandle = NULL; |
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:
737
diff
changeset
|
2025 |
|
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:
737
diff
changeset
|
2026 |
for (int i = 0; (INCLUDE_DIRECTORIES[i] != NULL) && (filehandle == NULL); i++) { |
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:
737
diff
changeset
|
2027 |
char *full_name; |
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:
737
diff
changeset
|
2028 |
full_name = strdup3(INCLUDE_DIRECTORIES[i], "/", filename); |
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:
737
diff
changeset
|
2029 |
if (full_name == NULL) { |
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:
737
diff
changeset
|
2030 |
fprintf(stderr, "Out of memory!\n"); |
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:
737
diff
changeset
|
2031 |
exit( 1 ); |
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:
737
diff
changeset
|
2032 |
} |
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:
737
diff
changeset
|
2033 |
filehandle = fopen(full_name, "r"); |
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:
737
diff
changeset
|
2034 |
free(full_name); |
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:
737
diff
changeset
|
2035 |
} |
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:
737
diff
changeset
|
2036 |
|
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:
737
diff
changeset
|
2037 |
if (NULL == filehandle) { |
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:
737
diff
changeset
|
2038 |
fprintf(stderr, "Error opening included file %s\n", filename); |
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:
737
diff
changeset
|
2039 |
exit( 1 ); |
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:
737
diff
changeset
|
2040 |
} |
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:
737
diff
changeset
|
2041 |
|
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:
737
diff
changeset
|
2042 |
/* now process the new file... */ |
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:
737
diff
changeset
|
2043 |
handle_include_file_(filehandle, filename); |
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:
737
diff
changeset
|
2044 |
} |
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:
737
diff
changeset
|
2045 |
|
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:
737
diff
changeset
|
2046 |
|
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:
737
diff
changeset
|
2047 |
|
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:
737
diff
changeset
|
2048 |
|
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:
737
diff
changeset
|
2049 |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2050 |
/* return all the text in the current token back to the input stream, except the first n chars. */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2051 |
void unput_text(unsigned int n) { |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2052 |
/* it seems that flex has a bug in that it will not correctly count the line numbers |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2053 |
* if we return newlines back to the input stream. These newlines will be re-counted |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2054 |
* a second time when they are processed again 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
|
2055 |
* We therefore determine how many newlines are in the text we are returning, |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2056 |
* and decrement the line counter acordingly... |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2057 |
*/ |
879 | 2058 |
/* |
2059 |
unsigned int i; |
|
136 | 2060 |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2061 |
for (i = n; i < strlen(yytext); i++) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2062 |
if (yytext[i] == '\n') |
879 | 2063 |
current_tracking->lineNumber--; |
2064 |
*/ |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2065 |
/* now return all the text back to the input stream... */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2066 |
yyless(n); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2067 |
} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2068 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2069 |
|
547
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2070 |
/* return all the text in the current token back to the input stream, |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2071 |
* but first return to the stream an additional character to mark the end of the token. |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2072 |
*/ |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2073 |
void unput_and_mark(const char c) { |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2074 |
char *yycopy = strdup( yytext ); /* unput() destroys yytext, so we copy it first */ |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2075 |
unput(c); |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2076 |
for (int i = yyleng-1; i >= 0; i--) |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2077 |
unput(yycopy[i]); |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2078 |
|
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2079 |
free(yycopy); |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2080 |
} |
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2081 |
|
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2082 |
|
dab341e80664
Fix parsing os TIME literals & rename the extract_integer() function.
mjsousa <msousa@fe.up.pt>
parents:
415
diff
changeset
|
2083 |
|
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2084 |
/* The body_state tries to find a ';' before a END_PROGRAM, END_FUNCTION or END_FUNCTION_BLOCK or END_ACTION |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2085 |
* To do so, it must ignore comments and pragmas. This means that we cannot do this in a signle lex rule. |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2086 |
* However, we must store any text we consume in every rule, so we can push it back into the buffer |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2087 |
* once we have decided if we are parsing ST or IL code. The following functions manage that buffer used by |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2088 |
* the body_state. |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2089 |
*/ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2090 |
/* The buffer used by the body_state state */ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2091 |
char *bodystate_buffer = NULL; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2092 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2093 |
/* append text to bodystate_buffer */ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2094 |
void append_bodystate_buffer(const char *text) { |
1020
36fb9443b6ea
fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop)
mjsousa
parents:
1016
diff
changeset
|
2095 |
//printf("<<<append_bodystate_buffer>>> %d <%s><%s>\n", bodystate_buffer, text, (NULL != bodystate_buffer)?bodystate_buffer:"NULL"); |
1016
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2096 |
long int old_len = 0; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2097 |
if (NULL != bodystate_buffer) old_len = strlen(bodystate_buffer); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2098 |
bodystate_buffer = (char *)realloc(bodystate_buffer, old_len + strlen(text) + 1); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2099 |
if (NULL == bodystate_buffer) ERROR; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2100 |
strcpy(bodystate_buffer + old_len, text); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2101 |
//printf("=<%s> %d %d\n", (NULL != bodystate_buffer)?bodystate_buffer:NULL, old_len + strlen(text) + 1, bodystate_buffer); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2102 |
} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2103 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2104 |
/* Return all data in bodystate_buffer back to flex, and empty bodystate_buffer. */ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2105 |
void unput_bodystate_buffer(void) { |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2106 |
if (NULL == bodystate_buffer) ERROR; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2107 |
//printf("<<<unput_bodystate_buffer>>>\n%s\n", bodystate_buffer); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2108 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2109 |
for (long int i = strlen(bodystate_buffer)-1; i >= 0; i--) |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2110 |
unput(bodystate_buffer[i]); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2111 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2112 |
free(bodystate_buffer); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2113 |
bodystate_buffer = NULL; |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2114 |
} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2115 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2116 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2117 |
/* Return true if bodystate_buffer is empty */ |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2118 |
int isempty_bodystate_buffer(void) { |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2119 |
return (NULL == bodystate_buffer); |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2120 |
} |
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2121 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2122 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2123 |
|
91bef6704b44
Add support for functions returning VOID (i.e. non-standard extension, allowing functions that do not return any data)
mjsousa
parents:
1014
diff
changeset
|
2124 |
|
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 |
/* Called by flex when it reaches the end-of-file */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2126 |
int yywrap(void) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2127 |
{ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2128 |
/* We reached the end of the input file... */ |
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 |
/* Should we continue with another file? */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2131 |
/* If so: |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2132 |
* open the new file... |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2133 |
* 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
|
2134 |
*/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2135 |
|
737
f6bc5230aadd
Fix comments and code alignment
Mario de Sousa <msousa@fe.up.pt>
parents:
686
diff
changeset
|
2136 |
/* to stop processing... |
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2137 |
* return 1; |
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 |
return 1; /* Stop scanning at end of input file. */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2141 |
} |
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 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2144 |
|
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2145 |
/*******************************/ |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2146 |
/* Public Interface for Bison. */ |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2147 |
/*******************************/ |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2148 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2149 |
/* The following functions will be called from inside bison code! */ |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2150 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2151 |
void include_string(const char *source_code) {include_string_(source_code);} |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2152 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2153 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2154 |
/* Tell flex which file to parse. This function will not imediately start parsing the file. |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2155 |
* To parse the file, you then need to call yyparse() |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2156 |
* |
761
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
2157 |
* Returns NULL on error opening the file (and a valid errno), or 0 on success. |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
2158 |
* Caller must close the file! |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
2159 |
*/ |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
2160 |
FILE *parse_file(const char *filename) { |
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2161 |
FILE *filehandle = NULL; |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2162 |
|
761
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
2163 |
if((filehandle = fopen(filename, "r")) != NULL) { |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
2164 |
yyin = filehandle; |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
2165 |
current_filename = strdup(filename); |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
2166 |
current_tracking = GetNewTracking(yyin); |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
2167 |
} |
7b52623a2f37
Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents:
757
diff
changeset
|
2168 |
return filehandle; |
757
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2169 |
} |
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2170 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2171 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2172 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2173 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2174 |
|
f1fc4aa6f0e3
Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents:
756
diff
changeset
|
2175 |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2176 |
/*************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2177 |
/* Include a main() function to test */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2178 |
/* the token parsing 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
|
2179 |
/*************************************/ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2180 |
#ifdef TEST_MAIN |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2181 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2182 |
#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
|
2183 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2184 |
yystype yylval; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2185 |
YYLTYPE yylloc; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2186 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2187 |
|
15
0b472e25eb16
Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
13
diff
changeset
|
2188 |
|
0b472e25eb16
Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
13
diff
changeset
|
2189 |
|
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 |
int get_identifier_token(const char *identifier_str) {return 0;} |
175
dadda1b5401e
Adding support for checking direct variable declared before using
lbessard
parents:
152
diff
changeset
|
2191 |
int get_direct_variable_token(const char *direct_variable_str) {return 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
|
2192 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2193 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2194 |
int main(int argc, char **argv) { |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2195 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2196 |
FILE *in_file; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2197 |
int res; |
136 | 2198 |
|
0
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2199 |
if (argc == 1) { |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2200 |
/* Work as an interactive (command line) parser... */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2201 |
while((res=yylex())) |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2202 |
fprintf(stderr, "(line %d)token: %d\n", yylineno, res); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2203 |
} else { |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2204 |
/* Work as non-interactive (file) parser... */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2205 |
if((in_file = fopen(argv[1], "r")) == NULL) { |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2206 |
char *errmsg = strdup2("Error opening main file ", argv[1]); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2207 |
perror(errmsg); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2208 |
free(errmsg); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2209 |
return -1; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2210 |
} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2211 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2212 |
/* parse the file... */ |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2213 |
yyin = in_file; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2214 |
current_filename = argv[1]; |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2215 |
while(1) { |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2216 |
res=yylex(); |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2217 |
fprintf(stderr, "(line %d)token: %d (%s)\n", yylineno, res, yylval.ID); |
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 |
} |
136 | 2220 |
|
2221 |
return 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
|
2222 |
|
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2223 |
} |
fb772792efd1
Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff
changeset
|
2224 |
#endif |