I want to get words from a file and print them out. But I'm not sure how to make yylval a pointer to the string yytext. Could somebody let me know how to modify the following code so that the string can be retrieved the symbol WORD.
>yylval_string.l %option nodefault %{ # include "yylval_string.tab.h" %} %% [A-Za-z]+ { /*I'm not sure how to make yylval a point to yytext */ return WORD; } [[:space:]] { /*SPACE*/ } . { return UNEXPECTED_CHARACTER; /*fprintf(stderr, "unexpeced_character: '%s'\n", yytext);*/ } %% >yylval_string.y %{ # include <stdio.h> %} %token WORD UNEXPECTED_CHARACTER %% words: WORD { printf("WORD = %s\n", $1); } | words WORD { printf("WORD = %d\n", $2); } ; %% main() { yyparse(); } yyerror(char *s) { fprintf(stderr, "error: %s\n", s); } _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison