Accept newline in COBOL reference modification patterns.
COBOL lexer now correctly handles newlines within reference modification patterns.
GCC’s COBOL front-end has been updated to correctly parse reference modification patterns that may include newline characters. This involved modifying the lexer’s recognition rules and fixing an is_refmod() function to ensure proper handling of these patterns, alongside other minor lexer and parser corrections for compatibility and robustness.
In Details
The lexer's regular expression for LPAREN in gcc/cobol/scan.l was modified to no longer exclude newline characters, allowing them within reference modification patterns. Concurrently, issues in is_refmod() were addressed to prevent out-of-bounds access. Helper functions like rsearch and skip_string were introduced or updated for C++11 compatibility and improved string literal handling, respectively. The parse.y file was also corrected to report LPAREN tokens as '(', and formatting in util.cc was adjusted.
- COBOL
- A compiled high-level programming language with an English-like syntax, primarily used in business applications. GCC includes a COBOL front-end.
- lexer
- A component of a compiler that breaks down the source code text into a stream of tokens (lexemes).
- reference modification
- In COBOL, a feature that allows specifying a portion of a data item to be accessed, similar to substring operations in other languages. E.g.,
data-item(start:length). - token
- A lexical unit recognized by the lexer, representing a keyword, identifier, operator, or literal in the source code.
- C++11
- A major revision of the C++ programming language standard, published in 2011. This commit ensures compatibility with its features.