package ppx_tools

  1. Overview
  2. Docs

Convenience functions to help build and deconstruct AST fragments.

Compatibility modules

module Label : sig ... end
module Constant : sig ... end

Misc

val lid : ?loc:Ast_helper.loc -> string -> Ast_helper.lid

Expressions

val evar : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> string -> Parsetree.expression
val let_in : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> ?recursive:bool -> Parsetree.value_binding list -> Parsetree.expression -> Parsetree.expression
val constr : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> string -> Parsetree.expression list -> Parsetree.expression
val record : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> ?over:Parsetree.expression -> (string * Parsetree.expression) list -> Parsetree.expression
val nil : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> unit -> Parsetree.expression
val unit : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> unit -> Parsetree.expression
val str : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> string -> Parsetree.expression
val int : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> int -> Parsetree.expression
val int32 : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> int32 -> Parsetree.expression
val int64 : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> int64 -> Parsetree.expression
val char : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> char -> Parsetree.expression
val float : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> float -> Parsetree.expression

Return () if the list is empty. Tail rec.

Patterns

val pvar : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> string -> Parsetree.pattern
val pconstr : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> string -> Parsetree.pattern list -> Parsetree.pattern
val precord : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> ?closed:Asttypes.closed_flag -> (string * Parsetree.pattern) list -> Parsetree.pattern
val pnil : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> unit -> Parsetree.pattern
val pstr : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> string -> Parsetree.pattern
val pint : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> int -> Parsetree.pattern
val pchar : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> char -> Parsetree.pattern
val pfloat : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> float -> Parsetree.pattern
val punit : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> unit -> Parsetree.pattern

Types

val tconstr : ?loc:Ast_helper.loc -> ?attrs:Ast_helper.attrs -> string -> Parsetree.core_type list -> Parsetree.core_type

AST deconstruction

val get_str : Parsetree.expression -> string option
val get_str_with_quotation_delimiter : Parsetree.expression -> (string * string option) option
val get_lid : Parsetree.expression -> string option
val has_attr : string -> Parsetree.attributes -> bool
val find_attr : string -> Parsetree.attributes -> Parsetree.payload option
val find_attr_expr : string -> Parsetree.attributes -> Parsetree.expression option
OCaml

Innovation. Community. Security.