[antlr-interest] null pointer to ADAPTOR->setTokenBoundaries
John B. Brodie
jbb at acm.org
Wed May 19 15:36:07 PDT 2010
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
More information about the antlr-interest
mailing list