[antlr-interest] Grammar Ambiguity

Johannes Luber jaluber at gmx.de
Tue May 22 11:14:51 PDT 2007


Hi,

The following grammar snippet is ambiguous, but I can't think of a way
to remove it. I have to solve this in lexer mode only, so switching to
parser rules isn't possible. Has anyone an idea how to solve this problem?

DELIMITED_COMMENT
	:	'/*' DELIMITED_COMMENT_SECTION* ASTERISKS '/'
	;
		
fragment DELIMITED_COMMENT_SECTION
	:	NOT_ASTERISK
	|	ASTERISKS NOT_SLASH
	;

fragment ASTERISKS
	:	'*'+
	;
	
fragment NOT_ASTERISK
	:	~'*' // Any Unicode character except *
	;
	
fragment NOT_SLASH
	:	~'/' // Any Unicode character except /
	;

Thanks in advance,
Johannes Luber


More information about the antlr-interest mailing list