diff options
author | Alexander Kiryukhin <a.kiryukhin@mail.ru> | 2022-02-02 21:19:32 +0300 |
---|---|---|
committer | Alexander Kiryukhin <a.kiryukhin@mail.ru> | 2022-02-02 21:19:32 +0300 |
commit | d8d462d3f91e85323ebe478b01fc4bdaae17afe9 (patch) | |
tree | d686759807430a31f78f2b4d614eba32218066c6 /lexer.go | |
parent | ff198abd8fc9e2019c2f3ef9b7e74206ecdb99b7 (diff) |
Return true on AcceptWhile and AcceptWhileNot functionsv0.0.3
Diffstat (limited to 'lexer.go')
-rw-r--r-- | lexer.go | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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 |