def test_dummy_any(self): _, Y = DummyVar('_'), Var('Y') eq_(eval(begin(parse_text(any(char(_), _, Y), '222'), Y)), ['2', '2', '2']) eq_(eval(begin(parse_text(any(char(_), _, Y), '234'), Y)), ['2', '3', '4']) eq_(eval(begin(parse_text(any(char(_), _, Y), ''), Y)), [])
def test_any5(self): _ = DummyVar('_') y = LogicVar('y') eq_( eval( begin(set_text('aaa'), any(char(_), _, y), char(_), eoi, getvalue(y))), ['a', 'a'])
def test_any_some(self): X, Y = Var('X'), Var('Y') eq_( eval( begin( parse_text( char(X) + any(~char('b') + some(char(X))) + eoi, 'abaaaa'), X)), 'a')
def testIndentUndent(self): _, n, s, line = DummyVar('_'), Var('n'), Var('s'), Var('line') space = char(' ') ruleList = [(s,function( ((n,), some(line(n)),s(add(n,1))), ((n,), some(line(n))))), (line,function( ((n,), times(space, n),some(letter(_)),any(space),char('\n')))) ] eq_(eval(letr(ruleList, parse_text(s(0), 'a\n b\n c\n'))), True) eq_(eval(letr(ruleList, parse_text(s(0), 'asd\n bdf\n cdfh\n'))), True)
def testIndentUndent(self): _, n, s, line = DummyVar('_'), Var('n'), Var('s'), Var('line') space = char(' ') ruleList = [(s, function(((n, ), some(line(n)), s(add(n, 1))), ((n, ), some(line(n))))), (line, function(((n, ), times(space, n), some(letter(_)), any(space), char('\n'))))] eq_(eval(letr(ruleList, parse_text(s(0), 'a\n b\n c\n'))), True) eq_(eval(letr(ruleList, parse_text(s(0), 'asd\n bdf\n cdfh\n'))), True)
def test_any2(self): text, pos = il.Var('text'), il.Var('pos') any_cont = il.Var('any_cont') result = cps(any(char('1'))) expect = 1 eq_(result, expect)
def test_any(self): any_cont = il.Var('any_cont') result = cps(any(1, nongreedy)) expect = 1 eq_(result, expect)
def test_any5(self): _ = DummyVar('_') y = LogicVar('y') eq_(eval(begin(set_text('aaa'), any(char(_), _, y), char(_), eoi, getvalue(y))), ['a', 'a'])
def test_any3(self): eq_(eval(begin(set_text('aaa'), any(char('a')))), True)
def test_dummy_any(self): _, Y = DummyVar('_'), Var('Y') eq_(eval(begin(parse_text(any(char(_), _, Y), '222'), Y)), ['2','2','2']) eq_(eval(begin(parse_text(any(char(_), _, Y), '234'), Y)), ['2', '3', '4']) eq_(eval(begin(parse_text(any(char(_), _, Y), ''), Y)), [])
def test_any(self): X, Y = Var('X'), Var('Y') eq_(eval(begin(parse_text(any(char(X), X, Y), '222'), Y)), ['2', '2', '2']) eq_(eval(begin(parse_text(any(char(X), X, Y), '234'), Y)), ['2']) eq_(eval(begin(parse_text(any(char(X), X, Y), ''), Y)), [])
def test_any(self): X, Y = Var('X'), Var('Y') eq_(eval(begin(parse_text(any(char(X), X, Y), '222'), Y)), ['2','2','2']) eq_(eval(begin(parse_text(any(char(X), X, Y), '234'), Y)), ['2']) eq_(eval(begin(parse_text(any(char(X), X, Y), ''), Y)), [])
def test_any_some(self): X, Y = Var('X'), Var('Y') eq_(eval(begin(parse_text(char(X)+any(~char('b')+some(char(X)))+eoi, 'abaaaa'), X)), 'a')
def test_any2(self): eq_(eval(parse_text(any(or_p(char('1'), char('2'))), '2')), True)