diff options
author | Case Duckworth | 2024-04-16 22:30:22 -0500 |
---|---|---|
committer | Case Duckworth | 2024-04-16 22:30:22 -0500 |
commit | 86e8b519e4d41a5539e8f19b560bef2493674a54 (patch) | |
tree | 79f9bf51329a0070997f87c207f276e2e73eb815 | |
parent | Fix a subtle bug in adding parameters to local procedure envs (diff) | |
download | lam-86e8b519e4d41a5539e8f19b560bef2493674a54.tar.gz lam-86e8b519e4d41a5539e8f19b560bef2493674a54.zip |
Fix #\, #t, #f reading bug
-rw-r--r-- | read.lua | 20 |
1 files 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 | |||
42 | 42 | ||
43 | local function consume_literal (cs) | 43 | local function consume_literal (cs) |
44 | local tok | 44 | local tok |
45 | -- bail on just '#\' | ||
46 | if not (cs[2] and cs[3]) then | ||
47 | cs = {} | ||
48 | error("bad literal", "#\\") | ||
49 | end | ||
50 | 45 | ||
51 | -- read '#\ ' and such correctly | 46 | -- read '#\ ' and such correctly |
52 | if cs[2] == "\\" and cs[3]:match(token_separators) then | 47 | if cs[2] == "\\" then |
53 | pop(cs) -- remove '\' | 48 | if not cs[3] then error("bad literal", "#\\") end |
54 | pop(cs) -- remove next character | 49 | if cs[3]:match(token_separators) then |
55 | return type.character(cs[1]) | 50 | pop(cs) -- remove '\' |
51 | pop(cs) -- remove next character | ||
52 | return type.character(cs[1]) | ||
53 | end | ||
56 | end | 54 | end |
57 | 55 | ||
58 | pop(cs) -- discard '#' ... | 56 | pop(cs) -- discard '#' ... |
59 | tok, cs = consume_token(cs) | 57 | tok, cs = consume_token(cs) |
60 | tok = "#" .. tok -- ... then put it back | 58 | tok = "#" .. tok -- ... then put it back |
61 | 59 | ||
60 | print(tok) | ||
61 | |||
62 | local val | 62 | local val |
63 | if m.readtable.literals.lit[tok] then | 63 | if m.readtable.literals.lit[tok] ~= nil then |
64 | val = m.readtable.literals.lit[tok] | 64 | val = m.readtable.literals.lit[tok] |
65 | else | 65 | else |
66 | for re, fn in pairs(m.readtable.literals.regex) | 66 | for re, fn in pairs(m.readtable.literals.regex) |