[antlr-interest] Problem building a real parser using v3

Kay Roepke kroepke at classdump.org
Mon Oct 2 16:08:49 PDT 2006


Hi Alexandre!

On 3. Oct 2006, at 0:21 Uhr, Alexandre Porcelli wrote:

> I just cut off the getCharPositionInLine() test and the problem  
> still.... :(
> In fact... I couldn't see anything really different.

Ok. I just tried again, and the culprit seems to be the semantic  
predicate on COMMENT_ENTRY.
The set afterwards ( (~'.')+ is a huge set!) seems to blow up the DFA  
construction. Maybe you can try something else besides the sempred,  
I'm a bit short on time at the moment, but removing that predicate  
eliminates the special transitions almost completely.
It is pretty logical, when you think about it, since ANTLR has to  
include the sempred for every decision that involves ~'.' at a  
possible edge. That essentially gives you every combination of pair- 
wise different characters in the lookahead, which virtually is every  
token in your grammar. Since the semantic predicate can't go into the  
DFA tables, it must go into specialStateTransitions(int) and that is  
a lot of code :(

My advice, FWIW:
Try to do away with the semantic predicate or more closely specify  
what can constitute a COMMENT_ENTRY, rather than saying ~'.'. That  
should give you fewer special states.

HTH,

-k





More information about the antlr-interest mailing list