예제 #1
0
 function testModeMapping()
 {
     $handler = new MockTestParser($this);
     $handler->setReturnValue("a", true);
     $handler->expectArgumentsAt(0, "a", array("aa", DOKU_LEXER_MATCHED, 0));
     $handler->expectArgumentsAt(1, "a", array("(", DOKU_LEXER_ENTER, 2));
     $handler->expectArgumentsAt(2, "a", array("bb", DOKU_LEXER_MATCHED, 3));
     $handler->expectArgumentsAt(3, "a", array("a", DOKU_LEXER_UNMATCHED, 5));
     $handler->expectArgumentsAt(4, "a", array("bb", DOKU_LEXER_MATCHED, 6));
     $handler->expectArgumentsAt(5, "a", array(")", DOKU_LEXER_EXIT, 8));
     $handler->expectArgumentsAt(6, "a", array("b", DOKU_LEXER_UNMATCHED, 9));
     $handler->expectCallCount("a", 7);
     $lexer = new Doku_Lexer($handler, "mode_a");
     $lexer->addPattern("a+", "mode_a");
     $lexer->addEntryPattern("(", "mode_a", "mode_b");
     $lexer->addPattern("b+", "mode_b");
     $lexer->addExitPattern(")", "mode_b");
     $lexer->mapHandler("mode_a", "a");
     $lexer->mapHandler("mode_b", "a");
     $this->assertTrue($lexer->parse("aa(bbabb)b"));
     $handler->tally();
 }
예제 #2
0
 function testModeMapping()
 {
     $handler = new MockTestParser();
     $handler->setReturnValue("a", true);
     $handler->expectAt(0, "a", array("aa", LEXER_MATCHED));
     $handler->expectAt(1, "a", array("(", LEXER_ENTER));
     $handler->expectAt(2, "a", array("bb", LEXER_MATCHED));
     $handler->expectAt(3, "a", array("a", LEXER_UNMATCHED));
     $handler->expectAt(4, "a", array("bb", LEXER_MATCHED));
     $handler->expectAt(5, "a", array(")", LEXER_EXIT));
     $handler->expectAt(6, "a", array("b", LEXER_UNMATCHED));
     $handler->expectCallCount("a", 7);
     $lexer = new SimpleLexer($handler, "mode_a");
     $lexer->addPattern("a+", "mode_a");
     $lexer->addEntryPattern("(", "mode_a", "mode_b");
     $lexer->addPattern("b+", "mode_b");
     $lexer->addExitPattern(")", "mode_b");
     $lexer->mapHandler("mode_a", "a");
     $lexer->mapHandler("mode_b", "a");
     $this->assertTrue($lexer->parse("aa(bbabb)b"));
 }
예제 #3
0
 public function testModeMapping()
 {
     $handler = new MockTestParser();
     $handler->returnsByValue('a', true);
     $handler->expectAt(0, 'a', array('aa', LEXER_MATCHED));
     $handler->expectAt(1, 'a', array('(', LEXER_ENTER));
     $handler->expectAt(2, 'a', array('bb', LEXER_MATCHED));
     $handler->expectAt(3, 'a', array('a', LEXER_UNMATCHED));
     $handler->expectAt(4, 'a', array('bb', LEXER_MATCHED));
     $handler->expectAt(5, 'a', array(')', LEXER_EXIT));
     $handler->expectAt(6, 'a', array('b', LEXER_UNMATCHED));
     $handler->expectCallCount('a', 7);
     $lexer = new SimpleLexer($handler, 'mode_a');
     $lexer->addPattern('a+', 'mode_a');
     $lexer->addEntryPattern('(', 'mode_a', 'mode_b');
     $lexer->addPattern('b+', 'mode_b');
     $lexer->addExitPattern(')', 'mode_b');
     $lexer->mapHandler('mode_a', 'a');
     $lexer->mapHandler('mode_b', 'a');
     $this->assertTrue($lexer->parse('aa(bbabb)b'));
 }