/** * @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); }
/** * @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)); }
/** * @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)); }
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; }
/** * @param ParserState $state * @return ParseResult */ public function parse(ParserState $state) { return new ParseResult(new ParserState(array_slice($state->getCharacters(), 1), $state->getBraceCount()), null); }