GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
cobol

Cobol PICTURE validation uses automaton for edited types.

Cobol PICTURE validation for edited types now uses an automaton, reporting errors in the lexer.

The Cobol compiler’s PICTURE clause validation for edited types has been significantly refactored. It now employs an automaton to validate the PICTURE syntax within the lexer, providing error reporting earlier in the compilation process. The parser receives a new PICTURE token, and the verbatim picture string is retained for later codegen interpretation.

In Details

This commit introduces a significant change to the Cobol front-end's handling of PICTURE clauses for edited data types. It replaces previous validation logic with an automaton-based approach within the lexer. This allows for earlier detection and reporting of PICTURE syntax errors. A new PICTURE token is introduced to pass interpreted syntax information to the parser, while the original picture string is preserved for subsequent code generation phases. Changes span across lexer, parser, and semantic analysis components (scan.l, parse.y, picture.cc, cbldiag.h, etc.).

For Context
PICTURE clause
A clause in COBOL that defines the format and data type of a data item, specifying its appearance, such as leading zeros, currency symbols, or decimal points. It controls how data is stored, displayed, and edited.
edited types
In COBOL, data items that are formatted for display or printing, often including characters like currency symbols, decimal points, or commas. They are distinct from purely numeric or alphanumeric data items.
automaton
A computational model used in compiler design, particularly in lexing and parsing. It's a finite state machine that processes input symbols to recognize patterns or validate syntax.
lexer
The lexical analyzer, or scanner, the first phase of a compiler. It reads the source code character by character and groups them into meaningful tokens (e.g., keywords, identifiers, operators).
parser
The component of a compiler that takes a stream of tokens from the lexer and builds a hierarchical structure (like an abstract syntax tree) representing the program's syntax, checking for grammatical correctness.
codegen
Code generation. The phase of a compiler that translates the intermediate representation of the program into the target machine code or an intermediate code for a virtual machine.
Filed Under: cobolcompilerlexerparser