Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file ast.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276(**
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.
*)openMopsa_utils(** A variable with a unique identifier *)typevar={name:string;(** original name in the source code *)uid:int;(** a unique identifier at the scope level *)}typeprogram={prog_body:stmt;prog_globals:varlist;}(** Statements *)andstmt={skind:stmt_kind;srange:Location.range;}andbinop=|O_arithmeticofCst.binop|O_comparisonofCst.cmpop|O_boolofCst.boolopandstmt_kind=|S_assignofexpr(** target *)*expr(** value *)|S_type_annotofexpr(** target *)*expr(** value *)|S_expressionofexpr(** expression statements *)|S_whileofexpr(** test *)*stmt(** body *)*stmtoption(** else *)|S_break|S_continue|S_blockofstmtlist|S_aug_assign(** such as x += e *)ofexpr(** taregt *)*binop(** operator *)*expr(** value *)|S_ifofexpr(** test *)*stmt(** then branch *)*stmtoption(** optional else branch *)|S_function(** function definition *)offunc|S_class(** class definition *)ofcls|S_for(** for loops *)ofexpr(** target *)*expr(** iterator *)*stmt(** body *)*stmtoption(** else *)|S_return(** return *)ofexpr(** return expression. Empty returns are equivalent to return None *)|S_raiseofexproption(** exn *)*exproption(** cause *)(** try/except statement *)|S_tryofstmt(** body *)*exceptlist(** except handlers *)*stmtoption(** else body *)*stmtoption(** final body *)|S_importofstring(** module *)*varoption(** asname *)*var(** root module var *)|S_import_fromofstring(** module *)*string(** name *)*var(** root module var *)*var(** module var *)(** Import statements *)|S_deleteofexpr|S_assertofexpr*exproption|S_withofexpr(** context *)*exproption(** as *)*stmt(** body *)|S_pass(** Exception handler *)andexcept=exproption(** exception type *)*varoption(** as name *)*stmt(** body *)(** Function declaration *)andfunc={func_var:var;(** function object variable *)func_parameters:varlist;(** list of parameters variables *)func_defaults:exproptionlist;(** list of default parameters values *)func_vararg:varoption;(* variable argument arg (usually *args), if any *)func_kwonly_args:varlist;(* list of keyword-only arguments *)func_kwonly_defaults:exproptionlist;(* default values associated to keyword-only arguments *)func_kwarg:varoption;(* keyword-based variable argument (usually **kwargs) if any *)func_locals:varlist;(** list of local variables *)func_globals:varlist;(** list of variables declared as global *)func_nonlocals:varlist;(** list of variables declared as nonlocal *)func_body:stmt;(** function body *)func_is_generator:bool;(** is the function a generator? *)func_decors:exprlist;func_types_in:exproptionlist;(* type of the arguments *)func_type_out:exproption;(* type of the return *)func_range:Location.range;}(** Class definition *)andcls={cls_var:var;(** class object variable *)cls_body:stmt;(** class body *)cls_static_attributes:varlist;cls_bases:exprlist;(** inheritance base classes *)cls_decors:exprlist;cls_keywords:(stringoption*expr)list;(** keywords (None id for **kwargs) *)cls_range:Location.range;}andlambda={lambda_body:expr;lambda_parameters:varlist;(** list of parameters variables *)lambda_defaults:exproptionlist;(** list of default parameters values *)}(** Expressions *)andexpr={ekind:expr_kind;erange:Location.range;}andexpr_kind=|E_ellipsis|E_true|E_false|E_none|E_notimplemented|E_numofCst.number|E_strofstring|E_bytesofstring(** attribute access *)|E_attrofexpr(** object *)*string(** attribute name *)|E_idofvar(** function call *)|E_callofexpr(** function expression *)*exprlist(** arguments *)*(stringoption*expr)list(** keywords (None id for **kwargs) *)|E_listofexprlist(** list of elements *)(** Index-based subscript access *)|E_index_subscriptofexpr(** object *)*expr(** index *)(** Slice-based subscript access *)|E_slice_subscriptofexpr(** object *)*expr(** Lower bound. None if not specified *)*expr(** Uper bound. None if not specified *)*expr(** Step. None if not specified *)|E_tupleofexprlist|E_setofexprlist|E_dictofexprlist(** keys *)*exprlist(** values *)(** Generator comprehension *)|E_generator_compofexpr(** generator expression *)*comprehensionlist(** list of comprehensions *)(** List comprehension *)|E_list_compofexpr(** element expression *)*comprehensionlist(** list of comprehensions *)(** Set comprehension *)|E_set_compofexpr(** element expression *)*comprehensionlist(** list of comprehensions *)(** Dictionary comprehension *)|E_dict_compofexpr(** key expression *)*expr(** value expression *)*comprehensionlist(** list of comprehensions *)(** If expressions *)|E_ifofexpr(* test *)*expr(* body *)*expr(* else *)(** Yield expression *)|E_yieldofexpr|E_yield_fromofexpr(** Binary operator expressions *)|E_binopofexpr(** left operand *)*binop*expr(** right operand *)|E_multi_compareofexpr(* left *)*binoplist(* ops *)*exprlist(* comparators *)(** Unary operato expressions *)|E_unopofCst.unop*expr|E_lambdaoflambda(** Comprehensions *)andcomprehension=expr(** target *)*expr(** iterator *)*exprlist(** list of conditions *)moduleVarSet=Set.Make(structtypet=varletcompare=compareend)moduleVarMap=MapExt.Make(structtypet=varletcompare=compareend)moduleVarSetMap=MapExt.Make(structtypet=VarSet.tletcompare=VarSet.compareend)