variableInformation = $variableInformation; } public function testPos($pos) { throw new Exception(__CLASS__ . " has no positions."); } public function testPosInChildren($pos) { try { $this->getChildByPos($pos); } catch(Exception $e) { return false; } return true; } public function getPos() { return $this->parent->getPos(); } public function getChildByPos($pos) { foreach($this->children as $child) { if($child instanceof VariableIndex && $child->getPos() == $pos) return $child; } throw new Exception("No child with position '$pos' found."); } public function getChildByName($name) { foreach($this->children as $child) { if($child instanceof VariableIndex) return $child->getChildByName($name); elseif($child instanceof VariableValueTree && $child->getName() == $name) return $child; } throw new Exception("No child with name '$name' found."); } public function getName() { if($this->variableInformation instanceof VariableInformationTree) return $this->variableInformation->getName(); } public function testName($name) { $this->variableInformation->getName() == $name; } public function testNameInChildren($name) { try { $this->getChildByName($name); } catch(Exception $e) { return false; } return true; } public function accept(Visitor $visitor, $level = 1) { $visitor->visit($this, $level++); foreach($this->children as $child) { $child->accept($visitor, $level); } $visitor->removeLastVariablePart(); } // end of member function accept } // end of VariableValueTree ?>