2019-02-05 02:44:07 +02:00
|
|
|
[Unit::] Unit Tests.
|
|
|
|
|
2020-03-28 21:42:53 +02:00
|
|
|
How we shall test it.
|
2019-02-05 02:44:07 +02:00
|
|
|
|
2020-05-11 21:14:00 +03:00
|
|
|
@h Minimal Preform grammar.
|
|
|
|
Only |<dividing-sentence>| can ever match, since the others are wired to match
|
|
|
|
any text but then fail.
|
2019-02-05 02:44:07 +02:00
|
|
|
|
|
|
|
=
|
|
|
|
<dividing-sentence> ::=
|
2020-07-28 11:57:58 +03:00
|
|
|
chapter ... | ==> { 1, - }
|
|
|
|
section ... ==> { 2, - }
|
2019-02-05 02:44:07 +02:00
|
|
|
|
|
|
|
<structural-sentence> ::=
|
2020-07-28 11:57:58 +03:00
|
|
|
... ==> { fail }
|
2019-02-05 02:44:07 +02:00
|
|
|
|
|
|
|
<language-modifying-sentence> ::=
|
2020-07-28 11:57:58 +03:00
|
|
|
... ==> { fail }
|
2020-05-11 21:14:00 +03:00
|
|
|
|
|
|
|
<comma-divisible-sentence> ::=
|
2020-07-28 11:57:58 +03:00
|
|
|
... ==> { fail }
|
2019-02-05 02:44:07 +02:00
|
|
|
|
|
|
|
@h Syntax tree.
|
|
|
|
|
|
|
|
=
|
2020-03-05 14:42:33 +02:00
|
|
|
parse_node_tree *syntax_tree = NULL;
|
|
|
|
|
2019-02-05 02:44:07 +02:00
|
|
|
void Unit::test_tree(text_stream *arg) {
|
|
|
|
filename *F = Filenames::from_text(arg);
|
|
|
|
feed_t FD = Feeds::begin();
|
|
|
|
source_file *sf = TextFromFiles::feed_into_lexer(F, NULL_GENERAL_POINTER);
|
|
|
|
wording W = Feeds::end(FD);
|
|
|
|
if (sf == NULL) { PRINT("File has failed to open\n"); return; }
|
2020-05-11 17:21:29 +03:00
|
|
|
syntax_tree = SyntaxTree::new();
|
2019-02-05 02:44:07 +02:00
|
|
|
PRINT("Read %d words\n", Wordings::length(W));
|
2020-03-31 02:17:21 +03:00
|
|
|
Sentences::break(syntax_tree, W);
|
2019-02-05 02:44:07 +02:00
|
|
|
|
|
|
|
text_stream *save_DL = DL;
|
|
|
|
DL = STDOUT;
|
|
|
|
Streams::enable_debugging(DL);
|
2020-05-11 17:21:29 +03:00
|
|
|
Node::log_tree(DL, syntax_tree->root_node);
|
2019-02-05 02:44:07 +02:00
|
|
|
DL = save_DL;
|
|
|
|
}
|