Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
9d4da8ef95 | |||
31f5aa6e52 |
12
reader.go
12
reader.go
@ -18,7 +18,7 @@ func New(r io.Reader) *Reader {
|
||||
return &Reader{
|
||||
buf: ds.NewArrayStack[posRune](),
|
||||
src: bufio.NewReader(r),
|
||||
pos: &Position{},
|
||||
pos: &Position{Index: 0, Line: 1, Column: 0},
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,15 +176,23 @@ func (r *Reader) PeekStringUntil(f ...RuneFunc) (string, error) {
|
||||
}
|
||||
|
||||
// SkipUntil acts as StringUntil but discards the string
|
||||
// The rune for which that function returned false will be unread.
|
||||
func (r *Reader) SkipUntil(f ...RuneFunc) error {
|
||||
_, err := r.StringUntil(f...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return r.UnreadRune()
|
||||
}
|
||||
|
||||
// SkipWhile acts as StringWhile but discards the string
|
||||
// SkipWhile acts as StringWhile but discards the string.
|
||||
// The rune for which that function returned false will be unread.
|
||||
func (r *Reader) SkipWhile(f ...RuneFunc) error {
|
||||
_, err := r.StringWhile(f...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return r.UnreadRune()
|
||||
}
|
||||
|
||||
// ExpectRune returns true if any function returns true for the next rune read from r
|
||||
|
Reference in New Issue
Block a user