Пример #1
0
def main():

    inputfile = open(sys.argv[1], 'r').read()
    symTab, tac = parse(inputfile)
    #print symTab.table
    tac.addlineNumbers()
    print("\n#Displaying 3AC\n")
    tac.display_code()
    modify3ACforCodegen(symTab, tac, tac.code)

    # FB = divideToFunctions(tac.code)
    regAlloc = varAllocateRegister(symTab, tac)

    tac.mapOffset()  # Map the offsets

    codeGen = CodeGenerator(symTab, tac, regAlloc)
    codeGen.setup_all()
    codeGen.display_code()
def main():
    file = sys.argv[1]
    content = reader(file)
    #print (content)

    # Construct the Symbol Table ?
    SymTab = SymTable()
    ac3 = ThreeAddrCode(SymTab)
    ac3.addTo3AC(content)

    FB = divideToFunctions(ac3.code)
    #print (FB)

    regAlloc = varAllocateRegister(SymTab, ac3)

    # Codegen object
    codeGen = CodeGenerator(SymTab, ac3, regAlloc, FB)
    codeGen.setup_all()
    codeGen.display_code()