stage1_2/iec.flex
changeset 81 de518eb7bc74
parent 80 d79c950fb9c3
child 82 2b6e9eeeff2c
equal deleted inserted replaced
80:d79c950fb9c3 81:de518eb7bc74
   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 		 fprintf(stderr, "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 		   fprintf(stderr, "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 		 fprintf(stderr, "rejecting\n"); 
   994 		 // fprintf(stderr, "rejecting\n"); 
   995 		 REJECT;
   995 		 REJECT;
   996 		}
   996 		}
   997 
   997 
   998 
   998 
   999 	/******************************************************/
   999 	/******************************************************/
  1357 TO		return TO;
  1357 TO		return TO;
  1358 BY		return BY;
  1358 BY		return BY;
  1359 DO		return DO;
  1359 DO		return DO;
  1360 END_FOR		return END_FOR;
  1360 END_FOR		return END_FOR;
  1361 
  1361 
  1362 WHILE		{fprintf(stderr, "flex: returning token WHILE\n"); return WHILE;}
  1362 WHILE		return WHILE;
  1363 DO		return DO;
  1363 DO		return DO;
  1364 END_WHILE	return END_WHILE;
  1364 END_WHILE	return END_WHILE;
  1365 
  1365 
  1366 REPEAT		return REPEAT;
  1366 REPEAT		return REPEAT;
  1367 UNTIL		return UNTIL;
  1367 UNTIL		return UNTIL;