예제 #1
0
 /**
  * Spawn a sub parser to parse the [] expression.
  *
  * @return void
  */
 private function subParserSquareBracket()
 {
     $this->getNextToken();
     $subparser = new StringValue($this);
     $subparser->parse();
     if ($subparser->getValue() === null) {
         // auto indexed array
         if ($this->tokenIs(']')) {
             $path = implode('.', $this->keystack);
             if (!isset($this->autoIndex[$path])) {
                 $this->autoIndex[$path] = 0;
             } else {
                 $this->autoIndex[$path]++;
             }
             $this->pushStack($this->autoIndex[$path]);
         } else {
             // invalid code?!
             $this->bailUnexpectedToken();
         }
     } else {
         $this->pushStack($subparser->getValue());
     }
 }
예제 #2
0
 /**
  * Parse the value portion of a key => value array element.
  *
  * @return void
  */
 private function parseValue()
 {
     $this->getNextToken();
     if ($this->tokenIs(T_ARRAY) || $this->tokenIs('[')) {
         // Sub array with key.
         $this->debug('Sub array with key.');
         $subparser = new ArrayParser($this->parser, $this->level + 1);
         $subparser->parse();
     } else {
         // String item with key.
         $this->debug('String item with key.');
         $subparser = new StringValue($this->parser, $this->level + 1);
         $subparser->parse();
         $this->parser->setValue($this->parser->getStack(), $subparser->getValue());
     }
 }