# HG changeset patch # User mario # Date 1193605407 -3600 # Node ID 0e623bbdee95efc114ccad40924b508d82eeaa6b # Parent 328b794f8922444b1c49533156db7fdf07e43af2 fixing infinite error loops at library level, and ... diff -r 328b794f8922 -r 0e623bbdee95 stage1_2/iec.flex --- a/stage1_2/iec.flex Sun Oct 28 20:15:54 2007 +0100 +++ b/stage1_2/iec.flex Sun Oct 28 22:03:27 2007 +0100 @@ -753,8 +753,17 @@ <> { if (--include_stack_ptr < 0) { + /* yyterminate() terminates the scanner and returns a 0 to the + * scanner's caller, indicating "all done". + * + * Our syntax parser (written with bison) has the token + * END_OF_INPUT associated to the value 0, so even though + * we don't explicitly return the token END_OF_INPUT + * calling yyterminate() is equivalent to doing that. + */ yyterminate(); - } else { + } + else { yy_delete_buffer(YY_CURRENT_BUFFER); yy_switch_to_buffer((include_stack[include_stack_ptr]).buffer_state); yylineno = include_stack[include_stack_ptr].lineno; @@ -1203,6 +1212,7 @@ * ANDN and &N)! */ /* The following tokens clash with ST expression operators and Standard Functions */ + /* They are also keywords! */ AND return AND; MOD return MOD; OR return OR; @@ -1210,6 +1220,7 @@ NOT return NOT; /* The following tokens clash with Standard Functions */ +{ ADD return ADD; DIV return DIV; EQ return EQ; @@ -1220,15 +1231,19 @@ MUL return MUL; NE return NE; SUB return SUB; +} /* The following tokens clash with SFC action qualifiers */ +{ S return S; R return R; +} /* The following tokens clash with ST expression operators */ & return AND2; /* The following tokens have no clashes */ +{ LD return LD; LDN return LDN; ST return ST; @@ -1254,7 +1269,7 @@ JMP return JMP; JMPC return JMPC; JMPCN return JMPCN; - +} /***********************/ /* B 3.1 - Expressions */ diff -r 328b794f8922 -r 0e623bbdee95 stage1_2/iec.y --- a/stage1_2/iec.y Sun Oct 28 20:15:54 2007 +0100 +++ b/stage1_2/iec.y Sun Oct 28 22:03:27 2007 +0100 @@ -206,6 +206,15 @@ /*****************************/ /* Prelimenary constructs... */ /*****************************/ +/* A token used to identify the very end of the input file + * after all includes have already been processed. + * + * Flex automatically returns the token with value 0 + * at the end of the file. We therefore specify + * a token with that exact same value here. + */ +%token END_OF_INPUT 0 + /* A bogus token that, in principle, flex MUST NEVER generate */ /* USE 1: * ====== @@ -1384,7 +1393,7 @@ } | library library_element_declaration {$$ = $1; $$->add_element($2);} -| library error +| library error END_OF_INPUT {$$ = NULL; print_err_msg(current_filename, @2.first_line, "unknown error."); yyerrok; @@ -1517,10 +1526,14 @@ * this list MUST be kept consistent!! */ /**/ +/* | PRIORITY {$$ = new identifier_c(strdup("PRIORITY"), locloc(@$));} | SINGLE {$$ = new identifier_c(strdup("SINGLE"), locloc(@$));} | INTERVAL {$$ = new identifier_c(strdup("INTERVAL"), locloc(@$));} +*/ /**/ +/* NOTE: AND, NOT, MOD, OR and XOR are keywords, so should not appear on this list... */ +/* | LD_operator {$$ = il_operator_c_2_identifier_c($1);} | LDN_operator {$$ = il_operator_c_2_identifier_c($1);} | ST_operator {$$ = il_operator_c_2_identifier_c($1);} @@ -1536,11 +1549,12 @@ | IN_operator {$$ = il_operator_c_2_identifier_c($1);} | PT_operator {$$ = il_operator_c_2_identifier_c($1);} | ANDN_operator {$$ = il_operator_c_2_identifier_c($1);} +*/ /* NOTE: ANDN2_operator corresponds to the string '&N' in the source code! * This is __not__ a valid name, so it is omitted from this list!! *| ANDN2_operator {$$ = il_operator_c_2_identifier_c($1);} */ -/* NOTE: 'AND' is a keyword, so should not appear on this list... */ +/* | ORN_operator {$$ = il_operator_c_2_identifier_c($1);} | XORN_operator {$$ = il_operator_c_2_identifier_c($1);} | ADD_operator {$$ = il_operator_c_2_identifier_c($1);} @@ -1562,6 +1576,7 @@ | JMP_operator {$$ = il_operator_c_2_identifier_c($1);} | JMPC_operator {$$ = il_operator_c_2_identifier_c($1);} | JMPCN_operator {$$ = il_operator_c_2_identifier_c($1);} +*/ ; /*********************/ @@ -5369,7 +5384,7 @@ const char *standard_function_block_names[] = { // 2.5.2.3.1 Bistable elements // Table 34 - Standard bistable function blocks -//"SR","RS", +"SR","RS", // 2.5.2.3.2 Edge detection // Table 35 - Standard edge detection function blocks "R_TRIG","F_TRIG",