Flow\Lexer::lexExpression PHP Метод

lexExpression() защищенный Метод

protected lexExpression ( )
    protected function lexExpression()
    {
        $tokens = array();
        $match = null;
        // eat whitespace
        if (preg_match('/\\s+/A', $this->source, $match, null, $this->cursor)) {
            $this->cursor += strlen($match[0]);
            $this->adjustLineChar($match[0]);
        }
        if (preg_match(self::REGEX_NUMBER, $this->source, $match, null, $this->cursor)) {
            $this->cursor += strlen($match[0]);
            $number = str_replace('_', '', $match[0]);
            $tokens[] = new Token(Token::NUMBER, $number, $this->line, $this->char);
            $this->adjustLineChar($match[0]);
        } elseif (preg_match(self::REGEX_OPERATOR, $this->source, $match, null, $this->cursor)) {
            $this->cursor += strlen($match[0]);
            $operator = $match[0];
            $tokens[] = new Token(Token::OPERATOR, $operator, $this->line, $this->char);
            $this->adjustLineChar($match[0]);
        } elseif (preg_match(self::REGEX_CONSTANT, $this->source, $match, null, $this->cursor)) {
            $this->cursor += strlen($match[0]);
            $constant = $match[0];
            $tokens[] = new Token(Token::CONSTANT, $constant, $this->line, $this->char);
            $this->adjustLineChar($match[0]);
        } elseif (preg_match(self::REGEX_NAME, $this->source, $match, null, $this->cursor)) {
            $this->cursor += strlen($match[0]);
            $name = $match[0];
            $tokens[] = new Token(Token::NAME, $name, $this->line, $this->char);
            $this->adjustLineChar($match[0]);
        } elseif (preg_match(self::REGEX_STRING, $this->source, $match, null, $this->cursor)) {
            $this->cursor += strlen($match[0]);
            $string = stripcslashes(substr($match[0], 1, strlen($match[0]) - 2));
            $tokens[] = new Token(Token::STRING, $string, $this->line, $this->char);
            $this->adjustLineChar($match[0]);
        } elseif ($this->position == self::POSITION_BLOCK && preg_match('/(.+?)\\s*(' . preg_quote(self::BLOCK_END_TRIM) . '|' . preg_quote(self::BLOCK_END) . ')/As', $this->source, $match, null, $this->cursor)) {
            // a catch-all text token
            $this->cursor += strlen($match[1]);
            $text = $match[1];
            $tokens[] = new Token(Token::TEXT, $text, $this->line, $this->char);
            $this->adjustLineChar($match[1]);
        } elseif ($this->position == self::POSITION_OUTPUT && preg_match('/(.+?)\\s*(' . preg_quote(self::OUTPUT_END_TRIM) . '|' . preg_quote(self::OUTPUT_END) . ')/As', $this->source, $match, null, $this->cursor)) {
            $this->cursor += strlen($match[1]);
            $text = $match[1];
            $tokens[] = new Token(Token::TEXT, $text, $this->line, $this->char);
            $this->adjustLineChar($match[1]);
        } else {
            $text = substr($this->source, $this->cursor);
            $this->cursor += $this->end;
            $tokens[] = new Token(Token::TEXT, $text, $this->line, $this->char);
            $this->adjustLineChar($text);
        }
        return $tokens;
    }