From e7091ba29c28352cfb33906092e212723db399b1 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Fri, 3 Dec 2021 19:03:08 -0500 Subject: [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 --- src/tparse/tokenize.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/tparse/tokenize.go') 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) -- cgit v1.2.3