Search code examples
syntax-errorcobolgnucobol

why am I getting an error in the identification division?


The following code :

IDENTIFICATION DIVISION.
PROGRAM-ID. tester.

PROCEDURE DIVISION.
greet_program.
   DISPLAY "HELLO WORLD !".
STOP RUN.

produces a compiler error which says : Error: syntax error, unexpected WORD, expecting PROGRAM_ID

I am unable to spot the error. Where is it ?

The errors with the program are listed here at ideone


Solution

  • You are compiling using the option of a traditional "fixed" Cobol layout.

    That means you need to start each line with seven blanks.

    You should have asked yourself why the first error messages referred to column seven. You could also have found some sample Cobol cobde and compare it to yours. Other people you can find with Google who've done the same thing.