[antlr-interest] RES: RES: COBOL grammar
Parsiad Azimzadeh
parsiad.azimzadeh at gmail.com
Tue Jul 12 13:32:06 PDT 2011
I think I can make some educated guesses as to the syntax you're
trying to describe from your example:
> There is another sample I can show:
> IF some_expression
> A
> B
> ELSE
> C.
The END character is used in an IF statement to terminate it. It is
not an optional element in each statement, it is a required element
for particular statements. See the (unambiguous) grammar below:
grammar COBOL;
options
{
language = Java;
}
program
: 'procedure' 'division' END
section *
;
section
: ID 'section' END
paragraph *
;
paragraph
: ID END
command *
END
;
// TODO: replace with actual commands
command
: 'A'
| 'B'
// Conditional, as shown in your example
| IF expression
command *
ELSE
command *
END
;
// TODO: replace with actual expressions
expression
: 'E0'
| 'E1'
;
fragment LETTER: 'a'..'z' | 'A'..'Z';
END: '.';
IF: 'IF';
ELSE: 'ELSE';
ID: LETTER ( LETTER | '0'..'9' | '-' )*;
More information about the antlr-interest
mailing list