package libsail

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

Module Libsail.Ast_utilSource

Utilities and helper functions for operating on Sail ASTs

module Big_int = Nat_big_num

Untyped AST annotations and locations

Sourcetype uannot

The type of annotations for untyped AST nodes. When expressions are type-checked the untyped annotations are replaced with typed annotations Type_check.tannot.

Sourcetype untyped_def = (uannot, unit) Ast.def

Aliases for an untyped definitions and full AST for readability

Sourcetype untyped_ast = (uannot, unit) Ast_defs.ast
Sourceval empty_uannot : uannot

The empty annotation

Attributes

Sourceval string_of_attribute : string -> Ast.attribute_data option -> string
Sourceval string_of_attribute_data : Ast.attribute_data -> string
Sourceval json_of_attribute : string -> Ast.attribute_data option -> Yojson.Basic.t
Sourceval json_of_attribute_data : Ast.attribute_data -> Yojson.Basic.t
Sourceval attribute_data_object : Ast.attribute_data -> (string * Ast.attribute_data) list option
Sourceval attribute_data_bool : Ast.attribute_data -> bool option
Sourceval attribute_data_string : Ast.attribute_data -> string option
Sourceval attribute_data_string_with_loc : Ast.attribute_data -> (string * Parse_ast.l) option
Sourceval attribute_data_list : Ast.attribute_data -> Ast.attribute_data list option
Sourceval add_attribute : Ast.l -> string -> Ast.attribute_data option -> uannot -> uannot

Add an attribute to an annotation. Attributes are attached to expressions in Sail via:

  $[attribute argument] expression

The location argument should be a span that corresponds to the attribute itself, and not include the expression.

Sourceval remove_attribute : string -> uannot -> uannot
Sourceval get_attribute : string -> uannot -> (Ast.l * Ast.attribute_data option) option
Sourceval get_attributes : uannot -> (Ast.l * string * Ast.attribute_data option) list
Sourceval find_attribute_opt : string -> (Ast.l * string * Ast.attribute_data option) list -> (Ast.l * Ast.attribute_data option) option
Sourceval mk_def_annot : ?doc:string -> ?attrs:(Ast.l * string * Ast.attribute_data option) list -> ?visibility:Ast.visibility -> Ast.l -> 'a -> 'a Ast.def_annot
Sourceval uannot_of_def_annot : 'a Ast.def_annot -> uannot
Sourceval add_def_attribute : Ast.l -> string -> Ast.attribute_data option -> 'a Ast.def_annot -> 'a Ast.def_annot
Sourceval get_def_attribute : string -> 'a Ast.def_annot -> (Ast.l * Ast.attribute_data option) option
Sourceval remove_def_attribute : string -> 'a Ast.def_annot -> 'a Ast.def_annot
Sourceval def_annot_map_loc : (Ast.l -> Ast.l) -> 'a Ast.def_annot -> 'a Ast.def_annot
Sourceval def_annot_map_env : ('a -> 'b) -> 'a Ast.def_annot -> 'b Ast.def_annot
Sourceval no_annot : Ast.l * uannot

The empty annotation (as a location + uannot pair). Should be used carefully because it can result in unhelpful error messgaes. However a common pattern is generating code with no_annot, then adding location information with the various locate_ functions in this module.

Generated locations

gen_loc l takes a location l and generates a location which means 'generated/derived from location l'. This is useful for debugging errors that occur in generated code.

Sourceval is_gen_loc : Parse_ast.l -> bool

Visibility modifiers

Sourceval is_private : Ast.visibility -> bool
Sourceval is_public : Ast.visibility -> bool
Sourceval visibility_loc : Ast.visibility -> Parse_ast.l

Variable information

Sourcetype mut =
  1. | Immutable
  2. | Mutable
Sourcetype 'a lvar =
  1. | Register of 'a
  2. | Enum of 'a
  3. | Local of mut * 'a
  4. | Unbound of Ast.id

lvar is the type of variables - they can either be registers, local mutable or immutable variables constructors or unbound identifiers.

