Documentation ¶
Overview ¶
Package text defines a text input reader and basic terminal parsers.
Index ¶
- func LeftTrim(p parsley.Parser, wsMode WsMode) parser.Func
- func RightTrim(p parsley.Parser, wsMode WsMode) parser.Func
- func Trim(p parsley.Parser) parser.Func
- type File
- type Position
- type Reader
- func (r *Reader) IsEOF(pos parsley.Pos) bool
- func (r *Reader) MatchString(pos parsley.Pos, str string) (parsley.Pos, bool)
- func (r *Reader) MatchWord(pos parsley.Pos, word string) (parsley.Pos, bool)
- func (r *Reader) Pos(cur int) parsley.Pos
- func (r *Reader) ReadRegexp(pos parsley.Pos, expr string) (parsley.Pos, []byte)
- func (r *Reader) ReadRegexpSubmatch(pos parsley.Pos, expr string) (parsley.Pos, [][]byte)
- func (r *Reader) ReadRune(pos parsley.Pos, ch rune) (parsley.Pos, bool)
- func (r *Reader) Readf(pos parsley.Pos, f func(b []byte) ([]byte, int)) (parsley.Pos, []byte)
- func (r *Reader) Remaining(pos parsley.Pos) int
- func (r *Reader) SkipWhitespaces(pos parsley.Pos, wsMode WsMode) (parsley.Pos, parsley.Error)
- type WsMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LeftTrim ¶ added in v0.6.0
LeftTrim skips the whitespaces before it tries to match the given parser
Types ¶
type File ¶ added in v0.6.0
type File struct {
// contains filtered or unexported fields
}
File contains the contents of a file and the line offsets for quick line+column lookup
type Position ¶
Position is a text file position
func NewPosition ¶
NewPosition creates a new text position
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader defines a text input reader For more efficient reading it provides methods for regexp matching.
func NewReader ¶
NewReader creates a new reader instance The Windows-style line endings (\r\n) are automatically replaced with Unix-style line endings (\n).
func (*Reader) MatchString ¶ added in v0.6.0
MatchString matches the given string
func (*Reader) MatchWord ¶ added in v0.6.0
MatchWord matches the given word It's different from MatchString() as it checks that the next character is not a word character
func (*Reader) ReadRegexp ¶ added in v0.6.0
ReadRegexp matches part of the input based on the given regular expression and returns with the full match
func (*Reader) ReadRegexpSubmatch ¶ added in v0.6.0
ReadRegexpSubmatch matches part of the input based on the given regular expression and returns with all capturing groups
type WsMode ¶ added in v0.6.0
type WsMode uint8
WsMode is a type for definining how to handle whitespaces after the tokens
Whitespace modes WsNone means no whitespaces will read and skipped after a token WsSpaces means spaces and tabs will be read and skipped automatically after a match WsSpacesNl means spaces, tabs and new lines will be read and skipped automatically after a match