future
This commit is contained in:
parent
c096fbf605
commit
f31a7a9810
@ -177,11 +177,10 @@ static int scan_day(struct scan *const scan, union date32 date,
|
||||
<bracket> "document: " :=> document_title
|
||||
|
||||
<document_title> * { fail = "document title"; goto catch; }
|
||||
<document_title> @s0 bralabel @s1 "]" => text_input {
|
||||
<document_title> @s0 bralabel @s1 "]" => future {
|
||||
const union line64 key = { { (uint32_t)line, date } };
|
||||
size_t *pi;
|
||||
struct source *doc;
|
||||
fprintf(stderr, "document: <<%.*s>>\n", (int)(s1 - s0), s0);
|
||||
if(!(doc = source_array_new(&scan->documents.array))) goto catch;
|
||||
doc->name.a = s0, doc->name.b = s1;
|
||||
doc->desc.a = 0, doc->desc.b = 0;
|
||||
@ -193,7 +192,6 @@ static int scan_day(struct scan *const scan, union date32 date,
|
||||
}
|
||||
fprintf(stderr, "%s[%zu]: new document <<%.*s>> stored at %zu.\n",
|
||||
datestr, line, (int)(s1 - s0), s0, *pi);
|
||||
assert(future);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -270,9 +268,8 @@ static int scan_day(struct scan *const scan, union date32 date,
|
||||
fprintf(stderr, "%s[%zu]: source <<%.*s>>\n",
|
||||
datestr, line, (int)(s1 - s0), s0);
|
||||
} continue; }
|
||||
/* New source. fixme: desc not set. */
|
||||
////////
|
||||
<source> @s0 keyword @s1 ":" [^\x00\n]+ / "\n" => skip {
|
||||
/* New source. */
|
||||
<source> @s0 keyword @s1 ":" => future {
|
||||
struct pair keyword = pair(s0, s1);
|
||||
size_t *idx;
|
||||
struct source *source;
|
||||
@ -284,7 +281,8 @@ static int scan_day(struct scan *const scan, union date32 date,
|
||||
if(!(source = source_array_new(&scan->sources.array))) goto catch;
|
||||
*idx = (size_t)(source - scan->sources.array.data);
|
||||
source->name.a = s0, source->name.b = s1;
|
||||
source->desc.a = 0, source->desc.b = 0; /* fixme */
|
||||
source->desc.a = 0, source->desc.b = 0;
|
||||
assert(!future), future = &source->desc;
|
||||
fprintf(stderr, "%s[%zu]: new source <<%.*s>> stored at %zu.\n",
|
||||
datestr, line, (int)(s1 - s0), s0, *idx);
|
||||
goto also_source;
|
||||
@ -625,39 +623,38 @@ static int scan_day(struct scan *const scan, union date32 date,
|
||||
}
|
||||
|
||||
|
||||
/* "<<\ntext\n>>" or "text\n" used by several.
|
||||
Must have future and */
|
||||
<text_input, text_multi> * { fail = "text input"; goto catch; }
|
||||
<text_input> ws+ { continue; }
|
||||
<text_input> "\n" => line { // empty is okay
|
||||
/* "<<\ntext\n>>" or "text\n" used by several. Must have pointers to
|
||||
future input. */
|
||||
<future, future_multi> * { fail = "text input"; goto catch; }
|
||||
<future> ws+ { continue; }
|
||||
<future> "\n" => line { // empty is okay
|
||||
line++;
|
||||
assert(future);
|
||||
future->a = future->b = 0, future = 0;
|
||||
continue;
|
||||
}
|
||||
<text_input> "<<\n" @s0 => text_multi { // multi-line
|
||||
<future> "<<\n" @s0 => future_multi { // multi-line
|
||||
line++;
|
||||
fprintf(stderr, "$$$ multi-line!\n");
|
||||
assert(future);
|
||||
future->a = s0;
|
||||
continue;
|
||||
}
|
||||
<text_input> @s0 anylabel @s1 "\n" => line { // one line
|
||||
//<text_input> @s0 semilabel @s1 "\n" => line { // one line
|
||||
<future> @s0 anylabel @s1 "\n" => line { // one line
|
||||
line++;
|
||||
fprintf(stderr, "text: [[%.*s]]\n", (int)(s1 - s0), s0);
|
||||
fprintf(stderr, "text: <<%.*s>>\n", (int)(s1 - s0), s0);
|
||||
assert(future);
|
||||
future->a = s0, future->b = s1, future = 0;
|
||||
continue;
|
||||
}
|
||||
<text_multi> [^\x00\n] { continue; }
|
||||
<text_multi> [\x00] { fail = "missing closing \">>\""; goto catch; }
|
||||
<text_multi> "\n" { line++; continue; }
|
||||
<text_multi> @s1 ">>\n" => line {
|
||||
<future_multi> [^\x00\n] { continue; }
|
||||
<future_multi> [\x00] { fail = "missing closing \">>\""; goto catch; }
|
||||
<future_multi> "\n" { line++; continue; }
|
||||
/* Restricts this to be the last one; you could imagine that it would
|
||||
be more flexible, "<<\n>>; <<\n>>\n". */
|
||||
<future_multi> @s1 ">>\n" => line {
|
||||
line++;
|
||||
assert(future && future->a);
|
||||
future->b = s1;
|
||||
future = 0;
|
||||
future->b = s1, future = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user