[antlr-interest] Please help with arbitrary arrangements and oldBNF syntax

Matt Benson gudnabrsam at yahoo.com
Fri Dec 16 13:08:58 PST 2005


well, except that, even after my fix, it's probably
much more complicated with the other elements in
Brannon's original example... the part that I skimmed
originally.  ;)

-Matt

--- Geir Ove Skjaervik <geiroves at online.no> wrote:

> Hello,
> 
> Neat ! Surely more elegant than my solution :-)
> 
> 
> Geir Ove
> 
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org
> [mailto:antlr-interest-bounces at antlr.org] On Behalf
> Of Matt Benson
> Sent: 16. desember 2005 21:34
> To: Brannon King; antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Please help with
> arbitrary arrangements
> and oldBNF syntax
> 
> 
> Also, when you have a set as small as three, you
> could
> use this non-scaling approach:
> 
> test
>   :  (  foo (bar (baz)? | baz)?
>      |  bar (foo (baz)? | baz)?
>      |  baz (foo (bar)? | bar)?
>      )?
>   ;
> 
> FWIW,
> Matt
> 
> --- Brannon King <BBKing at starbridgesystems.com>
> wrote:
> 
> > Suppose I have the following parser rule snipped
> > from edif.org:
> > 
> > written :
> > 	LP! "written"
> > 	     timeStamp
> > 	     ( < author > | < program > | < dataOrigin >
> |
> > 	     property | comment | userData )*
> > 	RP!;
> > 
> > Where the angle brackets mean that those can only
> > appear once (in an
> > arbitrary order). How do I enforce this in an
> ANTLR
> > grammar?
> > 
> > In a similar vein, is this the right way to limit
> an identifier 
> > length?
> > 
> > IDENTIFIER
> > 	options {testLiterals=true;} //make sure it's not
> a
> > built in
> > function
> > 	:	(ALPHA|'&')	a:('_'|ALPHA|DIGIT)*
> > {a.getText().length() < 256}? ; //less than 256
> > chars total
> > 
> > Thanks for your time
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 
> 
> 
> 


__________________________________________________
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