Joey Mazzarelli avatar Joey Mazzarelli committed d035aff

code documentation

Comments (0)

Files changed (25)

src/php/Trekel/Evaluator.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
-
+/**
+ * Evaluate a Trekel parse tree for a given root node
+ *
+ * @package Trekel
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Evaluator {
 
+  /**
+   * Set the parse tree to evaluate
+   * @param Trekel_Node $tree Tree to use
+   * @return void
+   */
   public function setParseTree ($tree) {
     $this->tree = $tree;
   }
 
+  /**
+   * Set the object on which to evaluate the parse tree
+   * @param object $root Root of data tree
+   * @return void
+   */
   public function setRootNode ($root) {
     $this->root = new Trekel_Root($root);
   }
 
+  /**
+   * Kick off the evaluation of the parse tree for the given input
+   * @return Trekel_List
+   */
   public function evaluate () {
     return $this->reduce();
   }
 
+  /**
+   * Actually perform the evaluation
+   * @return Trekel_List
+   */
   private function reduce () {
     $matches = new Trekel_List();
     $matches->append($this->root);

src/php/Trekel/List.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Ordered set
+ *
+ * @package Trekel
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_List extends Trekel_Set implements IteratorAggregate {
 
+  /**
+   * @var array
+   */
   private $list = array();
+
+  /**
+   * @var int
+   */
   private $idx = 0;
 
-  public function append ($node) {
-    if ($node && !$this->has($node)) {
-      $this->add($node);
-      $this->list[] = $node;
+  /**
+   * Append an item to the list
+   * @param mixed $item Item to append
+   * @return void
+   */
+  public function append ($item) {
+    if ($item && !$this->has($item)) {
+      $this->add($item);
+      $this->list[] = $item;
     }
   }
 
-  public function appendAll ($nodes) {
-    foreach ($nodes as $node) {
-      $this->append($node);
+  /**
+   * Append the items to the list
+   * @param array $items Items to append
+   * @return void
+   */
+  public function appendAll ($items) {
+    foreach ($items as $item) {
+      $this->append($item);
     }
   }
 
+  /**
+   * Get the iterator
+   * @return ArrayIterator
+   */
   public function getIterator () {
     return new ArrayIterator($this->getItems());
   }
 
+  /**
+   * Get all items
+   * @return array
+   */
   public function getItems () {
     return $this->list;
   }
 
+  /**
+   * Get the next item in the list
+   * @return mixed Next item or null
+   */
   public function next () {
     if (isset($this->list[$this->idx])) {
       return $this->list[$this->idx++];

src/php/Trekel/Node.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Abstract node in the trekel parse tree
+ *
+ * The term "tree" is used loosely here. The grammar is constructed
+ * such that the tree will only ever be a list. So only one child will
+ * ever exist for a given node.
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 abstract class Trekel_Node {
 
+  /**
+   * Reduce a node
+   * @param object $node Node of tree to evaluate
+   * @param int $idx Index of node in matched results
+   * @param int $total Total number of matched results
+   * @return Trekel_List
+   */
+  abstract public function reduce ($node, $idx, $total);
 
+  /**
+   * A node only has one child.
+   * @var Trekel_Node
+   */
   protected $child = null;
+
+  /**
+   * The identifier of this node, the meaning of which may be context sensitive.
+   * @var string
+   */
   protected $identifier = null;
+
+  /**
+   * The selector of this node, the meaning of which may be context sensitive.
+   * @var string
+   */
   protected $selector = null;
 
+  /**
+   * Set the selector
+   * @param string $selector Selector for this node
+   * @return void
+   */
   public function setSelector ($selector) {
     $this->selector = $selector;
   }
 
+  /**
+   * Get the selector
+   * @return string
+   */
   public function getSelector () {
     return $this->selector;
   }
 
+  /**
+   * Set the identifier
+   * @param string $identifier Identifier for this node
+   * @return void
+   */
   public function setIdentifier ($id) {
     $this->setSelector($id);
     $this->identifier = $id;
   }
 
+  /**
+   * Get the identifier
+   * @return string
+   */
   public function getIdentifier () {
     return $this->identifier;
   }
 
+  /**
+   * Set the child
+   * @param Trekel_Node $node Node to use as child
+   * @return void
+   */
   public function setChild ($node) {
     $this->child = $node;
   }
 
+  /**
+   * Push a child to the bottom of the tree
+   * @param Trekel_Node $node Node to push onto tree
+   * @return void
+   */
   public function pushChild ($node) {
     if ($this->child) {
       $this->child->pushChild($node);
     }
   }
 
+  /**
+   * Get the child
+   * @return Trekel_Node
+   */
   public function getChild () {
     return $this->child;
   }
 
-  public function next () {
-    return $this->getChild();
-  }
-
-  abstract public function reduce ($node, $idx, $total);
-
+  /**
+   * List of matching nodes
+   * @var Trekel_List
+   */
   private $matches = null;
 
+  /**
+   * Get ready to collect matches
+   * @return void
+   */
   protected function initMatches () {
     $this->matches = new Trekel_List();
   }
 
+  /**
+   * Match based on type
+   * @param object $node Node to match
+   * @return void
+   */
   protected function matchType ($node) {
     $type = $this->getIdentifier();
     if ('*' == $type || $node instanceof $type) {
     }
   }
 
+  /**
+   * Unconditionally match a node
+   * @param object $node Node to add as a match
+   * @return void
+   */
   protected function matchNode ($node) {
     $this->matches->append($node);
   }
 
+  /**
+   * Match a node when values are equal
+   * @param mixed $actual Actual value to match
+   * @param mixed $expected Expected value to match against
+   * @param object $node Node to match upon value equality
+   * @return Trekel_List
+   */
+  protected function matchValue ($actual, $expected, $node) {
+    $this->initMatches();
+    if ($actual === $expected) {
+      $this->matchNode($node);
+    }
+    return $this->getMatches();
+  }
+
+  /**
+   * Get the list of matches
+   * @return Trekel_List
+   */
   protected function getMatches () {
     return $this->matches;
   }
 
-  protected function getParent ($node) {
-    return $node->getParent();
-  }
-
-
+  /**
+   * Queue used for state
+   * @var Trekel_List
+   */
   private $queue;
 
+  /**
+   * Start the queue with a give node or nodes
+   * @param array|object $node Node to initialize with
+   * @return void
+   */
   protected function initQueue ($node) {
     $this->queue = new Trekel_List();
     $this->enqueue($node);
   }
 
+  /**
+   * Enqueue a node or nodes
+   * @param array|object $node Node to enqueue
+   * @return void
+   */
   protected function enqueue ($node) {
     if (is_array($node)) {
       $this->queue->appendAll($node);
     }
   }
 
+  /**
+   * Dequeue a node
+   * @return object
+   */
   protected function dequeue () {
     return $this->queue->next();
   }
 
 } // end Trekel_Node
-

src/php/Trekel/Node/Attribute.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Abstract attribute node
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 abstract class Trekel_Node_Attribute extends Trekel_Node {
 
+  /**
+   * @var string
+   */
   protected $attributeValue = null;
+
+  /**
+   * @var string
+   */
   protected $attributeId = null;
 
+  /**
+   * Get the value to match against
+   * @return string
+   */
   public function getValue () {
     return $this->attributeValue;
   }
 
+  /**
+   * Set the value to match against
+   * @param string $value Value to match against
+   * @return void
+   */
   public function setValue ($value) {
     $this->attributeValue = $value;
   }
 
+  /**
+   * Set the attribute id
+   * @param string $id Id to use
+   * @return void
+   */
   public function setIdentifier ($id) {
     $this->attributeId = $id;
   }
 
+  /**
+   * Get the attribute id
+   * @return string
+   */
   public function getIdentifier () {
     return $this->attributeId;
   }
 
+  /**
+   * Get the data from a node
+   * @param object $node Node from which to get the attribute data
+   * @return string
+   */
   protected function getData ($node) {
     if (substr($this->attributeId, -2) == "()") {
       $method = substr($this->attributeId, 0, -2);
     }
   }
 
-}
+} // end Trekel_Node_Attribute

src/php/Trekel/Node/Attribute/Contains.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Contains attribute
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Node_Attribute_Contains extends Trekel_Node_Attribute {
 
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     $this->initMatches();
     $data = $this->getData($node);

src/php/Trekel/Node/Attribute/EndsWith.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Ends with attribute
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Node_Attribute_EndsWith extends Trekel_Node_Attribute {
 
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     $this->initMatches();
     $data = $this->getData($node);

src/php/Trekel/Node/Attribute/Equals.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Equals attribute
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Node_Attribute_Equals extends Trekel_Node_Attribute {
+
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     $this->initMatches();
     $data = $this->getData($node);

src/php/Trekel/Node/Attribute/Exists.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Exists attribute
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Node_Attribute_Exists extends Trekel_Node_Attribute {
+
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     $this->initMatches();
     $data = $this->getData($node);

src/php/Trekel/Node/Attribute/NotEquals.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Not equals attribute
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Node_Attribute_NotEquals extends Trekel_Node_Attribute {
+
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     $this->initMatches();
     $data = $this->getData($node);

src/php/Trekel/Node/Attribute/Regex.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Regex attribute
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Node_Attribute_Regex extends Trekel_Node_Attribute {
 
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     $this->initMatches();
     $data = $this->getData($node);

src/php/Trekel/Node/Attribute/StartsWith.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Starts with attribute
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Node_Attribute_StartsWith extends Trekel_Node_Attribute {
+
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     $this->initMatches();
     $data = $this->getData($node);
 
     return $this->getMatches();
   }
+
 }// end Trekel_Node_Attribute_StartsWith

src/php/Trekel/Node/Pseudo.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Psuedo node
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 abstract class Trekel_Node_Pseudo extends Trekel_Node {
 
+  /**
+   * Build a pseudo object based on the type requested
+   * @param string $type Type of node to build
+   * @param string $data Data to pass to constructor
+   * @return Trekel_Node_Pseudo
+   */
   static public function create ($type, $data = '') {
     $type = ucfirst($type);
     $class = "Trekel_Node_Pseudo_{$type}";
     }
   }
 
-  protected function matchValue ($actual, $expected, $node) {
-    $this->initMatches();
-    if ($actual === $expected) {
-      $this->matchNode($node);
-    }
-    return $this->getMatches();
-  }
-
 } // end Trekel_Node_Pseudo

src/php/Trekel/Node/Pseudo/Even.php

+<?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
-<?php
+/**
+ * Finds the even matches
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
+class Trekel_Node_Pseudo_Even extends Trekel_Node_Pseudo {
 
-class Trekel_Node_Pseudo_Even extends Trekel_Node_Pseudo {
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     return $this->matchValue(!($idx%2), false, $node);
   }
-}
+
+} // end Trekel_Node_Pseudo_Even

src/php/Trekel/Node/Pseudo/First.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Finds the first match
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Node_Pseudo_First extends Trekel_Node_Pseudo {
+
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     return $this->matchValue($idx, 0, $node);
   }
-}
+
+} // end Trekel_Node_Pseudo_First

src/php/Trekel/Node/Pseudo/Last.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Finds the last match
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Node_Pseudo_Last extends Trekel_Node_Pseudo {
+
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     return $this->matchValue($idx, $total-1, $node);
   }
-}
+
+} // end Trekel_Node_Pseudo_Last

src/php/Trekel/Node/Pseudo/Odd.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Finds the odd matches
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Node_Pseudo_Odd extends Trekel_Node_Pseudo {
+
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     return $this->matchValue(!($idx%2), true, $node);
   }
-}
+
+} // end Trekel_Node_Pseudo_Odd

src/php/Trekel/Node/Selector.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
-abstract class Trekel_Node_Selector extends Trekel_Node { }
+/**
+ * Selector node
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
+abstract class Trekel_Node_Selector extends Trekel_Node {
+} // end Trekel_Node_Selector

src/php/Trekel/Node/Selector/Adjacent.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
 /**
+ * Adjacent selector
+ *
  * Adjacent means "directly after the specified sibling
- * 
+ *
  * <div><a /><b /><i /></div>
  *
  * a + b  // matches one (b)
  * b + a  // matches none
  * b + i  // matches one (i)
  * * + *  // matches two (b, i)
+ *
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
  */
 class Trekel_Node_Selector_Adjacent extends Trekel_Node_Selector {
 
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     $this->initMatches();
     if ($parent = $node->getParent()) {

src/php/Trekel/Node/Selector/Child.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Child selector
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Node_Selector_Child extends Trekel_Node_Selector {
 
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     //echo "reducing: " . get_class($node) . "\n";
     //echo "ident: " . $this->getIdentifier() . "\n";
     return $this->getMatches();
   }
 
-}
+} // end Trekel_Node_Selector_Child

src/php/Trekel/Node/Selector/Descendant.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Descendant selector
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Node_Selector_Descendant extends Trekel_Node_Selector {
 
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     $this->initMatches();
     $this->initQueue($node->getChildren());

src/php/Trekel/Node/Selector/Sibling.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Sibling selector
+ *
+ * @package Trekel
+ * @subpackage Trekel_Node
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Node_Selector_Sibling extends Trekel_Node_Selector {
 
+  /**
+   * @inheritdoc
+   */
   public function reduce ($node, $idx, $total) {
     $this->initMatches();
     if ($parent = $node->getParent()) {

src/php/Trekel/ParseException.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
-class Trekel_ParseException extends Exception { }
+/**
+ * Parse Exception
+ *
+ * @package Trekel
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
+class Trekel_ParseException extends Exception {
+} // end Trekel_ParseException

src/php/Trekel/Root.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
+
+/**
+ * A placeholder object for the data to evaluate.
+ *
+ * This object is created when data is about to be evaluated against the
+ * parse tree. It provides a way to bootstrap the evaulation. It will never
+ * be a part of the matching data. It does not set the parent nodes of
+ * its children to itself, so it will never be visited either after
+ * the initial bootstrap.
+ *
+ * @package Trekel
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Root {
-  public function __construct ($root) {
-    $this->root = $root;
+
+  /**
+   * @var mixed
+   */
+  private $data;
+
+  /**
+   * Constructor
+   * @param mixed $data Data to bootstrap
+   */
+  public function __construct ($data) {
+    $this->data = $data;
   }
+
+  /**
+   * Get the children
+   * @return array
+   */
   public function getChildren () {
-    return array($this->root);
+    return (is_array($this->data))? $this->data: array($this->data);
   }
-}
+
+} // end Trekel_Root

src/php/Trekel/Set.php

 <?php
+/**
+ * Copyright 2010 Joey Mazzarelli. All rights reserved.
+ *
+ * Redistribution and use in source, with or without modification, is
+ * permitted provided that the following condition is met:
+ *
+ *    1. Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOEY MAZZARELLI ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JOEY MAZZARELLI OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Joey Mazzarelli.
+ */
 
+/**
+ * Unordered set
+ *
+ * @package Trekel
+ * @author Joey Mazzarelli <joey@mazzarelli.com>
+ * @copyright 2011 Joey Mazzarelli
+ */
 class Trekel_Set implements IteratorAggregate, Countable {
 
+  /**
+   * @var array
+   */
   private $set = array();
+
+  /**
+   * @var string
+   */
   private $salt;
 
+  /**
+   * Constructor
+   */
   public function __construct () {
     $this->salt = __CLASS__ . spl_object_hash($this);
   }
 
+  /**
+   * See if the set contains an item
+   * @return bool
+   */
   public function has ($item) {
     return isset($this->set[$this->id($item)]);
   }
 
+  /**
+   * Add an item to the set
+   * @param mixed $item Item to add
+   * @return void
+   */
   public function add ($item) {
     $this->set[$this->id($item)] = $item;
   }
 
+  /**
+   * Remove an item from the set
+   * @param mixed $item Item to remove
+   * @return void
+   */
   public function remove ($item) {
     unset($this->set[$this->id($item)]);
   }
 
+  /**
+   * Generate an id for an item
+   * @param mixed $item Item for which to generate an id
+   * @return string
+   */
   private function id ($item) {
     if (is_scalar($item)) {
       return "{$this->salt}{$item}";
     }
   }
 
+  /**
+   * Get the iterator
+   * @return ArrayIterator
+   */
   public function getIterator () {
     return new ArrayIterator($this->set);
   }
 
+  /**
+   * Count the items in the set
+   * @return int
+   */
   public function count () {
     return count($this->set);
   }

src/test/php/Trekel/PseudoTest.php

     $nodes = $evaluator->evaluate();
     $this->assertEquals(1, count($nodes));
     $this->assertEquals("Trekel_PseudoTest_C2a", get_class($nodes[0]));
+
+    // Get C2a
+    $parser = new Trekel_Parser();
+    $parser->setSelector('*:odd:last');
+    $parseTree = $parser->parse();
+
+    $evaluator = new Trekel_Evaluator();
+    $evaluator->setParseTree($parseTree);
+    $evaluator->setRootNode($a);
+
+    $nodes = $evaluator->evaluate();
+    $this->assertEquals(1, count($nodes));
+    $this->assertEquals("Trekel_PseudoTest_C2a", get_class($nodes[0]));
   }
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.