Esempio n. 1
0
 /**
  * ArrayEntry ::= Value | KeyValuePair
  * KeyValuePair ::= Key "=" PlainValue
  * Key ::= string | integer
  *
  * @return array
  */
 private function ArrayEntry()
 {
     $peek = $this->lexer->glimpse();
     if (DocLexer::T_EQUALS === $peek['type']) {
         $this->match($this->lexer->isNextToken(DocLexer::T_INTEGER) ? DocLexer::T_INTEGER : DocLexer::T_STRING);
         $key = $this->lexer->token['value'];
         $this->match(DocLexer::T_EQUALS);
         return array($key, $this->PlainValue());
     }
     return array(null, $this->Value());
 }
Esempio n. 2
0
 /**
  * ArrayEntry ::= Value | KeyValuePair
  * KeyValuePair ::= Key ("=" | ":") PlainValue | Constant
  * Key ::= string | integer | Constant
  *
  * @return array
  */
 private function ArrayEntry()
 {
     $peek = $this->lexer->glimpse();
     if (DocLexer::T_EQUALS === $peek['type'] || DocLexer::T_COLON === $peek['type']) {
         if ($this->lexer->isNextToken(DocLexer::T_IDENTIFIER)) {
             $key = $this->Constant();
         } else {
             $this->matchAny(array(DocLexer::T_INTEGER, DocLexer::T_STRING));
             $key = $this->lexer->token['value'];
         }
         $this->matchAny(array(DocLexer::T_EQUALS, DocLexer::T_COLON));
         return array($key, $this->PlainValue());
     }
     return array(null, $this->Value());
 }
Esempio n. 3
0
 /**
  * Array ::= "{" ArrayEntry {"," ArrayEntry}* [","] "}"
  *
  * @return array
  */
 private function Arrayx()
 {
     $array = $values = array();
     $this->match(DocLexer::T_OPEN_CURLY_BRACES);
     $values[] = $this->ArrayEntry();
     while ($this->lexer->isNextToken(DocLexer::T_COMMA)) {
         $this->match(DocLexer::T_COMMA);
         // optional trailing comma
         if ($this->lexer->isNextToken(DocLexer::T_CLOSE_CURLY_BRACES)) {
             break;
         }
         $values[] = $this->ArrayEntry();
     }
     $this->match(DocLexer::T_CLOSE_CURLY_BRACES);
     foreach ($values as $value) {
         list($key, $val) = $value;
         if ($key !== null) {
             $array[$key] = $val;
         } else {
             $array[] = $val;
         }
     }
     return $array;
 }