[antlr-interest] Problem building a real parser using v3
Loring Craymer
lgcraymer at yahoo.com
Mon Oct 2 16:54:56 PDT 2006
Kay's first suggestion--do away with the sempred--is probably the best. Change the lexer rules which set comentEntryMode to true to incorporate the COMMENT_ENTRY DOT items and do away with the corresponding parser rules. If you really need the COMMENT_ENTRY text, you then just need to trim the leading 'SECURITY' ('.')? (and similar) and trailing '.' to get it.
--Loring
Kay Roepke <kroepke at classdump.org> wrote: 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
---------------------------------
Do you Yahoo!?
Next-gen email? Have it all with the all-new Yahoo! Mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20061002/05f33caa/attachment.html
More information about the antlr-interest
mailing list