-
Notifications
You must be signed in to change notification settings - Fork 1
/
droneX.lex
117 lines (116 loc) · 2.88 KB
/
droneX.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
char [A-Za-z]
digit [0-9]
sign [+-]
var {char}({char}|{digit})*
newLine \n
end_stmt ";"
assignment_op "="
LB "{"
RB "}"
LP "("
RP ")"
plus "+"
minus "-"
multiplication "*"
division "/"
modulus "%"
greaterThan ">"
greaterOrEqual ">="
lessThan "<"
lessOrEqual "<="
equal "=="
notEqual "!="
or "||"
and "&&"
not "!"
while while
for for
elseif elseif
if if
else else
true true
false false
comment_line "//"
constant const
dot "."
integer [sign]?{digit}+
float [sign]?{digit}+(\.){digit}+
boolean {true}|{false}
identifier ({char}{digit})+|{char}*
main main
return return
print print
function "function"
input "input"
connect "connect"
disconnect "disconnect"
receive receive
readAltitude readAltitude
readTemperature readTemperature
readAcceleration readAcceleration
turnOnCamera turnOnCamera
turnOffCamera turnOffCamera
takePicture takePicture
readTimestamp readTimestamp
connectToBase connectToBase
to to
comma ","
string \"[^"]*\"
%%
{main} return MAIN;
{if} return IF;
{elseif} return ELSEIF;
{else} return ELSE;
{LB} return LB;
{RB} return RB;
{LP} return LP;
{RP} return RP;
{comma} return COMMA;
{dot} return DOT;
{plus} return PLUS;
{minus} return MINUS;
{multiplication} return MULTIPLICATION;
{division} return DIVISION;
{modulus} return MODULUS;
{greaterThan} return GREATERTHAN;
{greaterOrEqual} return GREATEROREQUAL;
{lessThan} return LESSTHAN;
{lessOrEqual} return LESSOREQUAL;
{equal} return EQUAL;
{notEqual} return NOTEQUAL;
{or} return OR;
{and} return AND;
{not} return NOT;
{while} return WHILE;
{for} return FOR;
{assignment_op} return ASSIGNMENT_OP;
{comment_line} return COMMENT_LINE;
{constant} return CONSTANT;
{to} return TO;
{readAltitude} return READALTITUDE;
{readTemperature} return READTEMPERATURE;
{readAcceleration} return READACCELERATION;
{turnOnCamera} return TURNONCAMERA;
{turnOffCamera} return TURNOFFCAMERA;
{takePicture} return TAKEPICTURE;
{readTimestamp} return READTIMESTAMP;
{connectToBase} return CONNECTTOBASE;
{integer} return NUMBER;
{float} return FLOAT;
{boolean} return BOOLEAN;
{print} return PRINT;
{function}{var} return FUNCTION_START;
{return} return FUNCTION_RETURN;
{var}(\() return FUNCTION_CALL;
{input} return INPUT;
{connect} return CONNECT;
{disconnect} return DISCONNECT;
{receive} return RECEIVE;
{var} return IDENTIFIER;
{string} return STRING;
{end_stmt} return ENDSTMT;
{newLine} ;
[\t] ;
. return(yytext[0]);
%%
int yywrap() {return 1;}