“gnucobol”意外标识符,期望DIVISION。

huangapple go评论61阅读模式
英文:

gnucobol "unexpected Identifier, expecting DIVISION"

问题

000100 程序标识部.
000200 程序标识符 dnd.
000300 作者 Ishayahu Lastov.
000400 编写日期 15/05/2023
000500 环境部.
000600 数据部.
000700 01 用户名 PIC X(20)
000800 01 字符数 10
000900 过程部.
001000 显示 "LaSil/IT D&D 5e"
001100 显示 "你叫什么名字?"
001200 接受 用户名
001300 显示 "小组中有多少角色?"
001400 接受 字符数
001500 显示 "你好 " 用户名 "。 你想要 " 字符数 "个角色..."
001600 停止运行.
英文:

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 (git@github.com: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

答案1

得分: 1

The error message is:

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

checking your line 5:

000500 ENVIRONMENT DIVISION.

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.

英文:

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.

答案2

得分: 0

你在日期后面漏了一个句号。

英文:

you are missing a period after the date written date.

huangapple
  • 本文由 发表于 2023年5月15日 14:23:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76251357.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定