func (p *Parser) ParseCondition() (Condition, error) {
	// Two valid formats.
	// EXPR = FIELD OP VAL
	// COND = EXPR
	// COND = (COND BOOL COND)
	wasParen := p.acceptParenO()

	if !wasParen {
		// Simple condition.
		return p.parseExpression()
	}

	// Bool expression.
	c := JoinedCondition{}
	leftMember, err := p.ParseCondition()
	if err != nil {
		return nil, err
	}
	c.LeftCond = leftMember

	if !p.acceptBoolOp() {
		return nil, errors.New("expected boolean operator")
	}
	c.Op = BoolOperator(p.current)

	rightMember, err := p.ParseCondition()
	if err != nil {
		return nil, err
	}
	c.RightCond = rightMember

	if !p.acceptParenC() {
		return nil, errors.New("incoherent parentheses")
	}

	return &c, nil
}
// ParseCondition parses into a simple condition.
ParseCondition parses into a simple condition.
// ParseCondition parses into a simple condition .
func (p *Parser) ParseCondition() (Condition, error) {
	wasParen := p.acceptParenO()
	if !wasParen {
		return p.parseExpression()
	}
	c := JoinedCondition{}
	leftMember, err := p.ParseCondition()
	if err != nil {
		return nil, err
	}
	c.LeftCond = leftMember
	if !p.acceptBoolOp() {
		return nil, errors.New("expected boolean operator")
	}
	c.Op = BoolOperator(p.current)
	rightMember, err := p.ParseCondition()
	if err != nil {
		return nil, err
	}
	c.RightCond = rightMember
	if !p.acceptParenC() {
		return nil, errors.New("incoherent parentheses")
	}
	return &c, nil
}
func ( p * Parser ) ParseCondition ( ) ( Condition , error ) { wasParen := p . acceptParenO ( ) if ! wasParen { return p . parseExpression ( ) } c := JoinedCondition { } leftMember , err := p . ParseCondition ( ) if err != nil { return nil , err } c . LeftCond = leftMember if ! p . acceptBoolOp ( ) { return nil , errors . New ( " " ) } c . Op = BoolOperator ( p . current ) rightMember , err := p . ParseCondition ( ) if err != nil { return nil , err } c . RightCond = rightMember if ! p . acceptParenC ( ) { return nil , errors . New ( " " ) } return & c , nil }
ParseCondition parses into a simple condition.
ParseCondition parses into a simple condition .
// Two valid formats. // EXPR = FIELD OP VAL // COND = EXPR // COND = (COND BOOL COND) // Simple condition. // Bool expression.