def p_start_of_func(p): '''start_of_func : FUNCTION any_type id''' symboltable.mGlobal(p[3]) print(";LABEL " + p[3]) ll.insert("LABEL", str(p[3]), "", "") print(";LINK") ll.insert("LINK", "", "", "")
def p_func_decl(p): '''func_decl : start_of_func LPAREN param_decl_list RPAREN BEGIN func_body END ''' symboltable.mGlobal(0)
listor.pop(iterator) registerNum = registerNum + 1 end = end - 2 else: iterator = iterator + 1 if (len(listor) >= 2): registerNum = registerNum + 1 return end else: listor.pop(end+1) return end parser = yacc.yacc() symboltable.mGlobal("GLOBAL") parser.parse(data) ir = irConverter(ll) for i in symboltable.symbolTable['GLOBAL'].keys(): for j,k in symboltable.symbolTable['GLOBAL'][i].items(): if (k['type'] == 'INT'): print("var " + k['name']) for i in symboltable.symbolTable['GLOBAL'].keys(): for j,k in symboltable.symbolTable['GLOBAL'][i].items(): if (k['type'] == 'FLOAT'):
registerNum = registerNum + 1 end = end - 2 else: iterator = iterator + 1 if (len(listor) >= 2): registerNum = registerNum + 1 return end else: listor.pop(end + 1) return end parser = yacc.yacc() symboltable.mGlobal("GLOBAL") parser.parse(data) ir = irConverter(ll) for i in symboltable.symbolTable['GLOBAL'].keys(): for j, k in symboltable.symbolTable['GLOBAL'][i].items(): if (k['type'] == 'INT'): print("var " + k['name']) for i in symboltable.symbolTable['GLOBAL'].keys(): for j, k in symboltable.symbolTable['GLOBAL'][i].items(): if (k['type'] == 'FLOAT'): print("var " + k['name'])