Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
1bb8ab5e9b | |||
19e0a61345 |
@ -33,8 +33,8 @@ func (r *Reader) psrn(rn rune) posRune {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reader) Pos() (index, line, column int) {
|
func (r *Reader) Pos() Position {
|
||||||
return r.pos.Index, r.pos.Line, r.pos.Column
|
return *r.pos
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rune returns the next rune in r
|
// Rune returns the next rune in r
|
||||||
|
@ -11,8 +11,8 @@ func TestPos(t *testing.T) {
|
|||||||
|
|
||||||
unread := false
|
unread := false
|
||||||
for rn, err := r.Rune(); err == nil; rn, err = r.Rune() {
|
for rn, err := r.Rune(); err == nil; rn, err = r.Rune() {
|
||||||
index, line, col := r.Pos()
|
pos := r.Pos()
|
||||||
fmt.Println(string(rn), index, line, col)
|
fmt.Println(string(rn), pos.Index, pos.Line, pos.Column)
|
||||||
|
|
||||||
if !unread && rn == '\n' {
|
if !unread && rn == '\n' {
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
|
@ -12,8 +12,12 @@ func IsSpace(rn rune) bool {
|
|||||||
return rn == ' '
|
return rn == ' '
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsTab(rn rune) bool {
|
||||||
|
return rn == '\t'
|
||||||
|
}
|
||||||
|
|
||||||
func IsWhitespace(rn rune) bool {
|
func IsWhitespace(rn rune) bool {
|
||||||
return IsSpace(rn) || IsNewLine(rn)
|
return IsSpace(rn) || IsTab(rn) || IsNewLine(rn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func And(f ...RuneFunc) RuneFunc {
|
func And(f ...RuneFunc) RuneFunc {
|
||||||
|
Reference in New Issue
Block a user