/** * Constructor * * @api * * @param string $sourceName * @param integer $sourceIndex */ public function __construct($sourceName, $sourceIndex = 0) { $this->sourceName = $sourceName ?: '(stdin)'; $this->sourceIndex = $sourceIndex; $this->charset = null; if (empty(self::$operatorPattern)) { self::$operatorPattern = '([*\\/%+-]|[!=]\\=|\\>\\=?|\\<\\=\\>|\\<\\=?|and|or)'; $commentSingle = '\\/\\/'; $commentMultiLeft = '\\/\\*'; $commentMultiRight = '\\*\\/'; self::$commentPattern = $commentMultiLeft . '.*?' . $commentMultiRight; self::$whitePattern = '/' . $commentSingle . '[^\\n]*\\s*|(' . self::$commentPattern . ')\\s*|\\s+/Ais'; } }
/** * Constructor * * @api * * @param string $sourceName * @param integer $sourceIndex * @param string $encoding */ public function __construct($sourceName, $sourceIndex = 0, $encoding = 'utf-8') { $this->sourceName = $sourceName ?: '(stdin)'; $this->sourceIndex = $sourceIndex; $this->charset = null; $this->utf8 = !$encoding || strtolower($encoding) === 'utf-8'; $this->patternModifiers = $this->utf8 ? 'Aisu' : 'Ais'; if (empty(self::$operatorPattern)) { self::$operatorPattern = '([*\\/%+-]|[!=]\\=|\\>\\=?|\\<\\=\\>|\\<\\=?|and|or)'; $commentSingle = '\\/\\/'; $commentMultiLeft = '\\/\\*'; $commentMultiRight = '\\*\\/'; self::$commentPattern = $commentMultiLeft . '.*?' . $commentMultiRight; self::$whitePattern = $this->utf8 ? '/' . $commentSingle . '[^\\n]*\\s*|(' . self::$commentPattern . ')\\s*|\\s+/AisuS' : '/' . $commentSingle . '[^\\n]*\\s*|(' . self::$commentPattern . ')\\s*|\\s+/AisS'; } }
/** * Constructor * * @api * * @param string $sourceName * @param integer $sourceIndex * @param string $encoding */ public function __construct($sourceName, $sourceIndex = 0, $encoding = 'utf-8') { $this->sourceName = $sourceName ?: '(stdin)'; $this->sourceIndex = $sourceIndex; $this->charset = null; $this->utf8 = !$encoding || strtolower($encoding) === 'utf-8'; if ($this->utf8) { $this->patternModifiers = 'Aisu'; $this->patternKeywords = '(([\\pL\\w_\\-\\*!"\']|[\\\\].)([\\pL\\w\\-_"\']|[\\\\].)*)'; $this->patternPlaceholder = '([\\pL\\w\\-_]+|#[{][$][\\pL\\w\\-_]+[}])'; } else { $this->patternKeywords = '(([\\w_\\-\\*!"\']|[\\\\].)([\\w\\-_"\']|[\\\\].)*)'; $this->patternPlaceholder = '([\\w\\-_]+|#[{][$][\\w\\-_]+[}])'; } if (empty(self::$operatorPattern)) { self::$operatorPattern = '([*\\/%+-]|[!=]\\=|\\>\\=?|\\<\\=\\>|\\<\\=?|and|or)'; $commentSingle = '\\/\\/'; $commentMultiLeft = '\\/\\*'; $commentMultiRight = '\\*\\/'; self::$commentPattern = $commentMultiLeft . '.*?' . $commentMultiRight; self::$mCommentPattern = '/' . self::$commentPattern . '/' . $this->patternModifiers . 'S'; } }