I think that belongs in the flex file (example6.l), not the yacc file (example6.y).
-Chris On Sun, Dec 27, 2009 at 9:55 PM, Peng Yu <pengyu...@gmail.com> wrote: > I have the following example6.y and example6.l files. The compilation > gives me warnings. I'm not sure where to put '#define YYSTYPE char *' > (it is currently in example6.y). Could somebody let me know? The > example is from http://tldp.org/HOWTO/Lex-YACC-HOWTO-4.html > > $./compile.sh > here > example6.l: In function ‘yylex’: > example6.l:10: warning: assignment makes integer from pointer without a > cast > example6.l:11: warning: assignment makes integer from pointer without a > cast > $cat ./compile.sh > flex example6.l > bison -d example6.y > echo 'here' > gcc lex.yy.c example6.tab.c -o example6 > > > > $cat example6.y > %{ > #include <stdio.h> > #include <string.h> > > #define YYSTYPE char * > > void yyerror(const char *str) > { > fprintf(stderr,"error: %s\n",str); > } > > int yywrap() > { > return 1; > } > > main() > { > yyparse(); > } > > %} > > %token FILETOK SEMICOLON OBRACE EBRACE ZONETOK QUOTE WORD FILENAME > > %% > commands: > | > commands command SEMICOLON > ; > > command: > zone_set > ; > > zone_set: > ZONETOK quotedname zonecontent > { > printf("Complete zone for '%s' found\n",$2); > } > ; > > zonecontent: > OBRACE zonestatements EBRACE > > zonestatements: > | > zonestatements zonestatement SEMICOLON > ; > > zonestatement: > statements > | > FILETOK quotedname > { > printf("A zonefile name '%s' was encountered\n", $2); > } > ; > > > quotedname: > QUOTE FILENAME QUOTE > { > $$=$2; > } > > block: > OBRACE zonestatements EBRACE SEMICOLON > ; > > statements: > | statements statement > ; > > statement: WORD | block | quotedname > ; > $cat example6.l > %{ > #include <stdio.h> > #include "example6.tab.h" > %} > > %% > > zone return ZONETOK; > file return FILETOK; > [a-zA-Z][a-zA-Z0-9]* yylval=strdup(yytext); return WORD; > [a-zA-Z0-9\/.-]+ yylval=strdup(yytext); return FILENAME; > \" return QUOTE; > \{ return OBRACE; > \} return EBRACE; > ; return SEMICOLON; > \n /* ignore EOL */; > [ \t]+ /* ignore whitespace */; > %% > pe...@peng-yus-macbook-pro:~/morgan/test/flex/example6$ > > > _______________________________________________ > help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison > _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison