优化光标移动逻辑

This commit is contained in:
2020-12-19 11:41:57 +08:00
parent 93348cffdc
commit f995b932e4
3 changed files with 84 additions and 12 deletions

View File

@ -62,7 +62,7 @@ abstract class ReaderInterface
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:43
*/
abstract public function skipUntil(string $end="*/"): bool;
abstract public function skipUntil(string $end = "*/"): bool;
/**
* 重置读取器
@ -91,12 +91,37 @@ abstract class ReaderInterface
{
return $this->currentPosition;
}
public function getNextPosition(): int
{
return $this->nextPosition;
}
public function getCurrentLine(): int
{
return $this->currentLine;
}
public function getCurrentLinePosition(): int
{
return $this->currentLinePosition;
}
public function getCurrentToken(): string
{
return $this->currentToken;
}
protected function moveCursorToNextChar(): void
{
$this->currentPosition++;
$this->currentLinePosition++;
}
protected function moveCursorToNextLine(int $chars = 1): void
{
$this->currentPosition += $chars;
$this->currentLinePosition = 0;
$this->currentLine++;
}
}