[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnubol: DIVISION/SECTION headers.



At 09:41 AM 11/14/99 , Michael McKernan wrote:

>My problem arises in Identification Division where, for example, the
>syntax for the AUTHOR paragraph is defined thusly,
>
>    [ AUTHOR.  [comment-entry] ... ]
>
>and is further elucidated by this syntax rule:
>
>    The comment-entry may be any combination of the characters from
>    the computers character set. The continuation...
>
>So, as you see, neither the PERIOD nor the other fixed id-division
>paragraph names are excluded from the definition of comment-entry.
>Not even the next division header stops this thing.

Congratulations, you now understand why Cobol-85 made this obsolete.  In a 
margin-based world, the rest of this line is a comment, and any following 
lines with nothing in 8 thru 11 are also comments.  Some implementors 
interpreted "any combination of characters" to include mismatched 
quotes.  In the 1970s, many Cobol compilers eased margin restrictions, and 
ran into these problems.  Some implementations gag on reserved words:

REMARKS.
     BE SURE TO INCLUDE THIS IN THE CALLING PROGRAM.
         DATA DIVISION.
         WORKING-STORAGE SECTION.
             COPY "STD-PARAMS".

The "easy" fix was to make the identification division fixed form 
anyway.  For Cobol-85, J4's answer was just use * comments.

When Cobol was born, a program source was regarded as a sequence of cards 
or card images.  Once you look at a program source as a sequence of 
language tokens, some of the early Cobol rules are foolish or nonsensical.

BTW, Tim, you would expand that COPY, right?  Don't worry, that's not 
necessarily wrong.  The Cobol-74 position on that is "we don't know", while 
Cobol-85 bails out with "that's obsolete, and we're not going to fix 
it."  In theory, we are expected to continue the behavior of our Cobol-74 
compiler.  None such being found, we're free to do just about anything.  I 
say gobble up all the tokens until you hit a division header.  That means 
we die on the above example.  Too bad, but J4 has recognized long ago that 
some programs are non-portable because of this.  Most simple uses of the 
comment paragraphs will work.  If a program gets syntax errors due to 
divisions out of order, and also contains one of these old comment 
paragraphs, we should issue a message something like "REMARKS paragraph is 
obsolete and may cause compilation errors.  Use comment indicator * or 
*>".  If the preprocessor gets errors due to mismatched quotes, a 
mismatched quote error will suffice.

At 10:02 AM 11/12/99 , RKRayhawk@aol.com wrote:
>IMHO in the new world which will lack A-margin and B-margins the paragraph
>names and section names _will_ be a little harder find generally
>
>My frame of reference is tilted from yours.  My theme is that we are not
>compiling all possible valid programs, we are compiling all possible
>programs, period. :) (The English language emphatic 'period' is meant as a
>pun). And the glyph is meant to send your paren balancer off scope.

>So let me change the phrasing, twice.  The first approach is that "a
>separator period comes right before the header."  The second approach is that
>"a separator period SHOULD come right before the header."

A division (or section) header is a sequence of three tokens, and they must 
be the only three tokens on the line.  I had previously said that we should 
identify headers based in part on the preceding separator period.  After 
further thought, I believe we should identify division and section headers 
even if the preceding period is absent.  In fact we should recognize them 
when the trailing period is missing, also.  A header must be on its own 
line; other areas of the language are not line based.

If we identify these headers in preprocessing, we can have a different 
lexer/parser for each division.  I'm not sure the identification division 
needs a grammar.

>In the old world, the compiler can use the A-margin to help out. I confess
>that I am a little confused by the examples depicting procedure headers
>floating around in various places, with posted text describing them as
>acceptable. My confusion is that I can not tell if you are saying that stuff
>is valid code now. Is that COBOL-85, or dialectic extension?

Starting a header after the B-margin is available now as an extension in 
most compilers.  It dates to the 1970s.

--
RB |\  Randall Bart
aa |/  Barticus@usa.net 818-985-3259 Barticus@att.net
nr |\  8321 Burnet Av #1, North Hills, CA 91343
dt ||\
a   |/ Y2K website:    http://users.aol.com/PanicYr00
l   |\
l   |/ DOT-HS-808-065     I Love You    MS^7=6/28/107


--
This message was sent through the gnu-cobol mailing list.  To remove yourself
from this mailing list, send a message to majordomo@lusars.net with the
words "unsubscribe gnu-cobol" in the message body.  For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@lusars.net.