Frontend.Ast
Abstract syntax tree for Stan. Defined with the 'two-level types' pattern, where the variant types are not directly recursive, but rather parametric in some other type.
This type ends up being substituted for the fixpoint of the recursive type itself including metadata. So instead of recursively referencing expression
you would instead reference type parameter 'e
, which will later be filled in with something like type expr_with_meta = metadata expression
Our type for identifiers, on which we record a location
val identifier_of_sexp : Sexplib0.Sexp.t -> identifier
val sexp_of_identifier : identifier -> Sexplib0.Sexp.t
val hash_fold_identifier :
Ppx_hash_lib.Std.Hash.state ->
identifier ->
Ppx_hash_lib.Std.Hash.state
val hash_identifier : identifier -> Ppx_hash_lib.Std.Hash.hash_value
val compare_identifier : identifier -> identifier -> int
Indices for array access
val fold_index : ('a -> 'b -> 'a) -> 'a -> 'b index -> 'a
val index_of_sexp : 'e. (Sexplib0.Sexp.t -> 'e) -> Sexplib0.Sexp.t -> 'e index
val sexp_of_index : 'e. ('e -> Sexplib0.Sexp.t) -> 'e index -> Sexplib0.Sexp.t
val hash_fold_index :
'e. (Ppx_hash_lib.Std.Hash.state -> 'e -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
'e index ->
Ppx_hash_lib.Std.Hash.state
type fun_kind =
| StanLib of bool Middle.Fun_kind.suffix
| UserDefined of bool Middle.Fun_kind.suffix
Front-end function kinds
val fun_kind_of_sexp : Sexplib0.Sexp.t -> fun_kind
val sexp_of_fun_kind : fun_kind -> Sexplib0.Sexp.t
val hash_fold_fun_kind :
Ppx_hash_lib.Std.Hash.state ->
fun_kind ->
Ppx_hash_lib.Std.Hash.state
val hash_fun_kind : fun_kind -> Ppx_hash_lib.Std.Hash.hash_value
type ('e, 'f) expression =
| TernaryIf of 'e * 'e * 'e
| BinOp of 'e * Middle.Operator.t * 'e
| PrefixOp of Middle.Operator.t * 'e
| PostfixOp of 'e * Middle.Operator.t
| Variable of identifier
| IntNumeral of string
| RealNumeral of string
| ImagNumeral of string
| FunApp of 'f * identifier * 'e list
| CondDistApp of 'f * identifier * 'e list
| Promotion of 'e * Middle.UnsizedType.t * Middle.UnsizedType.autodifftype
| GetTarget
| ArrayExpr of 'e list
| RowVectorExpr of 'e list
| Paren of 'e
| Indexed of 'e * 'e index list
| TupleProjection of 'e * int
| TupleExpr of 'e list
Expression shapes (used for both typed and untyped expressions, where we substitute untyped_expression or typed_expression for 'e
val map_expression :
('a -> 'b) ->
('c -> 'd) ->
('a, 'c) expression ->
('b, 'd) expression
val fold_expression :
('a -> 'b -> 'a) ->
('a -> 'c -> 'a) ->
'a ->
('b, 'c) expression ->
'a
val expression_of_sexp :
'e 'f. (Sexplib0.Sexp.t -> 'e) ->
(Sexplib0.Sexp.t -> 'f) ->
Sexplib0.Sexp.t ->
('e, 'f) expression
val sexp_of_expression :
'e 'f. ('e -> Sexplib0.Sexp.t) ->
('f -> Sexplib0.Sexp.t) ->
('e, 'f) expression ->
Sexplib0.Sexp.t
val hash_fold_expression :
'e 'f. (Ppx_hash_lib.Std.Hash.state -> 'e -> Ppx_hash_lib.Std.Hash.state) ->
(Ppx_hash_lib.Std.Hash.state -> 'f -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
('e, 'f) expression ->
Ppx_hash_lib.Std.Hash.state
val compare_expression :
'e 'f. ('e -> 'e -> Core__.Import.int) ->
('f -> 'f -> Core__.Import.int) ->
('e, 'f) expression ->
('e, 'f) expression ->
Core__.Import.int
val fold_expr_with :
('a -> 'b -> 'a) ->
('a -> 'c -> 'a) ->
'a ->
('b, 'c) expr_with ->
'a
val expr_with_of_sexp :
'm 'f. (Sexplib0.Sexp.t -> 'm) ->
(Sexplib0.Sexp.t -> 'f) ->
Sexplib0.Sexp.t ->
('m, 'f) expr_with
val sexp_of_expr_with :
'm 'f. ('m -> Sexplib0.Sexp.t) ->
('f -> Sexplib0.Sexp.t) ->
('m, 'f) expr_with ->
Sexplib0.Sexp.t
val hash_fold_expr_with :
'm 'f. (Ppx_hash_lib.Std.Hash.state -> 'm -> Ppx_hash_lib.Std.Hash.state) ->
(Ppx_hash_lib.Std.Hash.state -> 'f -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
('m, 'f) expr_with ->
Ppx_hash_lib.Std.Hash.state
Untyped expressions, which have location_spans as meta-data
val map_located_meta : located_meta -> located_meta
val fold_located_meta : 'a -> located_meta -> 'a
val located_meta_of_sexp : Sexplib0.Sexp.t -> located_meta
val sexp_of_located_meta : located_meta -> Sexplib0.Sexp.t
val compare_located_meta : located_meta -> located_meta -> int
val hash_fold_located_meta :
Ppx_hash_lib.Std.Hash.state ->
located_meta ->
Ppx_hash_lib.Std.Hash.state
val hash_located_meta : located_meta -> Ppx_hash_lib.Std.Hash.hash_value
type untyped_expression = (located_meta, unit) expr_with
val untyped_expression_of_sexp : Sexplib0.Sexp.t -> untyped_expression
val sexp_of_untyped_expression : untyped_expression -> Sexplib0.Sexp.t
val compare_untyped_expression :
untyped_expression ->
untyped_expression ->
int
val hash_fold_untyped_expression :
Ppx_hash_lib.Std.Hash.state ->
untyped_expression ->
Ppx_hash_lib.Std.Hash.state
val hash_untyped_expression :
untyped_expression ->
Ppx_hash_lib.Std.Hash.hash_value
type typed_expr_meta = {
loc : Middle.Location_span.t;
ad_level : Middle.UnsizedType.autodifftype;
type_ : Middle.UnsizedType.t;
}
Typed expressions also have meta-data after type checking: a location_span, as well as a type and an origin block (lub of the origin blocks of the identifiers in it)
val map_typed_expr_meta : typed_expr_meta -> typed_expr_meta
val fold_typed_expr_meta : 'a -> typed_expr_meta -> 'a
val typed_expr_meta_of_sexp : Sexplib0.Sexp.t -> typed_expr_meta
val sexp_of_typed_expr_meta : typed_expr_meta -> Sexplib0.Sexp.t
val compare_typed_expr_meta : typed_expr_meta -> typed_expr_meta -> int
val hash_fold_typed_expr_meta :
Ppx_hash_lib.Std.Hash.state ->
typed_expr_meta ->
Ppx_hash_lib.Std.Hash.state
val hash_typed_expr_meta : typed_expr_meta -> Ppx_hash_lib.Std.Hash.hash_value
type typed_expression = (typed_expr_meta, fun_kind) expr_with
val typed_expression_of_sexp : Sexplib0.Sexp.t -> typed_expression
val sexp_of_typed_expression : typed_expression -> Sexplib0.Sexp.t
val compare_typed_expression : typed_expression -> typed_expression -> int
val hash_fold_typed_expression :
Ppx_hash_lib.Std.Hash.state ->
typed_expression ->
Ppx_hash_lib.Std.Hash.state
val hash_typed_expression :
typed_expression ->
Ppx_hash_lib.Std.Hash.hash_value
val mk_untyped_expression :
expr:((located_meta, 'a) expr_with, 'a) expression ->
loc:Middle.Location_span.t ->
(located_meta, 'a) expr_with
val mk_typed_expression :
expr:((typed_expr_meta, 'a) expr_with, 'a) expression ->
loc:Middle.Location_span.t ->
type_:Middle.UnsizedType.t ->
ad_level:Middle.UnsizedType.autodifftype ->
(typed_expr_meta, 'a) expr_with
val expr_loc_lub :
(typed_expr_meta, 'a) expr_with list ->
Middle.Location_span.t
val expr_ad_lub :
(typed_expr_meta, 'a) expr_with list ->
Middle.UnsizedType.autodifftype option
Least upper bound of expression autodiff types
Assignment operators
val assignmentoperator_of_sexp : Sexplib0.Sexp.t -> assignmentoperator
val sexp_of_assignmentoperator : assignmentoperator -> Sexplib0.Sexp.t
val hash_fold_assignmentoperator :
Ppx_hash_lib.Std.Hash.state ->
assignmentoperator ->
Ppx_hash_lib.Std.Hash.state
val hash_assignmentoperator :
assignmentoperator ->
Ppx_hash_lib.Std.Hash.hash_value
val compare_assignmentoperator :
assignmentoperator ->
assignmentoperator ->
int
val map_truncation : ('a -> 'b) -> 'a truncation -> 'b truncation
val fold_truncation : ('a -> 'b -> 'a) -> 'a -> 'b truncation -> 'a
val truncation_of_sexp :
'e. (Sexplib0.Sexp.t -> 'e) ->
Sexplib0.Sexp.t ->
'e truncation
val sexp_of_truncation :
'e. ('e -> Sexplib0.Sexp.t) ->
'e truncation ->
Sexplib0.Sexp.t
val hash_fold_truncation :
'e. (Ppx_hash_lib.Std.Hash.state -> 'e -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
'e truncation ->
Ppx_hash_lib.Std.Hash.state
val compare_truncation :
'e. ('e -> 'e -> int) ->
'e truncation ->
'e truncation ->
int
val fold_printable : ('a -> 'b -> 'a) -> 'a -> 'b printable -> 'a
val printable_of_sexp :
'e. (Sexplib0.Sexp.t -> 'e) ->
Sexplib0.Sexp.t ->
'e printable
val sexp_of_printable :
'e. ('e -> Sexplib0.Sexp.t) ->
'e printable ->
Sexplib0.Sexp.t
val hash_fold_printable :
'e. (Ppx_hash_lib.Std.Hash.state -> 'e -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
'e printable ->
Ppx_hash_lib.Std.Hash.state
type ('l, 'e) lvalue =
| LVariable of identifier
| LIndexed of 'l * 'e index list
| LTupleProjection of 'l * int
val fold_lvalue :
('a -> 'b -> 'a) ->
('a -> 'c -> 'a) ->
'a ->
('b, 'c) lvalue ->
'a
val lvalue_of_sexp :
'l 'e. (Sexplib0.Sexp.t -> 'l) ->
(Sexplib0.Sexp.t -> 'e) ->
Sexplib0.Sexp.t ->
('l, 'e) lvalue
val sexp_of_lvalue :
'l 'e. ('l -> Sexplib0.Sexp.t) ->
('e -> Sexplib0.Sexp.t) ->
('l, 'e) lvalue ->
Sexplib0.Sexp.t
val hash_fold_lvalue :
'l 'e. (Ppx_hash_lib.Std.Hash.state -> 'l -> Ppx_hash_lib.Std.Hash.state) ->
(Ppx_hash_lib.Std.Hash.state -> 'e -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
('l, 'e) lvalue ->
Ppx_hash_lib.Std.Hash.state
type 'l lvalue_pack =
| LValue of 'l
| LTuplePack of {
lvals : 'l lvalue_pack list;
loc : Middle.Location_span.t;
}
val map_lvalue_pack : ('a -> 'b) -> 'a lvalue_pack -> 'b lvalue_pack
val fold_lvalue_pack : ('a -> 'b -> 'a) -> 'a -> 'b lvalue_pack -> 'a
val lvalue_pack_of_sexp :
'l. (Sexplib0.Sexp.t -> 'l) ->
Sexplib0.Sexp.t ->
'l lvalue_pack
val sexp_of_lvalue_pack :
'l. ('l -> Sexplib0.Sexp.t) ->
'l lvalue_pack ->
Sexplib0.Sexp.t
val hash_fold_lvalue_pack :
'l. (Ppx_hash_lib.Std.Hash.state -> 'l -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
'l lvalue_pack ->
Ppx_hash_lib.Std.Hash.state
val compare_lvalue_pack :
'l. ('l -> 'l -> Core__.Import.int) ->
'l lvalue_pack ->
'l lvalue_pack ->
Core__.Import.int
val fold_lval_with :
('a -> 'b -> 'a) ->
('a -> 'c -> 'a) ->
'a ->
('b, 'c) lval_with ->
'a
val lval_with_of_sexp :
'e 'm. (Sexplib0.Sexp.t -> 'e) ->
(Sexplib0.Sexp.t -> 'm) ->
Sexplib0.Sexp.t ->
('e, 'm) lval_with
val sexp_of_lval_with :
'e 'm. ('e -> Sexplib0.Sexp.t) ->
('m -> Sexplib0.Sexp.t) ->
('e, 'm) lval_with ->
Sexplib0.Sexp.t
val hash_fold_lval_with :
'e 'm. (Ppx_hash_lib.Std.Hash.state -> 'e -> Ppx_hash_lib.Std.Hash.state) ->
(Ppx_hash_lib.Std.Hash.state -> 'm -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
('e, 'm) lval_with ->
Ppx_hash_lib.Std.Hash.state
type untyped_lval = (untyped_expression, located_meta) lval_with
val untyped_lval_of_sexp : Sexplib0.Sexp.t -> untyped_lval
val sexp_of_untyped_lval : untyped_lval -> Sexplib0.Sexp.t
val hash_fold_untyped_lval :
Ppx_hash_lib.Std.Hash.state ->
untyped_lval ->
Ppx_hash_lib.Std.Hash.state
val hash_untyped_lval : untyped_lval -> Ppx_hash_lib.Std.Hash.hash_value
val compare_untyped_lval : untyped_lval -> untyped_lval -> int
type untyped_lval_pack = untyped_lval lvalue_pack
val untyped_lval_pack_of_sexp : Sexplib0.Sexp.t -> untyped_lval_pack
val sexp_of_untyped_lval_pack : untyped_lval_pack -> Sexplib0.Sexp.t
val compare_untyped_lval_pack : untyped_lval_pack -> untyped_lval_pack -> int
type typed_lval = (typed_expression, typed_expr_meta) lval_with
val typed_lval_of_sexp : Sexplib0.Sexp.t -> typed_lval
val sexp_of_typed_lval : typed_lval -> Sexplib0.Sexp.t
val hash_fold_typed_lval :
Ppx_hash_lib.Std.Hash.state ->
typed_lval ->
Ppx_hash_lib.Std.Hash.state
val hash_typed_lval : typed_lval -> Ppx_hash_lib.Std.Hash.hash_value
val compare_typed_lval : typed_lval -> typed_lval -> int
type typed_lval_pack = typed_lval lvalue_pack
val typed_lval_pack_of_sexp : Sexplib0.Sexp.t -> typed_lval_pack
val sexp_of_typed_lval_pack : typed_lval_pack -> Sexplib0.Sexp.t
val compare_typed_lval_pack : typed_lval_pack -> typed_lval_pack -> int
val fold_variable : ('a -> 'b -> 'a) -> 'a -> 'b variable -> 'a
val variable_of_sexp :
'e. (Sexplib0.Sexp.t -> 'e) ->
Sexplib0.Sexp.t ->
'e variable
val sexp_of_variable :
'e. ('e -> Sexplib0.Sexp.t) ->
'e variable ->
Sexplib0.Sexp.t
val hash_fold_variable :
'e. (Ppx_hash_lib.Std.Hash.state -> 'e -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
'e variable ->
Ppx_hash_lib.Std.Hash.state
type ('e, 's, 'l, 'f) statement =
| Assignment of {
assign_lhs : 'l lvalue_pack;
assign_op : assignmentoperator;
assign_rhs : 'e;
}
| NRFunApp of 'f * identifier * 'e list
| TargetPE of 'e
| JacobianPE of 'e
| Tilde of {
arg : 'e;
distribution : identifier;
args : 'e list;
truncation : 'e truncation;
}
| Break
| Continue
| Return of 'e
| ReturnVoid
| Print of 'e printable list
| Reject of 'e printable list
| FatalError of 'e printable list
| Skip
| IfThenElse of 'e * 's * 's option
| While of 'e * 's
| For of {
loop_variable : identifier;
lower_bound : 'e;
upper_bound : 'e;
loop_body : 's;
}
| ForEach of identifier * 'e * 's
| Profile of string * 's list
| Block of 's list
| VarDecl of {
decl_type : 'e Middle.SizedType.t;
transformation : 'e Middle.Transformation.t;
is_global : bool;
variables : 'e variable list;
}
| FunDef of {
returntype : Middle.UnsizedType.returntype;
funname : identifier;
arguments : (Middle.UnsizedType.autodifftype
* Middle.UnsizedType.t
* identifier)
list;
body : 's;
}
Statement shapes, where we substitute untyped_expression and untyped_statement for 'e and 's respectively to get untyped_statement and typed_expression and typed_statement to get typed_statement
val fold_statement :
('a -> 'b -> 'a) ->
('a -> 'c -> 'a) ->
('a -> 'd -> 'a) ->
('a -> 'e -> 'a) ->
'a ->
('b, 'c, 'd, 'e) statement ->
'a
val statement_of_sexp :
'e 's 'l 'f. (Sexplib0.Sexp.t -> 'e) ->
(Sexplib0.Sexp.t -> 's) ->
(Sexplib0.Sexp.t -> 'l) ->
(Sexplib0.Sexp.t -> 'f) ->
Sexplib0.Sexp.t ->
('e, 's, 'l, 'f) statement
val sexp_of_statement :
'e 's 'l 'f. ('e -> Sexplib0.Sexp.t) ->
('s -> Sexplib0.Sexp.t) ->
('l -> Sexplib0.Sexp.t) ->
('f -> Sexplib0.Sexp.t) ->
('e, 's, 'l, 'f) statement ->
Sexplib0.Sexp.t
val hash_fold_statement :
'e 's 'l 'f. (Ppx_hash_lib.Std.Hash.state ->
'e ->
Ppx_hash_lib.Std.Hash.state) ->
(Ppx_hash_lib.Std.Hash.state -> 's -> Ppx_hash_lib.Std.Hash.state) ->
(Ppx_hash_lib.Std.Hash.state -> 'l -> Ppx_hash_lib.Std.Hash.state) ->
(Ppx_hash_lib.Std.Hash.state -> 'f -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
('e, 's, 'l, 'f) statement ->
Ppx_hash_lib.Std.Hash.state
Statement return types which we will decorate statements with during type checking:
Complete
corresponds to statements that exit the function (return or error) in every branchIncomplete
corresponds to statements which pass control flow to following statements in at least some branchesNonlocalControlFlow
is simila to Incomplete
but specifically used when breaks are present in loops. Normally, an infinite loop with Incomplete
return type is fine (and considered Complete
), since it either returns or diverges. However, in the presence of break statements, control flow may jump to the end of the loop.val statement_returntype_of_sexp : Sexplib0.Sexp.t -> statement_returntype
val sexp_of_statement_returntype : statement_returntype -> Sexplib0.Sexp.t
val hash_fold_statement_returntype :
Ppx_hash_lib.Std.Hash.state ->
statement_returntype ->
Ppx_hash_lib.Std.Hash.state
val hash_statement_returntype :
statement_returntype ->
Ppx_hash_lib.Std.Hash.hash_value
val compare_statement_returntype :
statement_returntype ->
statement_returntype ->
int
type ('e, 'm, 'l, 'f) statement_with = {
stmt : ('e, ('e, 'm, 'l, 'f) statement_with, 'l, 'f) statement;
smeta : 'm;
}
val map_statement_with :
('e -> 'a) ->
('m -> 'b) ->
('l -> 'c) ->
('f -> 'd) ->
('e, 'm, 'l, 'f) statement_with ->
('a, 'b, 'c, 'd) statement_with
val fold_statement_with :
('a -> 'b -> 'a) ->
('a -> 'c -> 'a) ->
('a -> 'd -> 'a) ->
('a -> 'e -> 'a) ->
'a ->
('b, 'c, 'd, 'e) statement_with ->
'a
val statement_with_of_sexp :
'e 'm 'l 'f. (Sexplib0.Sexp.t -> 'e) ->
(Sexplib0.Sexp.t -> 'm) ->
(Sexplib0.Sexp.t -> 'l) ->
(Sexplib0.Sexp.t -> 'f) ->
Sexplib0.Sexp.t ->
('e, 'm, 'l, 'f) statement_with
val sexp_of_statement_with :
'e 'm 'l 'f. ('e -> Sexplib0.Sexp.t) ->
('m -> Sexplib0.Sexp.t) ->
('l -> Sexplib0.Sexp.t) ->
('f -> Sexplib0.Sexp.t) ->
('e, 'm, 'l, 'f) statement_with ->
Sexplib0.Sexp.t
val compare_statement_with :
'e 'm 'l 'f. ('e -> 'e -> Core__.Import.int) ->
('m -> 'm -> Core__.Import.int) ->
('l -> 'l -> Core__.Import.int) ->
('f -> 'f -> Core__.Import.int) ->
('e, 'm, 'l, 'f) statement_with ->
('e, 'm, 'l, 'f) statement_with ->
Core__.Import.int
val hash_fold_statement_with :
'e 'm 'l 'f. (Ppx_hash_lib.Std.Hash.state ->
'e ->
Ppx_hash_lib.Std.Hash.state) ->
(Ppx_hash_lib.Std.Hash.state -> 'm -> Ppx_hash_lib.Std.Hash.state) ->
(Ppx_hash_lib.Std.Hash.state -> 'l -> Ppx_hash_lib.Std.Hash.state) ->
(Ppx_hash_lib.Std.Hash.state -> 'f -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
('e, 'm, 'l, 'f) statement_with ->
Ppx_hash_lib.Std.Hash.state
type untyped_statement =
(untyped_expression, located_meta, untyped_lval, unit) statement_with
Untyped statements, which have location_spans as meta-data
val untyped_statement_of_sexp : Sexplib0.Sexp.t -> untyped_statement
val sexp_of_untyped_statement : untyped_statement -> Sexplib0.Sexp.t
val compare_untyped_statement : untyped_statement -> untyped_statement -> int
val hash_fold_untyped_statement :
Ppx_hash_lib.Std.Hash.state ->
untyped_statement ->
Ppx_hash_lib.Std.Hash.state
val hash_untyped_statement :
untyped_statement ->
Ppx_hash_lib.Std.Hash.hash_value
val mk_untyped_statement :
stmt:
(untyped_expression,
(untyped_expression, located_meta, untyped_lval, unit) statement_with,
untyped_lval,
unit)
statement ->
loc:Middle.Location_span.t ->
untyped_statement
val map_stmt_typed_located_meta :
stmt_typed_located_meta ->
stmt_typed_located_meta
val stmt_typed_located_meta_of_sexp :
Sexplib0.Sexp.t ->
stmt_typed_located_meta
val sexp_of_stmt_typed_located_meta :
stmt_typed_located_meta ->
Sexplib0.Sexp.t
val compare_stmt_typed_located_meta :
stmt_typed_located_meta ->
stmt_typed_located_meta ->
int
val hash_fold_stmt_typed_located_meta :
Ppx_hash_lib.Std.Hash.state ->
stmt_typed_located_meta ->
Ppx_hash_lib.Std.Hash.state
val hash_stmt_typed_located_meta :
stmt_typed_located_meta ->
Ppx_hash_lib.Std.Hash.hash_value
type typed_statement =
(typed_expression, stmt_typed_located_meta, typed_lval, fun_kind)
statement_with
Typed statements also have meta-data after type checking: a location_span, as well as a statement returntype to check that function bodies have the right return type
val typed_statement_of_sexp : Sexplib0.Sexp.t -> typed_statement
val sexp_of_typed_statement : typed_statement -> Sexplib0.Sexp.t
val compare_typed_statement : typed_statement -> typed_statement -> int
val hash_fold_typed_statement :
Ppx_hash_lib.Std.Hash.state ->
typed_statement ->
Ppx_hash_lib.Std.Hash.state
val hash_typed_statement : typed_statement -> Ppx_hash_lib.Std.Hash.hash_value
val mk_typed_statement :
stmt:
('a, ('a, stmt_typed_located_meta, 'b, 'c) statement_with, 'b, 'c)
statement ->
loc:Middle.Location_span.t ->
return_type:statement_returntype ->
('a, stmt_typed_located_meta, 'b, 'c) statement_with
Program shapes, where we obtain types of programs if we substitute typed or untyped statements for 's
and comment_type =
| LineComment of string * Middle.Location_span.t
| Include of string * Middle.Location_span.t
| BlockComment of string list * Middle.Location_span.t
| Separator of Middle.Location.t
Separator records the location of items like commas, operators, and keywords which don't have location information stored in the AST but are useful for placing comments in pretty printing
*)val map_comment_type : comment_type -> comment_type
val fold_block : ('a -> 'b -> 'a) -> 'a -> 'b block -> 'a
val fold_comment_type : 'a -> comment_type -> 'a
val fold_program : ('a -> 'b -> 'a) -> 'a -> 'b program -> 'a
val block_of_sexp : 's. (Sexplib0.Sexp.t -> 's) -> Sexplib0.Sexp.t -> 's block
val comment_type_of_sexp : Sexplib0.Sexp.t -> comment_type
val program_of_sexp :
's. (Sexplib0.Sexp.t -> 's) ->
Sexplib0.Sexp.t ->
's program
val sexp_of_block : 's. ('s -> Sexplib0.Sexp.t) -> 's block -> Sexplib0.Sexp.t
val sexp_of_comment_type : comment_type -> Sexplib0.Sexp.t
val sexp_of_program :
's. ('s -> Sexplib0.Sexp.t) ->
's program ->
Sexplib0.Sexp.t
val hash_fold_block :
's. (Ppx_hash_lib.Std.Hash.state -> 's -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
's block ->
Ppx_hash_lib.Std.Hash.state
val hash_fold_comment_type :
Ppx_hash_lib.Std.Hash.state ->
comment_type ->
Ppx_hash_lib.Std.Hash.state
val hash_fold_program :
's. (Ppx_hash_lib.Std.Hash.state -> 's -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
's program ->
Ppx_hash_lib.Std.Hash.state
val hash_comment_type : comment_type -> Ppx_hash_lib.Std.Hash.hash_value
val compare_comment_type : comment_type -> comment_type -> int
val get_stmts : 'a block option -> 'a list
type untyped_program = untyped_statement program
Untyped programs (before type checking)
val untyped_program_of_sexp : Sexplib0.Sexp.t -> untyped_program
val sexp_of_untyped_program : untyped_program -> Sexplib0.Sexp.t
val compare_untyped_program : untyped_program -> untyped_program -> int
type typed_program = typed_statement program
Typed programs (after type checking)
val typed_program_of_sexp : Sexplib0.Sexp.t -> typed_program
val sexp_of_typed_program : typed_program -> Sexplib0.Sexp.t
val compare_typed_program : typed_program -> typed_program -> int
val untyped_expression_of_typed_expression :
typed_expression ->
untyped_expression
Forgetful function from typed to untyped expressions
val untyped_lvalue_of_typed_lvalue : typed_lval -> untyped_lval
val untyped_lvalue_of_typed_lvalue_pack :
typed_lval lvalue_pack ->
untyped_lval lvalue_pack
val untyped_statement_of_typed_statement :
(typed_expression, stmt_typed_located_meta, typed_lval, 'a) statement_with ->
(untyped_expression, located_meta, untyped_lval, unit) statement_with
Forgetful function from typed to untyped statements
val untyped_program_of_typed_program : typed_program -> untyped_program
Forgetful function from typed to untyped programs
val extract_ids : ('a, 'b) expr_with -> identifier Base__List.t
val lvalue_of_expr_opt :
untyped_expression ->
((located_meta, unit) expr_with, located_meta) lval_with lvalue_pack option
val type_of_arguments :
(Middle.UnsizedType.autodifftype * Middle.UnsizedType.t * 'a) list ->
Middle.UnsizedType.argumentlist
val get_loc_lvalue_pack : typed_lval lvalue_pack -> Middle.Location_span.t
val get_loc_dt :
untyped_expression Middle.SizedType.t ->
Middle.Location.t option
val get_loc_tf :
untyped_expression Middle.Transformation.t ->
Middle.Location.t option
val get_first_loc : untyped_statement -> Middle.Location.t