You've already forked MyDSL
优化下一行移动逻辑
This commit is contained in:
@ -19,9 +19,9 @@ abstract class ReaderInterface
|
||||
{
|
||||
protected $currentLine = 1;
|
||||
protected $currentPosition = 0;
|
||||
protected $currentLinePosition = 0;
|
||||
protected $nextPosition = 0;
|
||||
protected $currentToken = "";
|
||||
protected $currentLineDelta = 0;
|
||||
|
||||
/**
|
||||
* 获取下一个字符
|
||||
@ -73,6 +73,7 @@ abstract class ReaderInterface
|
||||
{
|
||||
$this->currentLine = 1;
|
||||
$this->currentPosition = 0;
|
||||
$this->currentLineDelta = 0;
|
||||
$this->nextPosition = 0;
|
||||
$this->moveToNextToken();
|
||||
}
|
||||
@ -104,7 +105,7 @@ abstract class ReaderInterface
|
||||
|
||||
public function getCurrentLinePosition(): int
|
||||
{
|
||||
return $this->currentLinePosition;
|
||||
return $this->currentPosition - $this->currentLineDelta;
|
||||
}
|
||||
|
||||
public function getCurrentToken(): string
|
||||
@ -115,13 +116,12 @@ abstract class ReaderInterface
|
||||
protected function moveCursorToNextChar(): void
|
||||
{
|
||||
$this->currentPosition++;
|
||||
$this->currentLinePosition++;
|
||||
}
|
||||
|
||||
protected function moveCursorToNextLine(int $chars = 1): void
|
||||
{
|
||||
$this->currentPosition += $chars;
|
||||
$this->currentLinePosition = 0;
|
||||
$this->currentLineDelta = $this->currentPosition;
|
||||
$this->currentLine++;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user