summaryrefslogtreecommitdiff
path: root/src/parser.l
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-12-11 10:01:52 -0700
committerMike Buland <eichlan@xagasoft.com>2011-12-11 10:01:52 -0700
commit4d5d24f1da11a1279da0b5ea9351c4372a74bc43 (patch)
tree90e2e93ee24518fc098b0109871f83fbd07ac392 /src/parser.l
downloadstage-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.l43
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
15game { return tokGame; }
16function { return tokFunction; }
17situation { return tokSituation; }
18while { return tokWhile; }
19for { return tokFor; }
20each { return tokEach; }
21in { return tokIn; }
22if { return tokIf; }
23then { return tokThen; }
24else { return tokElse; }
25command { return tokCommand; }
26goto { 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%%