--- /dev/null
+train santafe home X5 X6
void record_train_is(Train *tra, int addr, int head, int det, int tail);
void record_train_step(Train *tra, int step, int speed, int upw, int downw);
void record_train_step_count(void);
+void record_train_home(Train *tra, int backw, Segment *seg);
void record_seg_has(Segment *seg, int backw, Train *tra);
void record_seg_at(Segment *seg, const char *movposcomb_pname);
is { STR IS; }
at { STR AT; }
has { STR HAS; }
-step { STR STEP; }
+step { STR STEP; }
+home { STR HOME; }
end { STR END; }
/* new keywords must be added to %token<name> and ident: in record-y.y */
%{
#include "record-i.h"
#include "record-l.h"
+
+static Train *cur_train;
%}
%union {
int num;
}
-%token <name> TRAIN SEG IS AT HAS STEP END IDENT
+%token <name> TRAIN SEG IS AT HAS STEP HOME END IDENT
%token <name> NL
%token <num> NUM
| 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);
backwards: /* empty */ { return 0; }
| '-' { return 1; }
-ident: TRAIN | SEG | IS | AT | HAS | STEP | END | IDENT
+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); }
* train <trainpn> at [-]<foredetectpn>:<maxinto>+-<uncertainty>
* train <trainpn> is <addr> <head>+<detectable>+<tail>
* train <trainpn> step <step>=<speed> <upwait>/<downwait>
+ * train <trainpn> home [-]<segpn> [-]<segpn> [-]<segpn>
* seg <segpn> has [-]<ownerpn>
* seg <segpn> at <movposcomb>
*
tra->backwards= backw;
}
+void record_train_home(Train *tra, int backw, Segment *seg) {
+ if (!tra) return;
+ seg->home= tra;
+ seg->ho_backwards= backw;
+}
+
void record_seg_has(Segment *seg, int backw, Train *tra) {
seg->owner= tra;
seg->tr_backwards= backw;
struct Segment {
Train *owner; /* or 0 */
+ Train *home; /* or 0 */
unsigned
tr_backwards:1, /* train's motion is (would be) backwards wrt track */
+ ho_backwards:1, /* home train has its front and rear backwards wrt track */
movfeat_moving:1, /* feature(s) have been told to change to movposcomb */
cm_autostop:1, /* train should stop on detection */
seg_inverted:1, /* polarity is inverted */