-
Notifications
You must be signed in to change notification settings - Fork 1
/
lex.lex
171 lines (156 loc) · 4.35 KB
/
lex.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
SPACE [ \t]+
LP \(
RP \)
LSB \[
RSB \]
LESS_THAN <
GREATER_THAN >
LEFT_BRACE \{
RIGHT_BRACE \}
EXCLAMATION !
AND &&
OR \|\|
DOUBLE_QUOTE \"
SINGLE_QUOTE \'
HASHTAG #
DOT \.
ASSIGN_OP =
EQUALS_OP ==
NOT_EQUAL_OP !=
PLUS \+
MINUS -
SLASH \/
BACKSLASH \\
MULT_OP \*
QUESTION_MARK \?
UNDER_SCORE _
SEMI_COLON ;
COLON :
COMMA ,
LETTER [a-zA-Z]
LOWERCASE [a-z]
UPPERCASE [A-Z]
DIGIT [0-9]
NON_ZERO_DIGIT [1-9]
DIGITS {DIGIT}+
INT {SIGN}?{DIGIT}
DOUBLE {SIGN}?{DIGIT}*\.{DIGIT}+
EMPTY_FUNCTION_CALL {LP}{RP}
COMMENT {START}{CHARACTER}*{NEW_LINE}
START {SLASH}{SLASH}
CHARACTER [(\32-\91) | (\93-\230)]
SYMBOL [\40-\176]
SIGN {PLUS}|{MINUS}
DOLLAR_SIGN \$
TILDE ~
MODULO %
INT_TYPE int
STRING_TYPE string
BOOL_TYPE bool
DOUBLE_TYPE double
SENSOR_TYPE sensor
SWITCH_TYPE switch
VOID_TYPE void
SET_SWITCH_ON_IDENTIFIER {UNDER_SCORE}setSwitchOn
SET_SWITCH_OFF_IDENTIFIER {UNDER_SCORE}setSwitchOff
TOGGLE_SWITCH_IDENTIFIER {UNDER_SCORE}toggleSwitch
GET_TIME {UNDER_SCORE}getTime
GET_TIME_HOUR {UNDER_SCORE}getTime_Hour
PRINT {UNDER_SCORE}print
SCAN {UNDER_SCORE}scan
NEW_LINE \n
RETURN_IDENTIFIER return
LESS_THAN_OR_EQUALS_OP <=
GREATER_THAN_OR_EQUALS_OP >=
GET_METHOD_IDENTIFIER {UNDER_SCORE}get
POST_METHOD_IDENTIFIER {UNDER_SCORE}post
CONNECT_METHOD_IDENTIFIER {UNDER_SCORE}connect
READ_METHOD_IDENTIFIER {UNDER_SCORE}read
TRUE_CONSTANT true
FALSE_CONSTANT false
WHILE_IDENTIFIER while
FOR_IDENTIFIER for
IF_IDENTIFIER if
ELSE_IDENTIFIER else
IDENTIFIER_SYMBOL {LETTER}|{DIGIT}|{UNDER_SCORE}|{MINUS}
PURE_IDENTIFIER {LETTER}{IDENTIFIER_SYMBOL}*
METHOD_IDENTIFIER {UNDER_SCORE}{LETTER}{IDENTIFIER_SYMBOL}*
BOOL_IDENTIFIER @{LETTER}{IDENTIFIER_SYMBOL}*
SENSOR_IDENTIFIER {DOLLAR_SIGN}{LETTER}{IDENTIFIER_SYMBOL}*
SWITCH_IDENTIFIER {HASHTAG}{LETTER}{IDENTIFIER_SYMBOL}*
STRING {DOUBLE_QUOTE}{SYMBOL}*{DOUBLE_QUOTE}
SINGLE_QUOTE_STRING {SINGLE_QUOTE}{SYMBOL}*{SINGLE_QUOTE}
%%
{GET_TIME} return(GET_TIME);
{GET_TIME_HOUR} return(GET_TIME_HOUR);
{SET_SWITCH_ON_IDENTIFIER} return(SET_SWITCH_ON_IDENTIFIER);
{SET_SWITCH_OFF_IDENTIFIER} return(SET_SWITCH_OFF_IDENTIFIER);
{TOGGLE_SWITCH_IDENTIFIER} return(TOGGLE_SWITCH_IDENTIFIER);
{PRINT} return(PRINT);
{SCAN} return(SCAN);
{RETURN_IDENTIFIER} return(RETURN_IDENTIFIER);
{LESS_THAN_OR_EQUALS_OP} return(LESS_THAN_OR_EQUALS_OP);
{GREATER_THAN_OR_EQUALS_OP} return(GREATER_THAN_OR_EQUALS_OP);
{GET_METHOD_IDENTIFIER} return(GET_METHOD_IDENTIFIER);
{POST_METHOD_IDENTIFIER} return(POST_METHOD_IDENTIFIER);
{CONNECT_METHOD_IDENTIFIER} return(CONNECT_METHOD_IDENTIFIER);
{READ_METHOD_IDENTIFIER} return(READ_METHOD_IDENTIFIER);
{TRUE_CONSTANT} return(TRUE_CONSTANT);
{FALSE_CONSTANT} return(FALSE_CONSTANT);
{DIGITS} return(INT);
{DOUBLE} return(DOUBLE);
{VOID_TYPE} return(VOID_TYPE);
{IF_IDENTIFIER} return(IF_IDENTIFIER);
{ELSE_IDENTIFIER} return(ELSE_IDENTIFIER);
{WHILE_IDENTIFIER} return(WHILE_IDENTIFIER);
{FOR_IDENTIFIER} return(FOR_IDENTIFIER);
{BOOL_IDENTIFIER} return(BOOL_IDENTIFIER);
{LP} return(LP);
{RP} return(RP);
{LSB} return(LSB);
{RSB} return(RSB);
{LESS_THAN} return(LESS_THAN);
{GREATER_THAN} return(GREATER_THAN);
{LEFT_BRACE} return(LEFT_BRACE);
{RIGHT_BRACE} return(RIGHT_BRACE);
{EXCLAMATION} return(EXCLAMATION);
{AND} return(AND);
{OR} return(OR);
{DOUBLE_QUOTE} return(DOUBLE_QUOTE);
{SINGLE_QUOTE} return(SINGLE_QUOTE);
{HASHTAG} return(HASHTAG);
{DOT} return(DOT);
{EQUALS_OP} return(EQUALS_OP);
{NOT_EQUAL_OP} return(NOT_EQUAL_OP);
{ASSIGN_OP} return(ASSIGN_OP);
{PLUS} return(PLUS);
{MINUS} return(MINUS);
{SLASH} return(SLASH);
{BACKSLASH} return(BACKSLASH);
{MULT_OP} return(MULT_OP);
{QUESTION_MARK} return(QUESTION_MARK);
{UNDER_SCORE} return(UNDER_SCORE);
{SEMI_COLON} return(SEMI_COLON);
{COLON} return(COLON);
{COMMA} return(COMMA);
{DOLLAR_SIGN} return(DOLLAR_SIGN);
{TILDE} return(TILDE);
{MODULO} return(MODULO);
{STRING} return(STRING);
{SINGLE_QUOTE_STRING} return(SINGLE_QUOTE_STRING);
{INT_TYPE} return(INT_TYPE);
{STRING_TYPE} return(STRING_TYPE);
{BOOL_TYPE} return(BOOL_TYPE);
{DOUBLE_TYPE} return(DOUBLE_TYPE);
{SENSOR_TYPE} return(SENSOR_TYPE);
{SWITCH_TYPE} return(SWITCH_TYPE);
{PURE_IDENTIFIER} return(PURE_IDENTIFIER);
{SWITCH_IDENTIFIER} return(SWITCH_IDENTIFIER);
{SENSOR_IDENTIFIER} return(SENSOR_IDENTIFIER);
{EMPTY_FUNCTION_CALL} return(EMPTY_FUNCTION_CALL);
{METHOD_IDENTIFIER} return(METHOD_IDENTIFIER);
{COMMENT} {extern int lineno; lineno++;};
[\n] {extern int lineno; lineno++;};
. ;
%%
int yywrap(void){}