def get_contract_info(source_code): class_types, reformatted_code = pre_parse(source_code) py_ast = python_ast.parse(reformatted_code) annotate_ast(py_ast, reformatted_code, class_types) return py_ast, reformatted_code
def get_contract_info(source_code): class_types, reformatted_code = pre_parse(source_code) parsed_ast = ast.parse(reformatted_code) annotate_and_optimize_ast(parsed_ast, reformatted_code, class_types) return parsed_ast, reformatted_code
def parse_to_ast(code): class_names, code = pre_parse(code) if '\x00' in code: raise ParserException( 'No null bytes (\\x00) allowed in the source code.') o = ast.parse(code) # python ast decorate_ast(o, code, class_names) # decorated python ast o = resolve_negative_literals(o) return o.body
def parse_to_ast(source_code: str) -> list: if '\x00' in source_code: raise ParserException('No null bytes (\\x00) allowed in the source code.') class_types, reformatted_code = pre_parse(source_code) py_ast = python_ast.parse(reformatted_code) annotate_ast(py_ast, source_code, class_types) # Convert to Vyper AST. vyper_ast = parse_python_ast( source_code=source_code, node=py_ast, ) return vyper_ast.body # type: ignore
def parse_to_ast(source_code: str, source_id: int = 0) -> list: if '\x00' in source_code: raise ParserException( 'No null bytes (\\x00) allowed in the source code.') class_types, reformatted_code = pre_parse(source_code) try: py_ast = python_ast.parse(reformatted_code) except SyntaxError as e: # TODO: Ensure 1-to-1 match of source_code:reformatted_code SyntaxErrors raise PythonSyntaxException(e, source_code) from e annotate_ast(py_ast, source_code, class_types) asttokens.ASTTokens(source_code, tree=py_ast) # Convert to Vyper AST. vyper_ast = parse_python_ast( source_code=source_code, node=py_ast, source_id=source_id, ) return vyper_ast.body # type: ignore
def parse_to_ast(source_code: str) -> List[ast.stmt]: """ Parses the given vyper source code and returns a list of python AST objects for all statements in the source. Performs pre-processing of source code before parsing as well as post-processing of the resulting AST. :param source_code: The vyper source code to be parsed. :return: The post-processed list of python AST objects for each statement in ``source_code``. """ class_types, reformatted_code = pre_parse(source_code) if '\x00' in reformatted_code: raise ParserException( 'No null bytes (\\x00) allowed in the source code.') parsed_ast = ast.parse(reformatted_code) annotate_and_optimize_ast(parsed_ast, reformatted_code, class_types) return parsed_ast.body
def parse(code): class_names, code = pre_parse(code) o = ast.parse(code) # python ast decorate_ast(o, code, class_names) # decorated python ast o = resolve_negative_literals(o) return o.body
def parse(code): code = pre_parse(code) o = ast.parse(code) decorate_ast_with_source(o, code) o = resolve_negative_literals(o) return o.body