stage1_2/iec.flex
changeset 80 d79c950fb9c3
parent 76 ec7799ec929b
child 81 de518eb7bc74
equal deleted inserted replaced
79:7417b346e5a3 80:d79c950fb9c3
   972 	 *       as a funtion as in 'X := MOD(Y, Z);'
   972 	 *       as a funtion as in 'X := MOD(Y, Z);'
   973 	 *       We solve this by NOT testing for function names here, and
   973 	 *       We solve this by NOT testing for function names here, and
   974 	 *       handling this function and keyword clash in bison!
   974 	 *       handling this function and keyword clash in bison!
   975 	 */
   975 	 */
   976 {identifier} 	{int token = get_identifier_token(yytext);
   976 {identifier} 	{int token = get_identifier_token(yytext);
   977 		 // printf("flex: analysing identifier '%s'...", yytext); 
   977 		 fprintf(stderr, "flex: analysing identifier '%s'...", yytext); 
   978 		 if ((token == prev_declared_variable_name_token) ||
   978 		 if ((token == prev_declared_variable_name_token) ||
   979 //		     (token == prev_declared_derived_function_name_token) || // DO NOT add this condition!
   979 //		     (token == prev_declared_derived_function_name_token) || // DO NOT add this condition!
   980 		     (token == prev_declared_fb_name_token)) {
   980 		     (token == prev_declared_fb_name_token)) {
   981 		 /*
   981 		 /*
   982 		 if (token != identifier_token)
   982 		 if (token != identifier_token)
   985                   *       the simple test of (token != identifier_token), then 
   985                   *       the simple test of (token != identifier_token), then 
   986                   *       'MOD' et al must be removed from the 
   986                   *       'MOD' et al must be removed from the 
   987                   *       library_symbol_table as a default function name!
   987                   *       library_symbol_table as a default function name!
   988 		  */
   988 		  */
   989 		   yylval.ID=strdup(yytext);
   989 		   yylval.ID=strdup(yytext);
   990 		   // printf("returning token %d\n", token); 
   990 		   fprintf(stderr, "returning token %d\n", token); 
   991 		   return token;
   991 		   return token;
   992 		 }
   992 		 }
   993 		 /* otherwise, leave it for the other lexical parser rules... */
   993 		 /* otherwise, leave it for the other lexical parser rules... */
   994 		 // printf("rejecting\n"); 
   994 		 fprintf(stderr, "rejecting\n"); 
   995 		 REJECT;
   995 		 REJECT;
   996 		}
   996 		}
   997 
   997 
   998 
   998 
   999 	/******************************************************/
   999 	/******************************************************/
  1180 
  1180 
  1181 	/* PRIORITY is not a keyword, so we only return it when 
  1181 	/* PRIORITY is not a keyword, so we only return it when 
  1182 	 * it is explicitly required and we are not expecting any identifiers
  1182 	 * it is explicitly required and we are not expecting any identifiers
  1183 	 * that could also use the same letter sequence (i.e. an identifier: piority)
  1183 	 * that could also use the same letter sequence (i.e. an identifier: piority)
  1184 	 */
  1184 	 */
       
  1185  /*
  1185 <sfc_state>PRIORITY	return PRIORITY;
  1186 <sfc_state>PRIORITY	return PRIORITY;
       
  1187  */
  1186 
  1188 
  1187 <sfc_qualifier_state>{
  1189 <sfc_qualifier_state>{
  1188 L		return L;
  1190 L		return L;
  1189 D		return D;
  1191 D		return D;
  1190 SD		return SD;
  1192 SD		return SD;
  1355 TO		return TO;
  1357 TO		return TO;
  1356 BY		return BY;
  1358 BY		return BY;
  1357 DO		return DO;
  1359 DO		return DO;
  1358 END_FOR		return END_FOR;
  1360 END_FOR		return END_FOR;
  1359 
  1361 
  1360 WHILE		return WHILE;
  1362 WHILE		{fprintf(stderr, "flex: returning token WHILE\n"); return WHILE;}
  1361 DO		return DO;
  1363 DO		return DO;
  1362 END_WHILE	return END_WHILE;
  1364 END_WHILE	return END_WHILE;
  1363 
  1365 
  1364 REPEAT		return REPEAT;
  1366 REPEAT		return REPEAT;
  1365 UNTIL		return UNTIL;
  1367 UNTIL		return UNTIL;