/** * @return Token * @throws ParseException */ protected function readNext() { $this->readWhile([$this, 'isWhitespace']); if ($this->input->eof()) { return null; } $char = $this->input->peek(); if ($this->isComment()) { $this->skipComment(); return $this->readNext(); } if ($char == '"') { return $this->readDoubleQuotedString(); } if ($char == '\'') { return $this->readSingleQuotedString(); } if ($this->isDoubleBracketString()) { return $this->readDoubleBracketString(); } if ($this->isDigit($char)) { return $this->readNumber(); } if ($this->isStartIdentifierCharacter($char)) { return $this->readIdentifier(); } if ($this->isPunctuation($char)) { return $this->readPunctuation(); } $this->input->error('Cannot handle character: ' . $char . ' (ord: ' . ord($char) . ')'); }