Skip to content

Commit

Permalink
Fix: use unicode methods for digit and letter check.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsayantan committed Apr 1, 2022
1 parent 4430a6b commit 65bcc5e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"strconv"
"unicode"
)

type Scanner struct {
Expand Down Expand Up @@ -232,13 +233,11 @@ func (sc *Scanner) peekNext() rune {
}

func (sc *Scanner) isDigit(r rune) bool {
return r >= '0' && r <= '9'
return unicode.IsDigit(r)
}

func (sc *Scanner) isAlpha(r rune) bool {
return (r >= 'a' || r <= 'z') ||
(r >= 'A' || r <= 'Z') ||
(r == '_')
return unicode.IsLetter(r) || r == '_'
}

func (sc *Scanner) isAlphaNumeric(r rune) bool {
Expand Down

0 comments on commit 65bcc5e

Please sign in to comment.