[antlr-interest] Abstract syntax tree
Bryan Ewbank
ewbank at gmail.com
Wed Feb 23 07:40:45 PST 2005
To extend on normalizing the tree, I find it easier to avoid "(..)?"
operator when doing tree building; instead, I use an empty alternative
and build the tree explicitly.
// always a scope
interf: scope I_IDENT! IDENTIFIER^ ...
// but it might be empty, but the node is always in the tree
scope
: ( /* NULL MATCH */
{ ## = #[NO_SCOPE]; }
| PUBLIC
| PRIVATE
)
;
On Wed, 23 Feb 2005 06:38:44 -0800, John D. Mitchell
<johnm-antlr at non.net> wrote:
> 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.
More information about the antlr-interest
mailing list