From 86e8b519e4d41a5539e8f19b560bef2493674a54 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 16 Apr 2024 22:30:22 -0500 Subject: Fix #\, #t, #f reading bug --- read.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/read.lua b/read.lua index 658ad7d..5acb5c5 100644 --- a/read.lua +++ b/read.lua @@ -42,25 +42,25 @@ end local function consume_literal (cs) local tok - -- bail on just '#\' - if not (cs[2] and cs[3]) then - cs = {} - error("bad literal", "#\\") - end -- read '#\ ' and such correctly - if cs[2] == "\\" and cs[3]:match(token_separators) then - pop(cs) -- remove '\' - pop(cs) -- remove next character - return type.character(cs[1]) + if cs[2] == "\\" then + if not cs[3] then error("bad literal", "#\\") end + if cs[3]:match(token_separators) then + pop(cs) -- remove '\' + pop(cs) -- remove next character + return type.character(cs[1]) + end end pop(cs) -- discard '#' ... tok, cs = consume_token(cs) tok = "#" .. tok -- ... then put it back + print(tok) + local val - if m.readtable.literals.lit[tok] then + if m.readtable.literals.lit[tok] ~= nil then val = m.readtable.literals.lit[tok] else for re, fn in pairs(m.readtable.literals.regex) -- cgit 1.4.1-21-gabe81