package mopsa

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

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.

Cst_to_ast - Translates Python CST to a simpler AST.

The AST contains some additional static information, such as:

  • global variables,
  • functions locals,
  • detection of generator functions,
  • inlining of packages imports.

But we do not give yet unique IDs to variables.

val debug : ('a, Stdlib.Format.formatter, unit, unit) Stdlib.format4 -> 'a
val filename : string Stdlib.ref
val translate_program : string -> Cst.stmt list -> Ast.program

Main entry point that translates a CST to an AST

val find_program_globals : Cst.stmt list -> Ast.var list

Collect the set of global variables

val translate_stmt : Cst.stmt -> Ast.stmt

Statement visitor to

val translate_expr_option : Mopsa_utils.Location.range -> Cst.expr option -> Ast.expr
val translate_expr_option2 : Cst.expr option -> Ast.expr option
val translate_expr : Cst.expr -> Ast.expr

Expressions visitor

val translate_block : Cst.stmt list -> Mopsa_utils.Location.range -> Ast.stmt
val translate_block_option : Cst.stmt list -> Ast.stmt option
val translate_comprehension : Cst.comprehension -> Ast.comprehension
val translate_var : Cst.identifier -> Ast.var
val find_lvals_in_block : Cst.stmt list -> Cst.identifier list
val find_lvals_in_stmt : Cst.stmt -> Cst.identifier list
val find_lvals_in_excepts : Cst.excepthandler list -> Cst.identifier list
val find_lvals_in_expr : Cst.expr -> Cst.identifier list
val find_scopes_in_block : Cst.stmt list -> Cst.identifier list * Cst.identifier list * Cst.identifier list
val find_scopes_in_stmt : Cst.stmt -> Cst.identifier list * Cst.identifier list * Cst.identifier list
val find_globals_in_block : Cst.stmt list -> Cst.identifier list
val find_globals_in_stmt : Cst.stmt -> Cst.identifier list
val detect_yield_in_function : Cst.stmt list -> bool

Generator function detection

val add_implicit_return : Mopsa_utils.Location.range -> Ast.stmt list -> Ast.stmt list
val (+@) : (Cst.identifier list * Cst.identifier list * Cst.identifier list) -> (Cst.identifier list * Cst.identifier list * Cst.identifier list) -> Cst.identifier list * Cst.identifier list * Cst.identifier list
val (-@) : Cst.identifier list -> (Cst.identifier list * Cst.identifier list * Cst.identifier list) -> Cst.identifier list * Cst.identifier list * Cst.identifier list
val block_range : Cst.stmt list -> Mopsa_utils.Location.range
val module_hd : Cst.identifier -> Cst.identifier
OCaml

Innovation. Community. Security.