diff options
author | Undecidable Robot <undecidabot@gmail.com> | 2016-05-24 12:46:41 +0800 |
---|---|---|
committer | Undecidable Robot <undecidabot@gmail.com> | 2016-05-24 12:46:41 +0800 |
commit | d9a9cbdaadcecee63b7d7a47c5fa856e97d21950 (patch) | |
tree | 503658a4d79bf80e09366cfa77cf7cf4ba482390 /relabel.lua | |
parent | 389609e4299c0ca2295d55ac1c8622d14d31935c (diff) | |
download | lpeglabel-d9a9cbdaadcecee63b7d7a47c5fa856e97d21950.tar.gz lpeglabel-d9a9cbdaadcecee63b7d7a47c5fa856e97d21950.tar.bz2 lpeglabel-d9a9cbdaadcecee63b7d7a47c5fa856e97d21950.zip |
Improving error reporting on end of lines
Diffstat (limited to 'relabel.lua')
-rw-r--r-- | relabel.lua | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/relabel.lua b/relabel.lua index b0a6efc..797e094 100644 --- a/relabel.lua +++ b/relabel.lua | |||
@@ -347,9 +347,14 @@ local pattern = S * m.Cg(m.Cc(false), "G") * expect(exp, "NoPatt") / mm.P | |||
347 | 347 | ||
348 | local function lineno (s, i) | 348 | local function lineno (s, i) |
349 | if i == 1 then return 1, 1 end | 349 | if i == 1 then return 1, 1 end |
350 | local adjust = 0 | ||
351 | if s:sub(i,i) == '\n' then | ||
352 | i = i-1 | ||
353 | adjust = 1 | ||
354 | end | ||
350 | local rest, num = s:sub(1,i):gsub("[^\n]*\n", "") | 355 | local rest, num = s:sub(1,i):gsub("[^\n]*\n", "") |
351 | local r = #rest | 356 | local r = #rest |
352 | return 1 + num, r ~= 0 and r or 1 | 357 | return 1 + num, (r ~= 0 and r or 1) + adjust |
353 | end | 358 | end |
354 | 359 | ||
355 | local function compile (p, defs) | 360 | local function compile (p, defs) |