Add stage 06: Lua bootstrap
The goal of stage 06 is to try parse zig synax in lua. I pulled in lpeglable 1.2.0 and parser-gen off github to get started. All of this needs to be cleaned up rather soon. Lua boostraps using tcc and musl from the previous stage. Since musl 0.6.0 doesn't support dynamic linking this build of lua doesn't support shared libraries. I couldn't easily patch musl with dlopen and friends so instead I link statically and call deps with c api.
This commit is contained in:
parent
2ae045cf8a
commit
e6b88d5a0f
170 changed files with 72518 additions and 2 deletions
44
06/main.lua
Normal file
44
06/main.lua
Normal file
|
@ -0,0 +1,44 @@
|
|||
local pg = require("parser-gen.parser-gen")
|
||||
local peg = require "parser-gen.peg-parser"
|
||||
local errs = {errMissingThen = "Missing Then"} -- one custom error
|
||||
pg.setlabels(errs)
|
||||
|
||||
|
||||
local f = assert(io.open("zig.peg", "r"))
|
||||
local zig_grammar = f:read("*all")
|
||||
f:close()
|
||||
pg.compile(zig_grammar)
|
||||
|
||||
|
||||
-- local function dump(value, call_indent)
|
||||
-- if not call_indent then
|
||||
-- call_indent = ""
|
||||
-- end
|
||||
|
||||
-- local indent = call_indent .. " "
|
||||
|
||||
-- local output = ""
|
||||
|
||||
-- if type(value) == "table" then
|
||||
-- output = output .. "{"
|
||||
-- local first = true
|
||||
-- for inner_key, inner_value in pairs ( value ) do
|
||||
-- if not first then
|
||||
-- output = output .. ", "
|
||||
-- else
|
||||
-- first = false
|
||||
-- end
|
||||
-- output = output .. "\n" .. indent
|
||||
-- output = output .. inner_key .. " = " .. dump ( inner_value, indent )
|
||||
-- end
|
||||
-- output = output .. "\n" .. call_indent .. "}"
|
||||
|
||||
-- elseif type (value) == "userdata" then
|
||||
-- output = "userdata"
|
||||
-- else
|
||||
-- output = value
|
||||
-- end
|
||||
-- return output
|
||||
-- end
|
||||
|
||||
-- print(dump(res, ""))
|
Loading…
Add table
Add a link
Reference in a new issue