aboutsummaryrefslogtreecommitdiff
path: root/lexer.go
diff options
context:
space:
mode:
Diffstat (limited to 'lexer.go')
-rw-r--r--lexer.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/lexer.go b/lexer.go
index b556045..3b4da4d 100644
--- a/lexer.go
+++ b/lexer.go
@@ -134,16 +134,22 @@ func (l *Lexer) AcceptAnyOf(s []string, caseInsentive bool) bool {
}
// AcceptWhile passing symbols from input while they at `valid` string.
-func (l *Lexer) AcceptWhile(valid string) {
+func (l *Lexer) AcceptWhile(valid string) bool {
+ isValid := false
for l.Accept(valid) {
+ isValid = true
}
+ return isValid
}
// AcceptWhileNot passing symbols from input while they NOT in `invalid` string.
-func (l *Lexer) AcceptWhileNot(invalid string) {
+func (l *Lexer) AcceptWhileNot(invalid string) bool {
+ isValid := false
for !strings.ContainsRune(invalid, l.Next()) {
+ isValid = true
}
l.Back()
+ return isValid
}
// AtStart returns true if current lexem not empty