Module MenhirLib.EngineTypes

This module defines several types and module types that are used in the specification of the module Engine.

type ('state, 'semantic_value) stack = {
  1. state : 'state;
    (*

    The state that we should go back to if we pop this stack cell.

    This convention means that the state contained in the top stack cell is not the current state env.current. It also means that the state found within the sentinel is a dummy -- it is never consulted. This convention is the same as that adopted by the code-based back-end.

    *)
  2. semv : 'semantic_value;
    (*

    The semantic value associated with the chunk of input that this cell represents.

    *)
  3. startp : Lexing.position;
    (*

    The start position of the chunk of input that this cell represents.

    *)
  4. endp : Lexing.position;
    (*

    The end position of the chunk of input that this cell represents.

    *)
  5. next : ('state, 'semantic_value) stack;
    (*

    The next cell down in the stack. If this is a self-pointer, then this cell is the sentinel, and the stack is conceptually empty.

    *)
}

A stack is a linked list of cells. A sentinel cell -- which is its own successor -- is used to mark the bottom of the stack. The sentinel cell itself is not significant -- it contains dummy values.

type ('state, 'semantic_value, 'token) env = {
  1. error : bool;
    (*

    If this flag is true, then the first component of env.triple should be ignored, as it has been logically overwritten with the error pseudo-token.

    *)
  2. triple : 'token * Lexing.position * Lexing.position;
    (*

    The last token that was obtained from the lexer, together with its start and end positions. Warning: before the first call to the lexer has taken place, a dummy (and possibly invalid) token is stored here.

    *)
  3. stack : ('state, 'semantic_value) stack;
    (*

    The stack.

    *)
  4. current : 'state;
    (*

    The current state.

    *)
}

A parsing environment contains all of the parser's state (except for the current program point).

module type LOG = sig ... end

A number of logging hooks are used to (optionally) emit logging messages.

module type TABLE = sig ... end

This signature describes the parameters that must be supplied to the LR engine.

module type MONOLITHIC_ENGINE = sig ... end

This signature describes the monolithic (traditional) LR engine. When the engine is used in this mode, the parser controls the lexer.

module type INCREMENTAL_ENGINE_START = sig ... end

This signature describes just the entry point of the incremental LR engine. It is a supplement to IncrementalEngine.INCREMENTAL_ENGINE.

module type ENGINE = sig ... end

This signature describes the LR engine, which combines the monolithic and incremental interfaces.