[antlr-interest] ANTLR3 has an equivalent of LA(1)?

Johannes Luber JALuber at gmx.de
Tue Feb 10 04:00:36 PST 2009


> Hi all,
> 
> I am new to ANTLR. I have an old grammar to start from. I use antlr3
> with CSharp2 target.
> The condition does not compile:
> 
>  */
> NUM_INT
> 	:	('0'..'9')+ // everything starts with a digit sequence
> 		(	(	{(LA(2)!='.')&&(LA(2)!=')')}?				// force k=2; avoid ".."
> //PSPSPS example ARRAY (.1..99.) OF char; // after .. thinks it's a
> NUM_REAL
> 				'.' {state.type = NUM_REAL;}	// dot means we are float
> 				('0'..'9')+ (EXPONENT)?
> 			)?
> 		|	EXPONENT {state.type = NUM_REAL;}	// 'E' means we are float
> 		)
> 	;
> 
> But,  the function: LA(2)  is not defined? Is there an equivalent?
> 
> Thank you

Being a lexer rule, try using input.LA(2) instead.

Johannes
-- 
Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL 
für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a


More information about the antlr-interest mailing list