module Path:sig..end
type el =
| |
Pos of |
(* | Pos n denotes nth element in a tuple | *) |
| |
Match of |
(* | Match (tag, n) denotes nth argument of sum matching tag | *) |
| |
Rec of |
(* | Rec name denotes the record field having name | *) |
typet =el list
val parse : string -> tparse strFailure if the path is syntactically invalid.str.
Syntax:
"." -> separates path elements; must be present at start of string.
"[4]" -> specifies the 4th element in a tuple.
"some_tag[4]" ->
tries to match some_tag, then denotes its 4th argument.
"name" ->
denotes record field having name
Example from test code:
".t.x.B1" -> choose record field with name t, then subfield
x. Match this value against B, and denote its first argument.
val get : ?path:t -> ?str:string -> Sexp.t -> Sexp.tget ?path ?str sexp if path is provided, use it as path.
Otherwise, if str is provided, parse it as a path. If neither
is provided, assume an empty path.Failure if path is syntactically invalid or if the path
structure clashes with the structure of the data.sexp denoted by the path.val replace : ?path:t -> ?str:string -> Sexp.t -> subst:Sexp.t -> Sexp.treplace ?path ?str sexp ~subst like get, but does not extract
a sub-expression but substitutes it with subst.Failure if path is syntactically invalid or if the path
structure clashes with the structure of the data.val replace_no_path : str:string -> Sexp.t -> subst:Sexp.t -> Sexp.treplace_no_path ~str sexp ~subst like replace, but does not take
optional arguments. str must be specified.Failure if path is syntactically invalid or if the path
structure clashes with the structure of the data.val subst_path : Sexp.t -> t -> (Sexp.t -> Sexp.t) * Sexp.tsubst_path sexp pathFailure if path is syntactically invalid or if the path
structure clashes with the structure of the data.(subst, sub), where subst
is a function that returns an S-expression in which the subexpression
denoted by path in sexp has been substituted by its argument.
sub is the denoted subexpression. Note that subst sub = sexp.val extract_pos : int -> Sexp.t -> (Sexp.t option -> Sexp.t) * Sexp.textract_pos n sexpFailure if the position cannot be resolved within the given
S-expression.(subst, sub), where subst
is a function that returns an S-expression in which the subexpression
denoted at position n in sexp, which must be a list, has been
substituted by value if the optional argument is Some value, or
removes the denoted subexpression if the optional argument is None.
sub is the denoted subexpression. Note that subst (Some sub) =
sexp.val extract_match : string -> int -> Sexp.t -> (Sexp.t option -> Sexp.t) * Sexp.textract_match tag n sexpFailure if the S-expression does not represent a sum tag.(subst, sub), where
subst is a function that returns an S-expression in which the
subexpression denoted by matching tag and taking its nth argument
in sexp has been substituted by value if the argument is Some
value, or removes the denoted subexpression if the optional argument
is None. sub is the denoted subexpression. Note that subst
(Some sub) = sexp.val extract_rec : string -> Sexp.t -> (Sexp.t -> Sexp.t) * Sexp.textract_rec name sexpFailure if the S-expression does not represent a record.(subst, sub), where
subst is a function that returns an S-expression in which the
subexpression denoted by matching field name name in sexp has
been substituted by its argument. sub is the denoted subexpression.
Note that subst (Some sub) = sexp.