[antlr-interest] null pointer to ADAPTOR->setTokenBoundaries

Jim Idle jimi at temporal-wave.com
Wed May 19 18:27:18 PDT 2010


Possibly, though I suspect your easy work around is to make each alt a subrule. I will look tomorrow.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Alan Condit
> Sent: Wednesday, May 19, 2010 5:01 PM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] null pointer to ADAPTOR-
> >setTokenBoundaries
> 
> On page 164 of "The Definitive Antlr Reference" under the heading
> "Omitting Input Elements" Terrance shows using an empty rewrite rule to
> allow omitting unneeded symbols from the output AST tree.
> 
> This does not say that it could not be causing a problem with the
> generated 'C' code.
> 
> Jim, is there a possibility that this is a problem?
> 
> Alan
> ---
> 
> Alan Condit
> 1085 Tierra Ct.
> Woodburn, OR 97071
> 
> Email -- acondit at ipns.com
> Home-Office (503) 982-0906
> 
> On May 19, 2010, at 3:36 PM, John B. Brodie wrote:
> 
> > Pardon me for butting in.
> >
> > And I have never used the C code generator, but.....
> >
> > On Wed, 2010-05-19 at 14:06 -0700, Alan Condit wrote:
> >
> >> which I assume, based on the comment, is generated from this rule:
> >> line	:	line_number? segment+ K_NEWLINE
> >> 		-> ^(STMT segment+)
> >> 	|	line_number? K_NEWLINE
> >> 		->
> >> 	|	oword_stmt
> >> 		-> ^(STMT oword_stmt)
> >> 	;
> >>
> >> The grammar is for parsing an existing language not one of my
> invention,
> >> and grammatically the newlines delineate a semantic block therefore
> must
> >> be known by the parser, but empty lines are discarded and therefore
> >> should not be in the tree.
> >
> > having an empty RHS of the -> rewrite operator feels well unusual.
> >
> > i am not sure that ANTLR permits a rule which produces no tree when
> > output=AST is present....
> >
> > Maybe try (untested):
> >
> > line : line_number? ( segment+ -> ^(STMT segment+) )? K_NEWLINE
> >     | oword_stmt -> ^(STMT oword_stmt)
> >     ;
> >
> > but i do not know what would happen when no segment is present for
> the
> > above rule....
> >
> > have you considered building a dummy tree node for the empty case and
> > then your tree walker can just ignore it?
> >
> > not sure that i have really helped any, sorry.
> >   -jbb
> >
> >
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address





More information about the antlr-interest mailing list