Skip to content

Commit

Permalink
Merge pull request #5 from skuid/bug-demo
Browse files Browse the repository at this point in the history
PLIN-1851: Fixed a bug in parsing found during the demo
  • Loading branch information
Brian Newton authored Nov 9, 2018
2 parents c43eb0f + be09570 commit 905e2eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ func Parse(logic string) (Node, error) {
Reason: "unbalanced parenthesis",
}
}

if p.kind == OP {
return nil, &ParseError{
Position: len(logic) - p.buffer.Len(),
Logic: logic,
Reason: "unexpected operation",
}
}

if err := p.eval(len(logic)); err != nil {
if perr, ok := err.(*ParseError); ok {
perr.Logic = logic
Expand Down
9 changes: 9 additions & 0 deletions parse/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ func TestParseErrors(t *testing.T) {
Reason: "unexpected operation",
},
},
{
"Should fail with a missing leaf after last operation",
"1 AND",
&ParseError{
Position: 2,
Logic: "1 AND",
Reason: "unexpected operation",
},
},
{
"Should fail with an unacceptable operation",
"1 FOO 3",
Expand Down

0 comments on commit 905e2eb

Please sign in to comment.