Split main.lua and comment out code for now
I commented out the code because the lua linter I have running is showing so many warnings its really annoying me so I need to fix all those before writing anything.
This commit is contained in:
parent
6f021bad5e
commit
52164c82e3
4 changed files with 48 additions and 45 deletions
44
06/main.lua
44
06/main.lua
|
@ -1,44 +0,0 @@
|
|||
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, ""))
|
|
@ -12,7 +12,7 @@ int main (void) {
|
|||
|
||||
luaopen_lpeglabel(L);
|
||||
lua_setglobal(L, "m");
|
||||
luaL_loadfile(L, "main.lua");
|
||||
luaL_loadfile(L, "src/main.lua");
|
||||
error = lua_pcall(L, 0, LUA_MULTRET, 0);
|
||||
if (error) {
|
||||
fprintf(stderr, "%s", lua_tostring(L, -1));
|
||||
|
|
13
06/src/main.lua
Normal file
13
06/src/main.lua
Normal file
|
@ -0,0 +1,13 @@
|
|||
local pg = require("parser-gen.parser-gen")
|
||||
local peg = require("parser-gen.peg-parser")
|
||||
local util = require("src.util")
|
||||
|
||||
|
||||
-- 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)
|
||||
|
34
06/src/util.lua
Normal file
34
06/src/util.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
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
|
||||
|
||||
return {
|
||||
dump = dump
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue