summaryrefslogtreecommitdiff
path: root/src/tparse/tokenize.go
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2021-12-03 19:03:08 -0500
committerKyle Gunger <kgunger12@gmail.com>2021-12-03 19:03:08 -0500
commite7091ba29c28352cfb33906092e212723db399b1 (patch)
tree1c942808e861f3de2e40bef4b687a44dbd62d8e1 /src/tparse/tokenize.go
parent1100ac865074effb3a4735c7449779f7193b7d0c (diff)
[PARSE] Fix hex parsing
~ Apparently CF does work, it was probably just something on my end + Fix parsing of numeric literals with bases other than 10
Diffstat (limited to 'src/tparse/tokenize.go')
-rw-r--r--src/tparse/tokenize.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/tparse/tokenize.go b/src/tparse/tokenize.go
index 8a79b04..7f57576 100644
--- a/src/tparse/tokenize.go
+++ b/src/tparse/tokenize.go
@@ -26,16 +26,22 @@ import (
// Read in a number (may be a float)
func numericLiteral(r *bufio.Reader, line int, char *int) Token {
- decimal := false
+ decimal, base := false, false
run, _, err := r.ReadRune()
last := *char
b := strings.Builder{}
for ; err == nil; run, _, err = r.ReadRune() {
- if (run == '.') && !decimal {
+ if (run == '.') && !decimal && !base {
decimal = true
- } else if !unicode.IsNumber(run) {
+ } else if (run == '.') && (decimal || base) {
break
+ } else if !unicode.IsNumber(run) {
+ if decimal || checkResRune(run) != -1 || unicode.IsSpace(run) {
+ break
+ } else if !base {
+ base = true
+ }
}
*char++
b.WriteRune(run)