[antlr-interest] greedy question

Pierre Attar pat at tireme.fr
Tue Mar 18 14:14:56 PDT 2008


Gavin,

Thanks a lot, this solve my problem.
At the beginning, I've tried without using a lexer rule, keeping on to 
work at parser level, but this was not working.
So, I need to do some easy text trimming in action rules... not a problem.

Once more, thanks.

Pierre


Gavin Lambert a écrit :
> At 11:11 17/03/2008, Pierre Attar wrote:
> >Finally, I solve this problem by adding a star to the content for
> >repetition:
> >string : 'string["' (options {greedy=false;} : . )* '"]' ;
> >
> >The remaining problem is that I always have the following message
> >1>..\resources\mff.g3pl(234,87) : warning 200 : Decision can match
> >input such as "'"]'" using multiple alternatives: 1, 2 As a result,
> >alternative(s) 1 were disabled for that input
> >
> >How ca I say something like "any thing but not "]" for solving
> >ambiguity ?
>
> Spell it out explicitly:
>
> STRING : 'string["' (~('"') | '"' ~(']'))* '"]';
>
> (Note the upper case as well.  This should almost certainly be a lexer 
> rule, not a parser rule.)
>
>
>




More information about the antlr-interest mailing list