aboutsummaryrefslogtreecommitdiff
path: root/driver/parser_test.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2021-07-30 23:41:24 +0900
committerRyo Nihei <nihei.dev@gmail.com>2021-07-30 23:56:01 +0900
commita80538426fc6df3385e9567064d32b4b45a81669 (patch)
treec5049134d8e9011e0b7a0175fc4a64e52a7d5fd0 /driver/parser_test.go
parentAdd a token position and detailed info to a lexical error message (diff)
downloadurubu-a80538426fc6df3385e9567064d32b4b45a81669.tar.gz
urubu-a80538426fc6df3385e9567064d32b4b45a81669.tar.xz
Detect unused-symbol error
When there are productions and terminals that are cannot be reached from the start symbol, the compiler reports an error.
Diffstat (limited to 'driver/parser_test.go')
-rw-r--r--driver/parser_test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/driver/parser_test.go b/driver/parser_test.go
index 73d8fac..e32e34c 100644
--- a/driver/parser_test.go
+++ b/driver/parser_test.go
@@ -148,6 +148,46 @@ bar_text: "bar";
),
),
},
+ // Production `b` is unused.
+ {
+ specSrc: `
+a
+ : foo
+ ;
+b
+ : foo;
+foo: "foo";
+`,
+ src: `foo`,
+ specErr: true,
+ },
+ // Terminal `bar` is unused.
+ {
+ specSrc: `
+s
+ : foo
+ ;
+foo: "foo";
+bar: "bar";
+`,
+ src: `foo`,
+ specErr: true,
+ },
+ // Production `b` and terminal `bar` is unused.
+ {
+ specSrc: `
+a
+ : foo
+ ;
+b
+ : bar
+ ;
+foo: "foo";
+bar: "bar";
+`,
+ src: `foo`,
+ specErr: true,
+ },
{
specSrc: `
mode_tran_seq
@@ -258,6 +298,9 @@ bar: "bar";
{
specSrc: `
s
+ : foo
+ ;
+foo
: "foo" #ast #(s $1...)
;
`,