stage1_2/iec.flex
changeset 151 3b898fb11e73
parent 136 32bd7ef40897
child 152 efc510145ab2
equal deleted inserted replaced
150:398cfd6e8e4a 151:3b898fb11e73
   532 letter		[A-Za-z]
   532 letter		[A-Za-z]
   533 digit		[0-9]
   533 digit		[0-9]
   534 octal_digit	[0-7]
   534 octal_digit	[0-7]
   535 hex_digit	{digit}|[A-F]
   535 hex_digit	{digit}|[A-F]
   536 identifier	({letter}|(_({letter}|{digit})))((_?({letter}|{digit}))*)
   536 identifier	({letter}|(_({letter}|{digit})))((_?({letter}|{digit}))*)
   537 invalid_identifier ({letter}|{digit}|_)*
       
   538 
   537 
   539 /*******************/
   538 /*******************/
   540 /* B.1.2 Constants */
   539 /* B.1.2 Constants */
   541 /*******************/
   540 /*******************/
   542 
   541 
   883 }
   882 }
   884 
   883 
   885 	/* body_state -> (il_state | st_state) */
   884 	/* body_state -> (il_state | st_state) */
   886 <body_state>{
   885 <body_state>{
   887 {st_whitespace_no_pragma}			/* Eat any whitespace */
   886 {st_whitespace_no_pragma}			/* Eat any whitespace */
   888 {qualified_identifier}{st_whitespace}":="	unput_text(0); BEGIN(st_state);
   887 {qualified_identifier}{st_whitespace}":="	  unput_text(0); BEGIN(st_state);
   889 {qualified_identifier}"["			unput_text(0); BEGIN(st_state);
   888 {qualified_identifier}"["			unput_text(0); BEGIN(st_state);
   890 
   889 
   891 RETURN						unput_text(0); BEGIN(st_state);
   890 RETURN					unput_text(0); BEGIN(st_state);
   892 IF						unput_text(0); BEGIN(st_state);
   891 IF							unput_text(0); BEGIN(st_state);
   893 CASE						unput_text(0); BEGIN(st_state);
   892 CASE						unput_text(0); BEGIN(st_state);
   894 FOR						unput_text(0); BEGIN(st_state);
   893 FOR							unput_text(0); BEGIN(st_state);
   895 WHILE						unput_text(0); BEGIN(st_state);
   894 WHILE						unput_text(0); BEGIN(st_state);
   896 REPEAT						unput_text(0); BEGIN(st_state);
   895 REPEAT					unput_text(0); BEGIN(st_state);
   897 EXIT						unput_text(0); BEGIN(st_state);
   896 EXIT						unput_text(0); BEGIN(st_state);
       
   897 
   898 	/* ':=' occurs only in transitions, and not Function or FB bodies! */
   898 	/* ':=' occurs only in transitions, and not Function or FB bodies! */
   899 :=						unput_text(0); BEGIN(st_state);  
   899 :=							unput_text(0); BEGIN(st_state);
   900 
   900 
   901 	/* Hopefully, the above rules (along with the last one),
   901 	/* Hopefully, the above rules (along with the last one),
   902          * used to distinguish ST from IL, are 
   902          * used to distinguish ST from IL, are 
   903 	 * enough to handle all ocurrences. However, if
   903 	 * enough to handle all ocurrences. However, if
   904 	 * there is some situation where the compiler is getting confused,
   904 	 * there is some situation where the compiler is getting confused,
  1482 
  1482 
  1483 	/* do the single character tokens...
  1483 	/* do the single character tokens...
  1484 	 *
  1484 	 *
  1485 	 *  e.g.:  ':'  '('  ')'  '+'  '*'  ...
  1485 	 *  e.g.:  ':'  '('  ')'  '+'  '*'  ...
  1486 	 */
  1486 	 */
  1487 {invalid_identifier} return INVALID_IDENTIFIER;
       
  1488 .	{return yytext[0];}
  1487 .	{return yytext[0];}
  1489 
  1488 
  1490 
  1489 
  1491 %%
  1490 %%
  1492 
  1491