Module <tt>errmsg</tt>

HANDBOOK / LIBRARY REFERENCE MANUAL /

# Module `errmsg`

The module `errmsg` provides procedures to emit error messages. This module supports the Gentle type `POS` and encodes the current file, line, and column into a value.

    long yypos;

The variable `yypos` keeps track of the current source position.

To advance to the next column this variable must be incremented by one. To advance to the next line or the next file the procedures `yyPosToNextLine` or `yyPosToNextFile` must be used.

At the beginning of a line the column is set to one, after reading a token the column is the first column after the token.

    void yyGetPos(ref_pos)
       long *ref_pos;

The procedure `yyGetPos` sets the variable referred by its argument to the current source position minus 1.

    void yyPosToNextLine()

The procedure `yyPosToNextLine` must be called by the lexer when a new source line is read. It adjust the variable `yypos`.

    void yyPosToNextFile()

The procedure `yyPosToNextFile` must be called by the lexer when a new source file is read. It adjust the variable `yypos`.

    'action' Error (STRING, POS)

    void Error(msg, pos)
       char *msg;
       long pos;

The procedure `error` prints the message specified by the first parameter together with the source position specified by the second parameter. Then the program is terminated.

    yyerror(msg)
       char *msg;

The procedure `yyerror` is called by the Yacc generated parser in case of syntax errors. It may also be called by the lexer. It behaves like `Error` where the actual source position is used.