Entered "->" into parser, but does not have a data-structure.

This commit is contained in:
Neil 2023-04-30 01:15:04 -07:00
parent 2fe62099db
commit dd7ebd4075
3 changed files with 31 additions and 5 deletions

View File

@ -1,4 +1,4 @@
optimize := -ffast-math
optimize := -ffast-math
warnbasic := -Wall -pedantic #-ansi # -std=c99
warnclang := -Wextra -Weverything \
-Wno-comma \
@ -30,7 +30,7 @@ else
CF += -g
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))
default: $(projects)
@ -70,7 +70,7 @@ build/%.c: src/%.re.c
# # https://github.com/neil-edelman/cdoc documentation
# -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
test: $(projects)

View File

@ -26,6 +26,11 @@ struct score {
#define ARRAY_HEAD
#include "../src/array.h"
//////// fixme: place
/* Glider array. */
#define LAUNCH_TYPE \
X(MotorCarTow),\

View File

@ -122,9 +122,11 @@ static int scan_day(struct scan *const scan, union date32 date,
glyph = [^\x00-\x20\x7f]; // [^\x00\n\t ] + all weird
semitext = glyph \ ";";
natural = [1-9][0-9]*;
zero_natural = natural | "0";
zero_natural = [0-9]+;
decimal = "-"? zero_natural ("." zero_natural?)?;
uint = [0-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];
minutes = [0-5][0-9];
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, skip> "\n" => line { line++; continue; }
<line> * :=> skip
<line> "->" :=> place
<line> "--" / [^-] :=> source
<line> "::" / [^:] :=> score
<line> "[glider]" :=> glider_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> @s0 keyword @s1 / "\n" => skip { also_source: {
const struct pair keyword = pair(s0, s1);
@ -235,11 +253,13 @@ static int scan_day(struct scan *const scan, union date32 date,
=> score_date {
assert(new_score);
new_score->name.a = s0, new_score->name.b = s1;
continue;
}
<score_date> * { fail = "date unrecognized"; goto catch; }
<score_date> ws* "~"? @s0 date ws* ";" => score_edges {
assert(new_score);
if(!pair_to_date(s0, &new_score->date)) goto catch;
continue;
}
<score_edges> * { fail = "edges unrecognized"; goto catch; }
<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:
if(!errno) errno = EILSEQ;
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;
}