package menhirGLR

  1. Overview
  2. Docs

Module MenhirGLR.InputSource

This module provides an abstraction of the input stream that is convenient for use in an LR or GLR parser. It manages a one-place buffer which stores the lookahead symbol. It also manages two vectors of positions, which are used to translate dates into positions.

Sourcetype date = int

A date is an index into the input stream, viewed as a sequence of tokens; therefore it represents a place in between two tokens.

Sourcetype 'a input

An input stream is a (finite or infinite) sequence of tokens.

Sourceval create : (Lexing.lexbuf -> 'a) -> Lexing.lexbuf -> 'a input

create lexer lexbuf creates an input stream out of the lexer lexer and lexing buffer lexbuf.

Sourceval lookahead : 'a input -> 'a

lookahead input returns the first token of the input stream, without consuming it.

Sourceval consume : 'a input -> unit

consume input consumes the first token of the input stream. It is an error to call consume without first calling lookahead at least once.

Sourceval start_position : 'a input -> date -> Lexing.position

start_position input date translates the date date to a position, under the assumption that this date represents a start date, that is, the left end of a date interval.

Sourceval end_position : 'a input -> date -> Lexing.position

end_position input date translates the date date to a position, under the assumption that this date represents an end date, that is, the right end of a date interval.