Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file: -- http://angg.twu.net/LUA/blogme2021.lua.html -- http://angg.twu.net/LUA/blogme2021.lua -- (find-angg "LUA/blogme2021.lua") -- Author: Eduardo Ochs <eduardoochs@gmail.com> -- (find-angg "LUA/lua50init.lua" "Blogme") -- (find-blogme3 "brackets.lua") BlogMe = Class { type = "BlogMe", new = function (str) local bracks,s = {}, {} local push = function (n) table.insert(s, n) end local pop = function (pos) local n = s[#s]; s[#s] = nil if n == nil then error("Unbalanced ']' at pos="..pos) end return n end for pos,c in str:gmatch("()([%[%]])") do if c == "[" then push(pos) else local openpos = pop(pos) bracks[openpos],bracks[pos] = pos, openpos end end if #s > 0 then error("Unbalanced '[' at pos="..s[#s]) end return BlogMe {str=str, bracks=bracks} end, __index = { }, } --[==[ * (eepitch-lua51) * (eepitch-kill) * (eepitch-lua51) dofile "blogme2021.lua" bm = BlogMe.new("[[]] [][") bm = BlogMe.new("[[]] [] ][") bm = BlogMe.new("[[]] [] []") PPV(bm.bracks) --]==]