[antlr-interest] Unexpected Token problem

Meena Moktali mmoktali at bphx.dk
Tue Mar 22 05:00:23 PST 2005

Thnx for the suggestion .I made the necessary changes for reading more text,But now it is not reading consecutive statements 
Its giving the error--

C:\TEMP>java MapMain
line 1:1: unexpected token: map CURRENCY_SPACE in KSPS4_MSG to TEXT_CODE of STD_

I have given the grammar as below-----
class MapsParser extends Parser;


statement:	(mapval)+;						--------anything wrong in these 3 lines??

mapval   :	("map"^ viewfield "to"! viewfield );	--------  ''

viewfield:	(text((IN^|OF^)text)*);				--------  ''

text	   :	IDENT ;

class MapsLexer extends Lexer;


IDENT		options{testLiterals=true;}
	:	('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'\''|' ')('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'\''|' ')*;

WS	:	('\t'
		|'\r''\n' {newline();}
		|'\n'	  {newline();}
		|'\r'	  {newline();}
		|' ')*
IN	:	"in" ;
OF	:	"of" ;

-----Original Message-----
From: Bryan Ewbank [mailto:ewbank at gmail.com]
Sent: 22. marts 2005 14:11
To: antlr-interest
Subject: Re: [antlr-interest] Unexpected Token problem

I think the error is caused because IDENT matched "m" - the lexer rule
shown matches exactly one letter, followed by whitespace:

This needs to change by adding a * after the first set of parenthesis

On Tue, 22 Mar 2005 12:35:24 +0100, Meena Moktali <mmoktali at bphx.dk> wrote:
> class MapsLexer extends Lexer;
> options{k=2;}
> IDENT   :       ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'\'')(WS)* ;

More information about the antlr-interest mailing list