Sourceval is_unbound : 'a lvar -> bool
Sourceval lvar_typ : ?loc:Ast.l -> 'a lvar -> 'a

Note: Partial function -- fails for Unbound lvars

Sourceval is_order_inc : Ast.order -> bool
Sourceval is_order_dec : Ast.order -> bool

Functions for building and destructuring untyped AST elements

Functions for building untyped AST elements

Sourceval mk_id : ?loc:Ast.l -> string -> Ast.id
Sourceval mk_kid : ?loc:Ast.l -> string -> Ast.kid
Sourceval mk_nexp : ?loc:Ast.l -> Ast.nexp_aux -> Ast.nexp
Sourceval mk_exp : ?loc:Ast.l -> uannot Ast.exp_aux -> uannot Ast.exp
Sourceval mk_pat : ?loc:Ast.l -> uannot Ast.pat_aux -> uannot Ast.pat
Sourceval mk_mpat : ?loc:Ast.l -> uannot Ast.mpat_aux -> uannot Ast.mpat
Sourceval mk_pexp : ?loc:Ast.l -> uannot Ast.pexp_aux -> uannot Ast.pexp
Sourceval mk_mpexp : ?loc:Ast.l -> uannot Ast.mpexp_aux -> uannot Ast.mpexp
Sourceval mk_lexp : ?loc:Ast.l -> uannot Ast.lexp_aux -> uannot Ast.lexp
Sourceval mk_lit : ?loc:Ast.l -> Ast.lit_aux -> Ast.lit
Sourceval mk_lit_exp : ?loc:Ast.l -> Ast.lit_aux -> uannot Ast.exp
Sourceval mk_typ_pat : ?loc:Ast.l -> Ast.typ_pat_aux -> Ast.typ_pat
Sourceval mk_funcl : ?loc:Ast.l -> Ast.id -> uannot Ast.pat -> uannot Ast.exp -> uannot Ast.funcl
Sourceval mk_fundef : ?loc:Ast.l -> uannot Ast.funcl list -> untyped_def
Sourceval mk_val_spec : ?loc:Ast.l -> Ast.val_spec_aux -> untyped_def
Sourceval mk_typschm : ?loc:Ast.l -> Ast.typquant -> Ast.typ -> Ast.typschm
Sourceval mk_empty_typquant : loc:Ast.l -> Ast.typquant
Sourceval mk_typquant : ?loc:Ast.l -> Ast.quant_item list -> Ast.typquant
Sourceval mk_qi_id : ?loc:Ast.l -> Ast.kind_aux -> Ast.kid -> Ast.quant_item
Sourceval mk_qi_nc : ?loc:Ast.l -> Ast.n_constraint -> Ast.quant_item
Sourceval mk_qi_kopt : ?loc:Ast.l -> Ast.kinded_id -> Ast.quant_item
Sourceval mk_fexp : ?loc:Ast.l -> Ast.id -> uannot Ast.exp -> uannot Ast.fexp
Sourceval mk_letbind : ?loc:Ast.l -> uannot Ast.pat -> uannot Ast.exp -> uannot Ast.letbind
Sourceval mk_kopt : ?loc:Ast.l -> Ast.kind_aux -> Ast.kid -> Ast.kinded_id
Sourceval mk_def : ?loc:Ast.l -> ('a, 'b) Ast.def_aux -> 'b -> ('a, 'b) Ast.def
Sourceval pat_of_mpat : 'a Ast.mpat -> 'a Ast.pat

Mapping patterns are a subset of patterns, so we can always convert one to the other

Unwrap aux constructors

Sourceval unaux_exp : 'a Ast.exp -> 'a Ast.exp_aux
Sourceval unaux_pat : 'a Ast.pat -> 'a Ast.pat_aux
Sourceval unaux_nexp : Ast.nexp -> Ast.nexp_aux
Sourceval unaux_typ : Ast.typ -> Ast.typ_aux
Sourceval unaux_kind : Ast.kind -> Ast.kind_aux

Destruct type annotated patterns and expressions

