else:
right = str(self[node.right])
if isinstance(node.op, (pc_ast.Add, pc_ast.Sub,
- pc_ast.Mul, pc_ast.Div, pc_ast.Mod)):
+ pc_ast.Mul, pc_ast.Div, pc_ast.Mod,
+ pc_ast.Lt, pc_ast.Le,
+ pc_ast.Eq, pc_ast.NotEq,
+ pc_ast.Ge, pc_ast.Gt,
+ )):
op = {
pc_ast.Not: "~",
pc_ast.Add: "+",
pc_ast.Mul: "*",
pc_ast.Div: "/",
pc_ast.Mod: "%",
+ pc_ast.Lt: "<",
+ pc_ast.Le: "<=",
+ pc_ast.Eq: "==",
+ pc_ast.NotEq: "!=",
+ pc_ast.Ge: ">=",
+ pc_ast.Gt: ">",
}[node.op.__class__]
stmt = " ".join([left, op, right])
self[node].emit(stmt=f"({stmt})")
else:
raise ValueError(node)
- @pc_util.Hook(pc_ast.Not, pc_ast.Add, pc_ast.Sub,
- pc_ast.Mul, pc_ast.Div, pc_ast.Mod)
+ @pc_util.Hook(
+ pc_ast.Not, pc_ast.Add, pc_ast.Sub,
+ pc_ast.Mul, pc_ast.Div, pc_ast.Mod,
+ pc_ast.Lt, pc_ast.Le,
+ pc_ast.Eq, pc_ast.NotEq,
+ pc_ast.Ge, pc_ast.Gt,
+ )
def Op(self, node):
yield node