Example #1
0
 /**
  * Returns the next token
  *
  * @return \vc\Tokens\Token|NULL Returns NULL if no tokens are left
  */
 public function popToken()
 {
     if (!$this->hasToken()) {
         return NULL;
     }
     $next = $this->inner->popToken();
     // Peek at the next token to see if it is an interrupt
     $peek = $this->inner->peekAtToken();
     if (!$peek || in_array($peek->getType(), $this->until)) {
         $this->active = FALSE;
     }
     return $next;
 }
Example #2
0
 /**
  * Returns the next token
  *
  * @return \vc\Tokens\Token|NULL Returns NULL if no tokens are left
  */
 public function popToken()
 {
     $next = $this->inner->popToken();
     if ($next) {
         $type = $next->getType();
         if ($type == \vc\Tokens\Token::T_DOC_COMMENT) {
             $this->comment = $next->getContent();
         } else {
             if (in_array($type, self::$invalidate)) {
                 $this->comment = NULL;
             }
         }
     }
     return $next;
 }
Example #3
0
 /**
  * Using the given token types as open and close
  *
  * @param \vc\iface\Tokens\Reader $reader
  * @param Integer $open
  * @param Integer $close
  * @return String
  */
 private function parse(\vc\iface\Tokens\Reader $reader, array $open, $close)
 {
     $depth = 0;
     $first = TRUE;
     $content = '';
     while ($depth >= 0 && $reader->hasToken()) {
         $token = $reader->popToken();
         $type = $token->getType();
         if ($first) {
             $first = FALSE;
             if (in_array($type, $open)) {
                 continue;
             }
         }
         if (in_array($type, $open)) {
             $depth++;
         } else {
             if ($type == $close) {
                 $depth--;
             }
         }
         if ($depth >= 0) {
             $content .= $token->getContent();
         }
     }
     return $content;
 }
Example #4
0
 /**
  * @see \vc\iface\Tokens\Search::findSkipping
  */
 public function peekToSkipping(array $types)
 {
     while ($this->reader->hasToken()) {
         $token = $this->reader->peekAtToken();
         $type = $token->getType();
         if (in_array($type, $types)) {
             return $token;
         }
         $this->reader->popToken();
     }
 }
Example #5
0
 /**
  * Reads the path of a namespace
  *
  * @param \vc\iface\Tokens\Reader $reader The token source to pull from
  * @return NULL
  */
 public function parsePath(\vc\iface\Tokens\Reader $reader)
 {
     // Skip past any white space
     while ($reader->hasToken() && $reader->peekAtToken()->is(Token::T_WHITESPACE)) {
         $reader->popToken();
     }
     if (!$reader->hasToken()) {
         throw new \vc\Tokens\Exception\UnexpectedEnd(array(Token::T_STRING, Token::T_NS_SEPARATOR));
     }
     $reader->peekAtToken()->expect(array(Token::T_STRING, Token::T_NS_SEPARATOR));
     $path = array();
     while ($reader->hasToken()) {
         $token = $reader->peekAtToken();
         if ($token->is(array(Token::T_STRING, Token::T_NS_SEPARATOR))) {
             $path[] = $token->getContent();
         } else {
             break;
         }
         $reader->popToken();
     }
     return implode('', $path);
 }
Example #6
0
 /**
  * Returns the next token
  *
  * @return \vc\Tokens\Token|NULL Returns NULL if no tokens are left
  */
 public function popToken()
 {
     $this->peekAtToken();
     return $this->inner->popToken();
 }
Example #7
0
 /**
  * Dumps the remaining contents of this token reader to the output
  *
  * @return NULL
  */
 public function dump()
 {
     while ($this->reader->hasToken()) {
         $this->reader->popToken()->dump();
     }
 }