package orsetto

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

Deterministic finite automata for Unicode code points.

include Cf_dfa.Regular with type event := Uchar.t
type term

The type of a regular language term.

val nil : term

The empty term, representing no events.

val one : Uchar.t -> term

Use one v to make a term representing the single occurrence of v.

val sat : (Uchar.t -> bool) -> term

Use sat f to make a term representing any event that satisfies the predicate f.

val cat2 : term -> term -> term

Use cat2 a b to make a term representing a and b concatenated.

val cats : term Seq.t -> term

Use cats s to make a term representing the concatenation of all the terms of s in sequential order.

val alt2 : term -> term -> term

Use alt2 a b to make a term representing the occurrence of either a or b.

val alts : term Seq.t -> term

Use alts s to make a term representing the occurrence of any of the alternatives in s.

val opt : term -> term

Use opt t to make a term representing either zero or one occurences of t.

val star : term -> term

Use star t to make a term representing the Kleene star of t, i.e. zero, one or more occurrences of t.

val seq : ?a:int -> ?b:int -> term -> term

Use seq t to make a term representing a sequence of occurrences of t.

If ~a is used, then it specifies the minimum number of occurrences in the recognized sequence. If ~b is used then it specifies the maximum number of occurrences in the recognized sequence. Composition raises Invalid_argument if a < 0 or b < a.

type 'r fin

The type of a final state.

val fin : term -> 'a -> 'a fin

Use fin t r to make t into a final state identified by r

include Cf_dfa.Machine with type event := Uchar.t and type 'r fin := 'r fin
type 'r t

The type of automatons parameterized by final identifier type. An imperative programming interface is provided below for elaboration.

val create : 'r fin Seq.t -> 'r t

Use create s to make a new DFA with all the final states of s.

val copy : 'r t -> 'r t

Use copy dfa to copy the internal state of dfa into a new machine, ready to advance from the same point.

val reset : 'r t -> unit

Use reset dfa to reset the internal state of dfa to its initial state, ready to advance on new events.

val advance : 'r t -> Uchar.t -> unit

Use advance dfa event to advance dfa with event. Raises Failure if dfa has rejected an event previously.

val rejected : 'r t -> bool

Use finished dfa to check whether dfa has rejected an event and and may not be advanced any further.

val accepted : 'r t -> bool

Use accepted dfa to check whether dfa has reached a final state. A DFA may still be further advanced after reaching one of its final states the first time.

val finish : 'r t -> 'r

Use finish dfa to get the final value dfa. Raise Not_found if no final value is available, i.e. either because it has rejected an event or it has not yet reached an accepting state.

val text_to_term : Ucs_text.t -> term

Use text_to_term s to make a term representing the regular expression in s. Raises Invalid_argument if s is not a valid regular expression.

val uchars_to_term : Uchar.t Seq.t -> term

Use uchars_to_term s to make a term representing the regular expression parsed from the Unicode code points in s. Raises Invalid_argument if s does not comprise a valid regular expression.

module Affix : sig ... end

This module extends the usual set of affix operators.

OCaml

Innovation. Community. Security.