[antlr-interest] Abstract syntax tree

John D. Mitchell johnm-antlr at non.net
Wed Feb 23 06:38:44 PST 2005


>>>>> "Marcel" == Marcel Cerveny <mcerveny at gmail.com> writes:
[...]

> Accordingly, I have in the parser spec something like this: interf :
> (scope)? I_IDENT! IDENTIFIER^ (body) ; scope : (PUBLIC|PRIVATE) ; body :
> ...

> I was hoping for structure like this: interf |_ ITest |_ scopeConditional
> |_ present: bool |_ scope: private/public ...  Thus, I could do something
> like if (interf.scopeConditional.present) { ...  }

> Can anyone wake me up and give me some hints or put me to the right
> track?  Thanx in advance.

One of the key tricks is reducing the complexity in each successive stage.

Don't make things in the AST optional.  I.e., in your parser, build an AST
that has either a SCOPE node or a NO_SCOPE node.

Have fun,
	John




More information about the antlr-interest mailing list