[antlr-interest] RES: RES: COBOL grammar
Nilo
nilopaim at gmail.com
Tue Jul 12 13:59:09 PDT 2011
Thanks for your interest, Parsiad.
I was trying just to simplify the sample...
A command inside an 'IF' command can be another 'IF' command. In this case,
I cannot ends the inner 'IF' with a '.', because this will ends the outter
IF too.
On Tue, Jul 12, 2011 at 5:32 PM, Parsiad Azimzadeh <
parsiad.azimzadeh at gmail.com> wrote:
> 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' | '-' )*;
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
--
Nilo Roberto C Paim
TinyCobol Development Team
Brasília - DF - Brazil
More information about the antlr-interest
mailing list