Hoa central
Public Member Functions | Protected Attributes | List of all members
Hoa\Compiler\Llk\TreeNode Class Reference
Inheritance diagram for Hoa\Compiler\Llk\TreeNode:

Public Member Functions

 __construct ($id, $value=null, Array $children=[], TreeNode $parent=null)
 
 setId ($id)
 
 getId ()
 
 setValue ($value)
 
 getValue ()
 
 getValueToken ()
 
 getValueValue ()
 
 isToken ()
 
 prependChild (TreeNode $child)
 
 appendChild (TreeNode $child)
 
 setChildren (Array $children)
 
 getChild ($i)
 
 getChildren ()
 
 getChildrenNumber ()
 
 childExists ($i)
 
 setParent (TreeNode $parent)
 
 getParent ()
 
getData ()
 
 accept (Visitor\Visit $visitor, &$handle=null, $eldnah=null)
 
 __destruct ()
 
- Public Member Functions inherited from Hoa\Visitor\Element
 accept (Visit $visitor, &$handle=null, $eldnah=null)
 

Protected Attributes

 $_id = null
 
 $_value = null
 
 $_children = null
 
 $_parent = null
 
 $_data = []
 

Detailed Description

Class .

Provide a generic node for the AST produced by LL(k) parser.

Definition at line 49 of file TreeNode.php.

Constructor & Destructor Documentation

Hoa\Compiler\Llk\TreeNode::__construct (   $id,
  $value = null,
Array  $children = [],
TreeNode  $parent = null 
)

Constructor.

Parameters
string$idID.
string$valueValue.
array$childrenChildren.
\Hoa\Compiler\Llk\TreeNode$parentParent.
Returns
void

Definition at line 97 of file TreeNode.php.

102  {
103  $this->setId($id);
104  $this->setValue($value);
105  $this->setChildren($children);
106 
107  if (null !== $parent) {
108  $this->setParent($parent);
109  }
110 
111  return;
112  }
setChildren(Array $children)
Definition: TreeNode.php:223
setParent(TreeNode $parent)
Definition: TreeNode.php:278

Here is the call graph for this function:

Hoa\Compiler\Llk\TreeNode::__destruct ( )

Remove circular reference to the parent (help the garbage collector).

Returns
void

Definition at line 327 of file TreeNode.php.

328  {
329  unset($this->_parent);
330 
331  return;
332  }

Member Function Documentation

Hoa\Compiler\Llk\TreeNode::accept ( Visitor\Visit  $visitor,
$handle = null,
  $eldnah = null 
)

Accept a visitor.

Parameters
\Hoa\Visitor\Visit$visitorVisitor.
mixed&$handleHandle (reference).
mixed$eldnahHandle (no reference).
Returns
mixed

Definition at line 314 of file TreeNode.php.

318  {
319  return $visitor->visit($this, $handle, $eldnah);
320  }
Hoa\Compiler\Llk\TreeNode::appendChild ( TreeNode  $child)

Append a child.

Parameters
\Hoa\Compiler\Llk\TreeNode$childChild.
Returns

Definition at line 211 of file TreeNode.php.

212  {
213  $this->_children[] = $child;
214 
215  return $this;
216  }

Here is the caller graph for this function:

Hoa\Compiler\Llk\TreeNode::childExists (   $i)

Check if a child exists.

Returns
bool

Definition at line 267 of file TreeNode.php.

268  {
269  return array_key_exists($i, $this->_children);
270  }
Hoa\Compiler\Llk\TreeNode::getChild (   $i)

Get child.

Parameters
int$iIndex.
Returns

Definition at line 237 of file TreeNode.php.

238  {
239  return $this->_children[$i];
240  }
Hoa\Compiler\Llk\TreeNode::getChildren ( )

Get children.

Returns
array

Definition at line 247 of file TreeNode.php.

248  {
249  return $this->_children;
250  }

Here is the caller graph for this function:

