chiark / gitweb /
giant reorg abolishes TrainNum most of the time; working on making it build
[trains.git] / hostside / record-l.l
index 4a61e8d6b543cfc8ecd0a80bdd229b1da1b49e37..20f845bf0931140fabc15cb4b919c180ef0f12c0 100644 (file)
@@ -1,24 +1,22 @@
 /* -*- fundamental -*- */
 
 %{
-#include "y.tab.h"
+#include "record.h"
 %}
 
 %option warn
 %option batch
 %option noyywrap
-
-%option bison-locations
-%option bison-bridge
+%option yylineno
+%option prefix="record_yy"
+%option header-file="record-l.h"
 
 %{
-#define STR  yylval->str= xstrdup(yytext); return
+#define STR  record_yylval.name= record_tempzone_strdup(yytext);  return
 %}
 
 %%
 
-max-trains     { yylval->str= 0; return MAXTRAINS; }
-
 train          { STR TRAIN; }
 seg            { STR SEG; }
 is             { STR IS; }
@@ -27,15 +25,15 @@ has         { STR HAS; }
 step           { STR STEP; }           
 end            { STR END; }            
 
-[A-Za-z0-9_]+  { STR IDENT; }
+[A-Za-z][A-Za-z0-9_]+  { STR IDENT; }
 
-[0-9]{0,5}     { yylval->num= strtoul(yytext,0,10); return NUM; }
-[0-9]{6}       { badrecord("number too long"); }
+[0-9]{0,5}     { record_yylval.num= strtoul(yytext,0,10); return NUM; }
+[0-9]{6}       { record_yyerror("number too long"); }
 
-[-+:=~$/]      { yylval->str= 0; return yytext[0]; }
+[-+:=~/]       { record_yylval.name= 0; return yytext[0]; }
 
-\#.*\n|\       { yylval->str= 0; return NL; }
+\#.*\n|\n      { record_yylval.name= 0; return NL; }
 
 [ \t]          { }
 
-.              { badrecord("lexically invalid input"); }
+.              { record_yyerror("lexically invalid input"); }