CPPFLAGS=
LINK= $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS)
+LEX=flex
+BISON=bison
+
%.o: %.c $(AUTOINCS)
$(CC) $(CFLAGS) -MM $< >$*.d
$(CC) $(CFLAGS) -o $@ -c $<
+
+%.c: %.y
+ $(BISON) -o $@ $<
selectors.h
errorcodes.h
retransmit-table.h
+record-l.c
+record-y.[ch]
#
-AUTOINCS= auproto-pic.h layoutinfo.h selectors.h retransmit-table.h
+AUTOINCS= auproto-pic.h layoutinfo.h selectors.h retransmit-table.h \
+ errorcodes.h
TARGETS= hostside-old gui-plan-bot realtime
include ../common.make
hostside: hostside.o serialio.o client.o obc.o commands.o utils.o \
nmra.o encode.o retransmit.o output.o auproto-pic.o \
parseutils.o \
+ record-l.o record-y.o record.o \
-loop
$(LINK)
--- /dev/null
+/* -*- fundamental -*- */
+
+%{
+#include "y.tab.h"
+%}
+
+%option warn
+%option batch
+%option noyywrap
+
+%option bison-locations
+%option bison-bridge
+
+%{
+#define STR yylval->str= xstrdup(yytext); return
+%}
+
+%%
+
+max-trains { yylval->str= 0; return MAXTRAINS; }
+
+train { STR TRAIN; }
+seg { STR SEG; }
+is { STR IS; }
+at { STR AT; }
+has { STR HAS; }
+step { STR STEP; }
+end { STR END; }
+
+[A-Za-z0-9_]+ { STR IDENT; }
+
+[0-9]{0,5} { yylval->num= strtoul(yytext,0,10); return NUM; }
+[0-9]{6} { badrecord("number too long"); }
+
+[-+:=~$/] { yylval->str= 0; return yytext[0]; }
+
+\#.*\n|\ { yylval->str= 0; return NL; }
+
+[ \t] { }
+
+. { badrecord("lexically invalid input"); }
--- /dev/null
+/* -*- fundamental -*- */
+
+%{
+#include "realtime.h"
+%}
+
+%union {
+ char *name;
+ Train *train;
+ Segment *seg;
+ int num;
+}
+
+%token <name> TRAIN SEG IS AT HAS STEP END IDENT
+%token <name> MAXTRAINS NL
+%token <num> NUM
+
+%type <name> ident
+%type <train> train
+%type <segment> seg
+%type <num> sign
+
+%defines
+
+%%
+
+file: end
+ | line NL 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); }
+ | 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; }
+
+ident: IDENT | TRAIN | SEG | IS | AT | STEP | END
+
+seg: ident { $$= pname2seg($1); }
+train: ident { $$= pname2train($1); }
+
+end: END NL
+
+%%
*
* File format:
*
+ * max-trains num
* train <trainpn> at [-]<foredetectpn>:<maxinto>+-<uncertainty>
- * seg <segpn> has [-]<ownerpn>|$ <movposcomb>
- * train <trainpn> is #<addr> <head>+<detectable>+<tail>
+ * train <trainpn> is <addr> <head>+<detectable>+<tail>
* train <trainpn> step <step>=<speed> <upwait>/<downwait>
+ * seg <segpn> has [-]<ownerpn>|$
+ * seg <segpn> at <movposcomb>
*/