<div dir="ltr">Hi there,<div><br></div><div>total clang/llvm n00b here. I'm building a multilingual static analysis tool which has parsers for individual languages export an appropriately tagged language-agnostic AST for a single analyser binary to process. So far I've been using native parsers for Ruby and Go and <a href="http://www.antlr.org/">ANTLR</a>-based one for Swift.</div><div><br></div><div>ANTLR in particular won my heart because of it's <a href="http://www.antlr.org/api/Java/org/antlr/v4/runtime/tree/ParseTreeListener.html">Listener API</a> where 3 generic methods are provided:</div><div><br></div><div><div>void<span class="" style="white-space:pre">     </span>enterEveryRule(ParserRuleContext ctx) </div><div>void<span class="" style="white-space:pre">        </span>exitEveryRule(ParserRuleContext ctx) </div><div>void<span class="" style="white-space:pre"> </span>visitTerminal(TerminalNode node) </div><div><div><br></div><div>You can also subscribe to 'enter' and 'exit' events for particular rules that you find particularly interesting. So for a given rule you'd have four callbacks triggered - enterEveryRule, enterParticularRule, exitParticularRule, exitEveryRule - in this particular order. There is also concept of TerminalNodes which are things like literals etc.</div><div><br></div><div>Since this sort an API what feels most natural for the task at hand I would kindly like to solicit your advice on how to go about replicating it in clang.</div><div><br></div><div>Thanks in advance!</div><div><br></div><div>Best,</div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Marcin Wyszynski</div><div><br></div><div><i><font color="#999999">-- Everyone you meet is fighting a battle you know nothing about. Be kind.</font></i><br></div></div></div></div></div>
</div></div></div>