Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
crocodsl
grammar only defined partial expressions, without any rule to parse a complete input in one go. Because of this, callingparser.expr()
on any input would simply stop without error when a full expression was parsed even if the input token stream was not fully consumed. This led to the following situation:The
Gte 6
piece was unrecognized by theexpr
method so it was simply ignored, since the LHS parsed correctly. The supposed functionGte
would have caused an error ifexpr()
was called again, but it never was. The function should have beenGe
, which would have caused the entire input to be consumed, since it was a valid comparator expression.The fix is to add a
program
rule to the grammar which is defined asexpr + EOF
. This will inspire the parser to consume the entire input, raising one of several different types of errors if it can't. In this case, we would have hit anAttributeError
when it tried to look up the functionGte
infunc.py
, since the unrecognized string would be parsed as an infix expression. (We will now catch that exception and re-raise as a SyntaxError.)