Sourceval untyp_pat : 'a Ast.pat -> 'a Ast.pat * Ast.typ option

untyp_pat (P_aux (P_typ (typ, pat)), _) returns Some (pat, typ) or None if the pattern does not match.

Sourceval uncast_exp : 'a Ast.exp -> 'a Ast.exp * Ast.typ option

Same as untyp_pat, but for E_typ nodes

Utilites for working with kinded_ids

Sourceval kopt_kid : Ast.kinded_id -> Ast.kid
Sourceval kopt_kind : Ast.kinded_id -> Ast.kind
Sourceval is_int_kopt : Ast.kinded_id -> bool
Sourceval is_typ_kopt : Ast.kinded_id -> bool
Sourceval is_bool_kopt : Ast.kinded_id -> bool

Utility functions for constructing types

Sourceval mk_typ : ?loc:Ast.l -> Ast.typ_aux -> Ast.typ
Sourceval mk_typ_arg : ?loc:Ast.l -> Ast.typ_arg_aux -> Ast.typ_arg
Sourceval mk_id_typ : ?loc:Ast.l -> Ast.id -> Ast.typ
Sourceval is_typ_arg_nexp : Ast.typ_arg -> bool
Sourceval is_typ_arg_typ : Ast.typ_arg -> bool
Sourceval is_typ_arg_bool : Ast.typ_arg -> bool
Sourceval typ_arg_kind : Ast.typ_arg -> Ast.kind

Sail built-in types

Sourceval unknown_typ : Ast.typ
Sourceval int_typ : Ast.typ
Sourceval nat_typ : Ast.typ
Sourceval atom_typ : Ast.nexp -> Ast.typ
Sourceval implicit_typ : Ast.nexp -> Ast.typ
Sourceval range_typ : Ast.nexp -> Ast.nexp -> Ast.typ
Sourceval bit_typ : Ast.typ
Sourceval bool_typ : Ast.typ
Sourceval atom_bool_typ : Ast.n_constraint -> Ast.typ
Sourceval app_typ : Ast.id -> Ast.typ_arg list -> Ast.typ
Sourceval register_typ : Ast.typ -> Ast.typ
Sourceval unit_typ : Ast.typ
Sourceval string_typ : Ast.typ
Sourceval string_literal_typ : Ast.typ
Sourceval real_typ : Ast.typ
Sourceval vector_typ : Ast.nexp -> Ast.typ -> Ast.typ
Sourceval bitvector_typ : Ast.nexp -> Ast.typ
Sourceval list_typ : Ast.typ -> Ast.typ
Sourceval exc_typ : Ast.typ
Sourceval tuple_typ : Ast.typ list -> Ast.typ
Sourceval function_typ : Ast.typ list -> Ast.typ -> Ast.typ
Sourceval is_unit_typ : Ast.typ -> bool
Sourceval is_number : Ast.typ -> bool
Sourceval is_ref_typ : Ast.typ -> bool
Sourceval is_vector_typ : Ast.typ -> bool
Sourceval is_bit_typ : Ast.typ -> bool
Sourceval is_bitvector_typ : Ast.typ -> bool

Simplifcation of numeric expressions and constraints

These functions simplify nexps and n_constraints using various basic rules. In general they will guarantee to reduce constant numeric expressions like 2 + 5 into 7, although they will not simplify 2^constant, as that often leads to unreadable error messages containing huge numbers.

Sourceval nexp_simp : Ast.nexp -> Ast.nexp
Sourceval constraint_simp : Ast.n_constraint -> Ast.n_constraint
Sourceval get_nexp_constant : Ast.nexp -> Big_int.num option
Sourceval constraint_conj : Ast.n_constraint -> Ast.n_constraint list

If a constraint is a conjunction, return a list of all the top-level conjuncts

Sourceval constraint_disj : Ast.n_constraint -> Ast.n_constraint list

Same as constraint_conj but for disjunctions

