Define the copybook parser

Mainframe Connector supports two versions of the copybook parser:

  • Native copybook parser: The Native copybook parser is the latest version of the parser. The Native copybook parser implements an ANTLR4 based parser and supports COBOL copybooks. For more information on the features supported by the Native copybook parser and the restrictions of its use, see Native copybook parser.
  • Legacy copybook parser: The legacy copybook parser is an older version of the parser that supports non-COBOL features. If you are using Domain-Specific Language (DSL) based-copybook the legacy parser might be more suitable as the Native copybook parser might cause errors. For more information on the features supported by the legacy copybook parser and the restrictions of its use, see Legacy copybook parser.

You can define which parser you want to use based on your copybook by using the parser_type=legacy|copybook flag. The default value is auto which is the auto-detect mode. The auto-detect mode prioritizes using the Native copybook parser, which is suitable for parsing COBOL-based copybooks. However, if you are using a non-COBOL-based copybook with the old format, the parser_type=legacy flag offers backward compatibility helping you use the Legacy copybook parser.

The following table defines the behavior of Mainframe Connector based on the flag.

Flag Action
auto Mainframe Connector detects the parser automatically and executes three parsing attempts in the following order:
  • Parses using the Native parser and the explicit comment area in columns 1-6. If parsing is successful, Mainframe Connector logs the parser that is used and returns the result. If parsing fails, Mainframe Connector tries the next parser.
  • Parses using the Native parser without the comment area. If parsing is successful, Mainframe Connector logs the parser that is used and returns the result. If parsing fails, Mainframe Connector tries the next parser.
  • Parses using the Legacy parser. If parsing is successful, Mainframe Connector logs the parser that is used and returns the result. If parsing fails, Mainframe Connector shows an error.
legacy The Legacy parser is used for parsing. It expects a COBOL look-a-like copybook such as a Domain-Specific Language (DSL)-based copybook. When you use the legacy flag, Mainframe Connector shows a warning that the Legacy parser will get deprecated. After using the Legacy parser for parsing, Mainframe Connector compares the result of the Legacy parser with that of the Native parser by executing two parsing attempts in the following order:
  • Parses the copybook using the Native parser expecting an explicit comment area in columns 1-6. If parsing is successful, Mainframe Connector compares the parsed result with that of the Legacy parser. If it is not equal, a warning is shown. If parsing fails, Mainframe Connector tries the next parser.
  • Parses the copybook using the Native parser without comment area in columns 1-6. If parsing is successful, Mainframe Connector compares the parsed result with that of the Legacy parser. If it is not equal a warning is shown. If parsing fails, Mainframe Connector logs the exception.
copybook The Native copybook parser is used for parsing. It expects Native copybooks as input, including an explicit comment area in columns 1-6. If parsing fails Mainframe Connector shows an error.