[cfe-users] Help needed: ANTLR-like API on top of clang AST
Marcin Wyszyński via cfe-users
cfe-users at lists.llvm.org
Sun Feb 21 07:14:58 PST 2016
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 ANTLR
<http://www.antlr.org/>-based one for Swift.
ANTLR in particular won my heart because of it's Listener API
3 generic methods are provided:
void enterEveryRule(ParserRuleContext ctx)
void exitEveryRule(ParserRuleContext ctx)
void visitTerminal(TerminalNode node)
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.
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
Thanks in advance!
*-- Everyone you meet is fighting a battle you know nothing about. Be kind.*
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-users