From: ian Date: Sun, 4 May 2008 21:27:23 +0000 (+0000) Subject: preserve inversions X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=fb683837ce012a8b1e9b2c242ebe73af730f2cea;p=trains.git preserve inversions --- diff --git a/hostside/persist.c b/hostside/persist.c index b588f50..b1cf71c 100644 --- a/hostside/persist.c +++ b/hostside/persist.c @@ -387,9 +387,10 @@ void persist_entrails_run_converter(void) { if (seg->i != segi || !segi->pname || !seg->owner || !seg->owner->pname) continue; - printf("seg %s has %s%s\n", segi->pname, + printf("seg %s has %s%s%s\n", segi->pname, (seg->tr_backwards ^ seg->owner->backwards) ? "-" : "", - seg->owner->pname); + seg->owner->pname, + seg->seg_inverted ? " inverted" : ""); if (segi->n_poscombs>1 && (report= movpos_poscomb_actual(seg)) >=0 && diff --git a/hostside/record-i.h b/hostside/record-i.h index 81b04f9..3db3d91 100644 --- a/hostside/record-i.h +++ b/hostside/record-i.h @@ -12,7 +12,7 @@ void record_train_home(Train *tra, int backw, Segment *seg); void record_train_step_speed(Train *tra, int step, double speed); void record_train_stopregime_count(void); void record_train_stopregime(Train *tra, int step, int xs, int ts); -void record_seg_has(Segment *seg, int backw, Train *tra); +void record_seg_has(Segment *seg, int backw, Train *tra, int inverted); void record_seg_at(Segment *seg, const char *movposcomb_pname); void record_feature_nmrafeat(FeaturesFeature*, FeaturesAddr*, int num); void record_feature_motor(FeaturesFeature*, FeaturesAddr*, int speed); diff --git a/hostside/record-l.l b/hostside/record-l.l index a74fef8..330c70c 100644 --- a/hostside/record-l.l +++ b/hostside/record-l.l @@ -23,6 +23,7 @@ feature { STR FEATURE; } is { STR IS; } at { STR AT; } has { STR HAS; } +inverted { STR INVERTED; } step { STR STEP; } stops { STR STOPS; } home { STR HOME; } diff --git a/hostside/record-y.y b/hostside/record-y.y index 0a0211f..8ddbe8b 100644 --- a/hostside/record-y.y +++ b/hostside/record-y.y @@ -17,7 +17,7 @@ static Train *cur_train; double dbl; } -%token TRAIN FEATURE SEG IS AT HAS STEP STOPS HOME END +%token TRAIN FEATURE SEG IS AT HAS INVERTED STEP STOPS HOME END %token IDENT FEATLETTER %token NL %token NUM @@ -26,7 +26,7 @@ static Train *cur_train; %type ident %type train %type seg -%type backwards +%type backwards inverted %type dbl %type feature %type feataddr @@ -54,8 +54,8 @@ line: /* empty */ { if (!trains) record_train_stopregime_count(); else if ($2) record_train_stopregime($2,$4,$6,$7); } - | SEG seg HAS backwards train - { if ($2 && $5) record_seg_has($2,$4,$5); + | SEG seg HAS backwards train inverted + { if ($2 && $5) record_seg_has($2,$4,$5,$6); } | SEG seg AT ident { if ($2) record_seg_at($2,$4); @@ -70,11 +70,17 @@ line: /* empty */ backwards: /* empty */ { $$= 0; } | '-' { $$= 1; } +inverted: /* empty */ { $$= 0; } + | INVERTED { $$= 1; } + segments: { cur_train= (void*)-1; } | backwards seg { record_train_home(cur_train,$1,$2); } segments -ident: TRAIN | SEG | IS | AT | HAS | STEP | STOPS | HOME | END +ident: TRAIN | SEG + | IS | AT | HAS | INVERTED | STEP | STOPS | HOME + | END | IDENT | FEATLETTER + dbl: DBL | NUM { $$= $1 } diff --git a/hostside/record.c b/hostside/record.c index df7a668..c42b78d 100644 --- a/hostside/record.c +++ b/hostside/record.c @@ -8,7 +8,7 @@ * train home [-] [-] [-] * train step = * train stops at after - * seg has [-] + * seg has [-] [inverted] * seg at * feature is * feature is step [-] @@ -205,9 +205,10 @@ void record_train_step_speed(Train *tra, int step, double speed) { tra->speedcurve[step]= speed; } -void record_seg_has(Segment *seg, int backw, Train *tra) { +void record_seg_has(Segment *seg, int backw, Train *tra, int inverted) { seg->owner= tra; seg->tr_backwards= backw; + seg->seg_inverted= inverted; } void record_seg_at(Segment *seg, const char *movposcombpname) {