cobol: Recognize figurative constants for implicit PICTURE
COBOL parser now recognizes figurative constants for implicit PICTURE clauses.
This commit updates the COBOL compiler’s parser to correctly recognize figurative constants when an implicit PICTURE clause is present. This change affects how data fields are validated and updated, ensuring that figurative constants like ‘ZEROS’ or ‘SPACES’ are handled appropriately when they are assigned to variables without an explicitly defined PICTURE clause. The update_prior_invalid_field and field_add functions are modified to accommodate this.
In Details
The cobol front-end's parse_ante.h file has been updated to correctly handle figurative constants in conjunction with implicit PICTURE clauses. The update_prior_invalid_field function now uses is_figconst to check for figurative constants, and field_add ensures that update_prior_invalid_field is always called. This change addresses situations where a figurative constant might be assigned to a field where the PICTURE clause is implied by context, ensuring proper semantic validation and data type handling.
- figurative constant
- In COBOL, a reserved word or phrase that represents a specific value, such as SPACES (all spaces), ZEROS (all zeros), or HIGH-VALUES (all hexadecimal F's). These provide a shorthand for commonly used literal values.
- PICTURE clause
- A clause in COBOL used to define the data type, size, and format of a data item. It specifies how the data should be stored and displayed.
- implicit PICTURE clause
- A situation where the PICTURE clause for a data item is not explicitly written but is inferred by the compiler based on context, such as when a figurative constant is used.
- COBOL parser
- The component of the COBOL compiler responsible for analyzing the source code, checking its syntax, and building an internal representation.