Reducing imports.
This commit is contained in:
parent
2db2c68ac3
commit
4fd6d817c8
22
parser.lua
22
parser.lua
@ -1,9 +1,8 @@
|
|||||||
local lpeg = require('lpeg')
|
local lpeg = require('lpeg')
|
||||||
local re = require('re')
|
local re = require('re')
|
||||||
lpeg.setmaxstack(10000)
|
lpeg.setmaxstack(10000)
|
||||||
local P, R, V, S, Cg, C, Cp, B, Cmt, Carg
|
local P, R, S, C, Cmt, Carg
|
||||||
P, R, V, S, Cg, C, Cp, B, Cmt, Carg = lpeg.P, lpeg.R, lpeg.V, lpeg.S, lpeg.Cg, lpeg.C, lpeg.Cp, lpeg.B, lpeg.Cmt, lpeg.Carg
|
P, R, S, C, Cmt, Carg = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cmt, lpeg.Carg
|
||||||
local utils = require('utils')
|
|
||||||
local match, sub
|
local match, sub
|
||||||
do
|
do
|
||||||
local _obj_0 = string
|
local _obj_0 = string
|
||||||
@ -66,7 +65,11 @@ do
|
|||||||
if seen_errors[start_pos] then
|
if seen_errors[start_pos] then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if utils.size(seen_errors) >= 10 then
|
local num_errors = 0
|
||||||
|
for _ in pairs(seen_errors) do
|
||||||
|
num_errors = num_errors + 1
|
||||||
|
end
|
||||||
|
if num_errors >= 10 then
|
||||||
seen_errors[start_pos + 1] = colored.bright(colored.yellow(colored.onred("Too many errors, canceling parsing...")))
|
seen_errors[start_pos + 1] = colored.bright(colored.yellow(colored.onred("Too many errors, canceling parsing...")))
|
||||||
return #src + 1
|
return #src + 1
|
||||||
end
|
end
|
||||||
@ -164,7 +167,16 @@ Parser.parse = function(nomsu_code, source)
|
|||||||
tree = nil
|
tree = nil
|
||||||
end
|
end
|
||||||
if next(userdata.errors) then
|
if next(userdata.errors) then
|
||||||
local keys = utils.keys(userdata.errors)
|
local keys
|
||||||
|
do
|
||||||
|
local _accum_0 = { }
|
||||||
|
local _len_0 = 1
|
||||||
|
for k, v in pairs(userdata.errors) do
|
||||||
|
_accum_0[_len_0] = k
|
||||||
|
_len_0 = _len_0 + 1
|
||||||
|
end
|
||||||
|
keys = _accum_0
|
||||||
|
end
|
||||||
table.sort(keys)
|
table.sort(keys)
|
||||||
local errors
|
local errors
|
||||||
do
|
do
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
lpeg = require 'lpeg'
|
lpeg = require 'lpeg'
|
||||||
re = require 're'
|
re = require 're'
|
||||||
lpeg.setmaxstack 10000
|
lpeg.setmaxstack 10000
|
||||||
{:P,:R,:V,:S,:Cg,:C,:Cp,:B,:Cmt,:Carg} = lpeg
|
{:P,:R,:S,:C,:Cmt,:Carg} = lpeg
|
||||||
utils = require 'utils'
|
|
||||||
{:match, :sub} = string
|
{:match, :sub} = string
|
||||||
{:NomsuCode, :LuaCode, :Source} = require "code_obj"
|
{:NomsuCode, :LuaCode, :Source} = require "code_obj"
|
||||||
AST = require "nomsu_tree"
|
AST = require "nomsu_tree"
|
||||||
@ -51,7 +50,9 @@ NOMSU_DEFS = with {}
|
|||||||
seen_errors = userdata.errors
|
seen_errors = userdata.errors
|
||||||
if seen_errors[start_pos]
|
if seen_errors[start_pos]
|
||||||
return true
|
return true
|
||||||
if utils.size(seen_errors) >= 10
|
num_errors = 0
|
||||||
|
for _ in pairs(seen_errors) do num_errors += 1
|
||||||
|
if num_errors >= 10
|
||||||
seen_errors[start_pos+1] = colored.bright colored.yellow colored.onred "Too many errors, canceling parsing..."
|
seen_errors[start_pos+1] = colored.bright colored.yellow colored.onred "Too many errors, canceling parsing..."
|
||||||
return #src+1
|
return #src+1
|
||||||
err_pos = start_pos
|
err_pos = start_pos
|
||||||
@ -122,7 +123,7 @@ Parser.parse = (nomsu_code, source=nil)->
|
|||||||
tree = nil
|
tree = nil
|
||||||
|
|
||||||
if next(userdata.errors)
|
if next(userdata.errors)
|
||||||
keys = utils.keys(userdata.errors)
|
keys = [k for k,v in pairs(userdata.errors)]
|
||||||
table.sort(keys)
|
table.sort(keys)
|
||||||
errors = [userdata.errors[k] for k in *keys]
|
errors = [userdata.errors[k] for k in *keys]
|
||||||
error("Errors occurred while parsing:\n\n"..table.concat(errors, "\n\n"), 0)
|
error("Errors occurred while parsing:\n\n"..table.concat(errors, "\n\n"), 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user