[antlr-interest] Re: [antlr-dev] Hitting method size limit

Emond Papegaaij e.papegaaij at student.utwente.nl
Fri Jun 23 00:12:18 PDT 2006


On Thursday 22 June 2006 23:22, Terence Parr wrote:
> [switching to antlr-interest]
>
> Emond,  I changed the grammar to use fragment instead of protected
> and then chagned NESTED_METHOD_BODY_ACTION to use ~('{'|'\''|'"') instead
> of .  It now terminates, but rules like:
Ah, forgot to change that back. I tried to simplify the grammar to make it run 
through ANTLR.

> A better way is to use the filter=true option.  Then just list the
> tokens with your predicates; ANTLR will backtrack so it will be
> slower but you can do some really ambiguous stuff.  Things seen first
> take precedence.
>
> Look at codegen/action.g in distribution, which is the $x.y
> translator for actions.  It does stuff like:
<cut>
> These are all highly ambiguous but are resolved with predicates that
> fail/succeed after the syntax matches.  The default backtracking of
> the filter makes the lexer rewind and try next rule.  You should see
> a stream of tokens come out like normal even though this is "filter"
> mode.

I can't find these examples, but adding filter=true and moving some tokens did 
the trick. Note that ANTLR still takes very long to generate the parser and 
lexer, over a minute.

Thanks for your help.

Best regards,
Emond Papegaaij


More information about the antlr-interest mailing list