8d8d502

Faddle · faddle.git · Tickets

Branches > main > 8d8d502 > files

Add module-qualified symbols

Grahp, 2026-07-19

Commit: 8d8d502576ebe40a0ac3adcb62b1a03f72dcf041
Parent: 48607f0

3 changed files:

org/faddle/lang/read.lua modified (view file)

@@ -140,12 +140,20 @@     if token == "true" then return true end     if token == "false" then return false end     -- I don't think this is quite right, it has to be : followed by a-Z and a bunch of other things as well...-    if token:sub(1,1) == ":" and #token > 1 then-      return token:sub(2)-    end     local n = tonumber(token)     if n ~= nil then return n end++    if token:sub(1, 1) == ":" and #token > 1 then+      return token:sub(2)+    end++    local module, name = token:match("^([A-Za-z_][A-Za-z0-9_]*):(.*)$")+    if module ~= nil and name ~= "" then+      return intern(module, name)+    end+     if is_valid_symbol(token) then return intern(token) end+     error("Don't know how to read: " .. token)   end 

org/faddle/lang/symbol.lua modified (view file)

@@ -12,11 +12,12 @@ local NEWINDEX = function() error("Cannot mutate list!") end  local function is_valid_part(s)-  return s:match(symbol_regex) ~= nil+  return s ~= nil and s:match(symbol_regex) ~= nil end  local function is_valid_symbol(module, name)   if name == nil then+    -- TODO special stuff here. `.` is a specially valid symbol despite not being a valid lua identifier     if module == "." then return true end     return is_valid_part(module)   else

test.lua modified (view file)

@@ -139,6 +139,7 @@ teq(read_eval("()"), list()) teq(read_eval("[]"), {}) teq(read_eval("(quote x)"), intern("x"))+teq(read_eval("(quote x:y)"), intern("x", "y")) -- teq(read_eval("'x"), intern("x")) teq(read_eval("(plus)"), 0) teq(read_eval("(plus 1 2 3)"), 6)