[antlr-interest] preserving epsilon derivations when building trees

Mark Snyder marklsnyder at gmail.com
Mon Nov 12 06:37:57 PST 2007


I would like to build ASTs that preserve the
position of optional nonterminals.

For example, given Java syntax rule:
  importDeclaration
    : 'import' 'static'? qualifiedName ('.' '*')? ';'
    -> ^(IMPORT_DECL qualifiedName 'static'? '*'?)

and input:

  import xyz;

I would like to produce a tree like this:
  (IMPORT_DECL (QNAME xyz) EMPTY EMPTY)

Is there a way to do this within ANTRL V3?


Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071112/716c28b2/attachment.html 


More information about the antlr-interest mailing list