Sourcetype effects
Sourceval no_effect : effects
Sourceval monadic_effect : effects
Sourceval effectful : effects -> bool
Sourceval equal_effects : effects -> effects -> bool
Sourceval subseteq_effects : effects -> effects -> bool
Sourceval union_effects : effects -> effects -> effects

Functions for building numeric expressions

Sourceval nconstant : Big_int.num -> Ast.nexp
Sourceval nint : int -> Ast.nexp
Sourceval nminus : Ast.nexp -> Ast.nexp -> Ast.nexp
Sourceval ntimes : Ast.nexp -> Ast.nexp -> Ast.nexp
Sourceval npow2 : Ast.nexp -> Ast.nexp
Sourceval nvar : Ast.kid -> Ast.nexp
Sourceval napp : Ast.id -> Ast.nexp list -> Ast.nexp
Sourceval nid : Ast.id -> Ast.nexp

Functions for building numeric constraints

Sourceval nc_false : Ast.n_constraint
Sourceval nc_set : Ast.nexp -> Big_int.num list -> Ast.n_constraint
Sourceval nc_int_set : Ast.nexp -> int list -> Ast.n_constraint

Functions for building type arguments

Sourceval arg_nexp : ?loc:Ast.l -> Ast.nexp -> Ast.typ_arg
Sourceval arg_typ : ?loc:Ast.l -> Ast.typ -> Ast.typ_arg
Sourceval arg_bool : ?loc:Ast.l -> Ast.n_constraint -> Ast.typ_arg

Set and Map modules for various AST elements

Sourcemodule Id : sig ... end
Sourcemodule Kid : sig ... end
Sourcemodule Kind : sig ... end
Sourcemodule KOpt : sig ... end
Sourcemodule Nexp : sig ... end
Sourcemodule NC : sig ... end
Sourcemodule Typ : sig ... end
Sourcemodule IdSet : sig ... end
Sourcemodule NexpSet : sig ... end
Sourcemodule NexpMap : sig ... end
Sourcemodule KOptSet : sig ... end
Sourcemodule KOptMap : sig ... end
Sourcemodule KidSet : sig ... end
Sourcemodule KBindings : sig ... end
Sourcemodule Bindings : sig ... end
Sourcemodule NCMap : sig ... end
Sourcemodule TypMap : sig ... end

Functions for working with type quantifiers

Sourceval quant_items : Ast.typquant -> Ast.quant_item list
Sourceval quant_kopts : Ast.typquant -> Ast.kinded_id list
Sourceval quant_split : Ast.typquant -> Ast.kinded_id list * Ast.n_constraint list
Sourceval quant_fold_map_items : ('acc -> Ast.quant_item -> 'acc * Ast.quant_item) -> 'acc -> Ast.typquant -> 'acc * Ast.typquant
Sourceval is_quant_kopt : Ast.quant_item -> bool
Sourceval is_quant_constraint : Ast.quant_item -> bool

Functions to map over annotations in sub-expressions

Sourceval map_exp_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.exp -> 'b Ast.exp
Sourceval map_pat_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.pat -> 'b Ast.pat
Sourceval map_pexp_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.pexp -> 'b Ast.pexp
Sourceval map_lexp_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.lexp -> 'b Ast.lexp
Sourceval map_letbind_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.letbind -> 'b Ast.letbind
Sourceval map_mpat_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.mpat -> 'b Ast.mpat
Sourceval map_mpexp_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.mpexp -> 'b Ast.mpexp
Sourceval map_mapcl_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.mapcl -> 'b Ast.mapcl
Sourceval map_typedef_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.type_def -> 'b Ast.type_def
Sourceval map_fundef_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.fundef -> 'b Ast.fundef
Sourceval map_funcl_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.funcl -> 'b Ast.funcl
Sourceval map_mapdef_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.mapdef -> 'b Ast.mapdef
Sourceval map_valspec_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.val_spec -> 'b Ast.val_spec
Sourceval map_register_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.dec_spec -> 'b Ast.dec_spec
Sourceval map_scattered_annot : ('a Ast.annot -> 'b Ast.annot) -> 'a Ast.scattered_def -> 'b Ast.scattered_def
Sourceval map_def_annot : ('a Ast.annot -> 'b Ast.annot) -> ('a, 'c) Ast.def -> ('b, 'c) Ast.def
Sourceval map_def_def_annot : ('a Ast.def_annot -> 'b Ast.def_annot) -> ('c, 'a) Ast.def -> ('c, 'b) Ast.def
Sourceval map_ast_annot : ('a Ast.annot -> 'b Ast.annot) -> ('a, 'c) Ast_defs.ast -> ('b, 'c) Ast_defs.ast
Sourceval id_loc : Ast.id -> Parse_ast.l

