chiark / gitweb /
only autoflush if the message ends with \n
[trains.git] / hostside / record-l.l
1 /* -*- fundamental -*- */
2
3 %{
4 #include "record-i.h"
5 %}
6
7 %option warn
8 %option batch
9 %option noyywrap
10 %option yylineno
11 %option prefix="record_yy"
12 %option header-file="record-l.h"
13
14 %{
15 #define STR  record_yylval.name= record_tempzone_strdup(yytext);  return
16 %}
17
18 %%
19
20 train           { STR TRAIN; }
21 seg             { STR SEG; }
22 is              { STR IS; }
23 at              { STR AT; }
24 has             { STR HAS; }
25 step            { STR STEP; }
26 home            { STR HOME; }
27 end             { STR END; }
28  /* new keywords must be added to %token<name> and ident: in record-y.y */
29
30 [A-Za-z][A-Za-z0-9_]+   { STR IDENT; }
31
32 [0-9]{0,8}      { record_yylval.num= strtoul(yytext,0,10); return NUM; }
33 [0-9]{9}        { record_yyerror("number too long"); }
34
35 [-+:=~/]        { record_yylval.name= 0; return yytext[0]; }
36
37 \#.*\n|\n       { record_yylval.name= 0; return NL; }
38
39 [ \t]           { }
40
41 .               { record_yyerror("lexically invalid input"); }