%{ #include #include #include "parser.h" %} %option warn nodefault /* makes the scanner terminate after reaching <> instead of assuming a new input was provided */ %option noyywrap /* disable some unused functionality, add scanner tracking */ %option nounput noinput batch debug /* gimme a reentrant parser (overkill but more pure) */ %option reentrant %option bison-bridge NL [\n] SPACE [ \t] ROCK [A] PAPER [B] SCISSOR [C] LOSS [X] DRAW [Y] WIN [Z] %% {NL} { return NEWLINE; } {SPACE}+ { /* don't care */} {ROCK} { return ROCK; } {PAPER} { return PAPER; } {SCISSOR} { return SCISSOR; } {LOSS} { return LOSS; } {DRAW} { return DRAW; } {WIN} { return WIN; } <> { return END_OF_FILE; } . { printf("[error] Encountered unexpected token %s\n", yytext); return 0; } %%