-
Notifications
You must be signed in to change notification settings - Fork 1
/
CS315f22_team23.lex
146 lines (139 loc) · 3.05 KB
/
CS315f22_team23.lex
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
%{
#include <stdio.h>
%}
LETTER [a-zA-Z]
INT {DIGIT}+
UNDERSCORE \_
PLUS \+
MINUS \-
LEFT_BRACKET \{
RIGHT_BRACKET \}
LEFT_PARANTHESE \(
RIGHT_PARANTHESE \)
LEFT_SQUARE_BRACKET \[
RIGHT_SQUARE_BRACKET \]
SEMICOLON \;
DOL \$
DOT \.
COMMA \,
HASHTAG \#
AND \&\&
OR \|
ASSIGN \=
ENDLINE \n
STRING_IDENT \"
CHAR_IDENT \'
LESS_THAN \<
GREATER_THAN \>
LESS_THAN_EQ \<=
GREATER_THAN_EQ \>=
EQUAL \=\=
MULTIPLY \*
DIVIDE \/
IF if
WHILE while
FOR for
RETURN return
TRUE true
FALSE false
CHAR {CHAR_IDENT}[.*]{CHAR_IDENT}
BEGIN begin
END end
ELSE else
IDENT {LETTER}({LETTER}|{DIGIT}|{UNDERSCORE})*
FLOAT {DIGIT}*{DOT}?{DIGIT}+
STRING {STRING_IDENT}.*{STRING_IDENT}
COMMENT {HASHTAG}.*{HASHTAG}
INT_ID int
FLOAT_ID float
STRING_ID string
BOOL_ID bool
CHAR_ID char
QM \?
COLON \:
CHECK_CONNECTION CHECK_CONNECTION
CONNECT_TO_URL CONNECT_TO_URL
READ_TEMP_DATA READ_TEMP_DATA
READ_HUMIDITY_DATA READ_HUMIDITY_DATA
READ_PRESSURE_DATA READ_PRESSURE_DATA
READ_QUALITY_DATA READ_QUALITY_DATA
READ_LIGHT_DATA READ_LIGHT_DATA
READ_SOUND_DATA READ_SOUND_DATA
READ_TIMER_DATA READ_TIMER_DATA
SEND_DATA_TO_CONNECTION SEND_DATA_TO_CONNECTION
RECEIVE_DATA_FROM_CONNECTION RECEIVE_DATA_FROM_CONNECTION
SWITCH_OFF SWITCH_OFF
SWITCH_ON SWITCH_ON
IN IN
OUT OUT
DIGIT [0-9]
%%
{BEGIN} return(BEG);
{END} return(END);
{RETURN} return(RETURN);
{IF} return(IF);
{ELSE} return(ELSE);
{WHILE} return(WHILE);
{FOR} return(FOR);
{DIGIT} return (DIGIT);
{CHECK_CONNECTION} return(CHECK_CONNECTION);
{CONNECT_TO_URL} return(CONNECT_TO_URL);
{READ_TEMP_DATA} return(READ_TEMP_DATA);
{READ_HUMIDITY_DATA} return(READ_HUMIDITY_DATA);
{READ_PRESSURE_DATA} return(READ_PRESSURE_DATA);
{READ_QUALITY_DATA} return(READ_QUALITY_DATA);
{READ_LIGHT_DATA} return(READ_LIGHT_DATA);
{READ_SOUND_DATA} return(READ_SOUND_DATA);
{READ_TIMER_DATA} return(READ_TIMER_DATA);
{SEND_DATA_TO_CONNECTION} return(SEND_DATA_TO_CONNECTION);
{RECEIVE_DATA_FROM_CONNECTION} return(RECEIVE_DATA_FROM_CONNECTION);
{SWITCH_OFF} return(SWITCH_OFF);
{SWITCH_ON} return(SWITCH_ON);
{IN} return(IN);
{OUT} return(OUT);
{INT_ID} return(INT_ID);
{FLOAT_ID} return(FLOAT_ID);
{STRING_ID} return(STRING_ID);
{CHAR_ID} return(CHAR_ID);
{BOOL_ID} return(BOOL_ID);
{STRING} return(STRING);
{COMMENT} return(COMMENT);
{TRUE} return(TRUE);
{FALSE} return(FALSE);
{INT} return(INT);
{FLOAT} return(FLOAT);
{CHAR} return(CHAR);
{IDENT} return(IDENT);
{ASSIGN} return(ASSIGN);
{PLUS} return(PLUS);
{MINUS} return(MINUS);
{EQUAL} return(EQ);
{MULTIPLY} return(MUL);
{DIVIDE} return(DIV);
{SEMICOLON} return(SC);
{LEFT_BRACKET} return(LB);
{RIGHT_BRACKET} return(RB);
{LEFT_PARANTHESE} return(LP);
{RIGHT_PARANTHESE} return(RP);
{LEFT_SQUARE_BRACKET} return(LSB);
{RIGHT_SQUARE_BRACKET} return(RSB);
{DOT} return(DOT);
{COMMA} return(COMMA);
{HASHTAG} return(HASHTAG);
{ENDLINE} {extern int lineno; lineno++; };
{AND} return(AND);
{OR} return(OR);
{DOL} return(DOL);
{QM} return(QM);
{COLON} return(COLON);
{STRING_IDENT} return(STR_IDENT);
{LESS_THAN} return(LT);
{GREATER_THAN} return(GT);
{LESS_THAN_EQ} return(LTE);
{GREATER_THAN_EQ} return(GTE);
[ \t] ;
. ;
%%
int yywrap(){
return 1;
}