Example #1
0
 /**
  * Constructor
  *
  * @param string  $sourceName
  * @param boolean $rootParser
  */
 public function __construct($sourceName = null, $rootParser = true)
 {
     $this->sourceName = $sourceName;
     $this->rootParser = $rootParser;
     if (empty(self::$operatorStr)) {
         self::$operatorStr = $this->makeOperatorStr(self::$operators);
         $commentSingle = $this->pregQuote(self::$commentSingle);
         $commentMultiLeft = $this->pregQuote(self::$commentMultiLeft);
         $commentMultiRight = $this->pregQuote(self::$commentMultiRight);
         self::$commentMulti = $commentMultiLeft . '.*?' . $commentMultiRight;
         self::$whitePattern = '/' . $commentSingle . '[^\\n]*\\s*|(' . self::$commentMulti . ')\\s*|\\s+/Ais';
     }
 }
Example #2
0
 /**
  * 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';
     }
 }
Example #3
0
 /**
  * Constructor
  *
  * @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::$operatorStr)) {
         self::$operatorStr = $this->makeOperatorStr(self::$operators);
         $commentSingle = $this->pregQuote(self::$commentSingle);
         $commentMultiLeft = $this->pregQuote(self::$commentMultiLeft);
         $commentMultiRight = $this->pregQuote(self::$commentMultiRight);
         self::$commentMulti = $commentMultiLeft . '.*?' . $commentMultiRight;
         self::$whitePattern = '/' . $commentSingle . '[^\\n]*\\s*|(' . self::$commentMulti . ')\\s*|\\s+/Ais';
     }
 }
Example #4
0
 /**
  * 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';
     }
 }
Example #5
0
 /**
  * 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';
     }
 }