[antlr-interest] Why and how exactly does ANTLR manage to fail on non recursive grammar for finite language?

Nikolay Ognyanov nikolay.ognyanov at travelstoremaker.com
Wed Aug 12 16:27:32 PDT 2009


You know what, ANTLR can do it after all! With expr alternatives EOF 
terminated it still
issues the warning but then parses correctly

prefix_1 prefix_w suffix suffix
as
(expr(expr1(prefix expr2 (prefix_2 suffix) suffix)EOF))

even though the expr2 option "PREFIX2 SUFFIX" was allegedly disabled. As 
Alice says -
this is becoming "curiosuer and curiosier" :).

Regards
Nikolay

Loring Craymer wrote:
> The EOF won't fix the ambiguity, but it will make ANTLR parse all of
> PREFIX_1 PREFIX_2 SUFFIX SUFFIX
> instead of just parsing
> PREFIX_1 PREFIX_2 SUFFIX
> (as per the "disabling" message) and then "mysteriously" dropping the second SUFFIX on the floor.
>
> --Loring
>
>
>
> ----- Original Message ----
>   
>> From: Sam Barnett-Cormack <s.barnett-cormack at lancaster.ac.uk>
>> To: Loring Craymer <lgcraymer at yahoo.com>
>> Cc: Nikolay Ognyanov <nikolay.ognyanov at travelstoremaker.com>; Jim Idle <jimi at temporal-wave.com>; antlr-interest at antlr.org
>> Sent: Wednesday, August 12, 2009 3:49:48 PM
>> Subject: Re: [antlr-interest] Why and how exactly does ANTLR manage to fail on non recursive grammar for finite language?
>>
>> Loring Craymer wrote:
>>     
>>> Not true; your example can be interpreted either as
>>>
>>> (expr1:  PREFIX_1 (expr2:  PREFIX_2 SUFFIX) SUFFIX )
>>>
>>> or as
>>>
>>> (expr1:  PREFIX_1 (expr2:  PREFIX_2) SUFFIX) SUFFIX
>>>
>>> with the extra SUFFIX belonging to something else
>>>       
>> So, hazarding a guess, would it be okay if expr was EOF-terminated?
>>
>> -- Sam Barnett-Cormack
>>     
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
>
>
>   

-- 

*Nikolay Ognyanov, PhD*
Chief Technology Officer
*TravelStoreMaker.com Inc.* <http://www.travelstoremaker.com/>
Phone: +359 2 933 3832
Fax:     +359 2 983 6475

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090813/24783a7c/attachment.html 


More information about the antlr-interest mailing list