-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalc.l
19 lines (19 loc) · 896 Bytes
/
calc.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
%option noyywrap
%{
#include <stdio.h>
#include "calc.tab.h"
#include "functions.h"
extern int yylex();
%}
%%
[ \t] ;
\n {return NEWLINE;}
M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3}) {yylval = roman_to_decimal(yytext); return NUM;}
"+" {return PLUS;}
"-" {return MINUS;}
"*" {return MULTIPLY;}
"/" {return DIVIDE;}
"(" {return LEFT;}
")" {return RIGHT;}
. {return INVALID_TOKEN;}
%%