Add support for side-effect actions (pull request)#56
Open
jwcraftsman wants to merge 10 commits intoigordejanovic:masterfrom
Open
Add support for side-effect actions (pull request)#56jwcraftsman wants to merge 10 commits intoigordejanovic:masterfrom
jwcraftsman wants to merge 10 commits intoigordejanovic:masterfrom
Conversation
… method. - Added _resolve_side_effects() method to Grammar class, which mimics _resolve_actions(). - Modified constructor and _init_grammar() to pass along side_effects argument to _resolve_side_effects(). - Added call to side_effect action in _call_shift_action and _call_reduce_action Parser methods. Refactored some code out of _call_reduce_action to reduce code duplication between actions and side_effects. - No support for <grammar>_side_effects.py yet.
Contributor
Author
|
How does this implementation look? It seems to be working for me. Please let me know if this in on the right track. Thanks. |
Owner
|
I haven't had a change for a deeper look into it. I'll get to that probably after finishing current rework around error reporting. The thing that I don't like with the current side-effect implementation is that a lot of code is copy-pasted from plain actions. I would like to integrate/generalize that so it would be easier to maintain. I could provide more info when get back to it in the next week or two probably. |
Contributor
Author
|
Yes, I agree that the duplicated code should be minimized. Thanks. |
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.
This pull request was spawned as a result of the discussion in #51.
This branch divides grammar actions into two groups, based on whether their purpose is to 1) construct a parse result (e.g. AST tree nodes) or 2) manipulate external state for use by recognizers or dynamic filters. If the purpose is manipulate external state, then the action is a side-effect action, otherwise it is a standard action.
A new keyword argument "side_actions" was added to the Parser constructor. Support for a _side_actions.py file was also added to grammar.py.
The option added in #45 was removed, as it is no longer necessary, since side_actions are processed regardless of whether build_tree is true or false.