From 10f847acc7087317b0fbe20b7cf3307a0fafab8a Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Wed, 19 Apr 2023 14:34:22 +0100 Subject: Changes the parsing API for subex to be more suitable to being part of a larger program --- subex/lex.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'subex/lex.go') 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 } -- cgit v1.2.3