-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscanner.l
52 lines (50 loc) · 1.67 KB
/
scanner.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 "../include/tokens.h"
%}
%%
<<EOF>> return END_OF_FILE;
"class" return CLASS_KW;
"public" return PUBLIC_KW;
"static" return STATIC_KW;
"void" return VOID_KW;
"main" return MAIN_KW;
"(" return LPAREN;
"String" return STRING_KW;
"[" return LBRACKET;
"]" return RBRACKET;
")" return RPAREN;
"{" return LBRACE;
"}" return RBRACE;
"extends" return EXTENDS_KW;
";" return SEMICOLON;
"int" return INT_KW;
"boolean" return BOOLEAN_KW;
"if" return IF_KW;
"else" return ELSE_KW;
"while" return WHILE_KW;
"System.out.println" return PRINTLN_KW;
"&&" return AND;
"<" return LT;
"+" return PLUS;
"-" return MINUS;
"*" return TIMES;
"." return DOT;
"length" return LENGTH_KW;
"," return COMMA;
"true" return TRUE_KW;
"false" return FALSE_KW;
"this" return THIS_KW;
"new" return NEW_KW;
"!" return NOT;
"return" return RETURN_KW;
[_a-zA-Z][_a-zA-Z0-9]* return IDENTIFIER;
[0-9]+ return INTEGER;
"=" return EQUALS;
"//".*\n ;
[\r\t \n]+ ;
. return UNKNOWN;
%%
int yywrap(void)
{
return 1;
}