diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2021-12-03 19:03:08 -0500 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2021-12-03 19:03:08 -0500 |
commit | e7091ba29c28352cfb33906092e212723db399b1 (patch) | |
tree | 1c942808e861f3de2e40bef4b687a44dbd62d8e1 /src/tparse/tokenize.go | |
parent | 1100ac865074effb3a4735c7449779f7193b7d0c (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.go | 12 |
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) |