function testSingular() { $handler = new MockTestParser(); $handler->setReturnValue("a", true); $handler->setReturnValue("b", true); $handler->expectAt(0, "a", array("aa", LEXER_MATCHED)); $handler->expectAt(1, "a", array("aa", LEXER_MATCHED)); $handler->expectAt(2, "a", array("xx", LEXER_UNMATCHED)); $handler->expectAt(3, "a", array("xx", LEXER_UNMATCHED)); $handler->expectAt(0, "b", array("b", LEXER_SPECIAL)); $handler->expectAt(1, "b", array("bbb", LEXER_SPECIAL)); $handler->expectCallCount("a", 4); $handler->expectCallCount("b", 2); $lexer = new SimpleLexer($handler, "a"); $lexer->addPattern("a+", "a"); $lexer->addSpecialPattern("b+", "a", "b"); $this->assertTrue($lexer->parse("aabaaxxbbbxx")); }
/** * Matches attributes that are either single quoted, * double quoted or unquoted. * @param SimpleLexer $lexer Lexer to add patterns to. * @access private * @static */ function _addAttributeTokens(&$lexer) { $lexer->mapHandler('dq_attribute', 'acceptAttributeToken'); $lexer->addEntryPattern('=\\s*"', 'tag', 'dq_attribute'); $lexer->addPattern("\\\\\"", 'dq_attribute'); $lexer->addExitPattern('"', 'dq_attribute'); $lexer->mapHandler('sq_attribute', 'acceptAttributeToken'); $lexer->addEntryPattern("=\\s*'", 'tag', 'sq_attribute'); $lexer->addPattern("\\\\'", 'sq_attribute'); $lexer->addExitPattern("'", 'sq_attribute'); $lexer->mapHandler('uq_attribute', 'acceptAttributeToken'); $lexer->addSpecialPattern('=\\s*[^>\\s]*', 'tag', 'uq_attribute'); }
public function testSingular() { $handler = new MockTestParser(); $handler->returnsByValue('a', true); $handler->returnsByValue('b', true); $handler->expectAt(0, 'a', array('aa', LEXER_MATCHED)); $handler->expectAt(1, 'a', array('aa', LEXER_MATCHED)); $handler->expectAt(2, 'a', array('xx', LEXER_UNMATCHED)); $handler->expectAt(3, 'a', array('xx', LEXER_UNMATCHED)); $handler->expectAt(0, 'b', array('b', LEXER_SPECIAL)); $handler->expectAt(1, 'b', array('bbb', LEXER_SPECIAL)); $handler->expectCallCount('a', 4); $handler->expectCallCount('b', 2); $lexer = new SimpleLexer($handler, 'a'); $lexer->addPattern('a+', 'a'); $lexer->addSpecialPattern('b+', 'a', 'b'); $this->assertTrue($lexer->parse('aabaaxxbbbxx')); }