gnucobol "unexpected Identifier, expecting DIVISION"

80 Views Asked by At

I write simple program:

000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. dnd.
000300 AUTHOR. Ishayahu Lastov.
000400 DATE-WRITTEN. 15/05/2023
000500 ENVIRONMENT DIVISON.
000600 DATA DIVISION.
000700 01 Username PIC X(20)
000800 01 CharactersCount 10
000900 PROCEDURE DIVISION.
001000 DISPLAY "LaSil/IT D&D 5e"
001100 DISPLAY "What is your name?"
001200 ACCEPT Username
001300 DISPLAY "How many characters are in group?"
001400 ACCEPT CharactersCount
001500 DISPLAY "Hello " Username ". You want " CharactersCount "characters..."
001600 STOP RUN.

(I tried write it in free format, but got the same error, so I used fixed format (as I understand at the moment). And as I understand from that answer free format could be not used in enterprise, so I'm not sure that is worse to start with it)

cobc -fixed -vvv main.cob

cobc (GnuCOBOL) 3.1.2.0
Built     May 05 2023 16:23:39  Packaged  Dec 23 2020 12:04:58 UTC
C version "FreeBSD Clang 13.0.0 ([email protected]:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)"
loading standard configuration file 'default.conf'
command line:   cobc -fixed -vvv main.cob
preprocessing:  main.cob -> /tmp/cob77473_0.cob
main.cob:16: error: continuation character expected
return status:  1
parsing:        /tmp/cob77473_0.cob (main.cob)
main.cob:5: error: syntax error, unexpected Identifier, expecting DIVISION
return status:  1

As I understand from an error, compilator want to see "DIVISION" after "000100 ", but as I see from all examples first line is fine

2

There are 2 best solutions below

0
Simon Sobisch On

The error message is:

main.cob:5: error: syntax error, unexpected Identifier, expecting DIVISION

checking your line 5:

000500 ENVIRONMENT DIVISON.

as the compiler points out DIVISON is a possible user-defined COBOL word, an identifier, but it expects the reserved word DIVISION.

After fixing that you'll get more errors to fix (missing storage section, periods in the data definitions, likely PIC 99 instead of 10...), but in general the compiler messages should point those out to you as it did here.

0
James Anderson On

you are missing a period after the date written date.