diff options
-rw-r--r-- | relabel.lua | 10 | ||||
-rw-r--r-- | testerrors.lua | 5 |
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 |
361 | end | 361 | end |
362 | 362 | ||
363 | local 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 | ||
368 | end | ||
369 | |||
363 | local function compile (p, defs) | 370 | local 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 | ||
590 | testerror([[ | 590 | testerror([[ |
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 | ||
615 | print 'OK' | 615 | print 'OK' |
616 | \ No newline at end of file | ||