package pratter

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

Module PratterSource

This modules defines a functor whose image is a parser for terms with applications, binary and unary operators. These terms are specified in the argument of the functor.

The algorithm implemented is an extension of the Pratt parser. The Shunting Yard algorithm could also be used.

Sourcetype associativity =
  1. | Left
    (*

    If + is a left associative operator, x + y + z is parsed (x + y) + z.

    *)
  2. | Right
    (*

    If + is a right associative operator, x + y + z is parsed x + (y + z).

    *)
  3. | Neither
    (*

    If + is not associative, then (x + y) + z is not x + (y + z) and x + y + z results in a syntax error.

    *)

Associativity of an operator.

Sourcetype priority = float

Priority of operators, also called binding power. If * has a higher priority than +, than x + y * z is parsed x + (y * z).

Sourcetype operator =
  1. | Bin of associativity
    (*

    Binary operator with an associativity.

    *)
  2. | Una
    (*

    Unary operator.

    *)

A type to designate operators and their properties.

Sourcemodule type SUPPORT = sig ... end

Types and utilities on terms that are to be Pratt parsed.

Sourcemodule Make (Sup : SUPPORT) : sig ... end
OCaml

Innovation. Community. Security.