Hoa\Compiler\Llk\TreeNode::getChildrenNumber ( )

Get number of children.

Returns
int

Definition at line 257 of file TreeNode.php.

258  {
259  return count($this->_children);
260  }
& Hoa\Compiler\Llk\TreeNode::getData ( )

Get data.

Returns
array

Definition at line 301 of file TreeNode.php.

302  {
303  return $this->_data;
304  }
Hoa\Compiler\Llk\TreeNode::getId ( )

Get ID.

Returns
string

Definition at line 133 of file TreeNode.php.

134  {
135  return $this->_id;
136  }

Here is the caller graph for this function:

Hoa\Compiler\Llk\TreeNode::getParent ( )

Get parent.

Returns

Definition at line 291 of file TreeNode.php.

292  {
293  return $this->_parent;
294  }
Hoa\Compiler\Llk\TreeNode::getValue ( )

Get value.

Returns
array

Definition at line 157 of file TreeNode.php.

158  {
159  return $this->_value;
160  }
Hoa\Compiler\Llk\TreeNode::getValueToken ( )

Get value token.

Returns
string

Definition at line 167 of file TreeNode.php.

168  {
169  return $this->_value['token'];
170  }
Hoa\Compiler\Llk\TreeNode::getValueValue ( )

Get value value.

Returns
string

Definition at line 177 of file TreeNode.php.

178  {
179  return $this->_value['value'];
180  }
Hoa\Compiler\Llk\TreeNode::isToken ( )

Check if the node represents a token or not.

Returns
bool

Definition at line 187 of file TreeNode.php.

188  {
189  return null !== $this->_value;
190  }
Hoa\Compiler\Llk\TreeNode::prependChild ( TreeNode  $child)

Prepend a child.

Parameters
\Hoa\Compiler\Llk\TreeNode$childChild.
Returns

Definition at line 198 of file TreeNode.php.

199  {
200  array_unshift($this->_children, $child);
201 
202  return $this;
203  }
Hoa\Compiler\Llk\TreeNode::setChildren ( Array  $children)

Set children.

Returns
array

Definition at line 223 of file TreeNode.php.

224  {
225  $old = $this->_children;
226  $this->_children = $children;
227 
228  return $old;
229  }

Here is the caller graph for this function:

Hoa\Compiler\Llk\TreeNode::setId (   $id)

Set ID.

Parameters
string$idID.
Returns
string

Definition at line 120 of file TreeNode.php.

121  {
122  $old = $this->_id;
123  $this->_id = $id;
124 
125  return $old;
126  }

Here is the caller graph for this function:

Hoa\Compiler\Llk\TreeNode::setParent ( TreeNode  $parent)

Set parent.

Parameters
\Hoa\Compiler\Llk\TreeNode$parentParent.
Returns

Definition at line 278 of file TreeNode.php.

279  {
280  $old = $this->_parent;
281  $this->_parent = $parent;
282 
283  return $old;
284  }

Here is the caller graph for this function:

Hoa\Compiler\Llk\TreeNode::setValue (   $value)

Set value.

Parameters
array$valueValue (token & value).
Returns
array

Definition at line 144 of file TreeNode.php.

145  {
146  $old = $this->_value;
147  $this->_value = $value;
148 
149  return $old;
150  }

Here is the caller graph for this function:

Member Data Documentation

Hoa\Compiler\Llk\TreeNode::$_children = null
protected

Definition at line 70 of file TreeNode.php.

Hoa\Compiler\Llk\TreeNode::$_data = []
protected

Definition at line 84 of file TreeNode.php.

Hoa\Compiler\Llk\TreeNode::$_id = null
protected

Definition at line 56 of file TreeNode.php.

Hoa\Compiler\Llk\TreeNode::$_parent = null
protected

Definition at line 77 of file TreeNode.php.

Hoa\Compiler\Llk\TreeNode::$_value = null
protected

Definition at line 63 of file TreeNode.php.


The documentation for this class was generated from the following file: