diff options
author | Sergio Queiroz <sqmedeiros@gmail.com> | 2016-07-14 15:40:54 -0300 |
---|---|---|
committer | Sergio Queiroz <sqmedeiros@gmail.com> | 2016-07-14 15:40:54 -0300 |
commit | a0891e8f58c5ea1ab777bf607949237894249907 (patch) | |
tree | 5bab86939508a40fbd3e8dbecfc398a268f64af3 /testlabel.lua | |
parent | b764048fc85902100bdd26a68f83fb44098a97d3 (diff) | |
download | lpeglabel-a0891e8f58c5ea1ab777bf607949237894249907.tar.gz lpeglabel-a0891e8f58c5ea1ab777bf607949237894249907.tar.bz2 lpeglabel-a0891e8f58c5ea1ab777bf607949237894249907.zip |
Fixing a bug in lptree and testing the recovery operator
Diffstat (limited to 'testlabel.lua')
-rw-r--r-- | testlabel.lua | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/testlabel.lua b/testlabel.lua index 6ae184f..2243826 100644 --- a/testlabel.lua +++ b/testlabel.lua | |||
@@ -566,12 +566,29 @@ checkeqlab({nil, 3, "a"}, p:match("a")) | |||
566 | checkeqlab({nil, 3, "b"}, p:match("b")) | 566 | checkeqlab({nil, 3, "b"}, p:match("b")) |
567 | 567 | ||
568 | p = m.Rec(m.T(3), "b", 3) | 568 | p = m.Rec(m.T(3), "b", 3) |
569 | p:pcode() | ||
570 | checkeqlab({nil, 0, "a"}, p:match("a")) | 569 | checkeqlab({nil, 0, "a"}, p:match("a")) |
571 | assert(p:match("b") == 2) | 570 | assert(p:match("b") == 2) |
572 | 571 | ||
572 | --[[ | ||
573 | S -> (A //{fail} (!c .)*) C | ||
574 | A -> a*b | ||
575 | C -> c+ | ||
576 | ]] | ||
577 | g = m.P{ | ||
578 | "S", | ||
579 | S = m.Rec(m.V"A", (-m.P"c" * m.P(1))^0) * m.V"C", | ||
580 | A = m.P"a"^0 * "b", | ||
581 | C = m.P"c"^1, | ||
582 | } | ||
573 | 583 | ||
574 | print("OK") | 584 | assert(g:match("abc") == 4) |
575 | 585 | assert(g:match("aabc") == 5) | |
586 | assert(g:match("aadc") == 5) | ||
587 | assert(g:match("bc") == 3) | ||
588 | checkeqlab({nil, 0, "bc"}, g:match("bbc")) | ||
589 | assert(g:match("xxc") == 4) | ||
590 | assert(g:match("c") == 2) | ||
591 | checkeqlab({nil, 0, ""}, g:match("fail")) | ||
576 | 592 | ||
593 | print("OK") | ||
577 | 594 | ||