Entered "->" into parser, but does not have a data-structure.
This commit is contained in:
parent
2fe62099db
commit
dd7ebd4075
6
Makefile
6
Makefile
@ -1,4 +1,4 @@
|
|||||||
optimize := -ffast-math
|
optimize := -ffast-math
|
||||||
warnbasic := -Wall -pedantic #-ansi # -std=c99
|
warnbasic := -Wall -pedantic #-ansi # -std=c99
|
||||||
warnclang := -Wextra -Weverything \
|
warnclang := -Wextra -Weverything \
|
||||||
-Wno-comma \
|
-Wno-comma \
|
||||||
@ -30,7 +30,7 @@ else
|
|||||||
CF += -g
|
CF += -g
|
||||||
endif
|
endif
|
||||||
|
|
||||||
projects := bin/test-text bin/test-journal bin/test-source bin/test-kjv bin/kjv bin/flight bin/score bin/scan
|
projects := bin/test-text bin/test-journal bin/test-source bin/test-kjv bin/scan
|
||||||
#docs := $(patsubst test/test_%.c, doc/%.md, $(wildcard test/test_*.c))
|
#docs := $(patsubst test/test_%.c, doc/%.md, $(wildcard test/test_*.c))
|
||||||
|
|
||||||
default: $(projects)
|
default: $(projects)
|
||||||
@ -70,7 +70,7 @@ build/%.c: src/%.re.c
|
|||||||
# # https://github.com/neil-edelman/cdoc documentation
|
# # https://github.com/neil-edelman/cdoc documentation
|
||||||
# -cdoc -o $@ $<
|
# -cdoc -o $@ $<
|
||||||
|
|
||||||
.SECONDARY: build/kjv.c build/journal.c build/source.c build/scan_kjv.c build/flights.c build/kjvcite.c build/scores.c build/scan.c
|
.SECONDARY: build/kjv.c build/journal.c build/scan.c
|
||||||
.PHONY: clean release test
|
.PHONY: clean release test
|
||||||
|
|
||||||
test: $(projects)
|
test: $(projects)
|
||||||
|
@ -26,6 +26,11 @@ struct score {
|
|||||||
#define ARRAY_HEAD
|
#define ARRAY_HEAD
|
||||||
#include "../src/array.h"
|
#include "../src/array.h"
|
||||||
|
|
||||||
|
|
||||||
|
//////// fixme: place
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Glider array. */
|
/* Glider array. */
|
||||||
#define LAUNCH_TYPE \
|
#define LAUNCH_TYPE \
|
||||||
X(MotorCarTow),\
|
X(MotorCarTow),\
|
||||||
|
@ -122,9 +122,11 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
glyph = [^\x00-\x20\x7f]; // [^\x00\n\t ] + all weird
|
glyph = [^\x00-\x20\x7f]; // [^\x00\n\t ] + all weird
|
||||||
semitext = glyph \ ";";
|
semitext = glyph \ ";";
|
||||||
natural = [1-9][0-9]*;
|
natural = [1-9][0-9]*;
|
||||||
zero_natural = natural | "0";
|
zero_natural = [0-9]+;
|
||||||
|
decimal = "-"? zero_natural ("." zero_natural?)?;
|
||||||
uint = [0-9]+;
|
uint = [0-9]+;
|
||||||
keyword = [A-Za-z0-9][A-Za-z0-9_-]*;
|
keyword = [A-Za-z0-9][A-Za-z0-9_-]*;
|
||||||
|
label = semitext+ (" " semitext+)*; // perhaps??? do we want to include ;?
|
||||||
date = natural "-" [0-1][0-9] "-" [0-3][0-9];
|
date = natural "-" [0-1][0-9] "-" [0-3][0-9];
|
||||||
minutes = [0-5][0-9];
|
minutes = [0-5][0-9];
|
||||||
airport = [A-Z0-9]{4,4};
|
airport = [A-Z0-9]{4,4};
|
||||||
@ -140,12 +142,28 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
<line> "\x00" { return 1; } /* End of day. */
|
<line> "\x00" { return 1; } /* End of day. */
|
||||||
<line, skip> "\n" => line { line++; continue; }
|
<line, skip> "\n" => line { line++; continue; }
|
||||||
<line> * :=> skip
|
<line> * :=> skip
|
||||||
|
<line> "->" :=> place
|
||||||
<line> "--" / [^-] :=> source
|
<line> "--" / [^-] :=> source
|
||||||
<line> "::" / [^:] :=> score
|
<line> "::" / [^:] :=> score
|
||||||
<line> "[glider]" :=> glider_type
|
<line> "[glider]" :=> glider_type
|
||||||
<line> "[flight]" :=> flight_type
|
<line> "[flight]" :=> flight_type
|
||||||
|
|
||||||
|
|
||||||
|
<place> * { fail = "place unrecognized"; goto catch; }
|
||||||
|
<place> @t0 "(" decimal "," decimal ")" @t1 ws+ @s0 label @s1 / "\n"
|
||||||
|
=> skip {
|
||||||
|
const struct pair keyword = pair(s0, s1);
|
||||||
|
const struct pair coords = pair(t0, t1);
|
||||||
|
fprintf(stderr, "place: %.*s <<%.*s>>\n",
|
||||||
|
(int)(t1-t0), t0, (int)(s1-s0), s0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
<place> @s0 label @s1 / "\n" => skip {
|
||||||
|
const struct pair keyword = pair(s0, s1);
|
||||||
|
fprintf(stderr, "place: <<%.*s>>\n", (int)(s1-s0), s0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
<source> * { fail = "source unrecognized"; goto catch; }
|
<source> * { fail = "source unrecognized"; goto catch; }
|
||||||
<source> @s0 keyword @s1 / "\n" => skip { also_source: {
|
<source> @s0 keyword @s1 / "\n" => skip { also_source: {
|
||||||
const struct pair keyword = pair(s0, s1);
|
const struct pair keyword = pair(s0, s1);
|
||||||
@ -235,11 +253,13 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
=> score_date {
|
=> score_date {
|
||||||
assert(new_score);
|
assert(new_score);
|
||||||
new_score->name.a = s0, new_score->name.b = s1;
|
new_score->name.a = s0, new_score->name.b = s1;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
<score_date> * { fail = "date unrecognized"; goto catch; }
|
<score_date> * { fail = "date unrecognized"; goto catch; }
|
||||||
<score_date> ws* "~"? @s0 date ws* ";" => score_edges {
|
<score_date> ws* "~"? @s0 date ws* ";" => score_edges {
|
||||||
assert(new_score);
|
assert(new_score);
|
||||||
if(!pair_to_date(s0, &new_score->date)) goto catch;
|
if(!pair_to_date(s0, &new_score->date)) goto catch;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
<score_edges> * { fail = "edges unrecognized"; goto catch; }
|
<score_edges> * { fail = "edges unrecognized"; goto catch; }
|
||||||
<score_edges> ws* "~"? @s0 uint @s1 ws* / "\n" => skip {
|
<score_edges> ws* "~"? @s0 uint @s1 ws* / "\n" => skip {
|
||||||
@ -530,7 +550,8 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
catch:
|
catch:
|
||||||
if(!errno) errno = EILSEQ;
|
if(!errno) errno = EILSEQ;
|
||||||
date32_to_string(date, &datestr);
|
date32_to_string(date, &datestr);
|
||||||
fprintf(stderr, "%s line %zu: %s condition %d.\n", datestr, line, fail, condition);
|
fprintf(stderr, "%s line %zu: %s" /*" condition %d"*/ ".\n",
|
||||||
|
datestr, line, fail/*, condition*/);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user