CUSTOM

Synopsis

HELP:   Custom comment pattern (repeatable)
TYPE:   OBJECT
SYNTAX: CUSTOM[(CB='str',CE='str',SB='str',SE='str',SBCMT=num,SECMT=num,STRICT)...]

Description

A CUSTOM entry defines a user-supplied pattern for CNVCMT to detect on the read side. Each CUSTOM entry runs in one of two mutually exclusive modes:

* Classic comment mode -- specified via CB (and optionally CE). The pattern matches a comment region; everything outside the comment is DATA.

* Section mode -- specified via SB (and optionally SE/SBCMT/SECMT/ STRICT). Inverse polarity: outside the section is COMMENT; everything from SB to SE is DATA. See the main CNV.CMT manual page, section "SECTION-MODE", for details.

CB and SB are mutually exclusive; specifying both is an error (FLMRTC_ITF).

Classic-comment parameters:

CB -- comment-begin marker (required for classic mode). The pattern is detected when this string appears at the start of a record (after leading whitespace, depending on MODE).

CE -- comment-end marker. Leave empty ('') or omit to define a line comment (the pattern matches from CB to the end of the record). Supply a non-empty CE to define a block comment that may span multiple records.

Section-mode parameters:

SB -- section-begin marker (required for section mode). Switches the engine from COMMENT mode to DATA mode.

SE -- section-end marker. Switches back to COMMENT mode. If empty or omitted, the section runs from SB to EOF.

SBCMT -- number of leading bytes of SB that belong to the COMMENT, not the data (default 0; max strlen(SB)).

SECMT -- number of trailing bytes of SE that belong to the COMMENT, not the data (default 0; max strlen(SE)).

STRICT -- if set, an SB-opened section that reaches EOF without SE produces an error. Without STRICT, the remaining data is emitted as the section's final record and a warning is logged.

Multiple CUSTOM entries may be given. When ADD is set, they extend the active built-in PRESET selection; without ADD, the PRESET selection is replaced entirely by the CUSTOM list. Classic and section CUSTOM entries may be mixed (e.g. PEM blocks plus '#' line comments inside the data).

Example -- detect BASIC-style REM and C99-style // comments:

   flcl xcnv "inp(sav.fil(fio.txt(name='in.bas') cnv.chr(to=UTF-8)
      cnv.cmt(preset=none add custom(cb='REM ') custom(cb='//' ce=''))))
      out(sav.fil(fio.txt(name='out.txt')))"

Example -- SWIFT-MT section mode:

   CNV.CMT(PRESET=NONE
      CUSTOM(SB='{1:' SE='-}\n\n' SECMT=2 STRICT))

Arguments