Esempio n. 1
0
 def compile(self, cst, filename="<input>"):
     P = self.python.map_to_python(cst, self.langlet)
     try:
         ast = parser.tuple2ast(P)
         code = ast.compile(filename)
         self.python._code[filename] = ('cst', cst)
     except parser.ParserError, e:
         source = self.langlet.unparse(cst)
         code = compile(source, filename, "exec")
         self.python._code[filename] = ('src', source)
Esempio n. 2
0
 def compile(self, cst, filename = "<input>"):
     P = self.python.map_to_python(cst, self.langlet)
     try:
         ast = parser.tuple2ast(P)
         code = ast.compile(filename)
         self.python._code[filename] = ('cst', cst)
     except parser.ParserError, e:
         source = self.langlet.unparse(cst)
         code = compile(source, filename, "exec")
         self.python._code[filename] = ('src', source)
Esempio n. 3
0
def reallycompile(tuples_or_src, filename, mode, flag_names):
    if type(tuples_or_src) is str:
        flags = 0
        if 'nested_scopes' in flag_names:
            flags |= __future__.CO_NESTED
        if 'generators' in flag_names:
            flags |= __future__.CO_GENERATOR_ALLOWED
        if 'division' in flag_names:
            flags |= __future__.CO_FUTURE_DIVISION
        return compile(tuples_or_src, filename, mode, flags)
    return parser.compileast(parser.tuple2ast(tuples_or_src), filename)
Esempio n. 4
0
def reallycompile(tuples_or_src, filename, mode, flag_names):
    if type(tuples_or_src) is str:
        flags = 0
        if 'nested_scopes' in flag_names:
            flags |= __future__.CO_NESTED
        if 'generators' in flag_names:
            flags |= __future__.CO_GENERATOR_ALLOWED
        if 'division' in flag_names:
            flags |= __future__.CO_FUTURE_DIVISION
        return compile(tuples_or_src, filename, mode, flags)
    return parser.compileast(parser.tuple2ast(tuples_or_src), filename)
def testChunk(t, fileName):
    global _numFailed
    print '----', fileName,
    try:
        ast = parser.suite(t)
        tup = parser.ast2tuple(ast)
        # this discards the first AST; a huge memory savings when running
        # against a large source file like Tkinter.py.
        ast = None
        new = parser.tuple2ast(tup)
    except parser.ParserError, err:
        print
        print 'parser module raised exception on input file', fileName + ':'
        traceback.print_exc()
        _numFailed = _numFailed + 1
Esempio n. 6
0
def testChunk(t, fileName):
    global _numFailed
    print '----', fileName,
    try:
        ast = parser.suite(t)
        tup = parser.ast2tuple(ast)
        # this discards the first AST; a huge memory savings when running
        # against a large source file like Tkinter.py.
        ast = None
        new = parser.tuple2ast(tup)
    except parser.ParserError, err:
        print
        print 'parser module raised exception on input file', fileName + ':'
        traceback.print_exc()
        _numFailed = _numFailed + 1
Esempio n. 7
0
#! /usr/bin/env python
Esempio n. 8
0
#! /usr/bin/env python