str(self[node.rvalue]),
])
self[node].emit(stmt=f"{stmt};")
+ else:
+ raise ValueError(node)
@pc_util.Hook(pc_ast.BinaryExpr)
def BinaryExpr(self, node):
pc_ast.Lt, pc_ast.Le,
pc_ast.Eq, pc_ast.NotEq,
pc_ast.Ge, pc_ast.Gt,
+ pc_ast.LShift, pc_ast.RShift,
+ pc_ast.BitAnd, pc_ast.BitOr, pc_ast.BitXor,
)):
op = {
pc_ast.Not: "~",
pc_ast.NotEq: "!=",
pc_ast.Ge: ">=",
pc_ast.Gt: ">",
+ pc_ast.LShift: "<<",
+ pc_ast.RShift: "<<",
+ pc_ast.BitAnd: "&",
+ pc_ast.BitOr: "|",
+ pc_ast.BitXor: "^",
}[node.op.__class__]
stmt = " ".join([left, op, right])
self[node].emit(stmt=f"({stmt})")
pc_ast.Lt, pc_ast.Le,
pc_ast.Eq, pc_ast.NotEq,
pc_ast.Ge, pc_ast.Gt,
+ pc_ast.LShift, pc_ast.RShift,
+ pc_ast.BitAnd, pc_ast.BitOr, pc_ast.BitXor,
)
def Op(self, node):
yield node