package bare

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

Matching rule specification.

A rule is consists of the rule specification and matching state, thus applying a rule to a fact will produce another rule that will store the partial matching state and, if some states reached the completion, it will also produce a sequence of facts.

type t

rule abstract type

type error

an abstract representation of an error

Rule Parsing

val from_string : string -> (t list, error) Core_kernel.Result.t
val from_file : string -> (t list, error) Core_kernel.Result.t

from_file name parses a file that contains zero or more rule specifications. Returns Ok rules if all rules specifications were well-formed, otherwise returns Error e with a detailed description of an error and a location of a subterm that is not part of the grammar.

val of_string : string -> t

of_string s parses the rule specification s.

Precondition: s is a well-formed rule specification.

Rule introspecting

val lhs : t -> tuple list

lhs rule is the left hand side of the rule.

val rhs : t -> fact list

rhs rule is the right hand side of the rule

val spec : t -> string

spec rule is the human readable and machine parseable well-formed rule specification.

val pp : Stdlib.Format.formatter -> t -> unit

pp ppf rule prints rule into the formatter ppf.

Rule transformations

val apply : t -> fact -> t * fact list

apply rule fact applies rule to fact and produces a new rule that contains a partial mathcing state, as well as a list (possibly empty) of newly produced facts.

val reset : t -> t

reset rule discards the matching state and returns a fresh rule.

val report_error : ?filename:string -> Stdlib.Format.formatter -> error -> unit