[antlr-interest] ANTLR3 question

Manu manunews at gmail.com
Mon Nov 6 10:36:59 PST 2006


Hi,

I'm working with the latests ANTLR release and with this rules:

attribute_arguments: LEFT_BRACKET (positional_argument_list? |
(positional_argument_list COMMA named_argument_list) |
named_argument_list) RIGHT_BRACKET;

positional_argument_list: (positional_argument) (COMMA positional_argument)*;

positional_argument: attribute_argument_expression;

named_argument_list: (named_argument) (COMMA named_argument)*;

named_argument: identifier EQUALS attribute_argument_expression;

attribute_argument_expression: expression;

expression
	:	literal
	;

literal
	:	TRUE | FALSE
	| 	INTEGER_LITERAL
	| 	REAL_LITERAL
	|	CHARACTER_LITERAL
	|	STRING_LITERAL
	|	NULL
	;

I get the following message:

Decision can match input such as "<EPSILON>" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input

for the rule: attribute_arguments

I assume that ANTLR reports multiple alternates for the rule because
internally it works with the unfactored rule like this:

attribute_arguments
	:	LEFT_BRACKET positional_argument_list? RIGHT_BRACKET
	|	LEFT_BRACKET positional_argument_list COMMA named_argument_list RIGHT_BRACKET
	|	LEFT_BRACKET named_argument_list RIGHT_BRACKET
	;

So that's why it reports two alternates, right?

Anyway, from the first alternate, <EPSILON> can be obtained because
the positional_argument_list is optional, but I don't see how
<EPSILON> can be obtained in the second one. Am I missing something or
is it a bug?

This happens with options k=4;

I'm a newbie in ANTLR so I'd appreciate help.

Thanks a lot,
Manu


More information about the antlr-interest mailing list