aboutsummaryrefslogtreecommitdiff
path: root/test.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-04-30 18:23:40 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-04-30 18:23:40 -0300
commit1cc484a05cf9c7da8c859f3f52ea5a85009c4509 (patch)
tree68983c515343cb1759e6b94a14f911fa8405f0d7 /test.lua
parenteb8b906d5eb5113e7377f06afbfd641c1c5e6a1e (diff)
downloadlpeg-1cc484a05cf9c7da8c859f3f52ea5a85009c4509.tar.gz
lpeg-1cc484a05cf9c7da8c859f3f52ea5a85009c4509.tar.bz2
lpeg-1cc484a05cf9c7da8c859f3f52ea5a85009c4509.zip
'nullable' ('checkaux') uses tag from 'verifyrule'
When checking whether a rule is nullable, 'checkaux' reuses tag previously set by 'verifyrule'.
Diffstat (limited to 'test.lua')
-rwxr-xr-xtest.lua44
1 files changed, 44 insertions, 0 deletions
diff --git a/test.lua b/test.lua
index 3241408..a81c8b8 100755
--- a/test.lua
+++ b/test.lua
@@ -1662,6 +1662,50 @@ errmsg("x <- 'a' x <- 'b'", 'already defined')
1662errmsg("'a' -", "near '-'") 1662errmsg("'a' -", "near '-'")
1663 1663
1664 1664
1665if m.nullable then
1666 print "testing nullable predicate"
1667
1668
1669 local bg = re.compile[[
1670 A31 <- A30 A30
1671 A30 <- A29 A29
1672 A29 <- A28 A28
1673 A28 <- A27 A27
1674 A27 <- A26 A26
1675 A26 <- A25 A25
1676 A25 <- A24 A24
1677 A24 <- A23 A23
1678 A23 <- A22 A22
1679 A22 <- A21 A21
1680 A21 <- A20 A20
1681 A20 <- A19 A19
1682 A19 <- A18 A18
1683 A18 <- A17 A17
1684 A17 <- A16 A16
1685 A16 <- A15 A15
1686 A15 <- A14 A14
1687 A14 <- A13 A13
1688 A13 <- A12 A12
1689 A12 <- A11 A11
1690 A11 <- A10 A10
1691 A10 <- A9 A9
1692 A9 <- A8 A8
1693 A8 <- A7 A7
1694 A7 <- A6 A6
1695 A6 <- A5 A5
1696 A5 <- A4 A4
1697 A4 <- A3 A3
1698 A3 <- A2 A2
1699 A2 <- A1 A1
1700 A1 <- ""
1701 ]]
1702
1703 assert(bg:nullable())
1704 assert((bg * bg):nullable())
1705 assert(not (bg * bg * "a"):nullable())
1706 assert(m.P(-1):nullable())
1707end
1708
1665print"OK" 1709print"OK"
1666 1710
1667 1711