[antlr-interest] Order of token matching

Jenny Balfer ai06087 at Lehre.BA-Stuttgart.De
Wed Sep 3 09:53:50 PDT 2008


great, that's working :-D

I tried something like

IMPL : '{' (COMMENT|IMPL|~'}')* '}' ;

before, but without the predicates it was not working either.

Thanks a lot!

On Wed, 03 Sep 2008 09:46:09 -0700, Jim Idle <jimi at temporal-wave.com>
wrote:
> On Wed, 2008-09-03 at 18:34 +0200, Jenny Balfer wrote:
> 
>> No, it is too long. But I reproduced the error in a short one.
>> An example for the occuring error would be the following string:
> 
> 
> OK - well it would be searching for the } because you didn't tell the
> IMPL about comments :-). You need this (as well as the other stuff being
> fragments):
> 
> IMPL
>         :       '{' (
> 
>         				  (SLCOM|MLCOM)=> COMMENT
>         				| ('{')=>         IMPL
>         				| ~'}'
>         			)*
>         		'}'    {skip();}
>         ;
> 
> Also, in your grammar the paramLists in implementation need to be
> optional.
> 
> Jim
> 
>>
>> isWorking = function(param1,param2) {
>> 	some implementation;
>> 	some expressions;
>> }
>>
>> function throwsError(param1, param2) {
>> 	// this is a nasty comment {
>> 	something else
>> }
>>
>> function isIgnored() {
>> 	// lexer is still searching for a closing brace
>> }



More information about the antlr-interest mailing list