Dervall / Piglet

An easier to use parsing and lexing tool that is configurable in fluent code without a pre-build step.
binarysculpting.com
MIT License
91 stars 11 forks source link

Add contextual object for parsing #50

Open Dervall opened 11 years ago

Dervall commented 11 years ago

It would be good to have an option to use a contextual object when parsing. In this case, you would execute the Parse function together with a context object of a chosen type.

At the moment, if you need access to something while doing the parsing you'd need to capture it in a closure when creating the parser which encourages the bad practice of creating the parser anew every time you need to use it.

This could be applicable to symbol tables to determine what parse tree to output among other things. An overload on Configure that accepts another type and returns a new parser constructor which takes reduction functions with two parameters would be nice. This should be fully backwards compatible, the current functions should work as is.

Dervall commented 11 years ago

Leaving this for another release in order to get 1.4 out of the door