示例#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)), [])
示例#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'])
示例#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')
示例#4
0
文件: testparser.py 项目: chaosim/dao
 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)    
示例#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)
示例#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)
示例#7
0
 def test_any(self):
   any_cont = il.Var('any_cont')
   result = cps(any(1, nongreedy))
   expect = 1
   eq_(result, expect)
示例#8
0
文件: testparser.py 项目: chaosim/dao
 def test_any5(self):
   _ = DummyVar('_')
   y = LogicVar('y')
   eq_(eval(begin(set_text('aaa'), any(char(_), _, y), char(_), eoi, getvalue(y))), ['a', 'a'])
示例#9
0
文件: testparser.py 项目: chaosim/dao
 def test_any3(self):
   eq_(eval(begin(set_text('aaa'), any(char('a')))), True)
示例#10
0
文件: testparser.py 项目: chaosim/dao
 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)), [])
示例#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)), [])
示例#12
0
文件: testparser.py 项目: chaosim/dao
 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)), [])
示例#13
0
文件: testparser.py 项目: chaosim/dao
 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')
示例#14
0
 def test_any3(self):
     eq_(eval(begin(set_text('aaa'), any(char('a')))), True)
示例#15
0
 def test_any2(self):
     eq_(eval(parse_text(any(or_p(char('1'), char('2'))), '2')), True)
示例#16
0
 def test_any(self):
     any_cont = il.Var('any_cont')
     result = cps(any(1, nongreedy))
     expect = 1
     eq_(result, expect)
示例#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)
示例#18
0
文件: testparser.py 项目: chaosim/dao
 def test_any2(self):
   eq_(eval(parse_text(any(or_p(char('1'), char('2'))), '2')), True)