Should yychar be reliable in semantic actions when declaring %glr-parser? It gives results that I do not expect for both bison 1.875 and 2.0. I can understand that delayed semantic actions might cause trouble in the case of ambiguous grammars (although it would be nice if they didn't). However, for unambiguous grammars I expect results identical to that of an LALR(1) parser.
Here's a simple bison spec that demonstrates the problem. The bison-generated code is a complete C program with yylex(), yyerror(), and main() already defined, so it is easy to try out: %{ #include <stdio.h> void yyerror( char * msg ); int yylex(); %} %glr-parser /* Changes the value of yychar. */ %% S: 'a' { if ( yychar == YYEMPTY ) { printf( "yychar=YYEMPTY\n" ); } else { printf( "yychar='%c'\n", yychar ); } } ; %% void yyerror( char * msg ) { printf( "%s\n", msg ); } int yylex() { static int once = 0; if ( !once ) { once = 1; return 'a'; } return 0; } int main() { yydebug = 1; yyparse(); return 0; } If you remove the %glr-parser declaration, the output of the semantic action is as expected: yychar=YYEMPTY If not, it's: yychar='a' Thanks. Joel Denny _______________________________________________ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison