Module ErlangFrontend.ErlangAst

Erlang abstract forms, following https://erlang.org/doc/apps/erts/absform.html

Basics

type module_reference =
  1. | ModuleName of string
  2. | ModuleMissing
  3. | ModuleVariable of string
val sexp_of_module_reference : module_reference -> Sexplib0.Sexp.t
type function_reference =
  1. | FunctionName of string
  2. | FunctionVariable of string
val sexp_of_function_reference : function_reference -> Sexplib0.Sexp.t
type function_ = {
  1. module_ : module_reference;
  2. function_ : function_reference;
  3. arity : int;
}
val sexp_of_function_ : function_ -> Sexplib0.Sexp.t
type location = {
  1. line : int;
  2. col : int;
}
val sexp_of_location : location -> Sexplib0.Sexp.t
type record_name = string
val sexp_of_record_name : record_name -> Sexplib0.Sexp.t
type binary_operator =
  1. | Add
  2. | And
  3. | AndAlso
  4. | AtLeast
  5. | AtMost
  6. | BAnd
  7. | BOr
  8. | Bsl
  9. | Bsr
  10. | BXor
  11. | Equal
  12. | ExactlyEqual
  13. | ExactlyNotEqual
  14. | FDiv
  15. | Greater
  16. | IDiv
  17. | Less
  18. | ListAdd
  19. | ListSub
  20. | Mul
  21. | NotEqual
  22. | Or
  23. | OrElse
  24. | Rem
  25. | Send
  26. | Sub
  27. | Xor
val sexp_of_binary_operator : binary_operator -> Sexplib0.Sexp.t
type unary_operator =
  1. | UBNot
  2. | UMinus
  3. | UNot
val sexp_of_unary_operator : unary_operator -> Sexplib0.Sexp.t
type association_kind =
  1. | Arrow
  2. | Exact
val sexp_of_association_kind : association_kind -> Sexplib0.Sexp.t
type exception_ =
  1. | Atom of string
  2. | Pattern of string
val sexp_of_exception_ : exception_ -> Sexplib0.Sexp.t
type type_specifier = unit
val sexp_of_type_specifier : type_specifier -> Sexplib0.Sexp.t

S8.2: Atomic literals

type literal =
  1. | Atom of string
  2. | Char of string
  3. | Float of float
  4. | Int of string
  5. | String of string
val sexp_of_literal : literal -> Sexplib0.Sexp.t

S8.4: Expressions

type body = expression list
and simple_expression =
  1. | BinaryOperator of expression * binary_operator * expression
  2. | BitstringComprehension of {
    1. expression : expression;
    2. qualifiers : qualifier list;
    }
  3. | BitstringConstructor of bin_element list
  4. | Block of body
  5. | Call of {
    1. module_ : expression option;
    2. function_ : expression;
    3. args : expression list;
    }
  6. | Case of {
    1. expression : expression;
    2. cases : case_clause list;
    }
  7. | Catch of expression
  8. | Cons of {
    1. head : expression;
    2. tail : expression;
    }
  9. | Fun of function_
  10. | If of case_clause list
  11. | Lambda of {
    1. name : string option;
    2. cases : case_clause list;
    3. mutable procname : IR.Procname.t option;
    4. mutable captured : IR.Pvar.Set.t option;
    }
  12. | ListComprehension of {
    1. expression : expression;
    2. qualifiers : qualifier list;
    }
  13. | Literal of literal
  14. | Map of {
    1. map : expression option;
    2. updates : association list;
    }
  15. | MapComprehension of {
    1. expression : association;
    2. qualifiers : qualifier list;
    }
  16. | Match of {
    1. pattern : expression;
    2. body : expression;
    }
  17. | Maybe of {
    1. body : body;
    2. else_cases : case_clause list;
    }
  18. | MaybeMatch of {
    1. pattern : expression;
    2. body : expression;
    }
  19. | Nil
  20. | Receive of {
    1. cases : case_clause list;
    2. timeout : timeout option;
    }
  21. | RecordAccess of {
    1. record : expression;
    2. name : record_name;
    3. field : string;
    }
  22. | RecordIndex of {
    1. name : record_name;
    2. field : string;
    }
  23. | RecordUpdate of {
    1. record : expression option;
    2. name : record_name;
    3. updates : record_update list;
    }
  24. | TryCatch of {
    1. body : body;
    2. ok_cases : case_clause list;
    3. catch_cases : catch_clause list;
    4. after : body;
    }
  25. | Tuple of expression list
  26. | UnaryOperator of unary_operator * expression
  27. | Variable of {
    1. vname : string;
    2. mutable scope : IR.Procname.t option;
    }
and expression = {
  1. location : location;
  2. simple_expression : simple_expression;
}
and qualifier =
  1. | BitsGenerator of {
    1. pattern : expression;
    2. expression : expression;
    }
  2. | Filter of expression
  3. | Generator of {
    1. pattern : expression;
    2. expression : expression;
    }
  4. | MapGenerator of {
    1. pattern : association;
    2. expression : expression;
    }
and timeout = {
  1. time : expression;
  2. handler : body;
}
and bin_element = {
  1. expression : expression;
  2. size : expression option;
  3. types : type_specifier list option;
}
and record_update = {
  1. field : string option;
  2. expression : expression;
}
and association = {
  1. kind : association_kind;
  2. key : expression;
  3. value : expression;
}

S8.5 Clauses

and 'pat clause = {
  1. location : location;
  2. patterns : 'pat list;
  3. guards : expression list list;
  4. body : body;
}
and case_clause = expression clause
and catch_clause = catch_pattern clause
and catch_pattern = {
  1. exception_ : exception_;
  2. pattern : expression;
  3. variable : string;
}
val sexp_of_body : body -> Sexplib0.Sexp.t
val sexp_of_simple_expression : simple_expression -> Sexplib0.Sexp.t
val sexp_of_expression : expression -> Sexplib0.Sexp.t
val sexp_of_qualifier : qualifier -> Sexplib0.Sexp.t
val sexp_of_timeout : timeout -> Sexplib0.Sexp.t
val sexp_of_bin_element : bin_element -> Sexplib0.Sexp.t
val sexp_of_record_update : record_update -> Sexplib0.Sexp.t
val sexp_of_association : association -> Sexplib0.Sexp.t
val sexp_of_clause : 'pat. ('pat -> Sexplib0.Sexp.t) -> 'pat clause -> Sexplib0.Sexp.t
val sexp_of_case_clause : case_clause -> Sexplib0.Sexp.t
val sexp_of_catch_clause : catch_clause -> Sexplib0.Sexp.t
val sexp_of_catch_pattern : catch_pattern -> Sexplib0.Sexp.t

S8.7 Types

See also https://www.erlang.org/doc/reference_manual/typespec.html

type atom_type =
  1. | Any
  2. | Literal of string
val sexp_of_atom_type : atom_type -> Sexplib0.Sexp.t
type integer_type =
  1. | Any
  2. | Literal of int
  3. | Range of {
    1. low : int;
    2. high : int;
    }
  4. | Neg
  5. | NonNeg
  6. | Pos
val sexp_of_integer_type : integer_type -> Sexplib0.Sexp.t
type type_ =
  1. | Any
  2. | Atom of atom_type
  3. | BitString of {
    1. start_size : int;
    2. segment_size : int;
    }
  4. | Integer of integer_type
  5. | List of list_type
  6. | Map
  7. | Nil
  8. | None
  9. | Pid
  10. | Port
  11. | Record of string
  12. | Reference
  13. | Remote of {
    1. module_ : string;
    2. type_ : string;
    }
  14. | Tuple of tuple_type
  15. | Union of type_ list
  16. | UserDefined of string
  17. | Var of string
  18. | Unsupported
and list_type =
  1. | Proper of type_
and tuple_type =
  1. | AnySize
  2. | FixedSize of type_ list
val sexp_of_type_ : type_ -> Sexplib0.Sexp.t
val sexp_of_list_type : list_type -> Sexplib0.Sexp.t
val sexp_of_tuple_type : tuple_type -> Sexplib0.Sexp.t
type spec_disjunct = {
  1. arguments : type_ list;
  2. return : type_;
  3. constraints : type_ IStdlib.IStd.String.Map.t;
}
val sexp_of_spec_disjunct : spec_disjunct -> Sexplib0.Sexp.t
type spec = spec_disjunct list
val sexp_of_spec : spec -> Sexplib0.Sexp.t

S8.1: Module declarations and forms

type record_field = {
  1. field_name : string;
  2. initializer_ : expression option;
}
val sexp_of_record_field : record_field -> Sexplib0.Sexp.t
type attribute_record = {
  1. tag : string;
  2. value : string;
}
val sexp_of_attribute_record : attribute_record -> Sexplib0.Sexp.t
type attribute =
  1. | StringAttribute of attribute_record
val sexp_of_attribute : attribute -> Sexplib0.Sexp.t
type simple_form =
  1. | Export of function_ list
  2. | Import of {
    1. module_name : string;
    2. functions : function_ list;
    }
  3. | Module of string
  4. | Attribute of attribute
  5. | File of {
    1. path : string;
    }
  6. | Function of {
    1. function_ : function_;
    2. clauses : case_clause list;
    }
  7. | Record of {
    1. name : string;
    2. fields : record_field list;
    }
  8. | Spec of {
    1. function_ : function_;
    2. spec : spec;
    }
  9. | Type of {
    1. name : string;
    2. type_ : type_;
    }
val sexp_of_simple_form : simple_form -> Sexplib0.Sexp.t
type form = {
  1. location : location;
  2. simple_form : simple_form;
}
val sexp_of_form : form -> Sexplib0.Sexp.t
type module_ = form list
val sexp_of_module_ : module_ -> Sexplib0.Sexp.t