Skip to content

Commit 1a852ae

Browse files
Create simplecalc.l
1 parent d81776f commit 1a852ae

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
%{
2+
#include "y.tab.h"
3+
extern int yylval;
4+
5+
%}
6+
7+
%option noyywrap
8+
9+
10+
%%
11+
[0-9]+ { yylval = atoi(yytext); return NUMBER; }
12+
[a-z] { yylval = yytext[0]; return NAME; }
13+
[ \t] ; /* ignore whitespace */
14+
\n return 0; /* logical EOF */
15+
. return yytext[0];
16+
%%

0 commit comments

Comments
 (0)