예제 #1
0
// split returns a slice of all subexpressions in e that are connected by op.
// For example, given 'a || (b || c) || d' with the or op,
// split returns []{d, c, b, a}.
func (op boolOp) split(e ast.Expr) (exprs []ast.Expr) {
	for {
		e = astutil.Unparen(e)
		if b, ok := e.(*ast.BinaryExpr); ok && b.Op == op.tok {
			exprs = append(exprs, op.split(b.Y)...)
			e = b.X
		} else {
			exprs = append(exprs, e)
			break
		}
	}
	return
}
예제 #2
0
func unparen(e ast.Expr) ast.Expr { return astutil.Unparen(e) }
예제 #3
0
func unparen(x ast.Expr) ast.Expr { return astutil.Unparen(x) }