Index: src/lpvm.lua IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- src/lpvm.lua (revision 9760256feac8258ad497c1922935a6c5cddd210c) +++ src/lpvm.lua (revision ) @@ -31,7 +31,7 @@ local ffi = require"ffi" local lpcap = require"lpcap" --- local lpprint = require"lpprint" --only for debug purpose +local lpprint = require"lpprint" --only for debug purpose local band, rshift, lshift = bit.band, bit.rshift, bit.lshift @@ -237,11 +237,13 @@ while true do - --[[ Only for debug + ---[[ Only for debug + if DEBUG then io.write(("s: |%s| stck:%d, caps:%d \n"):format(s + 1, stackptr, captop)) if p ~= FAIL then lpprint.printinst(op.p, p, valuetable) lpprint.printcaplist(CAPTURE, captop, valuetable) + end end --]] if p == FAIL then return nil end Index: tests/testlr.lua IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- tests/testlr.lua (revision 9760256feac8258ad497c1922935a6c5cddd210c) +++ tests/testlr.lua (revision ) @@ -54,9 +54,11 @@ '(' * m.V("E") * ')' + m.R'09' ^ 1, } - +pat:ptree() +pat:pcode() +DEBUG = true assert(pat:match("-1*(6+2/4+3-1)**2") == 18) - +DEBUG = false --[[ left and right recursion with precedence rules E ← E1 + E2 / E1 − E2 / E2 ∗ E3 / E2 ÷ E3 / E3 ∗∗ E3 / − E4 / (E1) / n Index: tests/test.lua IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- tests/test.lua (revision 9760256feac8258ad497c1922935a6c5cddd210c) +++ tests/test.lua (revision ) @@ -131,7 +131,12 @@ assert(not m.match(word^3 * -1, "alo alo")) assert(not m.match(word^-1 * -1, "alo alo")) +DEBUG = true +local pat = word^-2 * -1 +pat:ptree() +pat:pcode() assert(m.match(word^-2 * -1, "alo alo")) +DEBUG = false assert(m.match(word^-3 * -1, "alo alo")) local eos = m.P(-1)