예제 #1
0
        return node


if __name__ == "__main__":
    import sys, compiler
    import logging, logging.config
    from comp_util import *
    from p0parser import P0Parser
    from p1flattener import P1Flattener
    from p1insselector import P1InstructionSelector
    if len(sys.argv) < 2:
        sys.exit(1)
    # configure logging 
    logging.config.fileConfig('logging.cfg')
    testcases = sys.argv[1:]
    for testcase in testcases:
        #parser = P0Parser()
        #parser.build()
        ast = compiler.parseFile(testcase)
        #ast = parser.parseFile(testcase)
        varalloc = VariableAllocator()
        explicator = P1Explicate(varalloc)
        flattener = P1Flattener(varalloc)
        instruction_selector = P1InstructionSelector(varalloc)
        ast = explicator.explicate(ast)
        ast = flattener.flatten(ast)
        ast = instruction_selector.visit(ast)
        stackallocator = P1StackAllocator(ast)
        ast = stackallocator.substitute()
        print prettyAST(ast)