-
Notifications
You must be signed in to change notification settings - Fork 1
/
buzen.l
61 lines (34 loc) · 992 Bytes
/
buzen.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
53
54
55
56
57
58
59
60
/* Programming Languages and Compilers Project 2011-2012 */
%{
#include "y.tab.h"
%}
%option noyywrap
DIGIT [0-9]
LETTER [a-zA-Z]
WORD {LETTER}{DIGIT}*{LETTER}*{DIGIT}*
NUMBER {DIGIT}+
%%
"program" return PROGRAM;
"procedure" return PROCEDURE;
"function" return FUNCTION;
";" return QM;
"." return DOT;
"var" return VAR;
"=" return EQUAL;
":" return COLON;
"," return COMMA;
"integer"|"boolean" return DATA_TYPES;
"(" return LPAR;
")" return RPAR;
"if" return IF;
"while" return WHILE;
"do" return DO;
"then" return THEN;
"else" return ELSE;
"begin" return BEGAN;
"end" return END;
"add"|"sub"|"not" return UOP;
"="|"<>"|"or"|"and"|"<"|">"|"<="|">="|"+"|"-"|"*"|"div"|"mod" return BOP;
{WORD} return ID;
{NUMBER} return INT;
%%