Hacker News new | comments | show | ask | jobs | submit login

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-...

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact