From 52b8d26e8c86fed84edae447169962dfbbec1659 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 23 Mar 2024 15:52:53 -0500 Subject: Read negative numbers --- read.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/read.lua b/read.lua index c3f3f64..9561d9f 100644 --- a/read.lua +++ b/read.lua @@ -124,13 +124,13 @@ read.readtable = { ["."] = function(chars) return pop(chars), "dot", chars end, ["\""] = consume_string, [";"] = consume_comment, - -- ["#"] = + -- ["#"] = ..., } function read.scan (chars) local chars = chars - return function() - if #chars == 0 then return nil end + return function () + if not next(chars) then return nil end local token, toktype = "", nil while true do if read.readtable[chars[1]] then @@ -139,7 +139,7 @@ function read.scan (chars) return token, toktype elseif chars[1]:match("%s") then chars = consume_whitespace(chars) - elseif chars[1]:match("%d") then + elseif chars[1]:match("[%d-]") then token, chars = consume_number(chars) return token, "number" else -- cgit 1.4.1-21-gabe81