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

--loadelpeg1()   -- (find-angg "LUA/ELpeg1.lua")
require "ELpeg1" -- (find-angg "LUA/ELpeg1.lua")
                 -- (find-angg "LUA/Show2.lua")
                 -- (find-angg "LUA/lua50init.lua" "loadshow2")
                 -- (find-angg "LUA/Show2.lua" "string.show")
string.show = function (bigstr, optscale)
    texbody = bigstr
    scale = optscale or 1
    return Show.try(tostring(outertexbody))
  end

show = show or function () return Show.try(tostring(outertexbody)) end

-- (find-angg "LUA/ELpeg1.lua" "AST")
tikzpicture          = function (o) return mkast("tikzpicture", o) end
AST.__index.tp       = function (o,...) return tikzpicture(o) end
AST.__index.tikzshow = function (o,...) return totex(tikzpicture(o)):show(...) end

usepackages = [=[
  \usepackage{tikz}
  \usetikzlibrary{shapes.geometric}
]=]
middletexbody = Dang.from [=[
\scalebox{<<scale>>}{%
  <<texbody>>
  }
]=]

fmts          = VTable {}
fmts["*"]     = "<1> \\cdot <2>"
fmts["sqrt"]  = "\\sqrt{<1>}"
fmts["tnode"] = "<tnode_totex(o)>"
fmts["tikzpicture"] = "\\begin{tikzpicture}\n\\path <1>;\n\\end{tikzpicture}"

tnode_tex         = VTable {}
tnode_tex["*"]    = "\\cdot"
tnode_tex["sqrt"] = "\\sqrt{\\;\\;}"

tnode_totex = function (o)
    local ntex = function (s) return tnode_tex[s] or s end
    local ctex = function (i) return format("\n  child {%s}", totex(o[i])) end
    local name     = ntex(o[1])
    local children = mapconcat(ctex, seq(2,#o), "")
    local preopts  = o.preopts and (o.preopts.."\n") or ""
    local opts     = o.opts    and (" "..o.opts)    or ""
    local chopts   = o.chopts  and ("\n"..o.chopts)  or ""
    return format("%snode%s {$%s$}%s%s", preopts, opts, name, chopts, children)
  end

to_tnode = function (o)
    if type(o) == "string" then return mkast("tnode", o) end
    local children = {}
    for _,c in ipairs(o) do table.insert(children, to_tnode(c)) end
    return mkast("tnode", o[0], unpack(children))
  end

--[==[
-- (find-es "tikz" "tut-child")

** (find-code-show2 "~/LATEX/Show2.tex")
*       (code-show2 "~/LATEX/Show2.tex")
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "TikzTrees1.lua"
oi = mkast("a", "b")
oi = mkast("a", "b", mkast("c", "d"))
oi = mkast("*", "b", mkast("+", "d", "e"))
oi = mkast("*", "b", mkast("+", "d", mkast("sqrt", "e")))
= oi
  on = to_tnode(oi)
= on
= on:totex()
  on   .preopts = "[every node/.style={ellipse,draw}]"
  on[3].preopts = "[every node/.style={ellipse,draw,fill=orange}]"
  on[3][3].opts = "[fill=red]"
= on
= on:tp()
= on     :totex()
= on:tp():totex()
= on:tp():show()   -- or: on:tikzshow()
= Show.bigstr
= Show.log
* (etv)

= on:tikzshow(0.5)
= Show.bigstr
= Show.log
* (etv)



-- Broken:
medstr = [=[
  [every node/.style={ellipse,fill=yellow,draw}]
  node {$\cdot$}
  [every node/.style={ellipse,fill=blue,draw}]
  child {node {$b$}}
  child {node [ellipse,fill=orange,draw] {$+$}
         child {node {$d$}}
         child {[every node/.style={ellipse,fill=green,draw}]
                node {$\sqrt{\;\;}$}
                child {node {$e$}}}
        }
]=]
= medstr:tikzshow()
= Show.bigstr
= Show.log
* (etv)


--]==]








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