Using more concise peg file finding.
This commit is contained in:
parent
d428725c86
commit
9bba7dd2cd
@ -130,22 +130,15 @@ end
|
||||
local Parsers = { }
|
||||
local max_parser_version = 0
|
||||
for version = 1, 999 do
|
||||
local peg_file = io.open("nomsu." .. tostring(version) .. ".peg")
|
||||
if not peg_file and package.nomsupath then
|
||||
for path in package.nomsupath:gmatch("[^;]+") do
|
||||
peg_file = io.open(path .. "/nomsu." .. tostring(version) .. ".peg")
|
||||
if peg_file then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if not (peg_file) then
|
||||
break
|
||||
end
|
||||
do
|
||||
local peg_contents = Files.read("nomsu." .. tostring(version) .. ".peg")
|
||||
if peg_contents then
|
||||
max_parser_version = version
|
||||
local peg_contents = peg_file:read("*a")
|
||||
Parsers[version] = make_parser(peg_contents, make_tree)
|
||||
peg_file:close()
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
local MAX_LINE = 80
|
||||
local NomsuCompiler = setmetatable({
|
||||
|
@ -78,16 +78,10 @@ make_tree = (tree, userdata)->
|
||||
Parsers = {}
|
||||
max_parser_version = 0
|
||||
for version=1,999
|
||||
peg_file = io.open("nomsu.#{version}.peg")
|
||||
if not peg_file and package.nomsupath
|
||||
for path in package.nomsupath\gmatch("[^;]+")
|
||||
peg_file = io.open(path.."/nomsu.#{version}.peg")
|
||||
break if peg_file
|
||||
break unless peg_file
|
||||
if peg_contents = Files.read("nomsu.#{version}.peg")
|
||||
max_parser_version = version
|
||||
peg_contents = peg_file\read("*a")
|
||||
Parsers[version] = make_parser(peg_contents, make_tree)
|
||||
peg_file\close!
|
||||
else break
|
||||
|
||||
MAX_LINE = 80 -- For beautification purposes, try not to make lines much longer than this value
|
||||
NomsuCompiler = setmetatable {name:"Nomsu"},
|
||||
|
Loading…
Reference in New Issue
Block a user