Files
Nexus/main.lua
T
2026-06-15 12:35:50 +01:00

41 lines
826 B
Lua

local ID = 1
local c = {}
setmetatable(c,{__call = function(c)
local this = {}
c[this] = {}
return this
end})
c.i = {}
c.o = {}
c.next = c()
for char in ("abcdefghijklmnopqrstuvwxyz $;"):match(".") do
c.i[char] = c()
end
local function n(class,data,...)
local this = {up = {},class = class,data = data}
table.insert(c[class],this)
return this
end
local i = {}
setmetatable(i,{__call = function(i,this)
end})
local prev
while true do
prev = n(c[";"],ID,nil)
local input = io.read()
local mode,input = io.read():match("([#P])(.*)")
local t = ({["$"]=c.i,["#"]=c.o})[mode]
if t then
for char in input:match(".") do
if t[char] then
local this = n(t[char],ID,nil)
n(t.next,ID,prev,this)
i(this)
prev = this
end
end
end
prev = n(t[";"],ID,nil)
end