Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for side-effect actions (pull request) #56

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

jwcraftsman
Copy link
Contributor

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.

… 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.
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.7%) to 82.937% when pulling 136430f on codecraftingtools:side-effects into c6e4d8a on igordejanovic:master.

@coveralls
Copy link

coveralls commented Aug 1, 2018

Coverage Status

Coverage decreased (-0.4%) to 85.526% when pulling 3228904 on codecraftingtools:side-effects into 39927c4 on igordejanovic:master.

@jwcraftsman
Copy link
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.

@igordejanovic
Copy link
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.

@jwcraftsman
Copy link
Contributor Author

Yes, I agree that the duplicated code should be minimized. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants