aboutsummaryrefslogtreecommitdiff
path: root/grammar/grammar_test.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2022-04-16 16:06:31 +0900
committerRyo Nihei <nihei.dev@gmail.com>2022-04-16 16:06:31 +0900
commit8bf4d234d0b983d92378ba91660cae30e35f16f0 (patch)
treee39a78975fb3005b0e02f6552723a887511acc83 /grammar/grammar_test.go
parentAdd tests for driver (diff)
downloadurubu-8bf4d234d0b983d92378ba91660cae30e35f16f0.tar.gz
urubu-8bf4d234d0b983d92378ba91660cae30e35f16f0.tar.xz
Prohibit ambiguous symbol in an #ast directive
Diffstat (limited to 'grammar/grammar_test.go')
-rw-r--r--grammar/grammar_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/grammar/grammar_test.go b/grammar/grammar_test.go
index 1448d3c..0295798 100644
--- a/grammar/grammar_test.go
+++ b/grammar/grammar_test.go
@@ -1024,6 +1024,34 @@ foo
errs: []*SemanticError{semErrDuplicateElem},
},
{
+ caption: "symbol `foo` is ambiguous because it appears in an alternative twice",
+ specSrc: `
+%name test
+
+s
+ : foo foo #ast foo
+ ;
+
+foo
+ : 'foo';
+`,
+ errs: []*SemanticError{semErrAmbiguousElem},
+ },
+ {
+ caption: "symbol `foo` is ambiguous because it appears in an alternative twice, even if one of them has a label",
+ specSrc: `
+%name test
+
+s
+ : foo@x foo #ast foo
+ ;
+
+foo
+ : 'foo';
+`,
+ errs: []*SemanticError{semErrAmbiguousElem},
+ },
+ {
caption: "the expansion operator cannot be applied to a terminal symbol",
specSrc: `
%name test