-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharr.l
executable file
·52 lines (38 loc) · 855 Bytes
/
arr.l
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
%{
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include "arr.h"
void yyerror(char *);
#include "y.tab.h"
int value;
int var;
char optr;
%}
%%
[0-9]+ {value=atoi(yytext);
yylval = numnode(value);
return DIGIT;}
[a-z] {var = *yytext;
var = var - 97;
yylval = numnode(var);
return ID;
}
"Write" {return Write;
}
"Read" {return Read;}
"=" {return equal;
}
";" {return semicolon;
}
[-+*/] {optr = *yytext;
yylval = opnode(optr);
return *yytext;}
[()] return *yytext;
\n return *yytext;
[ \t] ; /* skip whitespace */
. yyerror("invalid");
%%
int yywrap(void) {
return 1;
}