forked from zaach/jison
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclassy.jisonlex
39 lines (36 loc) · 1.53 KB
/
classy.jisonlex
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
digit [0-9]
id [a-zA-Z][a-zA-Z0-9]*
%%
"//".* /* ignore comment */
"main" return 'MAIN';
"class" return 'CLASS';
"extends" return 'EXTENDS';
"nat" return 'NATTYPE';
"if" return 'IF';
"else" return 'ELSE';
"for" return 'FOR';
"printNat" return 'PRINTNAT';
"readNat" return 'READNAT';
"this" return 'THIS';
"new" return 'NEW';
"var" return 'VAR';
"null" return 'NUL';
{digit}+ return 'NATLITERAL';
{id} return 'ID';
"==" return 'EQUALITY';
"=" return 'ASSIGN';
"+" return 'PLUS';
"-" return 'MINUS';
"*" return 'TIMES';
">" return 'GREATER';
"||" return 'OR';
"!" return 'NOT';
"." return 'DOT';
"{" return 'LBRACE';
"}" return 'RBRACE';
"(" return 'LPAREN';
")" return 'RPAREN';
";" return 'SEMICOLON';
\s+ /* skip whitespace */
"." throw 'Illegal character';
<<EOF>> return 'ENDOFFILE';