コード例 #1
0
ファイル: SimpleAssertion.php プロジェクト: mck89/rebuilder
 /**
  * Sets the identifier. It can be one of the following:
  * "b", "B", "A", "Z", "z", "G", "Q", "E", "K"
  * 
  * @param string $identifier Identifier to match
  * 
  * @return SimpleAssertion
  * 
  * @throws \REBuilder\Exception\Generic
  * 
  * @link http://php.net/manual/en/regexp.reference.escape.php
  */
 public function setIdentifier($identifier)
 {
     if (!\REBuilder\Parser\Rules::validateSimpleAssertion($identifier)) {
         throw new \REBuilder\Exception\Generic("'{$identifier}' is not a valid simple assertion type identifier");
     }
     return parent::setIdentifier($identifier);
 }
コード例 #2
0
ファイル: GenericCharType.php プロジェクト: mck89/rebuilder
 /**
  * Sets the identifier. It can be one of the following:
  * "d", "D", "h", "H", "s", "S", "v", "V", "w", "W"
  * 
  * @param string $identifier Identifier to match
  * 
  * @return GenericCharType
  * 
  * @throws \REBuilder\Exception\Generic
  * 
  * @link http://php.net/manual/en/regexp.reference.escape.php
  */
 public function setIdentifier($identifier)
 {
     if (!\REBuilder\Parser\Rules::validateGenericCharType($identifier)) {
         throw new \REBuilder\Exception\Generic("'{$identifier}' is not a valid generic character type identifier");
     }
     return parent::setIdentifier($identifier);
 }
コード例 #3
0
ファイル: NonPrintingChar.php プロジェクト: mck89/rebuilder
 /**
  * Sets the identifier. It can be one of the following:
  * "a", "e", "f", "n", "r", "t".
  * 
  * @param string $identifier Identifier to match
  * 
  * @return NonPrintingChar
  * 
  * @throws \REBuilder\Exception\Generic
  * 
  * @link http://php.net/manual/en/regexp.reference.escape.php
  */
 public function setIdentifier($identifier)
 {
     if (!\REBuilder\Parser\Rules::validateNonPrintingChar($identifier)) {
         throw new \REBuilder\Exception\Generic("'{$identifier}' is not a valid non-printing character identifier");
     }
     return parent::setIdentifier($identifier);
 }
コード例 #4
0
ファイル: UnicodeCharClass.php プロジェクト: mck89/rebuilder
 /**
  * Sets the character class. It can be any supported unicode property code
  * or script. If "X" it will be used as extended unicode sequence (\X)
  * 
  * @param string $class Character class to match
  * 
  * @return UnicodeCharClass
  * 
  * @throws \REBuilder\Exception\Generic
  * 
  * @link http://php.net/manual/en/regexp.reference.escape.php
  */
 public function setClass($class)
 {
     if ($class !== "X" && !\REBuilder\Parser\Rules::validateUnicodePropertyCode($class) && !\REBuilder\Parser\Rules::validateUnicodeScript($class)) {
         throw new \REBuilder\Exception\Generic("Unknow unicode character class '{$class}'");
     }
     $this->_class = $class;
     return $this;
 }
コード例 #5
0
ファイル: InternalOption.php プロジェクト: mck89/rebuilder
 /**
  * Sets internal option modifiers
  * 
  * @param string $modifiers Internal option modifiers
  * 
  * @return InternalOption
  * 
  * @throws \REBuilder\Exception\InvalidModifier
  */
 public function setModifiers($modifiers)
 {
     if (!\REBuilder\Parser\Rules::validateModifiers(str_replace("-", "", $modifiers), $wrongModifier)) {
         throw new \REBuilder\Exception\InvalidModifier("Invalid modifier '{$wrongModifier}'");
     }
     $this->_modifiers = $modifiers;
     return $this;
 }
コード例 #6
0
ファイル: HexChar.php プロジェクト: mck89/rebuilder
 /**
  * Sets the character code . It can be 0, 1 or 2 hexadecimal digits
  * that represent a character code
  * 
  * @param string $char Character to match
  * 
  * @return HexChar
  * 
  * @throws \REBuilder\Exception\Generic
  * 
  * @link http://php.net/manual/en/regexp.reference.escape.php
  */
 public function setChar($char)
 {
     if ($char !== "" && !\REBuilder\Parser\Rules::validateHexString($char)) {
         throw new \REBuilder\Exception\Generic("Invalid hexadecimal sequence '{$char}'");
     } elseif (strlen($char) > 2) {
         throw new \REBuilder\Exception\Generic("Hexadecimal character can match a maximum of 2 digits");
     }
     return parent::setChar($char);
 }
コード例 #7
0
ファイル: Tokenizer.php プロジェクト: mck89/rebuilder
 /**
  * Strip regex delimiters and modifiers and returns the end delimiter and
  * the regex modifiers
  * 
  * @return array
  * 
  * @throws \REBuilder\Exception\InvalidDelimiter
  */
 protected function _stripDelimitersAndModifiers()
 {
     //Emit the regex delimiter token and strip it from the beginning of the
     //regex
     $delimiter = $this->_regex[0];
     $this->_emitToken(Token::TYPE_REGEX_START_DELIMITER, $delimiter);
     $this->_regex = substr($this->_regex, 1);
     //Get the right end delimiter and strip it from the end of the regex,
     //then get the modifiers
     $endDelimiter = Rules::getEndDelimiter($delimiter);
     $endDelimiterPos = strrpos($this->_regex, $endDelimiter);
     if ($endDelimiterPos === false) {
         throw new Exception\InvalidDelimiter("End delimiter '{$endDelimiter}' not found");
     }
     $modifiers = substr($this->_regex, $endDelimiterPos + 1);
     $this->_regex = substr($this->_regex, 0, $endDelimiterPos);
     $this->_modifiersStack->push($modifiers);
     return array($delimiter, $endDelimiter, $modifiers);
 }
コード例 #8
0
ファイル: PosixCharClass.php プロジェクト: mck89/rebuilder
 /**
  * Sets the POSIX character class. It can be any supported POSIX classes
  * 
  * @param string $class Character class to match
  * 
  * @return PosixCharClass
  * 
  * @throws \REBuilder\Exception\Generic
  * 
  * @link http://php.net/manual/en/regexp.reference.character-classes.php
  */
 public function setClass($class)
 {
     if (!\REBuilder\Parser\Rules::validatePosixCharClass($class)) {
         throw new \REBuilder\Exception\Generic("Unknow POSIX character class '{$class}'");
     }
     $this->_class = $class;
     return $this;
 }