72 lines
3.3 KiB
Python
72 lines
3.3 KiB
Python
|
import ast
|
||
|
arm = open("Armonia.py")
|
||
|
source02 = "".join(x for x in arm.readlines())
|
||
|
tree02 = ast.parse(source02)
|
||
|
t = open("test.py")
|
||
|
source = "".join(x for x in t.readlines())
|
||
|
tree = ast.parse(source)
|
||
|
p = open("Prova_main.py")
|
||
|
source01 = "".join(x for x in p.readlines())
|
||
|
tree01 = ast.parse(source01)
|
||
|
|
||
|
ast.dump(tree01, annotate_fields = False)
|
||
|
|
||
|
def visitor_pers(self, node):
|
||
|
typeOfNode = { ast.Num : node.n,
|
||
|
ast.Str : node.s,
|
||
|
ast.FormattedValues : node.value,
|
||
|
ast.JoinedStr : node.values,
|
||
|
ast.Bytes : node.s,
|
||
|
ast.List : node.elts,
|
||
|
ast.Tuple : node.elts,
|
||
|
ast.Set : node.elts,
|
||
|
ast.Dict : node.keys,
|
||
|
ast.NameConstant : node.value,
|
||
|
ast.Name : node.id,
|
||
|
ast.Starred : node.value,
|
||
|
ast.Expr : node.value,
|
||
|
ast.UnaryOP : node.operand,
|
||
|
ast.BinOp : [node.left, node.right],
|
||
|
ast.BoolOP : node.values,
|
||
|
ast.Compare : [node.left, node.comparators],
|
||
|
ast.Call : node.args,
|
||
|
ast.keyword : [node.arg, node.value],
|
||
|
ast.ifExp : node.body,
|
||
|
ast.Attribute : [node.attr, node.value],
|
||
|
ast.Subscript : node.value,
|
||
|
ast.Index : node.value,
|
||
|
ast.Slice : [node.lower, node.upper],
|
||
|
ast.ExtSlice : node.dimis,
|
||
|
ast.ListCompe : [node.generators, node.elt],
|
||
|
ast.SetCompe : [node.generators, node.elt],
|
||
|
ast.GeneratorExp : [node.generators, node.elt],
|
||
|
ast.DictComp : [node.key, node.value, node.elt],
|
||
|
ast.comprehension : [node.target, node.iter],
|
||
|
ast.Assign : [node.targets, node.value],
|
||
|
ast.AnnAssign : [node.targets, node.value, node.simple],
|
||
|
ast.AugAssign : [node.targets, node.value],
|
||
|
ast.Print : [node.dest, node.values],
|
||
|
ast.Raise : [node.exce, node.cause],
|
||
|
ast.Assert : [node.test, node.msg],
|
||
|
ast.Delete : node.targets,
|
||
|
ast.Import : node.names,
|
||
|
ast.ImportFrom : [node.module, node.names],
|
||
|
ast.Alias : node.name,
|
||
|
ast.Assign : [node.targets, node.value],
|
||
|
ast.If : [node.test, node.body, node.orelse],
|
||
|
ast.For : [node.target, node.iter, node.body, node.orelse],
|
||
|
ast.While : [node.test, node.body, node.orelse],
|
||
|
ast.Try : [node.handlers, node.body, node.orelse, node.finalbody],
|
||
|
ast.TryFinally : [node.body, node.finalbody],
|
||
|
ast.TryExcept : [node.handlers, node.body, node.orelse],
|
||
|
ast.ExceptHandler : [node.type, node.name, node.body}
|
||
|
ast.With : [node.items, node.body],
|
||
|
ast.withitem : [node.context_expr],
|
||
|
ast.FunctionDef : [node.name, node.args, node.body],
|
||
|
ast.Lambda : [node.args, node.body],
|
||
|
ast.arguments : [node.args, node.default],
|
||
|
ast.arg : [node.items, node.body],
|
||
|
|
||
|
|
||
|
}
|