package mopsa
Install
Dune Dependency
Authors
Maintainers
Sources
md5=fdee20e988343751de440b4f6b67c0f4
sha512=f5cbf1328785d3f5ce40155dada2d95e5de5cce4f084ea30cfb04d1ab10cc9403a26cfb3fa55d0f9da72244482130fdb89c286a9aed0d640bba46b7c00e09500
doc/mopsa.mopsa_py_parser/Mopsa_py_parser/Ast/index.html
Module Mopsa_py_parser.Ast
Source
Copyright (c) 2017-2019 Aymeric Fromherz and The MOPSA Project
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AST - A more abstract representation than the original Python CST.
Contains some additional static information, such as unique variables IDs and the list of local variables of functions.
type var = {
name : string;
(*original name in the source code
*)uid : int;
(*a unique identifier at the scope level
*)
}
A variable with a unique identifier
Statements
and stmt_kind =
| S_assign of expr * expr
(*value
*)| S_type_annot of expr * expr
(*value
*)| S_expression of expr
(*expression statements
*)| S_while of expr * stmt * stmt option
(*else
*)| S_break
| S_continue
| S_block of stmt list
| S_aug_assign of expr * binop * expr
(*value
*)| S_if of expr * stmt * stmt option
(*optional else branch
*)| S_function of func
| S_class of cls
| S_for of expr * expr * stmt * stmt option
(*else
*)| S_return of expr
(*return expression. Empty returns are equivalent to return None
*)| S_raise of expr option * expr option
(*cause
*)| S_try of stmt * except list * stmt option * stmt option
(*final body
*)| S_import of string * var option * var
(*root module var
*)| S_import_from of string * string * var * var
(*module var
*)| S_delete of expr
| S_assert of expr * expr option
| S_with of expr * expr option * stmt
(*body
*)| S_pass
and func = {
func_var : var;
(*function object variable
*)func_parameters : var list;
(*list of parameters variables
*)func_defaults : expr option list;
(*list of default parameters values
*)func_vararg : var option;
func_kwonly_args : var list;
func_kwonly_defaults : expr option list;
func_kwarg : var option;
func_locals : var list;
(*list of local variables
*)func_globals : var list;
(*list of variables declared as global
*)func_nonlocals : var list;
(*list of variables declared as nonlocal
*)func_body : stmt;
(*function body
*)func_is_generator : bool;
(*is the function a generator?
*)func_decors : expr list;
func_types_in : expr option list;
func_type_out : expr option;
func_range : Mopsa_utils.Location.range;
}
Function declaration
and cls = {
cls_var : var;
(*class object variable
*)cls_body : stmt;
(*class body
*)cls_static_attributes : var list;
cls_bases : expr list;
(*inheritance base classes
*)cls_decors : expr list;
cls_keywords : (string option * expr) list;
(*keywords (None id for **kwargs)
*)cls_range : Mopsa_utils.Location.range;
}
Class definition
Expressions
and expr_kind =
| E_ellipsis
| E_true
| E_false
| E_none
| E_notimplemented
| E_num of Cst.number
| E_str of string
| E_bytes of string
| E_attr of expr * string
(*attribute name
*)| E_id of var
| E_call of expr * expr list * (string option * expr) list
(*keywords (None id for **kwargs)
*)| E_list of expr list
(*list of elements
*)| E_index_subscript of expr * expr
(*index
*)| E_slice_subscript of expr * expr * expr * expr
(*Step. None if not specified
*)| E_tuple of expr list
| E_set of expr list
| E_dict of expr list * expr list
(*values
*)| E_generator_comp of expr * comprehension list
(*list of comprehensions
*)| E_list_comp of expr * comprehension list
(*list of comprehensions
*)| E_set_comp of expr * comprehension list
(*list of comprehensions
*)| E_dict_comp of expr * expr * comprehension list
(*list of comprehensions
*)| E_if of expr * expr * expr
| E_yield of expr
| E_yield_from of expr
(*Binary operator expressions
*)| E_binop of expr * binop * expr
(*right operand
*)| E_multi_compare of expr * binop list * expr list
| E_unop of Cst.unop * expr
| E_lambda of lambda
module VarMap : sig ... end
module VarSetMap : sig ... end