diff options
author | Undecidable Robot <undecidabot@gmail.com> | 2016-05-16 18:54:14 +0800 |
---|---|---|
committer | Undecidable Robot <undecidabot@gmail.com> | 2016-05-16 18:54:14 +0800 |
commit | 726d4220db38e8990dd6a87d31f509c2533ca5c8 (patch) | |
tree | f684944959fa20750cc59a56c8c9796ab82fd71b /relabel.lua | |
parent | a669b5204cbe790a2316ed27e3ac0b4e950ff1c5 (diff) | |
download | lpeglabel-726d4220db38e8990dd6a87d31f509c2533ca5c8.tar.gz lpeglabel-726d4220db38e8990dd6a87d31f509c2533ca5c8.tar.bz2 lpeglabel-726d4220db38e8990dd6a87d31f509c2533ca5c8.zip |
Removing trailing newline in error reports
Diffstat (limited to '')
-rw-r--r-- | relabel.lua | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/relabel.lua b/relabel.lua index 2be7102..77718b6 100644 --- a/relabel.lua +++ b/relabel.lua | |||
@@ -3,8 +3,7 @@ | |||
3 | -- imported functions and modules | 3 | -- imported functions and modules |
4 | local tonumber, type, print, error, ipairs = tonumber, type, print, error, ipairs | 4 | local tonumber, type, print, error, ipairs = tonumber, type, print, error, ipairs |
5 | local setmetatable = setmetatable | 5 | local setmetatable = setmetatable |
6 | local unpack = table.unpack or unpack | 6 | local unpack, tinsert, concat = table.unpack or unpack, table.insert, table.concat |
7 | local tinsert = table.insert | ||
8 | local m = require"lpeglabel" | 7 | local m = require"lpeglabel" |
9 | 8 | ||
10 | -- 'm' will be used to parse expressions, and 'mm' will be used to | 9 | -- 'm' will be used to parse expressions, and 'mm' will be used to |
@@ -286,16 +285,16 @@ local function compile (p, defs) | |||
286 | errors = {} | 285 | errors = {} |
287 | local cp, label, suffix = pattern:match(p, 1, defs) | 286 | local cp, label, suffix = pattern:match(p, 1, defs) |
288 | if #errors > 0 then | 287 | if #errors > 0 then |
289 | local errmsg = "" | 288 | local errmsgs = {} |
290 | for i, err in ipairs(errors) do | 289 | for i, err in ipairs(errors) do |
291 | if #err == 1 then | 290 | if #err == 1 then |
292 | errmsg = errmsg .. err[1] .. "\n" | 291 | tinsert(errmsgs, err[1]) |
293 | else | 292 | else |
294 | local line, col = lineno(p, err[2]) | 293 | local line, col = lineno(p, err[2]) |
295 | errmsg = errmsg .. "Line" .. line .. ", Col " .. col .. ": " .. errorMessages[err[1]] .. "\n" | 294 | tinsert(errmsgs, "Line" .. line .. ", Col " .. col .. ": " .. errorMessages[err[1]]) |
296 | end | 295 | end |
297 | end | 296 | end |
298 | error(errmsg) | 297 | error(concat(errmsgs, "\n")) |
299 | end | 298 | end |
300 | return cp | 299 | return cp |
301 | end | 300 | end |