[antlr-interest] Re: optional sub rules

mklogic <mklogic at yahoo.com> mklogic at yahoo.com
Wed Feb 19 10:43:10 PST 2003


I think you are right, the problem is probably my use of optional 
rule. 

I was trying to come up with a rule for XML Schema's "all" group, 
where all elements inside "all" may appear once or not at all.
Assuming A,B, and C are elements that have minOccurs = 0, we will 
have the following rule. If we also assume minOccurs = 0 for "all" 
group itself, we will need to add ()* for zero or more according to 
antlr doc. 

Is what I am doing incorrect? 

all: ((A)? (B)? (C)?)*




--- In antlr-interest at yahoogroups.com, Terence Parr <parrt at j...> 
wrote:
> 
> On Tuesday, February 18, 2003, at 10:32 PM, mklogic <mklogic at y...> 
> wrote:
> 
> > Could you give me an example of a rule that has all sub rules
> > optional and doesn't generate nondeterminism warning? Thanks
> 
> a : b A ;
> 
> b : (B)? (C)? (D)? ;
> 
> It is your use of the optional rule not the optional rule that is 
the 
> problem :)
> 
> Terence
> --
> Co-founder, http://www.jguru.com
> Creator, ANTLR Parser Generator: http://www.antlr.org
> Lecturer in Comp. Sci., University of San Francisco


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list