-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop-parser.l
More file actions
29 lines (23 loc) · 750 Bytes
/
loop-parser.l
File metadata and controls
29 lines (23 loc) · 750 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
%{
#include "y.tab.h"
#include <stdio.h>
#include <stdlib.h>
#define border printf("\n---------------------------------------------------------------------------------\n")
%}
%%
"print" return (PRINT);
"for" return FOR;
"in" return IN;
"range" return (RANGE);
"xrange" return (XRANGE);
"and"|"assert"|"break"|"class"|"def"|"del"|"elif"|"else"|"except"|"exec"|"finally"|"for"|"from"|"global" return (RARE);
"if"|"import"|"in"|"is"|"lambda"|"not"|"or"|"pass"|"raise"|"return"|"try"|"while"|"with"|"yield" return (RARE);
[0-9]+ return NUMBER;
[_a-zA-Z][_a-zA-Z0-9]* return ID ;
[ \t] ;
\( return (LBRACKET);
\) return (RBRACKET);
\: return (COLON);
\, return COMMA;
. { printf("\nunidentified token %s\n",yytext); exit(1);}
%%