diff options
Diffstat (limited to 'grammar/grammar_test.go')
-rw-r--r-- | grammar/grammar_test.go | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/grammar/grammar_test.go b/grammar/grammar_test.go index 40c07aa..a90ee8b 100644 --- a/grammar/grammar_test.go +++ b/grammar/grammar_test.go @@ -442,6 +442,56 @@ foo `, errs: []*SemanticError{semErrMDInvalidParam}, }, + { + caption: "the `%left` cannot be specified multiple times for a symbol", + specSrc: ` +%name test + +%left foo foo + +s + : foo + ; + +foo + : 'foo'; +`, + errs: []*SemanticError{semErrDuplicateAssoc}, + }, + { + caption: "a symbol cannot have different precedence", + specSrc: ` +%name test + +%left foo +%left foo + +s + : foo + ; + +foo + : 'foo'; +`, + errs: []*SemanticError{semErrDuplicateAssoc}, + }, + { + caption: "a symbol cannot have different associativity", + specSrc: ` +%name test + +%right foo +%left foo + +s + : foo + ; + +foo + : 'foo'; +`, + errs: []*SemanticError{semErrDuplicateAssoc}, + }, } rightTests := []*specErrTest{ @@ -525,6 +575,56 @@ foo `, errs: []*SemanticError{semErrMDInvalidParam}, }, + { + caption: "the `%right` cannot be specified multiple times for a symbol", + specSrc: ` +%name test + +%right foo foo + +s + : foo + ; + +foo + : 'foo'; +`, + errs: []*SemanticError{semErrDuplicateAssoc}, + }, + { + caption: "a symbol cannot have different precedence", + specSrc: ` +%name test + +%right foo +%right foo + +s + : foo + ; + +foo + : 'foo'; +`, + errs: []*SemanticError{semErrDuplicateAssoc}, + }, + { + caption: "a symbol cannot have different associativity", + specSrc: ` +%name test + +%left foo +%right foo + +s + : foo + ; + +foo + : 'foo'; +`, + errs: []*SemanticError{semErrDuplicateAssoc}, + }, } errorSymTests := []*specErrTest{ |