[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Parsing nested statements: was Re: gnubol: subsets
>>>>> "Boris" == Boris Kortiak <BKortiak@genlyte.com>
>>>>> wrote the following on Mon, 29 Nov 1999 10:05:48 -0500
Boris> Results from test using sample program provided with
Boris> following changes: 1) all "size" phrases changed to "ON SIZE
Boris> ERROR" 2) inserted numbers by adding 6 columns at beginning
Boris> of text. Numbers start at 1000 and increment by 1000.
Boris> Test run on HP 3000 running MPE/iX O/S. Compiler is 1985
Boris> standard with HP extensions.
Thanks Boris. We'll count this one in the strict interpretation
column. Here are a couple of more data points.
Compaq/digital COBOL running on alpha/tru64 Unix
MicroFocus COBOL running on alpha/tru64 Unix
In summary, Compaq/digital COBOL also falls into the strict
interpretation camp. Rather good diagnostics, at least on the
conditional statements.
MicroFocus was a little confusing at first, diagnosing the two last
SIZE ERROR (as opposed to NOT SIZE ERROR) phrases, until I realized
that they would only accept both phrases when SIZE ERROR came
first. I modified the program to make it that way and then it
compiled without errors or warnings. The execution shows that it
had silently assumed the missing END-ADD's present.
All the gory details follow.
I uppercased the program when I had a little trouble on the first
try. I'm not sure I had to do that. This is the program I compiled
and the diagnostics.
IDENTIFICATION DIVISION.
PROGRAM-ID. COBOL-TEST.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 W PIC 9.
01 X PIC 9.
01 Y PIC 9.
01 Z PIC 9.
PROCEDURE DIVISION.
001.
MOVE 8 TO X Z
MOVE 9 TO W Y
ADD 1 TO W
SIZE ERROR
DISPLAY "OVERFLOW ON W"
ADD 1 TO X
NOT SIZE ERROR
DISPLAY "NO OVERFLOW ON X"
ADD 1 TO Y
SIZE ERROR
DISPLAY "OVERFLOW ON Y"
ADD 1 TO Z
NOT SIZE ERROR
DISPLAY "NO OVERFLOW ON Z"
DISPLAY "RIGHT ASSOCIATION IS SUFFICIENT"
SIZE ERROR
DISPLAY "OOPS - UNEXPECTED RESULT"
NOT SIZE ERROR
DISPLAY "OOPS - UNEXPECTED RESULT"
SIZE ERROR
DISPLAY "OOPS - UNEXPECTED RESULT"
NOT SIZE ERROR
DISPLAY "OOPS - UNEXPECTED RESULT"
END-ADD
.
cobol: Error: condtest.cbl, line 28: Conditional statement detected -
Imperative statement required
ADD 1 TO Z
---------------------^
cobol: Error: condtest.cbl, line 24: Conditional statement detected -
Imperative statement required
ADD 1 TO Y
------------------^
cobol: Error: condtest.cbl, line 20: Conditional statement detected -
Imperative statement required
ADD 1 TO X
---------------^
cobol: Severe: condtest.cbl, line 33: "." required at this point
SIZE ERROR
-------------------------^
cobol: Warning: condtest.cbl, line 34: Processing of source program resumes at
this point
DISPLAY "OOPS - UNEXPECTED RESULT"
-------------------------^
cobol: Severe: condtest.cbl, line 36: "." required at this point
NOT SIZE ERROR
---------------------^
cobol: Warning: condtest.cbl, line 37: Processing of source program resumes at
this point
DISPLAY "OOPS - UNEXPECTED RESULT"
---------------------^
cobol: Severe: condtest.cbl, line 39: "." required at this point
SIZE ERROR
------------------^
cobol: Warning: condtest.cbl, line 40: Processing of source program resumes at
this point
DISPLAY "OOPS - UNEXPECTED RESULT"
------------------^
cobol: Severe: condtest.cbl, line 42: "." required at this point
NOT SIZE ERROR
---------------^
cobol: Warning: condtest.cbl, line 43: Processing of source program resumes at
this point
DISPLAY "OOPS - UNEXPECTED RESULT"
---------------^
cobol: Severe: condtest.cbl, line 45: "." required at this point
END-ADD
------------^
cobol: Warning: condtest.cbl, line 47: Processing of source program resumes at
this point
.
------------^
<
~~~~~~~~~~~ original program ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Microfocus COBOL running on alpha/tru64 Unix
With the same source program.
32 SIZE ERROR
* 368-S**************************** **
** Exception phrase inappropriate
38 SIZE ERROR
* 368-S********************* **
** Exception phrase inappropriate
49
* 301-S **
** Unrecognized verb
cob: error(s) in compilation: condtest.cbl
~~~~~~~~~~~~ modified program ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Microfocus COBOL running on alpha/tru64 Unix
With this modified source program
IDENTIFICATION DIVISION.
PROGRAM-ID. COBOL-TEST.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 W PIC 9.
01 X PIC 9.
01 Y PIC 9.
01 Z PIC 9.
PROCEDURE DIVISION.
001.
MOVE 8 TO X Z
MOVE 9 TO W Y
ADD 1 TO W
SIZE ERROR
DISPLAY "OVERFLOW ON W"
ADD 1 TO X
SIZE ERROR
DISPLAY "OOPS - UNEXPECTED RESULT"
NOT SIZE ERROR
DISPLAY "NO OVERFLOW ON X"
ADD 1 TO Y
SIZE ERROR
DISPLAY "OVERFLOW ON Y"
ADD 1 TO Z
SIZE ERROR
DISPLAY "OOPS - UNEXPECTED RESULT"
NOT SIZE ERROR
DISPLAY "NO OVERFLOW ON Z"
DISPLAY "RIGHT ASSOCIATION IS SUFFICIENT"
NOT SIZE ERROR
DISPLAY "OOPS - UNEXPECTED RESULT"
NOT SIZE ERROR
DISPLAY "OOPS - UNEXPECTED RESULT"
END-ADD
.
Compiles successfully and produces this output on execution.
OVERFLOW ON W
NO OVERFLOW ON X
OVERFLOW ON Y
NO OVERFLOW ON Z
RIGHT ASSOCIATION IS SUFFICIENT
--
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.