-----Mensagem original----- De: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] Em nome de Parsiad Azimzadeh Enviada em: segunda-feira, 11 de julho de 2011 20:36 Para: antlr-interest@antlr.org Assunto: Re: [antlr-interest] RES: RES: COBOL grammar
That does not make much sense to me (however, I should state that I am too unfamiliar with COBOL). For example, suppose you have program text of the form: procedure division . id1 section . id2 . A . B . How do you know whether the '.' token after 'A' is meant to signify the end of a command and not the end of a block? Parsiad, 'B' is a command. That signifies that the '.' token after 'A' ends 'A' command. If 'B' would be an identifier and not a command, this would signify that the '.' token after 'A' would ends the block (and, by the way, the paragraph 'id2', in your sample). There is another sample I can show: IF some_expression A B ELSE C. The '.' token after C means the end of the 'IF' command. That's the reason why the '.' token after a command is optional. 'A' and 'B' forms a block, that ends with the 'ELSE' (that is optional too). Thanks for your interest. Perhaps a better question would be, is there any semantic value to a block? Can we remove the block rule altogether to yield: grammar COBOL; options { language = Java; } program : 'procedure' 'division' END section * ; section : ID 'section' END paragraph * ; paragraph : ID END ( command END ? ) * END ; // TODO: Put real commands here command : 'A' | 'B' ; fragment LETTER: 'a'..'z' | 'A'..'Z'; END: '.'; ID: LETTER ( LETTER | '0'..'9' | '-' )*; The above grammar is unambiguous. -- Parsiad Azimzadeh http://sfu.ca/~paa4 On Mon, Jul 11, 2011 at 3:39 PM, Nilo Roberto C Paim <nilop...@gmail.com>wrote: > 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-boun...@antlr.org > [mailto:antlr-interest-boun...@antlr.org] Em nome de Ron Burk > Enviada em: segunda-feira, 11 de julho de 2011 19:24 > Cc: antlr-interest@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 > 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 -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.