Skip to content

Commit

Permalink
fix grammar load bug causing files not to be found
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriBarronmore committed Dec 1, 2022
1 parent a3f710b commit a2854ef
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion luxtre/grammars/basic_local_scoping.luxg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# local path = filename:gsub("basic_local_scoping%.luxg", "")
# local path = filename:gsub("basic_local_scoping", "")
# include (path .. "variable_scoping_functions")

@ keywords {"global"}
Expand Down
2 changes: 1 addition & 1 deletion luxtre/grammars/import.luxg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# local path = filename:gsub("import%.luxg", "")
# local path = filename:gsub("import", "")
# include (path .. "variable_scoping_functions")

--[[ python-like import statement ]]--
Expand Down
2 changes: 1 addition & 1 deletion luxtre/grammars/luxtre_standard.luxg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

--[[ Variable Scoping Crimes ]]--

# local path = filename:gsub("luxtre_standard%.luxg", "")
# local path = filename:gsub("luxtre_standard", "")
# include (path .. "variable_scoping_functions")
@import "$basic_local_scoping"

Expand Down
6 changes: 3 additions & 3 deletions luxtre/grammars/read_grammars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ local function wrap_errors(linemap, outputchunk)
return check_err
end

local function make_grammar_function(filename, env, print_out)
local function make_grammar_function(filename, modulename, env, print_out)
local concat = {}
local file = fs.open(filename)
if not file then
Expand All @@ -369,7 +369,7 @@ local function make_grammar_function(filename, env, print_out)
end
-- local ppenv = preprocess(table.concat(concat, "\n"), filename)
local fulltxt = table.concat(concat, "\n")
local status, res = pcall(preprocess, fulltxt, filename)
local status, res = pcall(preprocess, fulltxt, modulename)
if status == false then
error(res, 0)
end
Expand Down Expand Up @@ -431,7 +431,7 @@ function module.load_grammar(name, print_out)
sandbox.__load_grammar = module.load_grammar
sandbox.__filepath = name
sandbox.__rootpath = name:gsub("[.\\/]?[^.\\/]-$", "")
local status, res = pcall(make_grammar_function, fixedname, sandbox, print_out)
local status, res = pcall(make_grammar_function, fixedname, name, sandbox, print_out)
if status == false then
error(res, 2)
else
Expand Down
2 changes: 1 addition & 1 deletion luxtre/utils/filesystems.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ end

loaders.lua.search_filepath = function(filepath, filetype)
filetype = filetype or ".lua"
local filepath = filepath:gsub("^[./]+", "")
local filepath = filepath:gsub("^%./+", "")
for path in package.path:gmatch("[^;]+") do
local fixed_path = path:gsub("%.lua", filetype):gsub("%?", (filepath:gsub("%.", "/")))
if loaders.lua.exists(fixed_path) then return fixed_path end
Expand Down

0 comments on commit a2854ef

Please sign in to comment.