diff options
author | Sergio Queiroz <sqmedeiros@gmail.com> | 2016-10-11 18:18:29 -0300 |
---|---|---|
committer | Sergio Queiroz <sqmedeiros@gmail.com> | 2016-10-11 18:18:29 -0300 |
commit | d84dd6b3659f94b09e67eb90a10e71eb05c5630e (patch) | |
tree | 643f74e8f14abd9b9277cc8b91b66c1715c1daed | |
parent | 5eb916ec7b845094ef121be13027690418395814 (diff) | |
download | lpeglabel-d84dd6b3659f94b09e67eb90a10e71eb05c5630e.tar.gz lpeglabel-d84dd6b3659f94b09e67eb90a10e71eb05c5630e.tar.bz2 lpeglabel-d84dd6b3659f94b09e67eb90a10e71eb05c5630e.zip |
Adding new examples to testlabel.lua
-rw-r--r-- | testlabel.lua | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/testlabel.lua b/testlabel.lua index 8cfb671..25036b2 100644 --- a/testlabel.lua +++ b/testlabel.lua | |||
@@ -761,5 +761,55 @@ print(eval "(1+1-1*(2/2+)-():") | |||
761 | --> syntax error: extra characters found after the expression (at index | 761 | --> syntax error: extra characters found after the expression (at index |
762 | 762 | ||
763 | 763 | ||
764 | print("+") | ||
765 | |||
766 | local g = m.P{ | ||
767 | "S", | ||
768 | S = V"End" + V'A' * V'S', | ||
769 | A = P'a' + T(1), | ||
770 | End = P"." * (-P(1) + T(2)), | ||
771 | } | ||
772 | |||
773 | assert(g:match("a.") == 3) | ||
774 | assert(g:match("aa.") == 4) | ||
775 | assert(g:match(".") == 2) | ||
776 | checkeqlab({nil, 1, "ba."}, g:match("ba.")) | ||
777 | checkeqlab({nil, 1, "ba."}, g:match("aba.")) | ||
778 | checkeqlab({nil, 1, "cba."}, g:match("cba.")) | ||
779 | checkeqlab({nil, 2, "a"}, g:match("a.a")) | ||
780 | |||
781 | |||
782 | local g2 = m.P{ | ||
783 | "S", | ||
784 | S = m.Rec(g, V"B", 1), | ||
785 | B = P'b'^1 + T(3) | ||
786 | } | ||
787 | |||
788 | assert(g2:match("a.") == 3) | ||
789 | assert(g2:match("aa.") == 4) | ||
790 | assert(g2:match(".") == 2) | ||
791 | assert(g2:match("ba.") == 4) | ||
792 | assert(g2:match("aba.") == 5) | ||
793 | checkeqlab({nil, 3, "cba."}, g2:match("cba.")) | ||
794 | checkeqlab({nil, 2, "a"}, g2:match("a.a")) | ||
795 | |||
796 | local g3 = m.P{ | ||
797 | "S", | ||
798 | S = m.Rec(g2, V"C", 2, 3), | ||
799 | C = P'c'^1 + T(4) | ||
800 | } | ||
801 | |||
802 | assert(g3:match("a.") == 3) | ||
803 | assert(g3:match("aa.") == 4) | ||
804 | assert(g3:match(".") == 2) | ||
805 | assert(g3:match("ba.") == 4) | ||
806 | assert(g3:match("aba.") == 5) | ||
807 | assert(g3:match("cba.") == 5) | ||
808 | checkeqlab({nil, 4, "a"}, g3:match("a.a")) | ||
809 | checkeqlab({nil, 4, "dc"}, g3:match("dc")) | ||
810 | checkeqlab({nil, 4, "d"}, g3:match(".d")) | ||
811 | |||
812 | |||
813 | |||
764 | print("OK") | 814 | print("OK") |
765 | 815 | ||