Пример #1
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));
 }
Пример #2
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;
 }
Пример #3
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);
 }
Пример #4
0
 /**
  * @param ParserState $state
  * @return ParseResult
  */
 public function parse(ParserState $state)
 {
     return new ParseResult(new ParserState(array_slice($state->getCharacters(), 1), $state->getBraceCount()), null);
 }
Пример #5
0
 /**
  * @param ParserState $state
  * @return bool
  */
 private function canStartGatheringValue(ParserState $state)
 {
     return !in_array($state->getHeadCharacter(), $this->illegalCharacters);
 }