package orsetto

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Functional LL(x) parsing with monadic combinators.

Overview

This module implements functional left-shift/left-reduce parser combinators using a state-exception monad over a sequence of input symbols. The input symbol sequence is the state, and the recognized production is either a returned value Some v, or None if the input stream is not recognized. Composing a grammar production from a sequence of other productions is done by using the bind operator. Backtracking assumes the input stream is confluently persistent.

The input is conceptually sequence of symbol value, attributed in the iota type with stream position. Accordingly, productions are returned wrapped in a 'a form type that conceptually represents the value and the span of positions where it was recognized in the input. However, a simplified module signature is provided where type iota = symbol and type 'a form = 'a.

Syntax errors can be raised with arbitrary OCaml exceptions. Exceptions can be caught, and various functions are available for error recovery.

Interface
module type Form = sig ... end

Define a module of this type in a scanner basis. It defines the functions required by the basic scanner to relate produced values and their corresponding 'a form.

module type Basis = sig ... end

Define a module of this type as the basis of a scanner.

module type Profile = sig ... end

The signature of a basic scanner. Note Well: names are short to economize on souce code size in writing grammars by hand.

module Create (B : Basis) : Profile with type symbol := B.Symbol.t and type 'a form := 'a B.Form.t and type position := B.position

Use Create(B) to create a basic scanner on the basis of B.

module Simple : sig ... end
module Staging : sig ... end
module ASCII : sig ... end

This module provides simple scanners for analyzing texts encoded in 8bit-extended ASCII text encodings, e.g. ISO 8859 Latin, without any concept of stream position.

OCaml

Innovation. Community. Security.