Skip to content

Commit

Permalink
Don't crash on valid input (i.e named empty terms
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Gordon committed Feb 13, 2020
1 parent d45e0aa commit 50a1cd5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion wbnf/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ func buildAtom(atom AtomNode) parser.Term {
case "term":
return buildTerm(atom.OneTerm())
}
panic("bad input")
// Must be the empty term '()'
return parser.Seq{}
}

func buildQuant(q QuantNode, term parser.Term) parser.Term {
Expand Down
8 changes: 8 additions & 0 deletions wbnf/grammar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,11 @@ func TestCombo2(t *testing.T) {
assert.NoError(t, err)
log.Print(p.Grammar())
}

func TestEmptyNamedTerm(t *testing.T) {
t.Parallel()

p, err := Compile(`x -> rel=();`)
assert.NoError(t, err)
log.Print(p.Grammar())
}

0 comments on commit 50a1cd5

Please sign in to comment.