stage1_2/iec.y
changeset 267 0a1204bcc9af
parent 264 6facabd9c2cd
child 275 af3d0e3ac65d
equal deleted inserted replaced
266:2f6d8866ec8d 267:0a1204bcc9af
   288 
   288 
   289 /**********************************************************************************/
   289 /**********************************************************************************/
   290 /* B XXX - Things that are missing from the standard, but should have been there! */
   290 /* B XXX - Things that are missing from the standard, but should have been there! */
   291 /**********************************************************************************/
   291 /**********************************************************************************/
   292 
   292 
   293 
   293 /* Pragmas that our compiler will accept.
   294 /* The pragmas... */
   294  * See the comment in iec.flex for why these pragmas exist. 
       
   295  */
       
   296 %token          disable_code_generation_pragma_token
       
   297 %token          enable_code_generation_pragma_token
       
   298 %type <leaf>	disable_code_generation_pragma
       
   299 %type <leaf>	enable_code_generation_pragma
       
   300 
       
   301 
       
   302 /* All other pragmas that we do not support... */
       
   303 /* In most stage 4, the text inside the pragmas will simply be copied to the output file.
       
   304  * This allows us to insert C code (if using stage 4 generating C code) 
       
   305  * inside/interningled with the IEC 61131-3 code!
       
   306  */
   295 %token <ID>	pragma_token
   307 %token <ID>	pragma_token
   296 %type <leaf>	pragma
   308 %type <leaf>	pragma
       
   309 
       
   310 /* The joining of all previous pragmas, i.e. any possible pragma */
       
   311 %type <leaf>	any_pragma
   297 
   312 
   298 
   313 
   299 /* Where do these tokens belong?? They are missing from the standard! */
   314 /* Where do these tokens belong?? They are missing from the standard! */
   300 /* NOTE: There are other tokens related to these 'EN' ENO', that are also 
   315 /* NOTE: There are other tokens related to these 'EN' ENO', that are also 
   301  * missing from the standard. However, their location in the annex B is 
   316  * missing from the standard. However, their location in the annex B is 
  1374 /* B XXX - Things that are missing from the standard, but should have been there! */
  1389 /* B XXX - Things that are missing from the standard, but should have been there! */
  1375 /**********************************************************************************/
  1390 /**********************************************************************************/
  1376 
  1391 
  1377 
  1392 
  1378 /* the pragmas... */
  1393 /* the pragmas... */
       
  1394 
       
  1395 
       
  1396 disable_code_generation_pragma:
       
  1397   disable_code_generation_pragma_token	{$$ = new disable_code_generation_pragma_c(locloc(@$));}
       
  1398 
       
  1399 enable_code_generation_pragma:
       
  1400   enable_code_generation_pragma_token	{$$ = new enable_code_generation_pragma_c(locloc(@$));}
       
  1401 
  1379 pragma:
  1402 pragma:
  1380   pragma_token	{$$ = new pragma_c($1, locloc(@$));}
  1403   pragma_token	{$$ = new pragma_c($1, locloc(@$));}
       
  1404 
       
  1405 any_pragma:
       
  1406   disable_code_generation_pragma
       
  1407 | enable_code_generation_pragma
       
  1408 | pragma
       
  1409 ;
  1381 
  1410 
  1382 
  1411 
  1383 /* EN/ENO */
  1412 /* EN/ENO */
  1384 /* Tese tokens are essentially used as variable names, so we handle them 
  1413 /* Tese tokens are essentially used as variable names, so we handle them 
  1385  * similarly to these...
  1414  * similarly to these...
  1481 	{if (tree_root == NULL)
  1510 	{if (tree_root == NULL)
  1482 	  tree_root = new library_c();
  1511 	  tree_root = new library_c();
  1483 	 $$ = (list_c *)tree_root;
  1512 	 $$ = (list_c *)tree_root;
  1484 	}
  1513 	}
  1485 | library library_element_declaration
  1514 | library library_element_declaration
       
  1515 	{$$ = $1; $$->add_element($2);}
       
  1516 | library any_pragma
  1486 	{$$ = $1; $$->add_element($2);}
  1517 	{$$ = $1; $$->add_element($2);}
  1487 /* ERROR_CHECK_BEGIN */
  1518 /* ERROR_CHECK_BEGIN */
  1488 | library error library_element_declaration
  1519 | library error library_element_declaration
  1489 	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unknown syntax error."); yyerrok;}
  1520 	{$$ = $1; print_err_msg(locf(@2), locl(@2), "unknown syntax error."); yyerrok;}
  1490 | library error END_OF_INPUT
  1521 | library error END_OF_INPUT
  6078 
  6109 
  6079 
  6110 
  6080 instruction_list:
  6111 instruction_list:
  6081   il_instruction
  6112   il_instruction
  6082 	{$$ = new instruction_list_c(locloc(@$)); $$->add_element($1);}
  6113 	{$$ = new instruction_list_c(locloc(@$)); $$->add_element($1);}
  6083 | pragma eol_list
  6114 | any_pragma eol_list
  6084 	{$$ = new instruction_list_c(locloc(@$)); $$->add_element($1);}
  6115 	{$$ = new instruction_list_c(locloc(@$)); $$->add_element($1);}
  6085 | instruction_list il_instruction
  6116 | instruction_list il_instruction
  6086 	{$$ = $1; $$->add_element($2);}
  6117 	{$$ = $1; $$->add_element($2);}
  6087 | instruction_list pragma
  6118 | instruction_list any_pragma
  6088 	{$$ = $1; $$->add_element($2);}
  6119 	{$$ = $1; $$->add_element($2);}
  6089 ;
  6120 ;
  6090 
  6121 
  6091 
  6122 
  6092 
  6123 
  7145 /* B 3.2 Statements */
  7176 /* B 3.2 Statements */
  7146 /********************/
  7177 /********************/
  7147 statement_list:
  7178 statement_list:
  7148   statement ';'
  7179   statement ';'
  7149 	{$$ = new statement_list_c(locloc(@$)); $$->add_element($1);}
  7180 	{$$ = new statement_list_c(locloc(@$)); $$->add_element($1);}
  7150 | pragma
  7181 | any_pragma
  7151 	{$$ = new statement_list_c(locloc(@$)); $$->add_element($1);}
  7182 	{$$ = new statement_list_c(locloc(@$)); $$->add_element($1);}
  7152 | statement_list statement ';'
  7183 | statement_list statement ';'
  7153 	{$$ = $1; $$->add_element($2);}
  7184 	{$$ = $1; $$->add_element($2);}
  7154 | statement_list pragma
  7185 | statement_list any_pragma
  7155 	{$$ = $1; $$->add_element($2);}
  7186 	{$$ = $1; $$->add_element($2);}
  7156 /* ERROR_CHECK_BEGIN */
  7187 /* ERROR_CHECK_BEGIN */
  7157 | statement error
  7188 | statement error
  7158 	{$$ = new statement_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at the end of statement in ST statement."); yyerrok;}
  7189 	{$$ = new statement_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at the end of statement in ST statement."); yyerrok;}
  7159 | statement_list statement error
  7190 | statement_list statement error