1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-05 08:34:22 +03:00
inform7/inbuild/syntax-test/Chapter 1/Unit Tests.w

39 lines
875 B
OpenEdge ABL
Raw Normal View History

2019-02-05 02:44:07 +02:00
[Unit::] Unit Tests.
How we shall test it.
2019-02-05 02:44:07 +02:00
@h
=
<dividing-sentence> ::=
chapter ... | ==> 1
section ... ==> 2
<structural-sentence> ::=
... ==> TRUE; return FAIL_NONTERMINAL;
<language-modifying-sentence> ::=
... ==> TRUE; return FAIL_NONTERMINAL;
@h Syntax tree.
=
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; }
syntax_tree = ParseTree::new_tree();
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);
ParseTree::log_tree(DL, syntax_tree->root_node);
2019-02-05 02:44:07 +02:00
DL = save_DL;
}