From 9a9444bdc00e2a738fb0aa7cac4afa8a123d679b Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sat, 16 Apr 2022 01:44:33 +0900 Subject: Prohibit using the same element multiple times in the #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 a90ee8b..2bb2358 100644 --- a/grammar/grammar_test.go +++ b/grammar/grammar_test.go @@ -771,6 +771,34 @@ bar `, errs: []*SemanticError{semErrDirInvalidParam}, }, + { + caption: "a symbol can appear in the `#ast` directive only once", + specSrc: ` +%name test + +s + : foo #ast foo foo + ; + +foo + : 'foo'; +`, + errs: []*SemanticError{semErrDuplicateElem}, + }, + { + caption: "a symbol can appear in the `#ast` directive only once, even if the symbol has a label", + specSrc: ` +%name test + +s + : foo@x #ast foo x + ; + +foo + : 'foo'; +`, + errs: []*SemanticError{semErrDuplicateElem}, + }, { caption: "the expansion operator cannot be applied to a terminal symbol", specSrc: ` -- cgit v1.2.3