summaryrefslogtreecommitdiff
path: root/src/test/check_grammar.c
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-11-08 16:37:57 +0800
committerJSDurand <mmemmew@gmail.com>2021-11-08 16:37:57 +0800
commit9594210f02572681ed581c5197ace4c207db0917 (patch)
tree08bf1bf079d111c64cf3128dd68323abdce78228 /src/test/check_grammar.c
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.
Diffstat (limited to 'src/test/check_grammar.c')
-rw-r--r--src/test/check_grammar.c35
1 files changed, 35 insertions, 0 deletions
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 <stdio.h>
+#include <stdlib.h>
+#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;
+}