16 lines
302 B
Plaintext
16 lines
302 B
Plaintext
%{
|
|
#include "token.h"
|
|
%}
|
|
DIGIT [0-9]
|
|
LETTER [a-zA-Z]
|
|
%%
|
|
(" "|\t|\n) /* skip whitespace */
|
|
\+ { return TOKEN_ADD; }
|
|
"=" { return TOKEN_ASSIGNMENT; }
|
|
while { return TOKEN_WHILE; }
|
|
{LETTER}+ { return TOKEN_IDENT; }
|
|
{DIGIT}+ { return TOKEN_NUMBER; }
|
|
. { return TOKEN_ERROR; }
|
|
%%
|
|
int yywrap() { return 1; }
|