package ppx_nanocaml

  1. Overview
  2. Docs
type np_type =
  1. | NP_term of Ast.core_type
    (*

    external types are "terminals" *

    *)
  2. | NP_nonterm of string
    (*

    named nonterminal *

    *)
  3. | NP_tuple of np_type list
    (*

    t * u * ... *

    *)
  4. | NP_list of np_type
    (*

    t list *

    *)

a type recognized by nanopass; usually a part of a production. e.g. string, stmt, (string * expr) list *

type np_production = {
  1. nppr_name : string;
  2. nppr_arg : np_type option;
}

a production is one of the forms in a nonterminal -- essentially just a variant, e.g. `Var, `App. *

type np_nonterm = {
  1. npnt_loc : Nanocaml.Ast.Location.t;
  2. npnt_name : string;
  3. npnt_productions : np_production list;
}

a nonterminal is a type defined by a nanopass language, e.g. expr, stmt. *

type np_language = {
  1. npl_loc : Nanocaml.Ast.Location.t;
  2. npl_name : string;
  3. npl_nonterms : np_nonterm list;
}

a nanopass language, e.g. L0, L1 (as traditionally named) *

val string_of_type : np_type -> string
val languages : (string, np_language) Batteries.Hashtbl.t

global table of all defined languages. *

val add_language : np_language -> unit

globally registers the given language. raises Location.Error if a language with the same name is already defined. *

val find_language : ?exn:exn -> string -> np_language

returns the language with the given name. raises Not_found if no such language has been defined. *

val language_nonterm : ?exn:exn -> np_language -> string -> np_nonterm

language_nonterm l name returns the nonterminal in language l with the given name. raises Not_found if no such nonterminal.

val type_of_core_type : nt_names:string list -> Ast.core_type -> np_type

convert core_type into nanopass type. *

val production_of_row_field : nt_names:string list -> Ast.row_field -> np_production

convert row_field (from polymorphic variant) into nanopass production *

val nonterm_of_type_decl : ?extending:np_language -> nt_names:string list -> Ast.type_declaration -> np_nonterm

convert type_declaration into nanopass nonterminal *

val language_of_module : Ast.module_binding -> np_language

convert module_binding into nanopass language *