示例#1
0
文件: bool.go 项目: ricardo-rossi/nut
// 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
}
func unparen(e ast.Expr) ast.Expr { return astutil.Unparen(e) }
示例#3
0
func unparen(x ast.Expr) ast.Expr { return astutil.Unparen(x) }