aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--relabel.lua10
-rw-r--r--testerrors.lua5
2 files changed, 10 insertions, 5 deletions
diff --git a/relabel.lua b/relabel.lua
index 3f3894d..d038531 100644
--- a/relabel.lua
+++ b/relabel.lua
@@ -360,13 +360,19 @@ local function lineno (s, i)
360 return 1 + num, (r ~= 0 and r or 1) + adjust 360 return 1 + num, (r ~= 0 and r or 1) + adjust
361end 361end
362 362
363local function splitlines(str)
364 local t = {}
365 local function helper(line) tinsert(t, line) return "" end
366 helper((str:gsub("(.-)\r?\n", helper)))
367 return t
368end
369
363local function compile (p, defs) 370local function compile (p, defs)
364 if mm.type(p) == "pattern" then return p end -- already compiled 371 if mm.type(p) == "pattern" then return p end -- already compiled
365 p = p .. " " -- for better reporting of column numbers in errors when at EOF 372 p = p .. " " -- for better reporting of column numbers in errors when at EOF
366 local cp, label, suffix = pattern:match(p, 1, defs) 373 local cp, label, suffix = pattern:match(p, 1, defs)
367 if #errfound > 0 then 374 if #errfound > 0 then
368 local lines = {} 375 local lines = splitlines(p)
369 for line in p:gmatch("[^\r\n]+") do tinsert(lines, line) end
370 local errors = {} 376 local errors = {}
371 for i, err in ipairs(errfound) do 377 for i, err in ipairs(errfound) do
372 if #err == 1 then 378 if #err == 1 then
diff --git a/testerrors.lua b/testerrors.lua
index d37cc0a..9c10aa6 100644
--- a/testerrors.lua
+++ b/testerrors.lua
@@ -589,7 +589,7 @@ L2:C9: unexpected characters after the pattern
589 589
590testerror([[ 590testerror([[
591 A <- 'A' /{'lab'} B / ! 591 A <- 'A' /{'lab'} B / !
592 592
593 B <- %{1, 2 3} 'b' / '6' & / 'B' 593 B <- %{1, 2 3} 'b' / '6' & / 'B'
594 594
595 C <- A^B 595 C <- A^B
@@ -611,6 +611,5 @@ L5:C10: expected a number after '^', '+' or '-' (no space)
611 ^ 611 ^
612]]) 612]])
613 613
614 614
615print 'OK' 615print 'OK'
616 \ No newline at end of file