Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DurationRegex = regexp.MustCompile(
"^(" + durationChunkRegex.String() + ")+$",
)
DurationRegex describes a valid duration value. See DurationOf for more details on what the individual units represent.
var SizeRegex = regexp.MustCompile(`^\d+[ckMGTP]$`)
SizeRegex describes a valid size value. See BytesOf for more details on what the individual units represent.
Functions ¶
func BytesOf ¶
BytesOf returns the number of bytes specified by the given size unit. Valid size units are:
c => character (byte) k => kibibyte M => mebibyte G => gibibyte T => tebibyte P => pebibyte
func DurationOf ¶
DurationOf returns the number of seconds specified by the given duration unit. Valid duration units are:
s => second m => minute h => hour d => day w => week
func ParseDuration ¶
ParseDuration parses a duration value as an int64. Duration values are described by DurationRegex.
func ParsePositiveInt ¶
ParsePositiveInt parses a positive integer.
Types ¶
type Parser ¶
Parser parses numeric values.
func Bracket ¶
Bracket returns a new parser g that parses all numbers satifying the regex `{<number>}` where <number> is s.t. p(<number>) does not return an error. For example, if p parses "15" as the number 15, then g parses "{15}" as the number "15". Bracket's typically used to implement negation semantics. For example, Bracket(Negate(ParsePositiveInt)) returns a parser that parses all n <= 0, where each n is represented as {m} where m = -n.
Note that g returns a syntax error if p(<number>) returns a match error.
type Predicate ¶
Predicate represents a Numeric predicate
func ParsePredicate ¶
ParsePredicate parses a numeric predicate from str. Str should satisfy the regex `(\+|\-)?<number>`, where <number> is s.t. that parser(<number>) does not return an error for at least one parser in parsers. The returned value is the parsed predicate and the id of the parser that parsed <number>.
func (Predicate) IsSatisfiedBy ¶
IsSatisfiedBy returns true if v satisfies the predicate, false otherwise