ThinkPHP/Library/Vendor/Boris/ShallowParser.php

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

/* vim: set shiftwidth=2 expandtab softtabstop=2: */

namespace Boris;

/**
 * The ShallowParser takes whatever is currently buffered and chunks it into individual statements.
 */
class ShallowParser {
  private $_pairs = array(
    '('   => ')',
    '{'   => '}',
    '['   => ']',
    '"'   => '"',
    "'"   => "'",
    '//'  => "\n",
    '#'   => "\n",
    '/*'  => '*/',
    '<<<' => '_heredoc_special_case_'
  );

  private $_initials;

  public function __construct() {
    $this->_initials   = '/^(' . implode('|', array_map(array($this, 'quote'), array_keys($this->_pairs))) . ')/';
  }

  /**
   * Break the $buffer into chunks, with one for each highest-level construct possible.
   *
   * If the buffer is incomplete, returns an empty array.
   *
   * @param string $buffer
   *
   * @return array
   */
  public function statements($buffer) {
    $result = $this->_createResult($buffer);

    while (strlen($result->buffer) > 0) {
      $this->_resetResult($result);

      if ($result->state == '<<<') {
        if (!$this->_initializeHeredoc($result)) {
          continue;
        }
      }

      $rules = array('_scanEscapedChar', '_scanRegion', '_scanStateEntrant', '_scanWsp', '_scanChar');

      foreach ($rules as $method) {
        if ($this->$method($result)) {
          break;
        }
      }

      if ($result->stop) {
        break;
      }
后面还有 173 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。