Module Cf_lexer


module Cf_lexer: sig .. end
Lexical analysis with functional composition of regular grammars.


Overview

This module implements functional parsers of the type defined in the Cf_parser.X module using lazy deterministic finite automata. Ordinary characters are the symbol type.

Note: functions for converting regular expression strings into lexer expressions are not provided.

Classes


The class of cursors used by lazy DFA parser. It inherits from the basic parser and defines a new method for handling errors.
class cursor : int -> object .. end

Types

type expr_t 
The type of lexer expressions.
type (#cursor, 'a) rule_t 
The type of lexer rules.
type (#cursor, 'a) t = (#cursor as 'b, char, 'a) Cf_parser.X.t 
The type of lexical analyzers, which are defined as parsers that use input symbols of type char.

Functions

module Op: sig .. end
Open this module to bring the operator functions into the current scope.
val nil : expr_t
The lexer expression that recognizes the empty input sequence, i.e. epsilon.
val create : (#cursor as 'a, 'b) rule_t -> ('a, 'b) t
Use create ?xf r to compose a lexical analyzer from the rule r.

type counter_t = {
   c_pos : int; (*The character index (counts from zero).*)
   c_row : int; (*The column number (counts from zero).*)
   c_col : int; (*The row number (counts from zero).*)
}
A record used by the line_cursor class defined below that indicates the character index, row and column in the input stream associated with a cursor position.
val counter_zero : counter_t
The initial value of a cursor position counter.
class line_cursor : ?c:counter_t -> string -> object .. end
A class derived from Cf_parser.cursor that intercepts newline characters to track the row and column of a cursor position.
exception Error of counter_t
The exception raised by the raise_exn exception handler function below.
val raise_exn : int -> (char * #line_cursor) Cf_seq.t -> exn
An optional exception handler function for use in streams woven with cursors of the #line_cursor class type. When the exception handler is called, the exception returned is constructed as Error c#counter.