Hi, I'm trying to write a parser to a simplified version of Pascal. In my parser.y file there is only one rule:
%{ /* declarations */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "teste.h" %} /* my tokens */ %token DOT %token END %token END_OF_FILE %token IDENTIFIER %token PROGRAM %token SEMICOLON %% programa : PROGRAM IDENTIFIER SEMICOLON END DOT END_OF_FILE {return 0;} ; %% Here is my Pascal program: program Example; end { notice that the dot after the "end" is missing, I want to cause an error } At the end the error is caught but the last identifier in yytext, which I get in the flex file is not what I want. In my flex file I have: [a-z][a-z0-9]* {atom=yytext; return(IDENTIFIER);} When I print the "atom" variable at the end of the parser, its content is "Example; end" but I want it to be only "Example" because it is the last identifier I got. Is it something wrong with my rule? Can someone help, please? Thanks Rodrigo _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison