aboutsummaryrefslogtreecommitdiff
path: root/relabel.lua
diff options
context:
space:
mode:
authorUndecidable Robot <undecidabot@gmail.com>2016-05-23 08:24:11 +0800
committerUndecidable Robot <undecidabot@gmail.com>2016-05-23 08:24:11 +0800
commitd891c969fca34d1b5ea3a41835d73ec7d067d6eb (patch)
tree615ac1be3f46f6c567ff319d709ad4ca4d62f6ae /relabel.lua
parentbd075f80398f4a21c47f8737922f21c4a4024f9b (diff)
downloadlpeglabel-d891c969fca34d1b5ea3a41835d73ec7d067d6eb.tar.gz
lpeglabel-d891c969fca34d1b5ea3a41835d73ec7d067d6eb.tar.bz2
lpeglabel-d891c969fca34d1b5ea3a41835d73ec7d067d6eb.zip
Improving error reporting of unterminated strings and character classes
Diffstat (limited to 'relabel.lua')
-rw-r--r--relabel.lua16
1 files changed, 11 insertions, 5 deletions
diff --git a/relabel.lua b/relabel.lua
index 95129db..170cb66 100644
--- a/relabel.lua
+++ b/relabel.lua
@@ -96,6 +96,13 @@ local ignore = m.Cmt(any, function (input, pos)
96 return errfound[#errfound][2], dummy 96 return errfound[#errfound][2], dummy
97end) 97end)
98 98
99local pointAtStart = m.Cmt(any, function (input, pos)
100 local ret = errfound[#errfound][2]
101 errfound[#errfound][2] = pos-1
102 return ret, dummy
103end)
104
105
99local function adderror(message) 106local function adderror(message)
100 tinsert(errfound, {message}) 107 tinsert(errfound, {message})
101end 108end
@@ -254,12 +261,10 @@ end
254local labelset1 = labify { 261local labelset1 = labify {
255 "ExpPatt2", "ExpPatt3", 262 "ExpPatt2", "ExpPatt3",
256 "ExpNum", "ExpCap", "ExpName1", 263 "ExpNum", "ExpCap", "ExpName1",
257 "MisTerm1", "MisTerm2"
258} 264}
259 265
260local labelset2 = labify { 266local labelset2 = labify {
261 "MisClose1", "MisClose2", "MisClose3", "MisClose4", "MisClose5", 267 "MisClose1", "MisClose2", "MisClose3", "MisClose4", "MisClose5", "MisClose7"
262 "MisClose7", "MisClose8"
263} 268}
264 269
265local exp = m.P{ "Exp", 270local exp = m.P{ "Exp",
@@ -300,8 +305,9 @@ local exp = m.P{ "Exp",
300 )^0, function (a,b,f) return f(a,b) end ); 305 )^0, function (a,b,f) return f(a,b) end );
301 PrimaryLC = m.Lc(m.V"Primary", ignore, unpack(labelset2)); 306 PrimaryLC = m.Lc(m.V"Primary", ignore, unpack(labelset2));
302 Primary = "(" * expect(m.V"Exp", "ExpPatt4") * expect(S * ")", "MisClose1") 307 Primary = "(" * expect(m.V"Exp", "ExpPatt4") * expect(S * ")", "MisClose1")
303 + String / mm.P 308 + m.Lc(String / mm.P, pointAtStart,
304 + Class 309 labels["MisTerm1"], labels["MisTerm2"])
310 + m.Lc(Class, pointAtStart, labels["MisClose8"])
305 + defined 311 + defined
306 + "%" * expect(m.V"Labels", "ExpNameOrLab") / mm.T 312 + "%" * expect(m.V"Labels", "ExpNameOrLab") / mm.T
307 + "{:" * (name * ":" + m.Cc(nil)) * expect(m.V"Exp", "ExpPatt5") 313 + "{:" * (name * ":" + m.Cc(nil)) * expect(m.V"Exp", "ExpPatt5")