diff options
author | Undecidable Robot <undecidabot@gmail.com> | 2016-05-21 22:35:11 +0800 |
---|---|---|
committer | Undecidable Robot <undecidabot@gmail.com> | 2016-05-21 23:44:21 +0800 |
commit | 6ef1c042cc18fb3f19e09ab7d13c6c384f740b0e (patch) | |
tree | 16e259648b3b7c321e21e56dc48a124e4507be29 | |
parent | 0445a35b012fe3e5d8df38de2becc94955124ace (diff) | |
download | lpeglabel-6ef1c042cc18fb3f19e09ab7d13c6c384f740b0e.tar.gz lpeglabel-6ef1c042cc18fb3f19e09ab7d13c6c384f740b0e.tar.bz2 lpeglabel-6ef1c042cc18fb3f19e09ab7d13c6c384f740b0e.zip |
Converting tabs to spaces and removing trailing whitespace
-rw-r--r-- | relabel.lua | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/relabel.lua b/relabel.lua index 1cc0b3c..775789b 100644 --- a/relabel.lua +++ b/relabel.lua | |||
@@ -33,7 +33,7 @@ local errinfo = { | |||
33 | 33 | ||
34 | {"ExpPatt2", "expected a pattern after '&'"}, | 34 | {"ExpPatt2", "expected a pattern after '&'"}, |
35 | {"ExpPatt3", "expected a pattern after '!'"}, | 35 | {"ExpPatt3", "expected a pattern after '!'"}, |
36 | 36 | ||
37 | {"ExpPatt4", "expected a pattern after '('"}, | 37 | {"ExpPatt4", "expected a pattern after '('"}, |
38 | {"ExpPatt5", "expected a pattern after ':'"}, | 38 | {"ExpPatt5", "expected a pattern after ':'"}, |
39 | {"ExpPatt6", "expected a pattern after '{~'"}, | 39 | {"ExpPatt6", "expected a pattern after '{~'"}, |
@@ -192,7 +192,7 @@ local String = "'" * m.C((any - "'" - m.P"\n")^0) * expect("'", "MisTerm1") + | |||
192 | 192 | ||
193 | local defined = "%" * Def / function (c,Defs) | 193 | local defined = "%" * Def / function (c,Defs) |
194 | local cat = Defs and Defs[c] or Predef[c] | 194 | local cat = Defs and Defs[c] or Predef[c] |
195 | if not cat then | 195 | if not cat then |
196 | adderror ("name '" .. c .. "' undefined") | 196 | adderror ("name '" .. c .. "' undefined") |
197 | return mm.P"" | 197 | return mm.P"" |
198 | end | 198 | end |
@@ -231,16 +231,16 @@ local function NT (n, b) | |||
231 | end | 231 | end |
232 | 232 | ||
233 | local function labchoice (...) | 233 | local function labchoice (...) |
234 | local t = { ... } | 234 | local t = { ... } |
235 | local n = #t | 235 | local n = #t |
236 | local p = t[1] | 236 | local p = t[1] |
237 | local i = 2 | 237 | local i = 2 |
238 | while i + 1 <= n do | 238 | while i + 1 <= n do |
239 | p = t[i] and mm.Lc(p, t[i+1], unpack(t[i])) or mt.__add(p, t[i+1]) | 239 | p = t[i] and mm.Lc(p, t[i+1], unpack(t[i])) or mt.__add(p, t[i+1]) |
240 | i = i + 2 | 240 | i = i + 2 |
241 | end | 241 | end |
242 | 242 | ||
243 | return p | 243 | return p |
244 | end | 244 | end |
245 | 245 | ||
246 | local function labify(labelnames) | 246 | local function labify(labelnames) |
@@ -265,7 +265,7 @@ local exp = m.P{ "Exp", | |||
265 | Exp = S * ( m.V"Grammar" | 265 | Exp = S * ( m.V"Grammar" |
266 | + (m.V"SeqLC" * ("/" * (m.V"Labels" + m.Cc(nil)) * S | 266 | + (m.V"SeqLC" * ("/" * (m.V"Labels" + m.Cc(nil)) * S |
267 | * m.Lc(expect(m.V"SeqLC", "ExpPatt1"), m.V"SkipToSlash", labels["ExpPatt1"]))^0) / labchoice ); | 267 | * m.Lc(expect(m.V"SeqLC", "ExpPatt1"), m.V"SkipToSlash", labels["ExpPatt1"]))^0) / labchoice ); |
268 | Labels = m.Ct(m.P"{" * S * expect(m.V"Label", "ExpLab1") * (S * "," * S | 268 | Labels = m.Ct(m.P"{" * S * expect(m.V"Label", "ExpLab1") * (S * "," * S |
269 | * expect(m.V"Label", "ExpLab2"))^0 * S * expect("}", "MisClose7")); | 269 | * expect(m.V"Label", "ExpLab2"))^0 * S * expect("}", "MisClose7")); |
270 | SkipToSlash = (-m.P"/" * m.V"Stuff")^0 * m.Cc(mm.P""); | 270 | SkipToSlash = (-m.P"/" * m.V"Stuff")^0 * m.Cc(mm.P""); |
271 | Stuff = m.V"GroupedStuff" + any; | 271 | Stuff = m.V"GroupedStuff" + any; |
@@ -297,7 +297,7 @@ local exp = m.P{ "Exp", | |||
297 | + String / mm.P | 297 | + String / mm.P |
298 | + Class | 298 | + Class |
299 | + defined | 299 | + defined |
300 | + "%{" * S * expect(m.V"Label", "ExpLab1") * (S * "," * S | 300 | + "%{" * S * expect(m.V"Label", "ExpLab1") * (S * "," * S |
301 | * expect(m.V"Label", "ExpLab2"))^0 * S * expect("}", "MisClose7") / mm.T | 301 | * expect(m.V"Label", "ExpLab2"))^0 * S * expect("}", "MisClose7") / mm.T |
302 | + "%" * expect(m.P(false), "ExpNameOrLab") | 302 | + "%" * expect(m.P(false), "ExpNameOrLab") |
303 | + "{:" * (name * ":" + m.Cc(nil)) * expect(m.V"Exp", "ExpPatt5") * expect(":}", "MisClose2") | 303 | + "{:" * (name * ":" + m.Cc(nil)) * expect(m.V"Exp", "ExpPatt5") * expect(":}", "MisClose2") |
@@ -309,7 +309,7 @@ local exp = m.P{ "Exp", | |||
309 | + "{" * expect(m.V"Exp", "ExpPattOrClose") * expect("}", "MisClose5") / mm.C | 309 | + "{" * expect(m.V"Exp", "ExpPattOrClose") * expect("}", "MisClose5") / mm.C |
310 | + m.P"." * m.Cc(any) | 310 | + m.P"." * m.Cc(any) |
311 | + (name * -arrow + "<" * expect(name, "ExpName3") * expect(">", "MisClose6")) * m.Cb("G") / NT; | 311 | + (name * -arrow + "<" * expect(name, "ExpName3") * expect(">", "MisClose6")) * m.Cb("G") / NT; |
312 | Label = num + name / function (f) return tlabels[f] end; | 312 | Label = num + name / function (f) return tlabels[f] end; |
313 | Definition = name * arrow * expect(m.V"Exp", "ExpPatt8"); | 313 | Definition = name * arrow * expect(m.V"Exp", "ExpPatt8"); |
314 | Grammar = m.Cg(m.Cc(true), "G") * | 314 | Grammar = m.Cg(m.Cc(true), "G") * |
315 | m.Cf(m.V"Definition" / firstdef * m.Cg(m.V"Definition")^0, | 315 | m.Cf(m.V"Definition" / firstdef * m.Cg(m.V"Definition")^0, |
@@ -384,7 +384,7 @@ local function gsub (s, p, rep) | |||
384 | end | 384 | end |
385 | 385 | ||
386 | local function setlabels (t) | 386 | local function setlabels (t) |
387 | tlabels = t | 387 | tlabels = t |
388 | end | 388 | end |
389 | 389 | ||
390 | -- exported names | 390 | -- exported names |
@@ -394,7 +394,7 @@ local re = { | |||
394 | find = find, | 394 | find = find, |
395 | gsub = gsub, | 395 | gsub = gsub, |
396 | updatelocale = updatelocale, | 396 | updatelocale = updatelocale, |
397 | setlabels = setlabels | 397 | setlabels = setlabels |
398 | } | 398 | } |
399 | 399 | ||
400 | if version == "Lua 5.1" then _G.re = re end | 400 | if version == "Lua 5.1" then _G.re = re end |