<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex/lex.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-19 14:34:22 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-19 14:34:22 +0100
commit10f847acc7087317b0fbe20b7cf3307a0fafab8a (patch)
tree4abf2f4009fcac55013672e841b2f9d3a2b2fb52 /subex/lex.go
parent5089fe689f17a3489b6be76588b8fc7f93d70e55 (diff)
downloadstred-go-10f847acc7087317b0fbe20b7cf3307a0fafab8a.tar
Changes the parsing API for subex to be more suitable to being part of a larger program
Diffstat (limited to 'subex/lex.go')
-rw-r--r--subex/lex.go16
1 files changed, 3 insertions, 13 deletions
diff --git a/subex/lex.go b/subex/lex.go
index f020b23..74bf370 100644
--- a/subex/lex.go
+++ b/subex/lex.go
@@ -5,11 +5,11 @@ import (
)
const eof rune = -1
-type RuneReader struct {
+type StringRuneReader struct {
input string
pos, width int
}
-func (l *RuneReader) next() rune {
+func (l *StringRuneReader) Next() rune {
if l.pos >= len(l.input) {
l.width = 0
return eof
@@ -19,16 +19,6 @@ func (l *RuneReader) next() rune {
l.pos += l.width
return r
}
-func (l *RuneReader) accept(chars string) bool {
- r := l.next()
- for _, char := range chars {
- if char == r {
- return true
- }
- }
- l.rewind()
- return false
-}
-func (l *RuneReader) rewind() {
+func (l *StringRuneReader) Rewind() {
l.pos -= l.width
}