Lang.Analysis
Functions for analysing and transforming Common.parseable
objects, notably including the Unparse
module.
val matches_empty : Common.parseable -> bool
Determines if the given parseable accepts the empty string.
For this function, a parseable p
is considered empty if: for all p2
, the parser Seq [p; p2]
accepts at least p2
. Note that Common.parseable.Eof
is not empty by this definition.
val seq_inner : Common.parseable -> Common.parseable -> Common.parseable
Attempts to create a parseable which performs l
then r
, but pushes r
as deep as possible to maximise backtracking.
val to_eof : Common.parseable -> Common.parseable
Attempts to modify the given parseable to require Common.parseable.Eof
immediately after it.
val vars : Common.parseable -> Common.StringSet.t
Obtains the set of names which are possibly bound when parsing the given parseable.
Names are bound by Common.parseable.Bind
structures.
val disjunctive_clauses : Common.parseable -> Common.parseable CCList.t
Converts the given parseable into its disjunctive clauses.
The disjunctive clauses are such that Or (disjunctive_clauses p)
accepts the same language as the original p
, and none of the disjunctive clauses contain an Or
within them.
Warning: The number of disjunctive clauses is exponential in the number of sequential Common.parseable.Or
terms.
module Unparse : sig ... end
Implementation of the "unparsing" functionality. The goal of this feature is to enable parsers to be used as printers by manually providing a Common.bindings
object with a structure matching those returned by Parse.run_parse
.
val unparse_with_bindings :
Common.parseable ->
Common.bindings ->
Common.output * Common.bindings
val unparse : Common.parseable -> Common.bindings -> Common.output
See Unparse.unparse
.