[antlr-interest] more lexical determinism

howardckatz howardk at fatdog.com
Wed Dec 5 12:26:55 PST 2001


I can see why I'm getting a lexical nondeterminism error in the 
following, since the lexer has no way of knowing whether "ABCDE" for 
example is a Word or an Identifier, but I can't see how to resolve
the amibiguity, using a predicate or otherwise. What's the easiest 
way to do this?

Thanks,
Howard


class TestParser extends Parser;

message:	(pair)+;

pair:		Identifier COLON Word;

class TestLexer extends Lexer;

Identifier:	( Letter | '_' ) (Letter | Digit)*;

Word:		(Letter)*;

protected
Letter: 	'a' .. 'z' | 'A' .. 'Z';

protected
Digit:		'0' .. '9';

COLON:		':';

WS :		( ' ' | '\t' | "\r\n" | '\n' | '\r' )
   		{ $setType(Token.SKIP); };



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list