Path: Module for Substitutions within S-expressions
Type of substitution paths
parse str
str.some_tag, then denotes its 4th argument.name1" -> choose record field with name t, then subfield
x. Match this value against B, and denote its first argument.
get ?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.
sexp denoted by the path.
replace ?path ?str sexp ~subst like get, but does not extract
a sub-expression but substitutes it with subst.
subst_path sexp path
(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.
extract_pos n sexp
(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.
extract_match tag n sexp
(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.
extract_rec name sexp
(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.