l/l.l
2024-02-16 14:16:47 -06:00

22 lines
387 B
Plaintext

%option noyywrap
%{
#include <stdio.h>
#define YY_DECL int yylex()
#include "y.tab.h"
%}
%%
[ \t\n] ; // ignore all whitespace
[0-9]+ {yylval = atoi(yytext); return T_INT;}
"+" {return T_PLUS;}
"-" {return T_MINUS;}
"*" {return T_MULTIPLY;}
"/" {return T_DIVIDE;}
"(" {return T_LPAREN;}
")" {return T_RPAREN;}
"quit" {return T_QUIT;}
%%