COBOL reserved words handling and screen syntax parsing improved.
GnuCOBOL reserved words are now correctly handled, and a new option allows parsing of GnuCOBOL screen syntax.
This commit enhances GCC’s COBOL support by refining the handling of reserved words and introducing new parsing capabilities. Reserved words that are not defined by the ISO standard are now renamed to prevent conflicts with user-defined names, ensuring that reserved words can be reliably identified by consulting the token list. Additionally, a new compiler option, -Wdisplay-screen, has been added to enable the parsing of GnuCOBOL’s screen syntax within DISPLAY statements. While this syntax is parsed, it does not affect the compiler’s output.
In Details
This patch addresses two key areas in GCC's COBOL front-end: reserved word management and GnuCOBOL-specific syntax. To improve robustness and clarity, non-ISO defined COBOL keywords (tokens) are renamed in parse.y and scan.l to avoid clashes with user identifiers. This aligns the handling of reserved words with a UAT test provided by GnuCOBOL. Furthermore, the -Wdisplay-screen option is introduced via lang.opt and cobol1.cc to enable the parser to recognize and process GnuCOBOL's DISPLAY statement screen syntax, as defined in cdf.y and parse.y, without altering code generation.
- COBOL
- A high-level programming language commonly used for business applications. GCC includes a compiler for the COBOL language.
- ISO standard
- A family of standards maintained by the International Organization for Standardization (ISO) that define specifications for a wide range of industries and technologies. In this context, it refers to the official COBOL language standards.
- reserved word
- A word that has a special meaning in a programming language and cannot be used as an identifier (e.g., a variable name).
- GnuCOBOL
- An open-source compiler for the COBOL programming language, formerly known as OpenCOBOL.
- screen syntax
- In COBOL, this refers to specific syntax used within
DISPLAYstatements to define the layout and content of data presented on a terminal screen. - token
- The basic lexical unit of a programming language, such as a keyword, identifier, or operator, produced by a lexer or scanner.