1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-16 22:14:23 +03:00
inform7/services/syntax-test/Chapter 1/Program Control.w

51 lines
1.3 KiB
OpenEdge ABL
Raw Normal View History

2019-02-05 02:44:07 +02:00
[Main::] Program Control.
What shall we test?
2019-02-05 02:44:07 +02:00
@h Main routine.
@d PROGRAM_NAME "syntax-test"
2019-02-05 02:44:07 +02:00
@e TEST_TREE_CLSW
2022-09-01 15:04:08 +03:00
@e TEST_DIALOGUE_CLSW
2019-02-05 02:44:07 +02:00
=
int main(int argc, char **argv) {
Foundation::start(argc, argv);
2019-02-05 02:44:07 +02:00
WordsModule::start();
SyntaxModule::start();
CommandLine::declare_heading(U"syntax-test: a tool for testing the syntax module\n");
2019-02-05 02:44:07 +02:00
CommandLine::declare_switch(TEST_TREE_CLSW, U"test-tree", 2,
U"test the syntax tree (from text in X)");
CommandLine::declare_switch(TEST_DIALOGUE_CLSW, U"test-dialogue", 2,
U"test a syntax tree with dialogue (from text in X)");
2019-02-05 02:44:07 +02:00
CommandLine::read(argc, argv, NULL, &Main::respond, &Main::ignore);
WordsModule::end();
SyntaxModule::end();
Foundation::end();
return 0;
}
void Main::respond(int id, int val, text_stream *arg, void *state) {
switch (id) {
case TEST_TREE_CLSW: Main::load(I"Syntax.preform"); Unit::test_tree(arg); break;
2022-09-01 15:04:08 +03:00
case TEST_DIALOGUE_CLSW: Main::load(I"Syntax.preform"); Unit::test_tree(arg); break;
2019-02-05 02:44:07 +02:00
}
}
void Main::load(text_stream *leaf) {
2020-05-20 02:02:28 +03:00
pathname *P = Pathnames::from_text(I"services");
P = Pathnames::down(P, I"syntax-test");
P = Pathnames::down(P, I"Tangled");
filename *S = Filenames::in(P, leaf);
2020-05-17 02:20:21 +03:00
LoadPreform::load(S, NULL);
2019-02-05 02:44:07 +02:00
}
void Main::ignore(int id, text_stream *arg, void *state) {
Errors::fatal("only switches may be used at the command line");
}