[antlr-interest] Syntactic predicate or not...

Tomasz Bluszcz moviem at web.de
Tue Jan 25 09:40:18 PST 2005


Hi,
my lexer contains the following rules...
The difference between LegalName and LegalNameEx is that the LegalNameEx
containst the special character '.'  and the first char must not be a
letter.
My problem is to write the right LEGALNAME_OR_LEGALNAMEEX_OR_INT rule... I
think it is completely wrong..
Is it necessary to use a syntactic pradicate?


Many thanks ... Tom


protected DIGIT		:('0'..'9');
protected INT		:(MINUS)? ( DIGIT )+;

protected DOT		:'.';
protected LETTER		:('a'..'z' | 'A'..'Z' | '_');

protected LEGALNAME
options {
	testLiterals = true;
	paraphrase = "LegalName";
} :(LETTER) (LETTER|DIGIT)*;

protected	LEGALNAMEEX
options {
	testLiterals = true;
	paraphrase = "LegalNameEx";
} : ( DOT | LETTER | DIGIT )+;


LEGALNAME_OR_LEGALNAMEEX_OR_INT
options {
	testLiterals = true;
	paraphrase = "LegalName_OR_LegalNameEx_OR_Int";
}	
	:(( DOT | DIGIT | BACKSLASH )+) => LEGALNAMEEX 
	|( LETTER (LETTER|DIGIT)*) => LEGALNAME { $setType(LEGALNAME); }
	|( INT ) { $setType(INT); }
	;




More information about the antlr-interest mailing list