def visit_constant(self, node: ast.Constant): print("const") ctype = None value = None for name, child in node.children(): if name == "type": ctype = child elif name == "value": value = child try: if ctype == "int": return int(value) elif ctype == "float": return float(value) elif ctype == "string": return value elif ctype == "character": return value except: pass
def visit_constant(self, node: ast.Constant): # print("visiting constant") ctype = None value = None for name, child in node.children(): if name == "type": ctype = child elif name == "value": value = child try: if ctype == "int": return int(value) elif ctype == "float": return float(value) elif ctype == "string": return value elif ctype == "character": return value elif ctype == 'bool': return value except Exception as e: raise Exception(e)