Documentation ¶
Overview ¶
package strparse provides a string parser and utilities.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Digit1 ¶
Digit1 initializes a parser that follows (0-9)+ syntax rule.
Example ¶
package main import ( "fmt" "github.com/Drumato/peachcomb/pkg/strparse" ) func main() { i := strparse.NewCompleteInput("112233abc") _, o, err := strparse.Digit1()(i) fmt.Println(o) fmt.Println(err) }
Output: 112233 <nil>
func Rune ¶
Rune initializes a parser that consumes one rune. It's just a specialized parser from combinator.Satisfy().
Example ¶
package main import ( "fmt" "github.com/Drumato/peachcomb/pkg/strparse" ) func main() { i := strparse.NewCompleteInput("abc") _, o, err := strparse.Rune('a')(i) fmt.Printf("%c\n", o) fmt.Println(err) }
Output: a <nil>
func Tag ¶
Tag initializes a parser that checks the input starts with the tag prefix.
Example ¶
package main import ( "fmt" "github.com/Drumato/peachcomb/pkg/strparse" ) func main() { i := strparse.NewCompleteInput("Drumato") _, o, err := strparse.Tag("Drum")(i) fmt.Println(o) fmt.Println(err) }
Output: Drum <nil>
Types ¶
type CompleteInput ¶ added in v0.3.0
type CompleteInput struct {
// contains filtered or unexported fields
}
CompleteInput holds the whole runes.
func NewCompleteInput ¶ added in v0.3.0
func NewCompleteInput(s string) *CompleteInput
NewCompleteInput initialiizes a CompleteInput.
type UnexpectedPrefixError ¶
type UnexpectedPrefixError struct {
// contains filtered or unexported fields
}
UnexpectedPrefixError notifies the prefix of the given input is unexpected.
func (*UnexpectedPrefixError) Error ¶
func (e *UnexpectedPrefixError) Error() string
Error implements error interface.
type UnexpectedRuneError ¶
type UnexpectedRuneError struct {
// contains filtered or unexported fields
}
UnexpectedRuneError notifies the head of the given input is unexpected.
func (*UnexpectedRuneError) Error ¶
func (e *UnexpectedRuneError) Error() string
Error implements error interface.
Click to show internal directories.
Click to hide internal directories.