[antlr-interest] A question about multiple alternatives

Alexandre Porcelli porcelli at uol.com.br
Sun Oct 22 16:04:58 PDT 2006


I´d like to know from you how could I solve this problem....

   I'm developing a Cobol Grammar using v3. The "IF" statement in
cobol language there isn't block to define scopes, for this there is
just the "." token to say it has finished.
  For this I created a nestedIfStatement that is the same as If but
with no ".", but with my approach I got always a message :

"[19:50:39] CobolParser.g:891:3: Decision can match input such as
"'ELSE'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
[19:50:39] CobolParser.g:892:3: Decision can match input such as
"'END-IF'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input"


Here is a piece of my code:

imperativeStatementList
	:	imperativeStatement+
	;

imperativeStatement
	:	acceptStatement
	|	addImperativeStatement
	|	alterStatement
	|	callImperativeStatement
	|	cancelStatement
	|	closeStatement
	|	computeImperativeStatement
	;

ifStatement
	:	'IF' generalCondition 'THEN'? (nestedIfStatement |
imperativeStatementList nestedIfStatement?)
		('ELSE' (nestedIfStatement | imperativeStatementList nestedIfStatement?) )?
		'END-IF'? DOT
	;

nestedIfStatement
	: 	'IF' generalCondition 'THEN'? (nestedIfStatement |
imperativeStatementList nestedIfStatement?)
		('ELSE' (nestedIfStatement | imperativeStatementList nestedIfStatement?))?
		'END-IF'?
	;

Does anyone has any sugestion?

Thanks in Advance,
Alexandre Porcelli


More information about the antlr-interest mailing list