chiark / gitweb /
hostside: more length for bavarian
[trains.git] / hostside / record-y.y
1 /* -*- fundamental -*- */
2
3 %{
4 #include "record-i.h"
5 #include "record-l.h"
6
7 static Train *cur_train;
8 %}
9
10 %union {
11   const char *name;
12   Train *train;
13   Segment *seg;
14   AdjunctsAdjunct *adjunct;
15   AdjunctsAddr *adjaddr;
16   int num;
17   double dbl;
18 }
19
20 %token <name>   TRAIN ADJUNCT SEG  IS AT HAS INVERTED STEP STOPS HOME  END
21 %token <name>   IDENT
22 %token <name>   NL
23 %token <num>    NUM
24 %token <dbl>    DBL
25
26 %type <name>            ident
27 %type <train>           train
28 %type <seg>             seg
29 %type <num>             backwards inverted
30 %type <dbl>             dbl
31 %type <adjunct>         adjunct
32 %type <adjaddr>         adjaddr
33
34 %defines
35 %error-verbose
36 %name-prefix="record_yy"
37
38 %%
39
40 file:           end
41         |       line NL { record_tempzone_clear(); } file
42
43 line:           /* empty */
44         |       TRAIN train IS NUM NUM '+' NUM '+' NUM
45         {         if ($2) record_train_is($2,$4,$5,$7,$9);
46         }
47         |       TRAIN train HOME { cur_train=$2; } segments
48         {
49         }
50         |       TRAIN train STEP NUM '=' dbl
51         {         if ($2) record_train_step_speed($2,$4,$6);
52         }
53         |       TRAIN train STOPS NUM ':' NUM NUM
54         {         if (!trains) record_train_stopregime_count();
55                   else if ($2) record_train_stopregime($2,$4,$6,$7);
56         }
57         |       SEG seg HAS backwards train inverted
58         {         if ($2 && $5) record_seg_has($2,$4,$5,$6);
59         }
60         |       SEG seg AT ident
61         {         if ($2) record_seg_at($2,$4);
62         }
63         |       ADJUNCT adjunct IS adjaddr NUM
64         {         if (trains) record_adjunct_nmrafunc($2,$4,$5);
65         }
66         |       ADJUNCT adjunct IS adjaddr STEP NUM
67         {         if (trains) record_adjunct_motor($2,$4,$6);
68         }
69
70 backwards:      /* empty */ { $$= 0; }
71         |       '-' { $$= 1; }
72
73 inverted:       /* empty */ { $$= 0; }
74         |       INVERTED { $$= 1; }
75
76 segments:       { cur_train= (void*)-1; }
77         |       backwards seg { record_train_home(cur_train,$1,$2); } segments
78
79 ident:          TRAIN | SEG
80         |       IS | AT | HAS | INVERTED | STEP | STOPS | HOME
81         |       END
82         |       IDENT
83
84 dbl:            DBL
85         |       NUM { $$= $1 }
86
87 seg:            ident { $$= record_pname2seg($1); }
88 train:          ident { $$= record_pname2train($1); }
89 adjunct:        ident ident { $$= record_pname2adjunct($1,$2); }
90         |       '-' { $$= 0; }
91 adjaddr:        NUM { $$= record_adjaddr($1); }
92
93 end:            END NL
94
95 %%