diff options
author | Undecidable Robot <undecidabot@gmail.com> | 2016-05-21 23:42:26 +0800 |
---|---|---|
committer | Undecidable Robot <undecidabot@gmail.com> | 2016-05-21 23:44:26 +0800 |
commit | b668d2f31234854bf509e3d32ddaaff9ad61a151 (patch) | |
tree | 8fc6109a2e54f7c4933d0a9709a07aa954e45651 | |
parent | 4e23e2d65e013077d200e85dbd85326909515bf6 (diff) | |
download | lpeglabel-b668d2f31234854bf509e3d32ddaaff9ad61a151.tar.gz lpeglabel-b668d2f31234854bf509e3d32ddaaff9ad61a151.tar.bz2 lpeglabel-b668d2f31234854bf509e3d32ddaaff9ad61a151.zip |
Refacotring grammar to reuse the labels variable
-rw-r--r-- | relabel.lua | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/relabel.lua b/relabel.lua index 5fa0db6..ca15555 100644 --- a/relabel.lua +++ b/relabel.lua | |||
@@ -263,10 +263,10 @@ local labelset2 = labify { | |||
263 | 263 | ||
264 | local exp = m.P{ "Exp", | 264 | 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.Ct(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.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; |
272 | GroupedStuff = "(" * (-m.P")" * m.V"Stuff")^0 * ")" | 272 | GroupedStuff = "(" * (-m.P")" * m.V"Stuff")^0 * ")" |
@@ -297,9 +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 | + "%" * expect(m.V"Labels", "ExpNameOrLab") / mm.T |
301 | * expect(m.V"Label", "ExpLab2"))^0 * S * expect("}", "MisClose7") / mm.T | ||
302 | + "%" * expect(m.P(false), "ExpNameOrLab") | ||
303 | + "{:" * (name * ":" + m.Cc(nil)) * expect(m.V"Exp", "ExpPatt5") * expect(":}", "MisClose2") | 301 | + "{:" * (name * ":" + m.Cc(nil)) * expect(m.V"Exp", "ExpPatt5") * expect(":}", "MisClose2") |
304 | / function (n, p) return mm.Cg(p, n) end | 302 | / function (n, p) return mm.Cg(p, n) end |
305 | + "=" * expect(name, "ExpName2") / function (n) return mm.Cmt(mm.Cb(n), equalcap) end | 303 | + "=" * expect(name, "ExpName2") / function (n) return mm.Cmt(mm.Cb(n), equalcap) end |