-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.l
More file actions
32 lines (28 loc) · 855 Bytes
/
basic.l
File metadata and controls
32 lines (28 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
%option yywrap yylineno
%{
#include "func.h"
#include "basic.tab.h"
%}
%%
"let" { return LET; }
"print" { return PRINT; }
"load" { return LOAD; }
"beta" { return BETA; }
"beta*" { return BETA_; }
"alpha" { return ALPHA; }
"dir" { return DIR; }
"exit" { return EXIT; }
"help" { return HELP; }
[a-zA-Z_][a-zA-Z_0-9]* { yylval.s = lookup(yytext); return ID; }
[0-9]+ { yylval.i = atoi(yytext); return NUM; }
\. |
"(" |
")" |
"\\" |
"=" { return yytext[0]; }
\n { return EOL; }
<<EOF>> { return EOF_; }
[ >\r\t] {}
"//".* {}
. { printf("#%d Mystery character %c\n",yylineno, yytext[0]); }
%%