Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- This file:
--   http://anggtwu.net/LUA/SexpAtEol1.lua.html
--   http://anggtwu.net/LUA/SexpAtEol1.lua
--           (find-angg "LUA/SexpAtEol1.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- (defun e () (interactive) (find-angg "LUA/SexpAtEol1.lua"))

-- Superseded by:
--   (find-blogme3 "sandwiches.lua" "SexpIntervals")

-- (find-blogme3 "sandwiches.lua" "getsexpr")
-- (find-angg "LUA/lua50init.lua" "getsexp")

-- «.SexpAtEol»		(to "SexpAtEol")
-- «.SexpAtEol-tests»	(to "SexpAtEol-tests")


-- «SexpAtEol»  (to ".SexpAtEol")
--
SexpAtEol = Class {
  type    = "SexpAtEol",
  from    = function (line)
      local line1,right = SexpAtEol.spacesateol(line)
      local sexp,head,skel,left = SexpAtEol.getsexp(line1)
      return SexpAtEol { line=line,
                         left=left, sexp=sexp, right=right,
                         head=head, skel=skel
                       }
    end,
  spacesateol = function (line, n)
      local rightn = #(line:reverse():match("^[ \t]"))
      local rightp = #line - (n or rightn)
      local line1  = line:sub(1, rightp)
      local right  = line:sub(rightp + 1)
      return line1,right
    end,
  getsexp = function (str)
      if str:sub(-1) ~= ")" then return end
      local rep_ = function (n) return string.rep("_", n) end
      local simpq = function (s) return '"'..rep_(#s-2)..'"' end  -- simplify '"'s
      local simpp = function (s) return '('..rep_(#s-2)..')' end  -- simplify '()'s
      local leks = str:gsub("\\.", "__")                      -- simplify '\char's
                      :reverse()
                      :gsub('"[^"]*"', simpq)
                      :match("^%b)(")
      if not leks then return end
      local skel = leks:reverse()
      local sexp = str:sub(-#skel)
      local head = sexp:match("^%(([^ ()\"]+)")
      local skel = "(" .. skel:sub(2):gsub("%b()", simpp)
      local left = str:sub(1, -1-#skel)
      return sexp, head, skel, left
    end,
  __tostring = function (se)
      return se:tostring()
    end,
  __index = {
    tostring = function (se)
        local s = function (str) return string.rep(" ", #str) end
        local d = function (str) return string.rep("-", #str) end
        if not se.sexp then return "line: "..se.line end
        return "line: " .. se.line
          .. "\nsexp: " .. s(se.left) .. se.sexp
          .. "\nskel: " .. s(se.left) .. se.skel
          .. "\nhead: " .. s(se.left) .. " " .. se.head
          .. "\nleft: " .. se.left
      end,
  },
}

-- «SexpAtEol-tests»  (to ".SexpAtEol-tests")
--[==[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "SexpAtEol1.lua"
li = [[bla_(foo "bar\" \"plic" (+ 2 3)) ]]
se = SexpAtEol.from(li)
-- PPPV(se)
= se


--]==]







-- Local Variables:
-- coding:  utf-8-unix
-- End: