Exemplo n.º 1
0
 /**
  * Create an array from the token stream which contains only the tokens and the operators/values.
  *
  * @param TokenStream $stream The stream containing the lexer tokens.
  * @return array The actual list with tokens and operators/values.
  */
 private function buildActualTokens(TokenStream $stream)
 {
     $actual = array();
     while ($stream->valid()) {
         /* @var \com\mohiva\pyramid\Token $current */
         $current = $stream->current();
         $stream->next();
         $actual[] = array($current->getCode() => $current->getValue());
     }
     return $actual;
 }
Exemplo n.º 2
0
 /**
  * Test if the `valid` method returns false.
  */
 public function testValidReturnsFalse()
 {
     $list = new SplDoublyLinkedList();
     $list->push($this->getMock('\\com\\mohiva\\common\\parser\\Token'));
     $list->rewind();
     $stream = new TokenStream($list);
     $stream->next();
     $this->assertFalse($stream->valid());
 }