aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUndecidable Robot <undecidabot@gmail.com>2016-05-16 21:07:03 +0800
committerUndecidable Robot <undecidabot@gmail.com>2016-05-16 21:07:03 +0800
commit043f455b6ef018b7ee06829845fd7b1f9f08f74f (patch)
treecae9ac24866e766d0b11076cfaf69e4890bfabf4
parent977213610df9ca3065de4ae60c7cf012c46f2834 (diff)
downloadlpeglabel-043f455b6ef018b7ee06829845fd7b1f9f08f74f.tar.gz
lpeglabel-043f455b6ef018b7ee06829845fd7b1f9f08f74f.tar.bz2
lpeglabel-043f455b6ef018b7ee06829845fd7b1f9f08f74f.zip
Adding better handling of unterminated strings
-rw-r--r--relabel.lua6
-rw-r--r--testerrors.lua6
2 files changed, 8 insertions, 4 deletions
diff --git a/relabel.lua b/relabel.lua
index e3b7d48..0594777 100644
--- a/relabel.lua
+++ b/relabel.lua
@@ -129,8 +129,8 @@ local Def = name * m.Carg(1)
129 129
130local num = m.C(m.R"09"^1) * S / tonumber 130local num = m.C(m.R"09"^1) * S / tonumber
131 131
132local String = "'" * m.C((any - "'")^0) * ("'" + throw(31)) + 132local String = "'" * m.C((any - "'" - m.P"\n")^0) * ("'" + throw(31)) +
133 '"' * m.C((any - '"')^0) * ('"' + throw(30)) 133 '"' * m.C((any - '"' - m.P"\n")^0) * ('"' + throw(30))
134 134
135 135
136local defined = "%" * Def / function (c,Defs) 136local defined = "%" * Def / function (c,Defs)
@@ -195,7 +195,7 @@ local exp = m.P{ "Exp",
195 Stuff = m.V"GroupedStuff" + any; 195 Stuff = m.V"GroupedStuff" + any;
196 GroupedStuff = "(" * (-m.P")" * m.V"Stuff")^0 * ")" 196 GroupedStuff = "(" * (-m.P")" * m.V"Stuff")^0 * ")"
197 + "{" * (-m.P"}" * m.V"Stuff")^0 * "}"; 197 + "{" * (-m.P"}" * m.V"Stuff")^0 * "}";
198 SeqLC = m.Lc(m.V"Seq", m.V"SkipToSlash", 5, 6, 7, 8, 9, 10); 198 SeqLC = m.Lc(m.V"Seq", m.V"SkipToSlash", 5, 6, 7, 8, 9, 10, 31, 30);
199 Seq = m.Cf(m.Cc(m.P"") * m.V"Prefix"^1 , mt.__mul); 199 Seq = m.Cf(m.Cc(m.P"") * m.V"Prefix"^1 , mt.__mul);
200 Prefix = "&" * S * (m.V"Prefix" + throw(5)) / mt.__len 200 Prefix = "&" * S * (m.V"Prefix" + throw(5)) / mt.__len
201 + "!" * S * (m.V"Prefix" + throw(6)) / mt.__unm 201 + "!" * S * (m.V"Prefix" + throw(6)) / mt.__unm
diff --git a/testerrors.lua b/testerrors.lua
index bcab65f..271773a 100644
--- a/testerrors.lua
+++ b/testerrors.lua
@@ -123,10 +123,14 @@ local patterns = {
123 [[ A <- %nosuch ('error' ]], 123 [[ A <- %nosuch ('error' ]],
124 [[A <- Unknown Rules]], 124 [[A <- Unknown Rules]],
125 [['a' / &@ ('c' / 'd')]], 125 [['a' / &@ ('c' / 'd')]],
126 -- 81 - 83 126 -- 81 - 84
127 [['x' / & / 'y']], 127 [['x' / & / 'y']],
128 [[&/'p'/!/'q']], 128 [[&/'p'/!/'q']],
129 [['p'//'q']], 129 [['p'//'q']],
130 [[
131 S <- 'forgot to close / T
132 T <- 'T' & / 't'
133 ]]
130} 134}
131 135
132for i, patt in ipairs(patterns) do 136for i, patt in ipairs(patterns) do