예제 #1
0
 /**
  * @param ParserState $state
  * @return ParseResult
  */
 public function parse(ParserState $state)
 {
     $parsingKey = $state->isParsingKey();
     if ($state->getHeadCharacter() === Tokens::NEW_LINE) {
         $parsingKey = true;
     }
     return new ParseResult(new ParserState(array_slice($state->getCharacters(), 1), $state->getBraceCount(), $state->isParsingString(), $parsingKey), null);
 }
예제 #2
0
 /**
  * @param ParserState $state
  * @return ParseResult
  */
 public function parse(ParserState $state)
 {
     $characters = $state->getCharacters();
     $keyName = '';
     while ($this->canParseKey($characters)) {
         $keyName .= array_shift($characters);
     }
     $this->checkForBadlyFormedKey($keyName);
     return new ParseResult(new ParserState($characters, $state->getBraceCount(), false, true), new Key($keyName));
 }
예제 #3
0
 /**
  * @param ParserState $state
  * @return ParseResult
  */
 public function parse(ParserState $state)
 {
     $characters = $state->getCharacters();
     $value = '';
     if (true === ($this->isQuotedString = $this->isQuotedString($state->getHeadCharacter()))) {
         $this->quoteCharacter = array_shift($characters);
     }
     while ($this->canStillParseValue($characters)) {
         $value .= array_shift($characters);
     }
     if (count($characters) && $characters[0] === $this->quoteCharacter) {
         array_shift($characters);
     }
     return new ParseResult(new ParserState($characters, $state->getBraceCount()), $this->getObjectForValue($value));
 }
예제 #4
0
 private function parseState(ParserState $state)
 {
     if (count($state->getCharacters()) === 0) {
         return $state;
     }
     foreach ($this->parserChain as $parser) {
         if ($parser->canParse($state)) {
             $result = $parser->parse($state);
             if (null !== ($element = $result->getElement())) {
                 $this->tokens[] = $result->getElement();
             }
             return $this->parseState($result->getState());
         }
     }
     return $state;
 }
예제 #5
0
 /**
  * @param ParserState $state
  * @return ParseResult
  */
 public function parse(ParserState $state)
 {
     return new ParseResult(new ParserState(array_slice($state->getCharacters(), 1), $state->getBraceCount()), null);
 }