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
|
<bracket> "document: " :=> document_title
|
||||||
|
|
||||||
<document_title> * { fail = "document title"; goto catch; }
|
<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 } };
|
const union line64 key = { { (uint32_t)line, date } };
|
||||||
size_t *pi;
|
size_t *pi;
|
||||||
struct source *doc;
|
struct source *doc;
|
||||||
fprintf(stderr, "document: <<%.*s>>\n", (int)(s1 - s0), s0);
|
|
||||||
if(!(doc = source_array_new(&scan->documents.array))) goto catch;
|
if(!(doc = source_array_new(&scan->documents.array))) goto catch;
|
||||||
doc->name.a = s0, doc->name.b = s1;
|
doc->name.a = s0, doc->name.b = s1;
|
||||||
doc->desc.a = 0, doc->desc.b = 0;
|
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",
|
fprintf(stderr, "%s[%zu]: new document <<%.*s>> stored at %zu.\n",
|
||||||
datestr, line, (int)(s1 - s0), s0, *pi);
|
datestr, line, (int)(s1 - s0), s0, *pi);
|
||||||
assert(future);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,9 +268,8 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
fprintf(stderr, "%s[%zu]: source <<%.*s>>\n",
|
fprintf(stderr, "%s[%zu]: source <<%.*s>>\n",
|
||||||
datestr, line, (int)(s1 - s0), s0);
|
datestr, line, (int)(s1 - s0), s0);
|
||||||
} continue; }
|
} continue; }
|
||||||
/* New source. fixme: desc not set. */
|
/* New source. */
|
||||||
////////
|
<source> @s0 keyword @s1 ":" => future {
|
||||||
<source> @s0 keyword @s1 ":" [^\x00\n]+ / "\n" => skip {
|
|
||||||
struct pair keyword = pair(s0, s1);
|
struct pair keyword = pair(s0, s1);
|
||||||
size_t *idx;
|
size_t *idx;
|
||||||
struct source *source;
|
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;
|
if(!(source = source_array_new(&scan->sources.array))) goto catch;
|
||||||
*idx = (size_t)(source - scan->sources.array.data);
|
*idx = (size_t)(source - scan->sources.array.data);
|
||||||
source->name.a = s0, source->name.b = s1;
|
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",
|
fprintf(stderr, "%s[%zu]: new source <<%.*s>> stored at %zu.\n",
|
||||||
datestr, line, (int)(s1 - s0), s0, *idx);
|
datestr, line, (int)(s1 - s0), s0, *idx);
|
||||||
goto also_source;
|
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.
|
/* "<<\ntext\n>>" or "text\n" used by several. Must have pointers to
|
||||||
Must have future and */
|
future input. */
|
||||||
<text_input, text_multi> * { fail = "text input"; goto catch; }
|
<future, future_multi> * { fail = "text input"; goto catch; }
|
||||||
<text_input> ws+ { continue; }
|
<future> ws+ { continue; }
|
||||||
<text_input> "\n" => line { // empty is okay
|
<future> "\n" => line { // empty is okay
|
||||||
line++;
|
line++;
|
||||||
assert(future);
|
assert(future);
|
||||||
future->a = future->b = 0, future = 0;
|
future->a = future->b = 0, future = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
<text_input> "<<\n" @s0 => text_multi { // multi-line
|
<future> "<<\n" @s0 => future_multi { // multi-line
|
||||||
line++;
|
line++;
|
||||||
fprintf(stderr, "$$$ multi-line!\n");
|
|
||||||
assert(future);
|
assert(future);
|
||||||
future->a = s0;
|
future->a = s0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
<text_input> @s0 anylabel @s1 "\n" => line { // one line
|
<future> @s0 anylabel @s1 "\n" => line { // one line
|
||||||
//<text_input> @s0 semilabel @s1 "\n" => line { // one line
|
|
||||||
line++;
|
line++;
|
||||||
fprintf(stderr, "text: [[%.*s]]\n", (int)(s1 - s0), s0);
|
fprintf(stderr, "text: <<%.*s>>\n", (int)(s1 - s0), s0);
|
||||||
assert(future);
|
assert(future);
|
||||||
future->a = s0, future->b = s1, future = 0;
|
future->a = s0, future->b = s1, future = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
<text_multi> [^\x00\n] { continue; }
|
<future_multi> [^\x00\n] { continue; }
|
||||||
<text_multi> [\x00] { fail = "missing closing \">>\""; goto catch; }
|
<future_multi> [\x00] { fail = "missing closing \">>\""; goto catch; }
|
||||||
<text_multi> "\n" { line++; continue; }
|
<future_multi> "\n" { line++; continue; }
|
||||||
<text_multi> @s1 ">>\n" => line {
|
/* 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++;
|
line++;
|
||||||
assert(future && future->a);
|
assert(future && future->a);
|
||||||
future->b = s1;
|
future->b = s1, future = 0;
|
||||||
future = 0;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user