[antlr-interest] Dealing with issues in non-greedy (.)* rules
Terence Parr
parrt at cs.usfca.edu
Thu May 10 13:04:08 PDT 2007
On May 10, 2007, at 12:08 PM, Marc-André Laverdière wrote:
> Hello,
>
> I just wanted to a) share a hack and b) ask for some help dealing
> with blob-matching rules.
>
> I have the following rule:
> sh_code_blob
> : ( options {greedy=false;} : . )*
> {if (false) throw new RecognitionException();};
>
> a) you will notice the "if (false) throw new RecognitionException();"
> This hack takes care of the compilation exception in the generated
> parser for this rule, since the generated code tries to catch an
> exception that won't ever be thrown.
Hmm... i think .+ would be better. .* matches nothing, not a
particularly useful input. ;)
that should remove error.
Ter
More information about the antlr-interest
mailing list