flex is happy when i run "flex scanner.l", but returns the error "flex scanner push-back overflow" when i run "flex new_scanner.l"
here are the files:
scanner.l:
new_scanner.l:Code:/* scanner for a toy Pascal-like language */ %{ #include <math.h> /* needed for call to atof() */ %} DIG [0-9] ID [a-z][a-z0-9]* %% {DIG}+ printf("Integer: %s (%d)\n", yytext, atoi(yytext)); {DIG}+"."{DIG}* printf("Float: %s (%g)\n", yytext, atof(yytext)); if|then|begin|end printf("Keyword: %s\n",yytext); "(" printf("Open paren\n"); ")" printf("Close paren\n"); {ID} printf("Identifier: %s\n",yytext); "+"|"-"|"*"|"/" printf("Operator: %s\n",yytext); ">"|"<" printf("Relational operator: %s\n",yytext); "{"[^}\n]*"}" /* skip one-line comments */ [ \t\n]+ /* skip whitespace */ . printf("UNRECOGNIZED: %s\n",yytext); %% main(){ yylex(); }
I tried ignoring the error, since lex.yy.c was still created, and entered "cc lex.yy.c -lfl", but I get the error:Code:/* scanner for a toy Pascal-like language */ %{ #include <math.h> /* needed for call to atof() */ %} DIG [0-9] ID [a-z][a-z0-9]* VAL {DIG}+"."?{DIG}*|{ID} SP [ \t\n]* EXP {EXP}{SP}("+"|"-"|"*"|"/"){SP}{VAL}|{VAL} %% {EXP}{SP}(">"|"<"){SP}{EXP} printf("Conditional: %s\n", yytext); {DIG}+ printf("Integer: %s (%d)\n", yytext, atoi(yytext)); {DIG}+"."{DIG}* printf("Float: %s (%g)\n", yytext, atof(yytext)); if|then|begin|end printf("Keyword: %s\n",yytext); "(" printf("Open paren\n"); ")" printf("Close paren\n"); {ID} printf("Identifier: %s\n",yytext); "+"|"-"|"*"|"/" printf("Operator: %s\n",yytext); ">"|"<" printf("Relational operator: %s\n",yytext); "{"[^}\n]*"}" /* skip one-line comments */ [ \t\n]+ /* skip whitespace */ . printf("UNRECOGNIZED: %s\n",yytext); %% main(){ yylex(); }
If it helps, I'm accessing the linux account via ssh (copied the error message from the putty.log). I'm just entering these commands into the command line and editing the files with emacs. I have a very limited access to the system, and I don't know how to get rid of that error. I need to add those lines for the project.Code:/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../libfl.a(libmain.o): In function `main': (.text+0x21): undefined reference to `yylex' collect2: ld returned 1 exit status




Reply With Quote