package mopsa
Install
Dune Dependency
Authors
Maintainers
Sources
md5=fdee20e988343751de440b4f6b67c0f4
sha512=f5cbf1328785d3f5ce40155dada2d95e5de5cce4f084ea30cfb04d1ab10cc9403a26cfb3fa55d0f9da72244482130fdb89c286a9aed0d640bba46b7c00e09500
doc/python_lang/Python_lang/Lang/Ast/index.html
Module Lang.Ast
Source
Python AST
Constants
Types
type py_type =
| Bool
| NotImplemented
| Complex
| NoneType
| Bytes
| Str
| Int
| Float of Universal.Ast.float_prec
Expressions
Python objects
optional value representation
type py_lambda = {
py_lambda_body : Mopsa.expr;
(*Body.
*)py_lambda_parameters : Mopsa.var list;
(*list of parameters variables
*)py_lambda_defaults : Mopsa.expr option list;
(*list of default parameters values
*)
}
Lambda functions.
type Mopsa.expr_kind +=
| E_py_undefined of bool
| E_py_object of py_object
| E_py_list of Mopsa.expr list
| E_py_index_subscript of Mopsa.expr * Mopsa.expr
(*index
*)| E_py_slice_subscript of Mopsa.expr * Mopsa.expr * Mopsa.expr * Mopsa.expr
(*step
*)| E_py_attribute of Mopsa.expr * string
(*attribute name
*)| E_py_dict of Mopsa.expr list * Mopsa.expr list
(*values
*)| E_py_set of Mopsa.expr list
| E_py_generator_comprehension of Mopsa.expr * (Mopsa.expr * Mopsa.expr * Mopsa.expr list) list
(*list of comprehensions
*)| E_py_list_comprehension of Mopsa.expr * (Mopsa.expr * Mopsa.expr * Mopsa.expr list) list
(*list of comprehensions
*)| E_py_set_comprehension of Mopsa.expr * (Mopsa.expr * Mopsa.expr * Mopsa.expr list) list
(*list of comprehensions
*)| E_py_dict_comprehension of Mopsa.expr * Mopsa.expr * (Mopsa.expr * Mopsa.expr * Mopsa.expr list) list
(*list of comprehensions
*)| E_py_call of Mopsa.expr * Mopsa.expr list * (string option * Mopsa.expr) list
(*keywords (None id for **kwargs)
*)| E_py_yield of Mopsa.expr
| E_py_yield_from of Mopsa.expr
| E_py_if of Mopsa.expr * Mopsa.expr * Mopsa.expr
(*orelse
*)| E_py_tuple of Mopsa.expr list
| E_py_bytes of string
| E_py_lambda of py_lambda
| E_py_multi_compare of Mopsa.expr * Mopsa.operator list * Mopsa.expr list
| E_py_annot of Mopsa.expr
| E_py_check_annot of Mopsa.expr * Mopsa.expr
(*low-level hasattribute working at the object level only
*)| E_py_ll_hasattr of Mopsa.expr * Mopsa.expr
(*attribute name
*)| E_py_ll_getattr of Mopsa.expr * Mopsa.expr
(*attribute name
*)| E_py_ll_setattr of Mopsa.expr * Mopsa.expr * Mopsa.expr option
Statements
type py_fundec = {
py_func_var : Mopsa.var;
(*function object variable
*)py_func_parameters : Mopsa.var list;
(*list of parameters variables
*)py_func_defaults : Mopsa.expr option list;
(*list of default parameters values
*)py_func_vararg : Mopsa.var option;
py_func_kwonly_args : Mopsa.var list;
py_func_kwonly_defaults : Mopsa.expr option list;
py_func_kwarg : Mopsa.var option;
py_func_locals : Mopsa.var list;
(*list of local variables
*)py_func_body : Mopsa.stmt;
(*function body
*)py_func_is_generator : bool;
(*is the function a generator?
*)py_func_decors : Mopsa.expr list;
py_func_types_in : Mopsa.expr option list;
py_func_type_out : Mopsa.expr option;
py_func_range : Mopsa.range;
(*range of the function
*)py_func_ret_var : Mopsa.var;
py_func_cellvars : Mopsa.var list;
py_func_freevars : Mopsa.var list;
}
Python function descriptor
type py_func_sig = {
py_funcs_parameters : Mopsa.var list;
py_funcs_defaults : bool list;
py_funcs_exceptions : Mopsa.expr list;
py_funcs_types_in : Mopsa.expr option list;
py_funcs_type_out : Mopsa.expr option;
}
type py_func_annot = {
py_funca_var : Mopsa.var;
py_funca_decors : Mopsa.expr list;
py_funca_range : Mopsa.range;
py_funca_ret_var : Mopsa.var;
py_funca_sig : py_func_sig list;
}
type py_clsdec = {
py_cls_var : Mopsa.var;
(*class object variable
*)py_cls_body : Mopsa.stmt;
py_cls_static_attributes : Mopsa.var list;
(*list of declared attributes: static variables and methods
*)py_cls_bases : Mopsa.expr list;
(*base classes
*)py_cls_decors : Mopsa.expr list;
py_cls_keywords : (string option * Mopsa.expr) list;
(*keywords (None id for **kwargs)
*)py_cls_range : Mopsa.range;
(*range of the class
*)
}
A Python class
type py_cls_annot = {
py_cls_a_var : Mopsa.var;
py_cls_a_body : Mopsa.stmt;
py_cls_a_bases : Mopsa.expr list;
py_cls_a_abases : Mopsa.expr list;
py_cls_a_static_attributes : Mopsa.var list;
py_cls_a_range : Mopsa.range;
}
type py_excpt = {
py_excpt_type : Mopsa.expr option;
(*exception class. None is used for the default except
*)py_excpt_name : Mopsa.var option;
(*optional name of exception instance
*)py_excpt_body : Mopsa.stmt;
(*body of the except handler
*)
}
Exception handler
type Mopsa.stmt_kind +=
| S_py_class of py_clsdec
| S_py_function of py_fundec
| S_py_try of Mopsa.stmt * py_excpt list * Mopsa.stmt * Mopsa.stmt
(*final body
*)| S_py_raise of Mopsa.expr option
| S_py_if of Mopsa.expr * Mopsa.stmt * Mopsa.stmt
| S_py_while of Mopsa.expr * Mopsa.stmt * Mopsa.stmt
| S_py_multi_assign of Mopsa.expr list * Mopsa.expr
| S_py_aug_assign of Mopsa.expr * Mopsa.operator * Mopsa.expr
| S_py_annot of Mopsa.expr * Mopsa.expr
| S_py_check_annot of Mopsa.expr * Mopsa.expr
| S_py_for of Mopsa.expr * Mopsa.expr * Mopsa.stmt * Mopsa.stmt
(*else
*)| S_py_import of string * Mopsa.var option * Mopsa.var
(*root module
*)| S_py_import_from of string * string * Mopsa.var * Mopsa.var
(*module var
*)| S_py_delete of Mopsa.expr
| S_py_assert of Mopsa.expr * Mopsa.expr option
(*message
*)| S_py_with of Mopsa.expr * Mopsa.expr option * Mopsa.stmt
(*body
*)
Statements
Programs
module K : sig ... end
Flow-insensitive context to keep the analyzed C program
val set_py_program :
(string * Mopsa.var list * Mopsa.stmt) ->
'a Mopsa.Flow.flow ->
'a Mopsa.Flow.flow
Set the Python program in the flow
Get the Python program from the flow
Utility functions
val mk_py_in :
?strict:bool ->
?left_strict:bool ->
?right_strict:bool ->
Mopsa.expr ->
Mopsa.expr ->
Mopsa.expr ->
Mopsa_utils.Location.range ->
Mopsa.expr
val mk_try :
Mopsa.stmt ->
py_excpt list ->
Mopsa.stmt ->
Mopsa.stmt ->
Mopsa_utils.Location.range ->
Mopsa.stmt
val mk_py_kall :
Mopsa.expr ->
Mopsa.expr list ->
(string option * Mopsa.expr) list ->
Mopsa_utils.Location.range ->
Mopsa.expr
val mk_py_attr :
Mopsa.expr ->
string ->
?etyp:Mopsa.typ ->
Mopsa_utils.Location.range ->
Mopsa.expr
val mk_py_index_subscript :
Mopsa.expr ->
Mopsa.expr ->
?etyp:Mopsa.typ ->
Mopsa_utils.Location.range ->
Mopsa.expr
val mk_py_object :
(Mopsa.addr * Mopsa.expr option) ->
Mopsa_utils.Location.range ->
Mopsa.expr
val mk_py_object_attr :
(Mopsa.addr * Mopsa.expr option) ->
string ->
?etyp:Mopsa.typ ->
Mopsa_utils.Location.range ->
Mopsa.expr
Decorators
val py_or :
Mopsa.expr ->
Mopsa.expr ->
?etyp:Mopsa.typ ->
Mopsa_utils.Location.range ->
Mopsa.expr
val py_and :
Mopsa.expr ->
Mopsa.expr ->
?etyp:Mopsa.typ ->
Mopsa_utils.Location.range ->
Mopsa.expr
val mk_py_ll_setattr :
Mopsa.expr ->
Mopsa.expr ->
Mopsa.expr ->
Mopsa_utils.Location.range ->
Mopsa.expr