# HG changeset patch # User mjsousa # Date 1464865185 -3600 # Node ID 36fb9443b6ea676ced5f9029f9b7ab070b2eb7e3 # Parent 1e3cefbbdee2c8e6a0289b77c32907aa3037ee26 fix bug introduced by commit 91bef6704b44 (parsing SFCs with transitions in ST and leading whitespace => endless loop) diff -r 1e3cefbbdee2 -r 36fb9443b6ea stage1_2/iec_flex.ll --- a/stage1_2/iec_flex.ll Thu May 26 18:30:17 2016 +0100 +++ b/stage1_2/iec_flex.ll Thu Jun 02 11:59:45 2016 +0100 @@ -1172,6 +1172,17 @@ /* body_state -> (il_state | st_state | sfc_state) */ { +{st_whitespace} {/* In body state we do not process any tokens, + * we simply store them for later processing! + * NOTE: all whitespace in the begining + * of body_state must be removed so we can + * detect ':=' in the beginning of TRANSACTION + * conditions preceded by whitespace. + * => only add to bodystate_buffer when not in beginning. + */ + if (!isempty_bodystate_buffer()) + append_bodystate_buffer(yytext); + } /* 'INITIAL_STEP' always used in beginning of SFCs !! */ INITIAL_STEP { if (isempty_bodystate_buffer()) {unput_text(0); BEGIN(sfc_state);} else {append_bodystate_buffer(yytext);} @@ -1234,7 +1245,10 @@ /* The whitespace */ {st_whitespace} /* Eat any whitespace */ {il_whitespace} /* Eat any whitespace */ -{st_whitespace} append_bodystate_buffer(yytext); /* in body state we do not process any tokens, we simply store them for later processing! */ + /* NOTE: Due to the need of having the following rule have higher priority, + * the following rule was moved to an earlier position in this file. +{st_whitespace} {...} + */ /* The comments */ {comment_beg} yy_push_state(comment_state); @@ -2072,7 +2086,7 @@ /* append text to bodystate_buffer */ void append_bodystate_buffer(const char *text) { - //printf("<<>> %d <%s><%s>\n", bodystate_buffer, (NULL != bodystate_buffer)?bodystate_buffer:"NULL", text); + //printf("<<>> %d <%s><%s>\n", bodystate_buffer, text, (NULL != bodystate_buffer)?bodystate_buffer:"NULL"); long int old_len = 0; if (NULL != bodystate_buffer) old_len = strlen(bodystate_buffer); bodystate_buffer = (char *)realloc(bodystate_buffer, old_len + strlen(text) + 1);