[antlr-interest] RES: RES: COBOL grammar

George S. Cowan cowang at comcast.net
Wed Jul 13 04:18:13 PDT 2011


Nilo,

I'm an old COBOL hacker from way back, so I understand COBOL periods,
although I don't know what version of the COBOL standards that your compiler
is using.

I think the way to solve the problem with periods is to make it optional for
every statement. Then, right after a new paragraph header is encountered,
check the previous token to make sure that it is a period. Try the
validating semantic predicate

  { ((Token)input.LT(-1)).getText().equals(".") }?

(Does anyone know a simpler way to do that?)

George
 

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Nilo Roberto C Paim
> Sent: Monday, July 11, 2011 6:39 PM
> To: 'Ron Burk'
> Cc: antlr-interest at antlr.org
> Subject: [antlr-interest] RES: RES: COBOL grammar
> 
> Hi, Ron.
> 
> Glad to say that I'm the maintainer of TinyCobol.
> 
> What I'm trying to do here is write a new version of it, using Antlr.
> In
> this new version, I want to implement a lot of things that does not
> exists
> today, like native GUI and native access to RDBMS in general. Also, I'm
> going to generate 'executables' for Java JVM and for .Net CIL. Current
> TinyCobol generates assembly code for 32 bits only, and I think this is
> a
> big limitation for it now.
> 
> But let's go to the real problem...
> 
> A command in Cobol may or may be not terminated by '.'. All sequence of
> commands terminated by only one '.' are a block. A sample of this are
> the
> commands in the 'then' or the 'else' part of an 'IF' command. In this
> case,
> the first '.' found on the end of some command terminates not only the
> command, but the 'IF' command as a whole.
> 
> Additionally, a '.' must be the last token between paragraphs. Alias,
> the
> command sequence on a paragraph needs only the final '.', if I want.
> 
> There is no way I could say if a '.' belongs to the preceding command
> or if
> it enclosing the current paragraph, except by the fact that, if the
> following token is a section name or a new paragraph, it quits the
> current
> paragraph; else it quits a block.
> 
> Maybe I'm just missing the way to say that to Antlr. As I've already
> said,
> I'm a newbie.
> 
> Thanks for interest and sorry the poor English. I'm Portuguese native
> speaker.
> 
> Nilo - Brazil
> 
> -----Mensagem original-----
> De: antlr-interest-bounces at antlr.org
> [mailto:antlr-interest-bounces at antlr.org] Em nome de Ron Burk
> Enviada em: segunda-feira, 11 de julho de 2011 19:24
> Cc: antlr-interest at antlr.org
> Assunto: Re: [antlr-interest] RES: COBOL grammar
> 
> > What else am I missing?
> 
> Are you certain you mean the '.' at the end of the command
> to be optional? An initial scan seems to indicate only one
> optional '.' in the tinyCobol grammar, in procedure declarations.
> 
> Likewise, an uneducated glance at another COBOL grammar:
>     http://www.cs.vu.nl/grammarware/browsable/cobol/#EBNF
> seemed to indicate the "." is rarely optional.
> 
> Or put another way, at the end of a command, what are
> the precise rules for deciding whether a '.' belongs to
> the current command or to the enclosing paragraph?
> If you can state an unambiguous rule for making that decision,
> you can probably force ANTLR to do it.
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address



More information about the antlr-interest mailing list