/* -*- fundamental -*- */ %{ #include "record-i.h" #include "record-l.h" static Train *cur_train; %} %union { const char *name; Train *train; Segment *seg; int num; } %token TRAIN SEG IS AT HAS STEP HOME END IDENT %token NL %token NUM %type ident %type train %type seg %type backwards %defines %error-verbose %name-prefix="record_yy" %% file: end | line NL { record_tempzone_clear(); } file line: /* empty */ | TRAIN train IS NUM NUM '+' NUM '+' NUM { 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 { cur_train=$2; } HOME segments { } | TRAIN train STEP NUM '=' NUM NUM '/' NUM { 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; } segments: { cur_train= 0; } | backwards seg { record_train_home(cur_train,$1,$2); } segments ident: TRAIN | SEG | IS | AT | HAS | STEP | HOME | END | IDENT seg: ident { $$= record_pname2seg($1); } train: ident { $$= record_pname2train($1); } end: END NL %%