[antlr-interest] OPEN, EOF ambiguity

Jim Idle jimi at temporal-wave.com
Thu Apr 8 13:07:45 PDT 2010


Your text rule can be empty, you need to rejig your use of + and * or you end up with the empty match in more than one place.

 

Jim

 

From: Cameron Ross [mailto:cross at kojeware.com] 
Sent: Thursday, April 08, 2010 1:05 PM
To: Jim Idle
Subject: Re: [antlr-interest] OPEN, EOF ambiguity

 

These rules give the gist of it...

 

start_rule

          : clif_file EOF

          ;

 

clif_file

          : cltext+

          ;

 

cltext

          : (OPEN CL_MODULE) => module -> ^(CLTEXT module)

          | text -> ^(CLTEXT text)

          ;

                      

module

          : OPEN CL_MODULE interpretablename exclusion_set? cltext CLOSE -> ^(MODULE ^(MODULE_IDENTIFIER interpretablename) exclusion_set? cltext)

          ;

 

text

          : phrase* -> ^(TEXT phrase*)

          ;

...

 

 

 

On Thu, Apr 8, 2010 at 3:57 PM, Jim Idle <jimi at temporal-wave.com> wrote:

You probably need to send the grammar rather than that graphic. It is likely something more fundamental and we cannot see what you predicates are doing from the graphic.

Jim


> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Cameron Ross
> Sent: Thursday, April 08, 2010 12:34 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] OPEN, EOF ambiguity
>
> Hi,
>
> I have a grammar with an ambiguity that I just can't resolve.  When I
> check the grammar using AntlrWorks I get the following: "Decision can
> match input such as "{EOF, OPEN}" using multiple alternatives: 1, 2".
> I've attached a screen grab of the syntax diagram generated by
> AntrlWorks.  I don't understand why ANLTR is thinking that EOF is
> ambiguous with OPEN.  I've checked the grammar and clif_file is the
> only rule that is not referenced from within the grammar, so I don't
> think that ANLTR should see module as a start rule.  Any help is much
> appreciated.
>
> Cameron





List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address




-- 
Kojeware Corporation





More information about the antlr-interest mailing list