/* example.lex */ %{ #include #include "example.parser.h" %} %option noyywrap %% [ \t]+ { /* ignore whitespace */ } "(" { return LPAREN; } ")" { return RPAREN; } "+" { return PLUS; } "-" { return MINUS; } "*" { return STAR; } \n { return NEWLINE; } [0-9]+ { yylval = atoi(yytext); return NUMBER; } . { printf("Ignoring invalid character '%s'\n", yytext); } %%