Skip to content

Commit

Permalink
fix(#75): invert core rule check
Browse files Browse the repository at this point in the history
  • Loading branch information
pandatix committed Dec 17, 2024
1 parent c22abe9 commit 0d3270e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion grammar.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ func lexABNF(input []byte, path *Path) (any, error) {
case "=/":
// Block core rules from being used
rule := GetRule(rl.Name, nil)
if rule == nil {
if rule != nil {
return nil, &ErrCoreRuleModify{
CoreRulename: rl.Name,
}
Expand Down
8 changes: 8 additions & 0 deletions grammar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ var ruleAbnf []byte
//go:embed testdata/element.abnf
var elementAbnf []byte

//go:embed testdata/multi.abnf
var multiAbnf []byte

//go:embed testdata/abnf.abnf
var abnfAbnf []byte

Expand Down Expand Up @@ -92,6 +95,11 @@ var testsParseAbnf = map[string]struct {
Validate: false,
ExpectErr: false,
},
"multi": {
Input: multiAbnf,
Validate: false,
ExpectErr: false,
},
"abnf": {
// This test validates we can parse ABNF using ABNF grammar
// and the ABNF structural model :)
Expand Down
2 changes: 2 additions & 0 deletions testdata/multi.abnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a = "a"
a =/ "aa"

0 comments on commit 0d3270e

Please sign in to comment.