245 * the body_state. |
245 * the body_state. |
246 */ |
246 */ |
247 void append_bodystate_buffer(const char *text, int is_whitespace = 0); |
247 void append_bodystate_buffer(const char *text, int is_whitespace = 0); |
248 void unput_bodystate_buffer(void); |
248 void unput_bodystate_buffer(void); |
249 int isempty_bodystate_buffer(void); |
249 int isempty_bodystate_buffer(void); |
|
250 void del_bodystate_buffer(void); |
|
251 |
250 |
252 |
251 int GetNextChar(char *b, int maxBuffer); |
253 int GetNextChar(char *b, int maxBuffer); |
252 %} |
254 %} |
253 |
255 |
254 |
256 |
1229 * parsing SFC code, that contains transitions or actions in other languages) |
1231 * parsing SFC code, that contains transitions or actions in other languages) |
1230 */ |
1232 */ |
1231 append_bodystate_buffer(yytext, 1 /* is whitespace */); |
1233 append_bodystate_buffer(yytext, 1 /* is whitespace */); |
1232 } |
1234 } |
1233 /* 'INITIAL_STEP' always used in beginning of SFCs !! */ |
1235 /* 'INITIAL_STEP' always used in beginning of SFCs !! */ |
1234 INITIAL_STEP { if (isempty_bodystate_buffer()) {unput_text(0); BEGIN(sfc_state);} |
1236 INITIAL_STEP { if (isempty_bodystate_buffer()) {unput_text(0); del_bodystate_buffer(); BEGIN(sfc_state);} |
1235 else {append_bodystate_buffer(yytext);} |
1237 else {append_bodystate_buffer(yytext);} |
1236 } |
1238 } |
1237 |
1239 |
1238 /* ':=', at the very beginning of a 'body', occurs only in transitions and not Function, FB, or Program bodies! */ |
1240 /* ':=', at the very beginning of a 'body', occurs only in transitions and not Function, FB, or Program bodies! */ |
1239 := { 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! */ |
1241 := { if (isempty_bodystate_buffer()) {unput_text(0); del_bodystate_buffer(); BEGIN(st_state);} /* We do _not_ return a start_ST_body_token here, as bison does not expect it! */ |
1240 else {append_bodystate_buffer(yytext);} |
1242 else {append_bodystate_buffer(yytext);} |
1241 } |
1243 } |
1242 |
1244 |
1243 /* 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). */ |
1245 /* 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). */ |
1244 END_ACTION | /* execute the next rule's action, i.e. fall-through! */ |
1246 END_ACTION | /* execute the next rule's action, i.e. fall-through! */ |
2181 if (bodystate_is_whitespace) return 1; |
2183 if (bodystate_is_whitespace) return 1; |
2182 return 0; |
2184 return 0; |
2183 } |
2185 } |
2184 |
2186 |
2185 |
2187 |
|
2188 /* Delete all data in bodystate. */ |
|
2189 /* Will be used to delete ST whitespace when not needed. If not deleted this whitespace |
|
2190 * will be prepended to the next text block of code being appended to bodystate_buffer, |
|
2191 * which may cause trouble if it is IL code |
|
2192 */ |
|
2193 void del_bodystate_buffer(void) { |
|
2194 free(bodystate_buffer); |
|
2195 bodystate_buffer = NULL; |
|
2196 bodystate_is_whitespace = 1; |
|
2197 } |
2186 |
2198 |
2187 |
2199 |
2188 /* Called by flex when it reaches the end-of-file */ |
2200 /* Called by flex when it reaches the end-of-file */ |
2189 int yywrap(void) |
2201 int yywrap(void) |
2190 { |
2202 { |