[antlr-interest] ANTLR 3.0 -> 3.1.1 Broke Working Parser
Randall R Schulz
rschulz at sonic.net
Tue Oct 7 09:07:42 PDT 2008
Hi,
I've just discovered that an ANTLR parser created using version 3.0 that
I'd been using successfully for over a year is broken now that I rebuilt
it using ANTLR 3.1.1.
The rules in question (hopefully this tiny excerpt is sufficient for
someone to recognize a change between 3.0 and 3.1) are:
termSequence
: ( term | SequenceMark ) *
;
atom
: ( Open term termSequence Close )
-> ^( Atom term termSequence )
| ...
("Open" and "Close" are left and right parens. "SequenceMark" is an
ellipsis, "...". "Atom" is a pseudo-token.)
This is eliciting the following excpetion on inputs in which there are
zero repetitions of the RHS of termSequence:
Exception in thread "main" org.antlr.runtime.tree.RewriteEmptyStreamException: rule termSequence
at org.antlr.runtime.tree.RewriteRuleElementStream._next(RewriteRuleElementStream.java:158)
at org.antlr.runtime.tree.RewriteRuleElementStream.nextTree(RewriteRuleElementStream.java:145)
at tau.cl.CLIFParser.atom(CLIFParser.java:2460)
The relevant CLIFParser.java code is:
root_0 = (CommonTree)adaptor.nil();
// 673:2: -> ^( Atom term termSequence )
{
dbg.location(673,5);
// CLIF.g:673:5: ^( Atom term termSequence )
{
CommonTree root_1 = (CommonTree)adaptor.nil();
dbg.location(673,8);
root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(Atom, "Atom"), root_1);
dbg.location(673,13);
adaptor.addChild(root_1, stream_term.nextTree());
dbg.location(673,18);
adaptor.addChild(root_1, stream_termSequence.nextTree());
adaptor.addChild(root_0, root_1);
}
}
Please let me know if:
1) This is a known change (or fix) in ANTLR from 3.0 to 3.1.1
1a) If so, what is the fix for my grammar
2) This is not enough information to go on.
Thanks.
Randall Schulz
More information about the antlr-interest
mailing list