opensourcecobol / opensourcecobol4j

A new version of opensourcecobol. Translate COBOL to Java.
https://opensourcecobol.github.io/opensourcecobol4j/
GNU General Public License v3.0
74 stars 34 forks source link

Fail to compile a HELLO.cbl #537

Closed alirezag closed 2 weeks ago

alirezag commented 2 weeks ago

I am able to compile cobol4j but it seems like I can't compile a basic program. Not sure if it is a dilect compatibility or a encoding issue:

HELLO.cbl

IDENTIFICATION DIVISION.
PROGRAM-ID. hello.
PROCEDURE DIVISION.
DISPLAY "Hello World!".
STOP RUN.
root@c0b52ef193c5:~/test# cobj HELLO.cbl 
HELLO.cbl:1: Error: Invalid indicator 'F' at column 7
HELLO.cbl:1: Error: syntax error, unexpected end of file, expecting PROGRAM_ID or FUNCTION_ID

cc @royxue

yutaro-sakamoto commented 2 weeks ago

@alirezag Please use the following program instead. hello.cbl

       IDENTIFICATION DIVISION.
       PROGRAM-ID. hello.
       PROCEDURE DIVISION.
       DISPLAY "Hello World!".
       STOP RUN.

COBOL compilers normally ignore the first 6 characters and 73th and succeeding characters of each line. If the seventh character of a line is '*', then the 8th and succeeding characters of that line are comments. Thus, the following program is equivalent to the one above.

       IDENTIFICATION DIVISION.
      *comment 1
       PROGRAM-ID. hello.
       PROCEDURE DIVISION.
      *comment 2
       DISPLAY "Hello World!".
       STOP RUN.

If you run cobj -free hello.cbl, then the compiler accepts the following program.

IDENTIFICATION DIVISION.
PROGRAM-ID. hello.
PROCEDURE DIVISION.
DISPLAY "Hello World!".
STOP RUN.
alirezag commented 2 weeks ago

thanks yes that fixed it.