diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-12-11 10:01:52 -0700 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-12-11 10:01:52 -0700 |
commit | 4d5d24f1da11a1279da0b5ea9351c4372a74bc43 (patch) | |
tree | 90e2e93ee24518fc098b0109871f83fbd07ac392 /src/parser.l | |
download | stage-4d5d24f1da11a1279da0b5ea9351c4372a74bc43.tar.gz stage-4d5d24f1da11a1279da0b5ea9351c4372a74bc43.tar.bz2 stage-4d5d24f1da11a1279da0b5ea9351c4372a74bc43.tar.xz stage-4d5d24f1da11a1279da0b5ea9351c4372a74bc43.zip |
Basic parser coming together.
Diffstat (limited to 'src/parser.l')
-rw-r--r-- | src/parser.l | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/parser.l b/src/parser.l new file mode 100644 index 0000000..d5ff735 --- /dev/null +++ b/src/parser.l | |||
@@ -0,0 +1,43 @@ | |||
1 | %{ | ||
2 | #include <stdint.h> | ||
3 | #include "parser.tab.h" | ||
4 | %} | ||
5 | |||
6 | %option noyywrap | ||
7 | |||
8 | %x sitname | ||
9 | %x comment | ||
10 | %x tdqstr tsqstr | ||
11 | %% | ||
12 | |||
13 | [-{}<>=+/*,();] { return yytext[0]; } | ||
14 | |||
15 | game { return tokGame; } | ||
16 | function { return tokFunction; } | ||
17 | situation { return tokSituation; } | ||
18 | while { return tokWhile; } | ||
19 | for { return tokFor; } | ||
20 | each { return tokEach; } | ||
21 | in { return tokIn; } | ||
22 | if { return tokIf; } | ||
23 | then { return tokThen; } | ||
24 | else { return tokElse; } | ||
25 | command { return tokCommand; } | ||
26 | goto { return tokGoto; } | ||
27 | |||
28 | "<<" { BEGIN( sitname ); } | ||
29 | <sitname>[- a-zA-Z0-9]+ { printf("situation: %s\n", yytext ); return tokSituationName; } | ||
30 | <sitname>">>" { BEGIN( INITIAL ); } | ||
31 | <sitname>. REJECT; | ||
32 | |||
33 | "//"[^\n]* {} | ||
34 | |||
35 | "/\*" { BEGIN( comment ); } | ||
36 | <comment>"\*/" { BEGIN( INITIAL ); } | ||
37 | <comment>. {} | ||
38 | |||
39 | [a-zA-Z_][a-zA-Z0-9_]* { return tokIdent; } | ||
40 | |||
41 | [ \t\n\r]+ {} | ||
42 | |||
43 | %% | ||