Hacker News new | ask | show | jobs
by nly 3537 days ago
Well, an alternative approach might to not to couple parsing and state manipulation :)

PEGTL does this. Approximately, you have a template parameter MyAction<> on the Parser<> template which in turn calls "MyAction<Rule>::apply (state)" when parsing of each rule is complete.

It's a fantastic library. I highly recommend giving it a whirl.

[0] https://github.com/ColinH/PEGTL/blob/master/doc/Actions-and-...