[antlr-interest] WORKAROUND: Re: TreeParser fails to find matched node in input tree
micheal_jor
open.zone at virgin.net
Wed May 7 14:50:46 PDT 2003
OK, I got this working. I consider this a workaround for this issue
unless someone can show me that I've missed some fundamental point
about the capability of the TreeParser's tree-pattern matching
ability. This is what I did:
classDecl
: #( CLASS IDENT
#( BASE (typeName)* )
#( BODY memberDecls RCURLY )
)
memberDecls
: #( MEMBERS
( memberDecl )*
)
I changed the Parser and TreeParser to collect all memberDecl nodes
into a subtree that has a MEMBER node as it's root (see the changed
memberDecls rule). I was actually planning to do this but I didn't
expect that it would be required.
Cheers,
Micheal
> Update:
>
> As a kind of sanity check, I have modified the grammar to generate
> Java and C++ instead and the relevant section of the output is the
> same. This issue would be present in a Java and C++ version of the
> TreeParser too.
>
> Is this related to the complexity of the pattern the TreeParser is
> matching in the classDecl rule?. Should I split the rule into a
> number of less complex rules? e.g.
>
> classDecl
> : #( CLASS IDENT
> baseSpec
> body
> )
>
> Cheers,
>
> Micheal
>
>
> > Given the rules below (assume memberDecl is properly defined), my
> > TreeParser always complains about the RCURLY not being found (it
> > finds ASTNULL instead) even though the RCURLY is definitely in
the
> > input tree.
> >
> > classDecl
> > : #( CLASS IDENT
> > #( BASE (typeName)* )
> > #( BODY memberDecls RCURLY )
> > )
> >
> > memberDecls
> > : ( memberDecl )*
> >
> > I am using ANTLR/C# and I just wanted to check this isn't a known
> > issue.
> >
> > Cheers,
> >
> > Micheal
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list