Esempio n. 1
0
 /**
  * Read a language string from the file.
  *
  * @return void
  */
 private function readLangString()
 {
     while (!$this->tokenIs(';')) {
         $this->getNextToken();
         if ($this->tokenIs('[')) {
             $this->subParserSquareBracket();
             continue;
         }
         if ($this->tokenIs('=')) {
             // right hand of the assignment.
             $this->getNextToken();
             if ($this->tokenIs(T_ARRAY) || $this->tokenIs('[')) {
                 $arrayParser = new ArrayParser($this, 1);
                 $arrayParser->parse();
                 $this->debug('After array. ' . var_export($this->getToken(), true));
             } else {
                 $subparser = new StringValue($this);
                 $subparser->parse();
                 $this->file->setValue(implode('.', $this->keystack), $subparser->getValue());
             }
             continue;
         }
         if (!$this->tokenIs(']')) {
             $this->bailUnexpectedToken();
         }
     }
     if ($this->tokenIs(';')) {
         // Reset stack.
         $this->resetStack();
     }
 }
 /**
  * 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());
     }
 }