From 6a18024f4fa3b96044d50e6308dad5e78128a9c3 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Thu, 15 Jul 2021 00:48:15 +0900 Subject: Add testing for the driver The driver can reduce productions that have the empty alternative and can generate a CST (and AST) node. --- driver/parser_test.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'driver/parser_test.go') diff --git a/driver/parser_test.go b/driver/parser_test.go index 8713893..3dec508 100644 --- a/driver/parser_test.go +++ b/driver/parser_test.go @@ -104,6 +104,50 @@ id: "[A-Za-z_][0-9A-Za-z_]*"; ), ), }, + // The driver can reduce productions that have the empty alternative and can generate a CST (and AST) node. + { + specSrc: ` +s + : foo bar + ; +foo + : + ; +bar + : bar_text + | + ; +bar_text: "bar"; +`, + src: ``, + cst: nonTermNode("s", + termNode("foo", ""), + termNode("bar", ""), + ), + }, + // The driver can reduce productions that have the empty alternative and can generate a CST (and AST) node. + { + specSrc: ` +s + : foo bar + ; +foo + : + ; +bar + : bar_text + | + ; +bar_text: "bar"; +`, + src: `bar`, + cst: nonTermNode("s", + termNode("foo", ""), + nonTermNode("bar", + termNode("bar_text", "bar"), + ), + ), + }, { specSrc: ` mode_tran_seq -- cgit v1.2.3