Skip to content

Commit

Permalink
use ascii space/digits in scanner
Browse files Browse the repository at this point in the history
cc #572
  • Loading branch information
gokcehan committed Jan 30, 2021
1 parent 2aa50ae commit 9d451ff
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"io/ioutil"
"log"
"strconv"
"unicode"
)

type tokenType byte
Expand Down Expand Up @@ -82,15 +81,23 @@ func (s *scanner) peek() byte {
}

func isSpace(b byte) bool {
return unicode.IsSpace(rune(b))
switch b {
case '\t', '\n', '\v', '\f', '\r', ' ':
return true
}
return false
}

func isDigit(b byte) bool {
return unicode.IsDigit(rune(b))
return '0' <= b && b <= '9'
}

func isPrefix(b byte) bool {
return b == '$' || b == '%' || b == '!' || b == '&'
switch b {
case '$', '%', '!', '&':
return true
}
return false
}

func (s *scanner) scan() bool {
Expand Down

0 comments on commit 9d451ff

Please sign in to comment.