aboutsummaryrefslogtreecommitdiff
path: root/internal/lexer/scanners.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/lexer/scanners.go')
-rw-r--r--internal/lexer/scanners.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/internal/lexer/scanners.go b/internal/lexer/scanners.go
new file mode 100644
index 0000000..6181c2d
--- /dev/null
+++ b/internal/lexer/scanners.go
@@ -0,0 +1,32 @@
+package lexer
+
+func scanNumber(l *Lexer) bool {
+ l.AcceptWhile("0123456789")
+ if l.AtStart() {
+ // not found any digit
+ return false
+ }
+ l.Accept(".")
+ l.AcceptWhile("0123456789")
+ return !l.AtStart()
+}
+
+func scanQuotedString(l *Lexer, quote rune) bool {
+ start := l.Pos
+ if l.Next() != quote {
+ l.Back()
+ return false
+ }
+ for {
+ ch := l.Next()
+ switch ch {
+ case eof:
+ l.Pos = start // Return position to start
+ return false // Unclosed quote string?
+ case '\\':
+ l.Next() // Skip next char
+ case quote:
+ return true // Closing quote
+ }
+ }
+}