Example #1
0
 /**
  * Adds a child to the class at the given index
  * 
  * @param AbstractPattern $child Child to add
  * 
  * @param int             $index Index
  * 
  * @return AlternationGroup
  * 
  * @throws \REBuilder\Exception\Generic
  */
 public function addChildAt(AbstractPattern $child, $index = null)
 {
     if (!$child instanceof Alternation) {
         throw new \REBuilder\Exception\Generic("Alternation groups can contain only alternations");
     }
     return parent::addChildAt($child, $index);
 }
Example #2
0
 /**
  * Adds a child to the class at the given index
  * 
  * @param AbstractPattern $child Child to add
  * @param int             $index Index
  * 
  * @return CharClass
  * 
  * @throws \REBuilder\Exception\Generic
  */
 public function addChildAt(AbstractPattern $child, $index = null)
 {
     if (!$child->canBeAddedToCharClassRange()) {
         throw new \REBuilder\Exception\Generic($this->_getClassName($child) . " cannot be added to character class ranges");
     } elseif (count($this->getChildren()) === 2) {
         throw new \REBuilder\Exception\Generic("Character class ranges can contain only 2 children");
     }
     return parent::addChildAt($child, $index);
 }
 /**
  * Adds a child to the class at the given index
  * 
  * @param AbstractPattern $child Child to add
  * @param int             $index Index
  * 
  * @return CharClass
  * 
  * @throws \REBuilder\Exception\Generic
  */
 public function addChildAt(AbstractPattern $child, $index = null)
 {
     $childClass = get_class($child);
     if (!in_array($childClass, $this->_childrenOrder)) {
         throw new \REBuilder\Exception\Generic($this->_getClassName($child) . " cannot be added to conditional subpatterns");
     }
     $index = array_search($childClass, array_values($this->_childrenOrder));
     if (!$this->_safeAdd) {
         if (isset($this->_children[$index])) {
             throw new \REBuilder\Exception\Generic($this->_getClassName($child) . " already present in conditional subpattern");
         }
     }
     $this->_safeAdd = false;
     return parent::addChildAt($child, $index);
 }
Example #4
0
 /**
  * Adds a child to the class at the given index
  * 
  * @param AbstractPattern $child Child to add
  * @param int             $index Index
  * 
  * @return CharClass
  * 
  * @throws \REBuilder\Exception\Generic
  */
 public function addChildAt(AbstractPattern $child, $index = null)
 {
     if (!$child->canBeAddedToCharClass()) {
         throw new \REBuilder\Exception\Generic($this->_getClassName($child) . " cannot be added to character classes");
     }
     return parent::addChildAt($child, $index);
 }