package mopsa

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

Module Mopsa_py_parser.Cst_to_astSource

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.

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

Main entry point that translates a CST to an AST

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

Collect the set of global variables

Sourceval translate_stmt : Cst.stmt -> Ast.stmt

Statement visitor to

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

Expressions visitor

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

Generator function detection

Sourceval add_implicit_return : Mopsa_utils.Location.range -> Ast.stmt list -> Ast.stmt list
Sourceval block_range : Cst.stmt list -> Mopsa_utils.Location.range
OCaml

Innovation. Community. Security.