From 8bf4d234d0b983d92378ba91660cae30e35f16f0 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sat, 16 Apr 2022 16:06:31 +0900 Subject: Prohibit ambiguous symbol in an #ast directive --- grammar/grammar_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'grammar/grammar_test.go') 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 @@ -1023,6 +1023,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: ` -- cgit v1.2.3