diff options
-rw-r--r-- | testfarthest.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/testfarthest.lua b/testfarthest.lua new file mode 100644 index 0000000..386cbbd --- /dev/null +++ b/testfarthest.lua | |||
@@ -0,0 +1,25 @@ | |||
1 | local m = require 'lpeglabel' | ||
2 | |||
3 | function matchPrint(p, s) | ||
4 | local r, l, sfail = p:match(s) | ||
5 | print("Input:", s) | ||
6 | print("Result:", r, l, sfail) | ||
7 | end | ||
8 | |||
9 | local p = m.P"a"^0 * m.P"b" + m.P"c" | ||
10 | |||
11 | p:pcode() | ||
12 | |||
13 | matchPrint(p, "aab") | ||
14 | matchPrint(p, "ck") | ||
15 | matchPrint(p, "dk") | ||
16 | matchPrint(p, "aak") | ||
17 | |||
18 | local p = m.P"a"^0 * m.P(1) * m.P(1) + m.P"a"^0 * m.P"c" | ||
19 | |||
20 | p:pcode() | ||
21 | |||
22 | matchPrint(p, "aabc") | ||
23 | matchPrint(p, "aac") | ||
24 | matchPrint(p, "aak") | ||
25 | matchPrint(p, "x") | ||