From 9594210f02572681ed581c5197ace4c207db0917 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Mon, 8 Nov 2021 16:37:57 +0800 Subject: initial commit Now the rough framework is established and the grammar class is sort of ready. It remains to write a general input reading mechanism. --- src/test/check_grammar.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/test/check_grammar.c (limited to 'src/test/check_grammar.c') diff --git a/src/test/check_grammar.c b/src/test/check_grammar.c new file mode 100644 index 0000000..1fe27dd --- /dev/null +++ b/src/test/check_grammar.c @@ -0,0 +1,35 @@ +#include +#include +#include "../grammar.h" + +int main(U_ATTR int argc, U_ATTR char **argv) +{ + /* check new_tnt and print it */ + TNT *tnt = new_tnt(1, 12); + + printf("Print a TNT value of type NT: "); + print_tnt(tnt); + printf("\n"); + + free(tnt); + + /* check new_tnt_string */ + + List *tnt_string = new_tnt_string("tntnt", 5, + (T) 1, (NT) 2, (T) 3, (NT) 4, (T) 15); + + if (!tnt_string) { + eprintf("error!\n"); + return 1; + } + + /* check new_rule, print_rule, and destroy_rule. */ + + Rule *rule = new_rule(1, tnt_string); + + print_rule(rule); + + destroy_rule(rule); + + return 0; +} -- cgit v1.2.3-18-g5258