tokens = $tokens; $this->index = $index; if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] !== Lexer::TOKEN_HORIZONTAL_WS) { return; } $this->index++; } public function currentTokenValue(): string { return $this->tokens[$this->index][Lexer::VALUE_OFFSET]; } public function currentTokenType(): int { return $this->tokens[$this->index][Lexer::TYPE_OFFSET]; } public function currentTokenOffset(): int { $offset = 0; for ($i = 0; $i < $this->index; $i++) { $offset += strlen($this->tokens[$i][Lexer::VALUE_OFFSET]); } return $offset; } public function isCurrentTokenValue(string $tokenValue): bool { return $this->tokens[$this->index][Lexer::VALUE_OFFSET] === $tokenValue; } public function isCurrentTokenType(int ...$tokenType): bool { return in_array($this->tokens[$this->index][Lexer::TYPE_OFFSET], $tokenType, true); } public function isPrecededByHorizontalWhitespace(): bool { return ($this->tokens[$this->index - 1][Lexer::TYPE_OFFSET] ?? -1) === Lexer::TOKEN_HORIZONTAL_WS; } /** * @throws ParserException */ public function consumeTokenType(int $tokenType): void { if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] !== $tokenType) { $this->throwError($tokenType); } $this->index++; if (($this->tokens[$this->index][Lexer::TYPE_OFFSET] ?? -1) !== Lexer::TOKEN_HORIZONTAL_WS) { return; } $this->index++; } /** * @throws ParserException */ public function consumeTokenValue(int $tokenType, string $tokenValue): void { if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] !== $tokenType || $this->tokens[$this->index][Lexer::VALUE_OFFSET] !== $tokenValue) { $this->throwError($tokenType, $tokenValue); } $this->index++; if (($this->tokens[$this->index][Lexer::TYPE_OFFSET] ?? -1) !== Lexer::TOKEN_HORIZONTAL_WS) { return; } $this->index++; } /** * @phpstan-impure */ public function tryConsumeTokenValue(string $tokenValue): bool { if ($this->tokens[$this->index][Lexer::VALUE_OFFSET] !== $tokenValue) { return false; } $this->index++; if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] === Lexer::TOKEN_HORIZONTAL_WS) { $this->index++; } return true; } /** * @phpstan-impure */ public function tryConsumeTokenType(int $tokenType): bool { if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] !== $tokenType) { return false; } $this->index++; if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] === Lexer::TOKEN_HORIZONTAL_WS) { $this->index++; } return true; } public function getSkippedHorizontalWhiteSpaceIfAny(): string { if ($this->index > 0 && $this->tokens[$this->index - 1][Lexer::TYPE_OFFSET] === Lexer::TOKEN_HORIZONTAL_WS) { return $this->tokens[$this->index - 1][Lexer::VALUE_OFFSET]; } return ''; } /** * @phpstan-impure */ public function joinUntil(int ...$tokenType): string { $s = ''; while (!in_array($this->tokens[$this->index][Lexer::TYPE_OFFSET], $tokenType, true)) { $s .= $this->tokens[$this->index++][Lexer::VALUE_OFFSET]; } return $s; } public function next(): void { $this->index++; if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] !== Lexer::TOKEN_HORIZONTAL_WS) { return; } $this->index++; } /** * @phpstan-impure */ public function forwardToTheEnd(): void { $lastToken = count($this->tokens) - 1; $this->index = $lastToken; } public function pushSavePoint(): void { $this->savePoints[] = $this->index; } public function dropSavePoint(): void { array_pop($this->savePoints); } public function rollback(): void { $index = array_pop($this->savePoints); assert($index !== null); $this->index = $index; } /** * @throws ParserException */ private function throwError(int $expectedTokenType, ?string $expectedTokenValue = null): void { throw new ParserException( $this->currentTokenValue(), $this->currentTokenType(), $this->currentTokenOffset(), $expectedTokenType, $expectedTokenValue ); } } __halt_compiler();----SIGNATURE:----n1KV+oGmF37jRhdUFH2VdqDtBiizfaAdhPiQlZciu2WAY/57gcB/ksc38qKgE0JWiEsWTL7m+iBJHsFh6Ytc/ctTiLRbTB55HnM0D7i6Mx0eWne2ca0NlYdKtvId9HnVKrRHyJaLwmaixp2HAL4litezDg/cdqQalIANO73Q1nZQLIYrrzFazfr8bdMvjzaA2NCwHPKn1LGplyBtKyPEQMrVp72hbFo8XodFXGXuJuOxl8zpo5VPXyfl0060VkMK/2BxY4J6913GoowrKFNemk+ilDJZhlp8iu95uGPHtOc555YQfd3Uk3Z9n1gfAU6ucUWrdFzFravHL0t3oYLDylVvvy2fZazbA6d45g6mNUCjVkOBiLMtbqC7d2a+PL/It1v7n9ma3WqR2belA+0l3spu8udnUrXHZgegaZ4BXYcDiy0spd0QZpGYKBuq0LRauixiAjkeADzgUZlx1btphx3xM16BaVDT1A6/eV5kjo77WIfiaFszumEOAlr112fOukIpRgaS56Dbafm0+zRQuQwsUQhIDQm6pWhV/KbJjxhg/WeWQOOC9hBv0/SLCdVcdCluPfVou2irA03ic7ID0j6xpPtCqe4PxyfpfuHfiqiYgFPniwixRDr/tAO83kMfYWLc1ZyLzo1WqMQrwRJ08bfzai4fP3Iz9ULkqUpqKDA=----ATTACHMENT:----MjAxMTE1NzAyMzk2MTQ5MiAzOTI1MDMxNjYwMDA2MTMgNDU1NTY0MjM3NTc2MDIwNg==