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

Tomasz Bluszcz moviem at web.de
Tue Jan 25 22:10:43 PST 2005


Thx... This strategy works fine... :)

Tom

> -----Ursprüngliche Nachricht-----
> Von: Tomasz Bluszcz [mailto:moviem at web.de]
> Gesendet: Dienstag, 25. Januar 2005 18:40
> An: antlr-interest at antlr.org
> Betreff: Syntactic predicate or not...
>
>
> 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