A Lexer for The Parser
A Lexer for The Parser
%{
#include “y.tab.h”
%}
%%
[0-9]+ {yylval = atoi(yytext); return NUMBER; }
[ \t] ; /* ignore whitespace */
\n return 0; /* logical EOF */
. return yytext[0]; /* return any other char */
%%
- We assume that yylval is defined in y.tab.h as type YYSTYPE.