def test_lookahead(self): x = t.Lookahead(t.Exactly("x")) self.assertEqual(writeBytecode(x), [t.Choice(7), t.Choice(4), t.Match('x'), t.Commit(1), t.Fail(), t.Commit(1), t.Fail()])
def generate_Lookahead(self, out, expr, debugname=None): L1 = out.emit(t.Choice()) L2 = out.emit(t.Choice()) self._generateNode(out, expr) L3 = out.emit(t.Commit(), label=L2) out.emit(t.Fail(), label=L3) out.patchNext(L1)
def test_not(self): x = t.Not(t.Exactly("x")) self.assertEqual(writeBytecode(x), [t.Choice(4), t.Match('x'), t.Commit(1), t.Fail()])
def generate_Not(self, out, expr, debugname=None): L1 = out.emit(t.Choice()) self._generateNode(out, expr) L2 = out.emit(t.Commit()) out.emit(t.Fail(), label=L1) out.patchNext(L2)