Extract locations from terms

Sourceval kid_loc : Ast.kid -> Parse_ast.l
Sourceval typ_loc : Ast.typ -> Parse_ast.l
Sourceval pat_loc : 'a Ast.pat -> Parse_ast.l
Sourceval mpat_loc : 'a Ast.mpat -> Parse_ast.l
Sourceval exp_loc : 'a Ast.exp -> Parse_ast.l
Sourceval lexp_loc : 'a Ast.lexp -> Parse_ast.l
Sourceval nexp_loc : Ast.nexp -> Parse_ast.l
Sourceval constraint_loc : Ast.n_constraint -> Parse_ast.l
Sourceval def_loc : ('a, 'b) Ast.def -> Parse_ast.l

Printing utilities

Note: For debugging and error messages only - not guaranteed to produce parseable Sail, or even print all language constructs!

Sourceval string_of_order : Ast.order -> string
Sourceval string_of_id : Ast.id -> string
Sourceval string_of_kid : Ast.kid -> string
Sourceval string_of_kind_aux : Ast.kind_aux -> string
Sourceval string_of_kind : Ast.kind -> string
Sourceval string_of_nexp : Ast.nexp -> string
Sourceval string_of_typ : Ast.typ -> string
Sourceval string_of_typ_arg : Ast.typ_arg -> string
Sourceval string_of_typ_pat : Ast.typ_pat -> string
Sourceval string_of_n_constraint : Ast.n_constraint -> string
Sourceval string_of_kinded_id : Ast.kinded_id -> string
Sourceval string_of_quant_item : Ast.quant_item -> string
Sourceval string_of_typquant : Ast.typquant -> string
Sourceval string_of_typschm : Ast.typschm -> string
Sourceval string_of_lit : Ast.lit -> string
Sourceval string_of_exp : 'a Ast.exp -> string
Sourceval string_of_pexp : 'a Ast.pexp -> string
Sourceval string_of_lexp : 'a Ast.lexp -> string
Sourceval string_of_pat : 'a Ast.pat -> string
Sourceval string_of_mpat : 'a Ast.mpat -> string
Sourceval string_of_letbind : 'a Ast.letbind -> string
Sourceval string_of_index_range : Ast.index_range -> string

Functions for getting identifiers from toplevel definitions

Sourceval id_of_fundef : 'a Ast.fundef -> Ast.id
Sourceval id_of_mapdef : 'a Ast.mapdef -> Ast.id
Sourceval id_of_type_def_aux : Ast.type_def_aux -> Ast.id
Sourceval id_of_type_def : 'a Ast.type_def -> Ast.id
Sourceval id_of_val_spec : 'a Ast.val_spec -> Ast.id
Sourceval id_of_dec_spec : 'a Ast.dec_spec -> Ast.id

Functions for manipulating identifiers

Sourceval natural_id_compare : Ast.id -> Ast.id -> int
Sourceval natural_sort_ids : Ast.id list -> Ast.id list
Sourceval deinfix : Ast.id -> Ast.id
Sourceval infix_swap : Ast.id -> Ast.id
Sourceval id_of_kid : Ast.kid -> Ast.id
Sourceval kid_of_id : Ast.id -> Ast.kid
Sourceval prepend_id : string -> Ast.id -> Ast.id
Sourceval append_id : Ast.id -> string -> Ast.id
Sourceval remove_id_suffix : Ast.id -> string -> Ast.id option
Sourceval prepend_kid : string -> Ast.kid -> Ast.kid

