summaryrefslogtreecommitdiff
path: root/src/parser.l
blob: d5ff7351f260261b550b368effd19c8be2b502f5 (plain)
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
%{
#include <stdint.h>
#include "parser.tab.h"
%}

%option noyywrap

%x sitname
%x comment
%x tdqstr tsqstr
%%

[-{}<>=+/*,();]					{ return yytext[0]; }

game							{ return tokGame; }
function						{ return tokFunction; }
situation						{ return tokSituation; }
while							{ return tokWhile; }
for								{ return tokFor; }
each							{ return tokEach; }
in								{ return tokIn; }
if								{ return tokIf; }
then							{ return tokThen; }
else							{ return tokElse; }
command							{ return tokCommand; }
goto							{ return tokGoto; }

"<<"							{ BEGIN( sitname ); }
<sitname>[- a-zA-Z0-9]+			{ printf("situation: %s\n", yytext ); return tokSituationName; }
<sitname>">>"					{ BEGIN( INITIAL ); }
<sitname>.						REJECT;

"//"[^\n]*						{}

"/\*"								{ BEGIN( comment ); }
<comment>"\*/"					{ BEGIN( INITIAL ); }
<comment>.						{}

[a-zA-Z_][a-zA-Z0-9_]*			{ return tokIdent; }

[ \t\n\r]+						{}

%%