kaby76 / Piggy

A transformational system for ASTs, including generation of a p/invoke API from C++ headers.
MIT License
32 stars 0 forks source link

Listener vs Visitor patterns #7

Open kaby76 opened 5 years ago

kaby76 commented 5 years ago

Antlr has both a visitor and listener pattern implementation. See https://saumitra.me/blog/antlr4-visitor-vs-listener-pattern/ . Piggy needs a similar pattern with syntax. At the moment, Piggy patterns are visitor patterns, in which once matched in a pass, the node and entire sub-tree eliminated from further pattern matching.

kaby76 commented 5 years ago

This is very important. I want to special case special cases for parameters of functions. I can do special case a parameter--but only by special casing the match for the entire function declaration. What I want is to add in a pattern specific for the parameter without adding in a whole new pattern for functions.