Misc functions

Sourceval nexp_identical : Ast.nexp -> Ast.nexp -> bool
Sourceval is_nexp_constant : Ast.nexp -> bool
Sourceval int_of_nexp_opt : Ast.nexp -> Big_int.num option
Sourceval lexp_to_exp : 'a Ast.lexp -> 'a Ast.exp
Sourceval typ_app_args_of : Ast.typ -> string * Ast.typ_arg_aux list * Ast.l
Sourceval vector_typ_args_of : Ast.typ -> Ast.nexp * Ast.typ
Sourceval kopts_of_nexp : Ast.nexp -> KOptSet.t
Sourceval kopts_of_typ : Ast.typ -> KOptSet.t
Sourceval kopts_of_typ_arg : Ast.typ_arg -> KOptSet.t
Sourceval kopts_of_constraint : Ast.n_constraint -> KOptSet.t
Sourceval kopts_of_quant_item : Ast.quant_item -> KOptSet.t
Sourceval ids_of_nexp : Ast.nexp -> IdSet.t
Sourceval ids_of_constraint : Ast.n_constraint -> IdSet.t
Sourceval ids_of_typ : Ast.typ -> IdSet.t
Sourceval ids_of_typ_arg : Ast.typ_arg -> IdSet.t
Sourceval tyvars_of_nexp : Ast.nexp -> KidSet.t
Sourceval tyvars_of_typ : Ast.typ -> KidSet.t
Sourceval tyvars_of_typ_arg : Ast.typ_arg -> KidSet.t
Sourceval tyvars_of_constraint : Ast.n_constraint -> KidSet.t
Sourceval tyvars_of_quant_item : Ast.quant_item -> KidSet.t
Sourceval is_kid_generated : Ast.kid -> bool
Sourceval undefined_of_typ : bool -> Ast.l -> (Ast.typ -> 'annot) -> Ast.typ -> 'annot Ast.exp
Sourceval pattern_vector_subranges : 'a Ast.pat -> (Big_int.num * Big_int.num) list Bindings.t
Sourceval destruct_pexp : 'a Ast.pexp -> 'a Ast.pat * 'a Ast.exp option * 'a Ast.exp * (Ast.l * 'a)
Sourceval construct_pexp : ('a Ast.pat * 'a Ast.exp option * 'a Ast.exp * (Ast.l * 'a)) -> 'a Ast.pexp
Sourceval destruct_mpexp : 'a Ast.mpexp -> 'a Ast.mpat * 'a Ast.exp option * (Ast.l * 'a)
Sourceval construct_mpexp : ('a Ast.mpat * 'a Ast.exp option * (Ast.l * 'a)) -> 'a Ast.mpexp
Sourceval is_valspec : Ast.id -> ('a, 'b) Ast.def -> bool
Sourceval is_fundef : Ast.id -> ('a, 'b) Ast.def -> bool
Sourceval rename_valspec : Ast.id -> 'a Ast.val_spec -> 'a Ast.val_spec
Sourceval rename_fundef : Ast.id -> 'a Ast.fundef -> 'a Ast.fundef
Sourceval split_defs : (('a, 'b) Ast.def -> bool) -> ('a, 'b) Ast.def list -> (('a, 'b) Ast.def list * ('a, 'b) Ast.def * ('a, 'b) Ast.def list) option
Sourceval append_ast : ('a, 'b) Ast_defs.ast -> ('a, 'b) Ast_defs.ast -> ('a, 'b) Ast_defs.ast
Sourceval append_ast_defs : ('a, 'b) Ast_defs.ast -> ('a, 'b) Ast.def list -> ('a, 'b) Ast_defs.ast
Sourceval concat_ast : ('a, 'b) Ast_defs.ast list -> ('a, 'b) Ast_defs.ast
Sourceval type_union_id : Ast.type_union -> Ast.id
Sourceval ids_of_def : ('a, 'b) Ast.def -> IdSet.t
Sourceval ids_of_defs : ('a, 'b) Ast.def list -> IdSet.t
Sourceval ids_of_ast : ('a, 'b) Ast_defs.ast -> IdSet.t
Sourceval val_spec_ids : ('a, 'b) Ast.def list -> IdSet.t
Sourceval record_ids : ('a, 'b) Ast.def list -> IdSet.t
Sourceval get_scattered_union_clauses : Ast.id -> ('a, 'b) Ast.def list -> Ast.type_union list
Sourceval get_scattered_enum_clauses : Ast.id -> ('a, 'b) Ast.def list -> Ast.id list
Sourceval pat_ids : 'a Ast.pat -> IdSet.t
Sourceval subst : Ast.id -> 'a Ast.exp -> 'a Ast.exp -> 'a Ast.exp
Sourceval hex_to_bin : string -> string
Sourceval vector_string_to_bit_list : Ast.lit -> Ast.lit list
Sourceval extern_assoc : string -> Ast.extern option -> string option

Manipulating locations

Sourceval locate : (Ast.l -> Ast.l) -> 'a Ast.exp -> 'a Ast.exp

locate takes an expression and recursively sets the location in every subexpression using a function that takes the orginal location as an argument. Expressions build using mk_exp and similar do not have locations, so they can then be annotated as e.g. locate (gen_loc l) (mk_exp ...) where l is the location from which the code is being generated.

Sourceval locate_pat : (Ast.l -> Ast.l) -> 'a Ast.pat -> 'a Ast.pat
Sourceval locate_lexp : (Ast.l -> Ast.l) -> 'a Ast.lexp -> 'a Ast.lexp
Sourceval locate_typ : (Ast.l -> Ast.l) -> Ast.typ -> Ast.typ
Sourceval locate_letbind : (Ast.l -> Ast.l) -> 'a Ast.letbind -> 'a Ast.letbind
Sourceval unique : Ast.l -> Ast.l

Make a unique location by giving it a Parse_ast.Unique wrapper with a generated number.

Sourceval unknown_to : Ast.l -> Ast.l -> Ast.l

Convert unknown locations into known ones by replacing any Unknown subparts of the second argument with the first argument. Set up so one can do: locate (unknown_to l) exp and similar.

Sourcemodule Scanner (Loc : sig ... end) : sig ... end

Try to find the annotation closest to the provided location (which can be in any format, as long as we can tell if it is smaller than any other location). Note that this function makes no guarantees about finding the closest annotation or even finding an annotation at all. This is used by the LSP to provide type-at-cursor functionality and we don't mind if it's a bit fuzzy in that context.

Substitutions

The function X_subst substitutes a type argument into something of type X. The type of the type argument determines which kind of type variables will be replaced

Sourceval nexp_subst : Ast.kid -> Ast.typ_arg -> Ast.nexp -> Ast.nexp
Sourceval typ_subst : Ast.kid -> Ast.typ_arg -> Ast.typ -> Ast.typ
Sourceval typ_arg_subst : Ast.kid -> Ast.typ_arg -> Ast.typ_arg -> Ast.typ_arg
Sourceval typquant_subst : Ast.kid -> Ast.typ_arg -> Ast.typquant -> Ast.typquant
Sourceval subst_kid : (Ast.kid -> Ast.typ_arg -> 'a -> 'a) -> Ast.kid -> Ast.kid -> 'a -> 'a
Sourceval subst_kids_nexp : Ast.nexp KBindings.t -> Ast.nexp -> Ast.nexp
Sourceval subst_kids_typ : Ast.nexp KBindings.t -> Ast.typ -> Ast.typ
Sourceval subst_kids_typ_arg : Ast.nexp KBindings.t -> Ast.typ_arg -> Ast.typ_arg
Sourceval quant_item_subst_kid : Ast.kid -> Ast.kid -> Ast.quant_item -> Ast.quant_item
Sourceval typquant_subst_kid : Ast.kid -> Ast.kid -> Ast.typquant -> Ast.typquant
Sourceval simple_string_of_loc : Parse_ast.l -> string
OCaml

Innovation. Community. Security.