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

Brannon King BBKing at starbridgesystems.com
Fri Dec 16 11:45:32 PST 2005


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


More information about the antlr-interest mailing list