[antlr-interest] Dangling ELSE on Cobol
Nilo Roberto C Paim
nilopaim at gmail.com
Thu Sep 20 12:20:16 PDT 2012
Hi, folks.
I'm trying to parse Cobol sources using Antlr 3.4 (ANTLR Parser Generator
3.4 Jul 19, 2011 11:35:12. actually).
I'm stuck with the old dangling ELSE problem. Here the relevant piece of
code of my grammar that shows me the problem:
command :
ifCmd
| initializeCmd
| moveCmd
| openCmd
;
ifCmd:
IF expr command+ ( (ELSE)=> ELSE command+)?
;
I cannot put a terminator on the commands 'cause commands in Cobol may end
or with a '.' or with the following command. This is true including the
ifCmd itself.
The code above shows me the following messages:
warning(200): /SuperCobol/src/SC.g:229:13:
Decision can match input such as "IF" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
|---> IF expr command+ ( (ELSE)=> ELSE command+)?
warning(200): /SuperCobol/src/SC.g:229:13:
Decision can match input such as "MOVE" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
|---> IF expr command+ ( (ELSE)=> ELSE command+)?
warning(200): /SuperCobol/src/SC.g:229:13:
Decision can match input such as "OPEN" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
|---> IF expr command+ ( (ELSE)=> ELSE command+)?
warning(200): /SuperCobol/src/SC.g:229:13:
Decision can match input such as "INITIALIZE" using multiple alternatives:
1, 2
As a result, alternative(s) 2 were disabled for that input
|---> IF expr command+ ( (ELSE)=> ELSE command+)?
warning(200): /SuperCobol/src/SC.g:229:38:
Decision can match input such as "IF" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
|---> IF expr command+ ( (ELSE)=> ELSE command+)?
warning(200): /SuperCobol/src/SC.g:229:38:
Decision can match input such as "MOVE" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
|---> IF expr command+ ( (ELSE)=> ELSE command+)?
warning(200): /SuperCobol/src/SC.g:229:38:
Decision can match input such as "OPEN" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
|---> IF expr command+ ( (ELSE)=> ELSE command+)?
warning(200): /SuperCobol/src/SC.g:229:38:
Decision can match input such as "INITIALIZE" using multiple alternatives:
1, 2
As a result, alternative(s) 2 were disabled for that input
|---> IF expr command+ ( (ELSE)=> ELSE command+)?
8 warnings
Please, any hints?
Thanks in advance,
Nilo
Brazil
More information about the antlr-interest
mailing list