package orsetto

  1. Overview
  2. Docs
A library of assorted structured data interchange languages

Install

Dune Dependency

Authors

Maintainers

Sources

r1.1.3.tar.gz
sha512=9b654edb663ae697563f150824047052f3b1bf760398f24bce6350553f031f73c46b6337239a1acd871e61238597ea92046809e3358290ff14d6ba671b449085

doc/orsetto.cf/Cf_scan/index.html

Module Cf_scan

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.