src/ViKon/Parser/Parser.php
public function parse($text, TokenList $tokenList = null, $recursive = false) {
        if ($this->startRule === null) {
            throw new ParserException('Start rule not set');
        }

        if ($this->lexer === null) {
            throw new ParserException('Lexer not set');
        }

        uasort($this->rules, [$this, 'sortRulesByOrder']);

        $this->connectRulesToLexer();

        \Event::fire('vikon.parser.before.parse', [&$text]);

        $tokenList = $this->lexer->tokenize($text, $this->startRule->getName(), $tokenList);

        foreach ($this->rules as $rule) {
            $rule->finalize($tokenList, $recursive);
        }

        return $tokenList;
    }
public function parse($text, TokenList $tokenList = null, $recursive = false) {
        if ($this->startRule === null) {
            throw new ParserException('Start rule not set');
        }

        if ($this->lexer === null) {
            throw new ParserException('Lexer not set');
        }

        uasort($this->rules, [$this, 'sortRulesByOrder']);

        $this->connectRulesToLexer();

        \Event::fire('vikon.parser.before.parse', [&$text]);

        $tokenList = $this->lexer->tokenize($text, $this->startRule->getName(), $tokenList);

        foreach ($this->rules as $rule) {
            $rule->finalize($tokenList, $recursive);
        }

        return $tokenList;
    }
public function parse ( $ text , TokenList $ tokenList = null , $ recursive = false ) { if ( $ this -> startRule === null ) { throw new ParserException ( 'Start rule not set' ) ; } if ( $ this -> lexer === null ) { throw new ParserException ( 'Lexer not set' ) ; } uasort ( $ this -> rules , [ $ this , 'sortRulesByOrder' ] ) ; $ this -> connectRulesToLexer ( ) ; \ Event :: fire ( 'vikon.parser.before.parse' , [ & $ text ] ) ; $ tokenList = $ this -> lexer -> tokenize ( $ text , $ this -> startRule -> getName ( ) , $ tokenList ) ; foreach ( $ this -> rules as $ rule ) { $ rule -> finalize ( $ tokenList , $ recursive ) ; } return $ tokenList ; }
Parse text by provided rules

@param string         $text      raw data
@param TokenList|null $tokenList already initialized token list
@param bool           $recursive indicates if parse called inside rule during tokenization

@return \ViKon\Parser\TokenList

@throws \ViKon\Parser\LexerException
@throws \ViKon\Parser\ParserException
Parse text by provided rules