Documentation
¶
Index ¶
- Variables
- func WithIntegerCombiner(items []interface{}) (item interface{}, value bool)
- func WithStringConcatCombiner(inputs []interface{}) (interface{}, bool)
- type Function
- func All(combiner MultipleResultCombiner, functions ...Function) Function
- func Any(functions ...Function) Function
- func AnyRune() Function
- func AtLeast(combiner MultipleResultCombiner, times int, f Function) Function
- func AtMost(combiner MultipleResultCombiner, times int, f Function) Function
- func Many(combiner MultipleResultCombiner, atLeast, atMost int, f Function) Function
- func Optional(combiner MultipleResultCombiner, f Function) Function
- func Or(a, b Function) Function
- func Rune(r rune) Function
- func RuneIn(set string) Function
- func RuneInRanges(rts ...*unicode.RangeTable) Function
- func RuneNotIn(set string) Function
- func RuneWhere(predicate func(r rune) bool) Function
- func String(s string) Function
- func StringInsensitive(s string) Function
- func StringUntil(delimiter Function) Function
- func StringUntilDelimiterOrEOF(delimiter Function) Function
- func Then(combiner MultipleResultCombiner, a, b Function) Function
- func Times(combiner MultipleResultCombiner, times int, f Function) Function
- type Input
- type MultipleResultCombiner
- type Result
Constants ¶
This section is empty.
Variables ¶
var Letter = RuneInRanges(unicode.Letter)
Letter returns a parser which accepts a rune within the Letter Unicode range.
var ZeroToNine = RuneIn("0123456789")
ZeroToNine returns a parser which accepts a rune within range, i.e. 0-9.
Functions ¶
func WithIntegerCombiner ¶
func WithIntegerCombiner(items []interface{}) (item interface{}, value bool)
WithIntegerCombiner is a MultipleResultCombiner which concatenates the results together as a string then parses the result as an integer.
func WithStringConcatCombiner ¶
func WithStringConcatCombiner(inputs []interface{}) (interface{}, bool)
WithStringConcatCombiner is a MultipleResultCombiner which concatenates the results together as a string.
Types ¶
type Function ¶
Function represents the state of the scanner as a function that returns the next state.
func All ¶
func All(combiner MultipleResultCombiner, functions ...Function) Function
All ensures that all of the parsers are captured, or winds the whole set of captures back.
func Any ¶
Any returns the first match out of the parse functions passed in, or a failure if no parsers match.
func AtLeast ¶
func AtLeast(combiner MultipleResultCombiner, times int, f Function) Function
AtLeast captures the passed function at least the number of times provided.
func AtMost ¶
func AtMost(combiner MultipleResultCombiner, times int, f Function) Function
AtMost captures the passed function between one and the number of times provided.
func Many ¶
func Many(combiner MultipleResultCombiner, atLeast, atMost int, f Function) Function
Many captures the function at least x times and at most y times and sets the result item to an array of the function captures.
func Optional ¶
func Optional(combiner MultipleResultCombiner, f Function) Function
Optional provides an optional parser.
func RuneInRanges ¶
func RuneInRanges(rts ...*unicode.RangeTable) Function
RuneInRanges returns a parser which accepts a rune within the specified Unicode range.
func StringInsensitive ¶ added in v0.0.47
StringInsensitive tests whether the string is present, but ignoring string casing.
func StringUntil ¶
StringUntil captures runes until the delimiter is encountered and returns a string.
func StringUntilDelimiterOrEOF ¶ added in v0.0.53
func Then ¶
func Then(combiner MultipleResultCombiner, a, b Function) Function
Then executes one function, then another, comining the results using the provided function.
type Input ¶
type Input interface { // Collect collects all of the string data parsed so far and returns it, then starts a new collection // from the current position in the input. Collect() string // Advance advances the input by a single rune and consumes it. Advance() (rune, error) // Retreat retreats the input position by a single rune and unconsumes it. Retreat() (rune, error) // Peek returns the next rune from the input without consuming it. Peek() (rune, error) // Position returns the line and column number of the current position within the stream. Position() (line, column int) // Index returns the current index of the parser input. Index() int64 }
Input represents the input to a parser.
type MultipleResultCombiner ¶
type MultipleResultCombiner func([]interface{}) (result interface{}, ok bool)
MultipleResultCombiner combines the results from multiple parse operations into a single result.