chiark / gitweb /
starting on flex/bison parser for hostside
[trains.git] / hostside / record-l.l
1 /* -*- fundamental -*- */
2
3 %{
4 #include "y.tab.h"
5 %}
6
7 %option warn
8 %option batch
9 %option noyywrap
10
11 %option bison-locations
12 %option bison-bridge
13
14 %{
15 #define STR  yylval->str= xstrdup(yytext); return
16 %}
17
18 %%
19
20 max-trains      { yylval->str= 0; return MAXTRAINS; }
21
22 train           { STR TRAIN; }
23 seg             { STR SEG; }
24 is              { STR IS; }
25 at              { STR AT; }
26 has             { STR HAS; }
27 step            { STR STEP; }           
28 end             { STR END; }            
29
30 [A-Za-z0-9_]+   { STR IDENT; }
31
32 [0-9]{0,5}      { yylval->num= strtoul(yytext,0,10); return NUM; }
33 [0-9]{6}        { badrecord("number too long"); }
34
35 [-+:=~$/]       { yylval->str= 0; return yytext[0]; }
36
37 \#.*\n|\        { yylval->str= 0; return NL; }
38
39 [ \t]           { }
40
41 .               { badrecord("lexically invalid input"); }