[antlr-interest] Grammar Ambiguity
Jim Idle
jimi at temporal-wave.com
Tue May 22 11:29:00 PDT 2007
Did you have some particular issue with:
COMMENT
: '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
;
?
Jim
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Johannes Luber
> Sent: Tuesday, May 22, 2007 11:15 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Grammar Ambiguity
>
> Hi,
>
> The following grammar snippet is ambiguous, but I can't think of a way
> to remove it. I have to solve this in lexer mode only, so switching to
> parser rules isn't possible. Has anyone an idea how to solve this
> problem?
>
> DELIMITED_COMMENT
> : '/*' DELIMITED_COMMENT_SECTION* ASTERISKS '/'
> ;
>
> fragment DELIMITED_COMMENT_SECTION
> : NOT_ASTERISK
> | ASTERISKS NOT_SLASH
> ;
>
> fragment ASTERISKS
> : '*'+
> ;
>
> fragment NOT_ASTERISK
> : ~'*' // Any Unicode character except *
> ;
>
> fragment NOT_SLASH
> : ~'/' // Any Unicode character except /
> ;
>
> Thanks in advance,
> Johannes Luber
More information about the antlr-interest
mailing list