Line and Column Number Counting

By default, a generated lexer stamps tokens with the line and column number to indicate where their according match occurred. This facilitates the localization of a token’s origin in the input stream. The underlying line and column counting behavior can be customized with the mode tag <counter: ...>. Counting is configured in terms of character specific column number increments, line number increments, and grid counting. The latter corresponds to the traditional tabulator effect, i.e. jumping to the next multiple of a grid’s base value. For example, if the current column number is 13 and a character appears causing a grid step of 8, then it will be set to 16 which is the next number greater 13 and dividable by 8.

The syntax to specify a counting action for a set of characters is:

<character-set> '=>' keyword [number] ';'

The character-set may be any expression that results in a character set. The keyword \else represents the complement of all character sets which are explicitly mentioned. keyword must be either columns, grid, or lines. The optional number specifies the increment or grid size. If number is not specified it is set to 1. The default counting behavior can be defined as shown below.

mode EXAMPLE :
<counter: \else => columns 1;
          [\t]  => grid 4;
          [\n]  => lines 1; >
{
    ...
}

Counting and token stamping can be controlled via the command line arguments mentioned in table Command line options to disable counting features.. The disablement of a counting feature, naturally, implies the disablement of the according token class stamping.

Table 13 Command line options to disable counting features.

Command line option

Consequence

–no-count

no counting, no stamping of line and column counts

–no-line-count

no counting, no stamping of line counts

–no-column-count

no counting, no stamping of column counts

–no-token-stamp

no stamping of line and column counts

–no-token-stamp-line-count

no stamping of line counts

–no-token-stamp-column-count

no stamping of column counts