Example #1
0
 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)), [])
Example #2
0
 def test_any5(self):
     _ = DummyVar('_')
     y = LogicVar('y')
     eq_(
         eval(
             begin(set_text('aaa'), any(char(_), _, y), char(_), eoi,
                   getvalue(y))), ['a', 'a'])
Example #3
0
 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')
Example #4
0
 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)    
Example #5
0
 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)
Example #6
0
 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)
Example #7
0
 def test_any(self):
   any_cont = il.Var('any_cont')
   result = cps(any(1, nongreedy))
   expect = 1
   eq_(result, expect)
Example #8
0
 def test_any5(self):
   _ = DummyVar('_')
   y = LogicVar('y')
   eq_(eval(begin(set_text('aaa'), any(char(_), _, y), char(_), eoi, getvalue(y))), ['a', 'a'])
Example #9
0
 def test_any3(self):
   eq_(eval(begin(set_text('aaa'), any(char('a')))), True)
Example #10
0
 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)), [])
Example #11
0
 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)), [])
Example #12
0
 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)), [])
Example #13
0
 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')
Example #14
0
 def test_any3(self):
     eq_(eval(begin(set_text('aaa'), any(char('a')))), True)
Example #15
0
 def test_any2(self):
     eq_(eval(parse_text(any(or_p(char('1'), char('2'))), '2')), True)
Example #16
0
 def test_any(self):
     any_cont = il.Var('any_cont')
     result = cps(any(1, nongreedy))
     expect = 1
     eq_(result, expect)
Example #17
0
 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)
Example #18
0
 def test_any2(self):
   eq_(eval(parse_text(any(or_p(char('1'), char('2'))), '2')), True)