예제 #1
0
파일: testparser.py 프로젝트: charyorde/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)    
예제 #2
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)
예제 #3
0
파일: testparser.py 프로젝트: charyorde/dao
 def test_parallel(self):
   x = Var('x')
   eq_(eval(parse_text(parallel(letter(x), char(x)), 'a')), 'a')
   assert_raises(NoSolutionFound, eval, parse_text(parallel(number(x), char('3')), '2'))
예제 #4
0
 def test_parallel(self):
     x = Var('x')
     eq_(eval(parse_text(parallel(letter(x), char(x)), 'a')), 'a')
     assert_raises(NoSolutionFound, eval,
                   parse_text(parallel(integer(x), char('3')), '2'))