Ejemplo n.º 1
0
 def descr_compile(self, space, filename="<syntax-tree>"):
     info = pyparse.CompileInfo(filename, self.mode)
     try:
         ast = ast_from_node(space, self.tree, info)
         result = compile_ast(space, ast, info)
     except error.IndentationError, e:
         raise OperationError(space.w_IndentationError, e.wrap_info(space))
Ejemplo n.º 2
0
 def _compile_ast(self, node, info):
     space = self.space
     try:
         mod = optimize.optimize_ast(space, node, info)
         code = codegen.compile_ast(space, mod, info)
     except parseerror.SyntaxError, e:
         raise OperationError(space.w_SyntaxError, e.wrap_info(space))
Ejemplo n.º 3
0
 def _compile_ast(self, node, info):
     space = self.space
     try:
         mod = optimize.optimize_ast(space, node, info)
         code = codegen.compile_ast(space, mod, info)
     except parseerror.SyntaxError as e:
         raise OperationError(space.w_SyntaxError, e.wrap_info(space))
     return code
Ejemplo n.º 4
0
 def _compile_ast(self, node, info, source=None):
     space = self.space
     try:
         mod = optimize.optimize_ast(space, node, info)
         code = codegen.compile_ast(space, mod, info)
     except parseerror.SyntaxError as e:
         raise OperationError(space.w_SyntaxError, e.find_sourceline_and_wrap_info(space, source))
     return code
Ejemplo n.º 5
0
 def descr_compile(self, space, filename="<syntax-tree>"):
     info = pyparse.CompileInfo(filename, self.mode)
     try:
         ast = ast_from_node(space, self.tree, info)
         result = compile_ast(space, ast, info)
     except error.IndentationError, e:
         raise OperationError(space.w_IndentationError,
                              e.wrap_info(space))
Ejemplo n.º 6
0
 def _compile_ast(self, node, info):
     from pypy.interpreter.astcompiler import optimize
     from pypy.interpreter.astcompiler.codegen import compile_ast
     from pypy.interpreter.pyparser.error import SyntaxError
     space = self.space
     try:
         mod = optimize.optimize_ast(space, node, info)
         code = compile_ast(space, mod, info)
     except SyntaxError, e:
         raise OperationError(space.w_SyntaxError, e.wrap_info(space))
Ejemplo n.º 7
0
 def _compile_ast(self, node, info):
     from pypy.interpreter.astcompiler import optimize
     from pypy.interpreter.astcompiler.codegen import compile_ast
     from pypy.interpreter.pyparser.error import SyntaxError
     space = self.space
     try:
         mod = optimize.optimize_ast(space, node, info)
         code = compile_ast(space, mod, info)
     except SyntaxError, e:
         raise OperationError(space.w_SyntaxError,
                              e.wrap_info(space))
Ejemplo n.º 8
0
 def descr_compile(self, space, filename="<syntax-tree>"):
     info = pyparse.CompileInfo(filename, self.mode)
     try:
         ast = ast_from_node(space, self.tree, info, self.recursive_parser)
         result = compile_ast(space, ast, info)
     except error.IndentationError as e:
         raise OperationError(space.w_IndentationError,
                              e.find_sourceline_and_wrap_info(space))
     except error.SyntaxError as e:
         raise OperationError(space.w_SyntaxError,
                              e.find_sourceline_and_wrap_info(space))
     return result
Ejemplo n.º 9
0
 def _compile_ast(self, node, info, source=None):
     from pypy.interpreter.astcompiler.unparse import unparse_annotations
     space = self.space
     if info.flags & consts.CO_FUTURE_ANNOTATIONS:
         node = unparse_annotations(space, node)
     try:
         mod = optimize.optimize_ast(space, node, info)
         code = codegen.compile_ast(space, mod, info)
     except parseerror.SyntaxError as e:
         raise OperationError(
             space.w_SyntaxError,
             e.find_sourceline_and_wrap_info(space, source))
     return code
Ejemplo n.º 10
0
def compile_with_astcompiler(expr, mode, space):
    p = pyparse.PythonParser(space)
    info = pyparse.CompileInfo("<test>", mode)
    cst = p.parse_source(expr, info)
    ast = astbuilder.ast_from_node(space, cst, info)
    return codegen.compile_ast(space, ast, info)
Ejemplo n.º 11
0
def compile_with_astcompiler(expr, mode, space):
    p = pyparse.PythonParser(space)
    info = pyparse.CompileInfo("<test>", mode)
    cst = p.parse_source(expr, info)
    ast = astbuilder.ast_from_node(space, cst, info)
    return codegen.compile_ast(space, ast, info)
Ejemplo n.º 12
0
 def descr_compile(self, space, filename="<syntax-tree>"):
     info = pyparse.CompileInfo(filename, self.mode)
     ast = ast_from_node(space, self.tree, info)
     return space.wrap(compile_ast(space, ast, info))
Ejemplo n.º 13
0
 def descr_compile(self, space, filename="<syntax-tree>"):
     info = pyparse.CompileInfo(filename, self.mode)
     ast = ast_from_node(space, self.tree, info)
     return space.wrap(compile_ast(space, ast, info))