about summary refs log tree commit diff stats
path: root/tools/scripts/config-install.sh
blob: 061081f86e95e64d77e4c1fc0b22f487d0d3951f (plain) (blame)
1
2
3
4
#!/bin/sh

CONF_DIR="$(dirname `dirname $0`)/conf"
echo "CONF_DIR=$CONF_DIR\n"
.highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
-- beginnings of a repl

function eval(buf)
  local f = load('return '..buf, 'REPL')
  if f then
    return run(f)
  end
  local f, err = load(buf, 'REPL')
  if f then
    return run(f)
  else
    return {err}
  end
end

-- you could perform parse and run separately
-- usually because there's a side-effect like drawing that you want to control the timing of
function parse_into_exec_payload(buf)
  local f = load('return '..buf, 'REPL')
  if f then
    exec_payload = f
    return
  end
  local f, err = load(buf, 'REPL')
  if f then
    exec_payload = f
    return
  else
    return {err}
  end
end

-- based on https://github.com/hoelzro/lua-repl
function run(f)
  local success, results = gather_results(xpcall(f, function(...) return debug.traceback() end))
  return results
end

function gather_results(success, ...)
  local n = select('#', ...)
  return success, { n = n, ... }
end