[antlr-interest] Problems with Antlr3 rewrite rules

Jim Idle jimi at temporal-wave.com
Wed Jun 6 08:29:13 PDT 2007


Did you donate to Ter's Beer and Pizza fund? That will probably speed
things up - though it is coming up to end of year at schools so Ter is
probably somewhat busy ;-). Please remember that this is free software
and you can hire help but you cannot sound petulant when you don't get
free help after three days concerning your upgrade from a beta - try
things like Parallel's VM support if you want to complain about
something! ;-)

The best thing to do is to debug the generated code in say Netbeans, so
you can see why you are getting the null pointers and where the tree is
being replaced by the imaginary token. Sometimes you can make things go
away by experimenting with your grammar as in 1) below, so I presume you
can work with that for a while? It may will be that the behavior you are
seeing in 2) is actually what you should expect and what you were
getting previously was an accident.

However, I also have a grammar that used to work, that I have been
meaning to debug for a while, so maybe that will turn out to be the same
thing.

At a guess I would say that 1) seems like a bug, but you have found a
work around, but 2) almost sounds right the way it is doing it now. How
are you getting $ent?

Jim



> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of shmuel siegel
> Sent: Wednesday, June 06, 2007 4:45 AM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Problems with Antlr3 rewrite rules
> 
> We've been told that this mail list is the triage for bug reports.
This
> patient has been languishing in triage for three days. There hasn't
> even
> been any placebos offered. Has there been a specification change? Is
> there one or more bugs here? As I stated, I have a workaround for the
> first issue but none for the second issue.
> 
> I would really like to move up to the release version but these two
> issues are standing in my way. Can I get some help.
> 
> shmuel siegel wrote:
> > It seems that the problems were introduced with the move to
> > RewriteRuleSubtreeStream. I don't see any other substantive changes
> in
> > the generated parser code.
> >
> > Shmuel Siegel wrote:
> >>
> >> I have upgraded my production grammar from 3.0b6 to the release
> >> version. I am having two problems with the rewrite rules. Hopefully
> I
> >> just missed a specification change.
> >>
> >>
> >>
> >>     * Problem 1: When I have subclauses that do rewrites, the final
> >>       rewrite gets a null pointer exception. The following rule
used
> >>       to work but now throws an exception. I avoid the exception if
> I
> >>       extract the parenthesized sub-rule and make it a named rule.
> >>
> >> assignEntityAttr:
> >>
> >>             (
> >>
> >>                         thisNode->thisNode
> >>
> >>                   |     symbolTableElement->symbolTableElement
> >>
> >>                   |     positionalElement->positionalElement
> >>
> >>             )
> >>
> >>             '.' a='attr' op='=' attr=attrValue
> >>             -> ^(ASSIGN[$op] ^($assignEntityAttr PROPERTY[$a])
> $attr)
> >>
> >>             ;
> >>
> >>
> >>
> >>     * Problem 2: Tree construction seems to have changed. I used to
> be
> >>       able to write
> >>           o ^($ent PROPERTY[$a]) where $ent was itself a tree. When
> I
> >>             do it now, I keep the head of the $ent tree but its
> >>             children are replaced by the PROPERTY token.
> >>
> >>
> >>
> >>
> >>
> >> What has changed since b6?
> >>
> >>
> >>
> >> Shmuel
> >>
> >
> >
> 



More information about the antlr-interest mailing list