chiark / gitweb /
giant reorg abolishes TrainNum most of the time; working on making it build
[trains.git] / hostside / record-y.y
index 3f8f76971550d5891f3634908ff25b61e4d272a6..5ba3d1ce6bf4ba52c5f73f492092048925971955 100644 (file)
@@ -1,55 +1,60 @@
 /* -*- fundamental -*- */
 
 %{
-#include "realtime.h"
+#include "record.h"
+#include "record-l.h"
 %}
 
 %union {
-  char *name;
+  const char *name;
   Train *train;
   Segment *seg;
   int num;
 }
 
 %token <name>  TRAIN  SEG IS AT HAS STEP END  IDENT
-%token <name>  MAXTRAINS NL
+%token <name>  NL
 %token <num>   NUM
 
 %type <name>   ident
 %type <train>  train
-%type <segment>        seg
-%type <num>    sign
+%type <seg>    seg
+%type <num>    backwards
 
 %defines
+%error-verbose
+%name-prefix="record_yy"
 
 %%
 
 file:          end
-       |       line NL file
+       |       line NL { record_tempzone_clear(); } file
 
 line:          /* empty */
-       |       MAXTRAINS NUM
-                { record_max_trains($2); }
-       |       TRAIN train AT sign SEG ':' NUM '+' '-' NUM
-                { record_train_at($2,$4,$5,$7,$10); }
        |       TRAIN train IS NUM NUM '+' NUM '+' NUM
-                { record_train_is($2,$4,$5,$7,$9); }
+       {         if ($2) record_train_is($2,$4,$5,$7,$9);
+       }
+       |       TRAIN train AT backwards seg ':' NUM '+' '-' NUM
+       {         if ($2) record_train_at($2,$4,$5,$7,$10);
+       }
        |       TRAIN train STEP NUM '=' NUM NUM '/' NUM
-                { record_train_step($2,$4,$6,$7,$9); }
-       |       SEG seg HAS sign train
-                { record_seg_has($2,$4,$5); }
-       |       SEG seg HAS '$'
-                { record_seg_has($2,0,0); }
-       |       SEG seg AT NUM
-                { record_seg_at($2,$4); }
-
-sign:          /* empty */ { return 1; }
-       |       '-' { return -1; }
+       {         if (!trains) record_train_step_count();
+                 else if ($2) record_train_step($2,$4,$6,$7,$9);
+       }
+       |       SEG seg HAS backwards train
+       {         if ($2 && $5) record_seg_has($2,$4,$5);
+       }
+       |       SEG seg AT ident
+       {         if ($2) record_seg_at($2,$4);
+       }
+
+backwards:     /* empty */ { return 0; }
+       |       '-' { return 1; }
 
 ident:         IDENT | TRAIN | SEG | IS | AT | STEP | END
 
-seg:           ident { $$= pname2seg($1); }
-train:         ident { $$= pname2train($1); }
+seg:           ident { $$= record_pname2seg($1); }
+train:         ident { $$= record_pname2train($1); }
 
 end:           END NL