Example #1
0
func LessThanNil(x interface{}) px.Parser {
	return func(st px.ParsexState) (interface{}, error) {
		val, _ := px.AnyOne(st)
		if x == nil || val == nil {
			return false, nil
		}
		return nil, ParsexSignErrorf("except nil value but: %v", val)
	}
}
Example #2
0
func TimeValue(st px.ParsexState) (interface{}, error) {
	val, err := px.AnyOne(st)
	if err == nil {
		if _, ok := val.(tm.Time); ok {
			return val, nil
		}
		return nil, ParsexSignErrorf("except a time value but: %v", err)
	}
	return nil, ParsexSignErrorf("except a time value but error: %v", err)
}
Example #3
0
func ListValue(st px.ParsexState) (interface{}, error) {
	val, err := px.AnyOne(st)
	if err == nil {
		if _, ok := val.(List); ok {
			return val, nil
		}
		return nil, ParsexSignErrorf("except a list value but %v ", val)
	}
	return nil, ParsexSignErrorf("except a list value but error: %v", err)
}
Example #4
0
func FalseIfHasNil(st px.ParsexState) (interface{}, error) {
	for {
		val, err := px.AnyOne(st)
		if err != nil {
			if err == io.EOF {
				return nil, fmt.Errorf("False If Nil Error: Found EOF.")
			}
			return nil, err
		}
		if val == nil {
			return false, err
		}
	}
}