예제 #1
0
 private function parseList(TokenStream $tokens)
 {
     $list = new Node\ListNode($tokens->current());
     $tokens->next();
     while ($tokens->valid() && !$tokens->current()->isType(Token::CLOSE_LIST)) {
         $list->add($this->doParse($tokens));
     }
     $tokens->next();
     return $list;
 }
예제 #2
0
 protected function parseDict(TokenStream $stream)
 {
     // expect and discard the openig brace
     $stream->expect(Tokens::T_OPEN_BRACE);
     $stream->next();
     $values = array();
     while ($stream->valid()) {
         $this->consumeWhitespace($stream);
         if ($stream->current()->test(Tokens::T_CLOSE_BRACE)) {
             break;
         }
         $key = $this->parseDictKey($stream);
         $this->consumeWhitespace($stream);
         $stream->expect(Tokens::T_COLON);
         $stream->next();
         $this->consumeWhitespace($stream);
         $values[$key] = $this->parseValue($stream);
         $this->consumeWhitespace($stream);
         $stream->expect(array(Tokens::T_COMMA, Tokens::T_CLOSE_BRACE));
         if ($stream->current()->test(Tokens::T_COMMA)) {
             $stream->next();
         }
     }
     $stream->expect(Tokens::T_CLOSE_BRACE);
     return $values;
 }