JMESPath let expression with operator in variable binding#691
Open
BartelNieuwenhuyse wants to merge 2 commits intodanielaparker:masterfrom
Open
Conversation
Owner
|
I figured this was coming :-) I'll review it when I have a chance. But I think the approach is basically right. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix for issue #690
I've added an implicit lparen '(' when encountering the '=' of the let expression, such that the operator stack can be rewind when hitting the ',' or 'in' of the let-expression.
I've stored the name of the variable in a variable token when encountering the '=', rather than storing it in the expression_context. And use this variable token to mark the start of the binding expression, rather than storing the end_index in the expression_context. I'm not sure if after this change, expression_context has any other use as it seems to be an empty class now.
When hitting the ',' or 'in' of the let-expression the variable token and the tokens of the expression, including the operator stack up until the implicit lparen '(' are moved into the variable_expression, which on evaluation will evaluate the tokens, store the result in the context and return the original document at the start of the let expression.
Moved this logic to push_token, rather than (duplicating it) in the compile function