[antlr-interest] Context-Sensitive Follow Sets.. Bug?

Terence Parr parrt at cs.usfca.edu
Sun May 23 10:48:36 PDT 2010


v4 is doing right thing. crap. ok, v3 is doing something crazy. grrr...
Ter
On May 23, 2010, at 10:35 AM, Terence Parr wrote:

> could be. ANTLR v4 also reports something wacky; was coincidentally working on itnow
> T
> On May 23, 2010, at 10:33 AM, Jim Idle wrote:
> 
>> Perhaps this is another instance of not clearing the cached set?
>> 
>> Jim
>> 
>>> -----Original Message-----
>>> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
>>> bounces at antlr.org] On Behalf Of Terence Parr
>>> Sent: Sunday, May 23, 2010 10:13 AM
>>> To: Sameh W. Zaky
>>> Cc: antlr-interest at antlr.org
>>> Subject: Re: [antlr-interest] Context-Sensitive Follow Sets.. Bug?
>>> 
>>> oh. it includes AND (not THE).  That *is* weird.
>>> 
>>> I'll look.
>>> Ter
>>> On May 23, 2010, at 10:06 AM, Sameh W. Zaky wrote:
>>> 
>>>> Here is the same message without formatting:
>>>> 
>>>> ---------- Forwarded message ----------
>>>> From: Sameh W. Zaky <sameh.wz at gmail.com>
>>>> Date: Sun, May 23, 2010 at 3:29 PM
>>>> Subject: [antlr-interest] Context-Sensitive Follow Sets.. Bug?
>>>> To: antlr-interest at antlr.org
>>>> 
>>>> 
>>>> Hello everyone..
>>>> After reading the wiki article
>>>> 
>>> http://www.antlr.org/wiki/display/ANTLR3/Custom+Syntax+Error+Recovery,
>>>> (thanks to Jim Idle, "Yes, you def. deserve a Masters too" ;-)) I
>>> went on
>>>> with developing my own example to test the
>>>> method: computeContextSensitiveRuleFOLLOW() (described here:
>>>> 
>>> http://www.antlr.org/api/Java/classorg_1_1antlr_1_1runtime_1_1_base_rec
>>> ognizer.html#2b566e00e5d771f66dd4e29a4a27a1c4
>>>> )
>>>> The method works perfectly in all cases except in the case of zero or
>>> one,
>>>> Consider the following simple grammar:
>>>> 
>>>> 
>>> =======================================================================
>>> ======================
>>>> 
>>>> start : animal (AND acClass)? service EOF;
>>>> 
>>>> animal : (DOG | CAT );
>>>> service : (HARDWARE | SOFTWARE) ;
>>>> AND : 'and';
>>>> DOG : 'dog';
>>>> CAT : 'cat';
>>>> HARDWARE: 'hardware';
>>>> SOFTWARE: 'software';
>>>> 
>>>> acClass
>>>> @init
>>>> {
>>> System.out.println(computeContextSensitiveRuleFOLLOW().toString());}
>>>>  :     ;
>>>> 
>>> =======================================================================
>>> ==============
>>>> 
>>>> Testing this grammar, with let's say input:
>>>> "dog and software",
>>>> the result in the console is:
>>>> "{4, 7, 8}" (which stands for tokens {THE, HARDWARE, SOFTWARE}),
>>>> although it is supposed to be:
>>>> "{7,8}" (which stand for tokens {HARDWARE, SOFTWARE} only).. Because
>>> after
>>>> acClass in start rule, if we get "the" as next token this will make
>>> the
>>>> input invalid..
>>>> 
>>>> Any idea why this happens? Or how we can overcome it?
>>>> Thanks a bunch..
>>>> --
>>>> Sameh W. Zaky
>>>> 
>>>> 
>>>> Regards
>>>> --
>>>> Sameh W. Zaky
>>>> 
>>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-
>>> interest/your-email-address
>>> 
>>> 
>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
>>> email-address
>> 
>> 
>> 
>> 
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list