[antlr-interest] grammar overlapping in a rule

Loring Craymer lgcraymer at yahoo.com
Tue Oct 17 17:23:56 PDT 2006


It is an ambiguity, probably resolved through the use
of symbol tables (to identify Constructors) and
semantic predicates.  I would resolve it by having

operator :  LowerCaseId | UpperCaseId | SpecialId ;

in the parser and distinguishing FunctionName from
Constructor in a tree pass--after you have built a
table of constructors that you can use for lookup. 
Then again, that may not be needed--do you really need
to distinguish constructors from functions in your
application?

--Loring

--- "Jigang (Robert) Sun" <sunjigang1965 at yahoo.com.cn>
wrote:

> The following garmmar is extracted from Clean
> Language Report version 2.1, p113, p116 and p117.
> You can see FunctionName and ConstructorName
> overlapping.
> 
> Operator = FunctionName 
>           | ConstructorName
> 
> FunctionName = LowerCaseId | UpperCaseId | FunnyId
> ConstructorName = UpperCaseId | FunnyId
> 
> LowerCaseId = LowerCaseChar~{IdChar}
> UpperCaseId = UpperCaseChar~{IdChar}
> FunnyId = {SpecialChar}+
> 
> Any ideas?
> 
> Thanks.
> Jigang
> 
> 
> 	
> 
> 	
> 		
>
___________________________________________________________
> 
> Mp3·è¿ñËÑ-иèÈȸè¸ßËÙÏÂ
>
http://music.yahoo.com.cn/?source=mail_mailbox_footer
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the antlr-interest mailing list