package ppx_nanocaml

  1. Overview
  2. Docs
type 'a loc = 'a Nanocaml.Ast.Asttypes.loc
type np_pass = {
  1. npp_name : string;
  2. npp_loc : Nanocaml.Ast.Location.t;
  3. npp_input : Lang.np_language;
  4. npp_output : Lang.np_language;
  5. npp_pre : Ast.expression -> Ast.expression;
  6. npp_post : Ast.expression;
  7. npp_procs : np_processor list;
}

represents a nanopass definition *

and np_processor = {
  1. npc_name : string;
  2. npc_loc : Nanocaml.Ast.Location.t;
  3. npc_dom : Lang.np_nonterm;
  4. npc_cod : Lang.np_nonterm option;
  5. npc_args : fun_arg list;
  6. npc_clauses : clause list;
  7. npc_clauses_loc : Nanocaml.Ast.Location.t;
}

represents a processor definition (a transformation between nonterminals in a nanopass) *

and clause = np_pat * Ast.expression
and np_pat =
  1. | NPpat_any of Nanocaml.Ast.Location.t
  2. | NPpat_var of string loc
  3. | NPpat_alias of np_pat * string loc
  4. | NPpat_tuple of np_pat list * Nanocaml.Ast.Location.t
  5. | NPpat_variant of string * np_pat option * Nanocaml.Ast.Location.t
  6. | NPpat_map of np_pat
  7. | NPpat_cata of np_pat * Ast.expression option

represents a pattern in a production. the pattern must be parsed by nanocaml so that we can correctly map over lists and apply catamorphims, e.g. for expressions like (x, e [@r]) [@l]. *

val loc_of_pat : np_pat -> Nanocaml.Ast.Location.t

returns the Location.t of the given pattern. *

val processor_of_rhs : name:string -> dom:Lang.np_nonterm -> cod:Lang.np_nonterm option -> loc:Nanocaml.Ast.Location.t -> Ast.expression -> np_processor

convert the RHS of a let into a np_processor. *

val pat_of_pattern : Ast.pattern -> np_pat

convert a pattern into a np_pat. *

val signature_arrow : string
val extract_pass_sig : Ast.expression -> (string * Location.t) * (string * Location.t)

extract L0 and L1 out of expression of form L0 --> L1. returns ("L0", loc_L0), ("L1", loc_L1) (for this particular example). *

val extract_dom_cod : loc:Nanocaml.Ast.Location.t -> Lang.np_language -> Lang.np_language -> string -> Lang.np_nonterm * Lang.np_nonterm option

extract domain and co-domain from the name of a production. the rules are: y_of_x => dom="x", cod="y" x_to_y => dom="x", cod="y" x => dom=cod="x" x_f => dom="x", cof=None

if the co-domain is not a valid nonterm of the output language, then the co-domain is None.

given the string name, returns dom, opt_cod. *

val pass_of_value_binding : Ast.value_binding -> np_pass

convert a value_binding into a np_pass