parglare icon indicating copy to clipboard operation
parglare copied to clipboard

Add support for side-effect actions (pull request)

Open jwcraftsman opened this issue 6 years ago • 5 comments

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.

jwcraftsman avatar Aug 01 '18 06:08 jwcraftsman

Coverage Status

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

coveralls avatar Aug 01 '18 13:08 coveralls

Coverage Status

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

coveralls avatar Aug 01 '18 13:08 coveralls

How does this implementation look? It seems to be working for me. Please let me know if this in on the right track. Thanks.

jwcraftsman avatar Aug 20 '18 03:08 jwcraftsman

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.

igordejanovic avatar Aug 20 '18 09:08 igordejanovic

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

jwcraftsman avatar Aug 20 '18 13:08 jwcraftsman