https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119221
Bug ID: 119221
Summary: RFE: fix-it hints for cobol syntax errors
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: cobol
Assignee: unassigned at gcc dot gnu.org
Reporter: dmalcolm at gcc dot gnu.org
Target Milestone: ---
Looking at https://gcc.gnu.org/pipermail/gcc-patches/2025-March/677314.html
after the patch to add source ranges, gcobol emits:
$ ./gcobol -B. hello.cob -S
hello.cob:2:8: error: syntax error, unexpected NAME, expecting FUNCTION or
PROGRAM-ID
2 | porgram-id. hello.
| ^~~~~~~~~~~
cobol1: error: failed compiling hello.cob
Assuming that "function" and "program-id" are literals (and that NAME isn't),
it would be nice if the wording was:
hello.cob:2:8: error: syntax error, unexpected NAME, expecting `function' or
`program-id'
2 | porgram-id. hello.
| ^~~~~~~~~~~
and if it emitted a fix-it hint, such as:
hello.cob:2:8: note: did you mean `program-id'
2 | porgram-id. hello.
| ^~~~~~~~~~~
| program-id
Looking at the implementation, the current wording seems to be from
yysyntax_error within the generated BUILD/cobol.parse.cc; I wonder if it's
possible to override that and provide out own implementation that e.g. does
spellchecking/fix-it hints etc.