aboutsummaryrefslogtreecommitdiff
path: root/driver/parser_test.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2021-07-28 01:54:39 +0900
committerRyo Nihei <nihei.dev@gmail.com>2021-07-28 01:54:39 +0900
commitadb12c2c1b2873d8775f55c02f54e6690687f1a2 (patch)
tree4715e03c051bfca3262b74046b79252d49c069b4 /driver/parser_test.go
parentAdd literal pattern syntax and change tree structure syntax (diff)
downloadcotia-adb12c2c1b2873d8775f55c02f54e6690687f1a2.tar.gz
cotia-adb12c2c1b2873d8775f55c02f54e6690687f1a2.tar.xz
Detect duplicate production errors
Diffstat (limited to 'driver/parser_test.go')
-rw-r--r--driver/parser_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/driver/parser_test.go b/driver/parser_test.go
index 272a14d..73d8fac 100644
--- a/driver/parser_test.go
+++ b/driver/parser_test.go
@@ -273,6 +273,48 @@ foo: "foo";
`,
specErr: true,
},
+ // A production must not have a duplicate alternative.
+ {
+ specSrc: `
+s
+ : foo
+ | foo
+ ;
+foo: "foo";
+`,
+ specErr: true,
+ },
+ // A production must not have a duplicate alternative.
+ {
+ specSrc: `
+a
+ : foo
+ ;
+b
+ :
+ |
+ ;
+foo: "foo";
+`,
+ specErr: true,
+ },
+ // A production must not have a duplicate alternative.
+ {
+ specSrc: `
+a
+ : foo
+ ;
+b
+ : bar
+ ;
+a
+ : foo
+ ;
+foo: "foo";
+bar: "bar";
+`,
+ specErr: true,
+ },
}
for i, tt := range tests {
t.Run(fmt.Sprintf("#%v", i), func(t *testing.T) {