完善注释,修正获取头尾元素的逻辑
This commit is contained in:
parent
f3b66aeac3
commit
273f6ba2e8
@ -15,8 +15,8 @@ class FileReader extends StringReader
|
||||
{
|
||||
/**
|
||||
* FileReader constructor.
|
||||
* @param string $fileName
|
||||
* @throws FileNotFoundException
|
||||
* @param string $fileName 文件名
|
||||
* @throws FileNotFoundException 文件不存在时报错
|
||||
* @author Jerry Yan <792602257@qq.com>
|
||||
* @date 2021/1/26 13:52
|
||||
*/
|
||||
|
@ -38,19 +38,23 @@ abstract class TokenInterface
|
||||
|
||||
/**
|
||||
* 获取链表第一个元素
|
||||
* @return ?$this
|
||||
* @return $this
|
||||
* @author Jerry Yan <792602257@qq.com>
|
||||
* @date 2021/1/22 10:01
|
||||
*/
|
||||
public function getFirstToken(): ?TokenInterface
|
||||
public function getFirstToken(): TokenInterface
|
||||
{
|
||||
if ($this->hasPrevToken()) return $this->getPrevToken()->getFirstToken();
|
||||
else return $this;
|
||||
return $this->hasPrevToken() ? $this->getPrevToken()->getFirstToken() : $this;
|
||||
}
|
||||
public function getLastToken(): ?TokenInterface
|
||||
/**
|
||||
* 获取链表最后一个元素
|
||||
* @return $this
|
||||
* @author Jerry Yan <792602257@qq.com>
|
||||
* @date 2021/2/19 11:05
|
||||
*/
|
||||
public function getLastToken(): TokenInterface
|
||||
{
|
||||
if ($this->hasNextToken()) return $this->getNextToken()->getLastToken();
|
||||
else return $this;
|
||||
return $this->hasNextToken() ? $this->getNextToken()->getLastToken() : $this;
|
||||
}
|
||||
public function hasPrevToken(): bool
|
||||
{
|
||||
@ -84,4 +88,8 @@ abstract class TokenInterface
|
||||
{
|
||||
return $this->getLength();
|
||||
}
|
||||
public function getRawString(): string
|
||||
{
|
||||
return $this->_raw;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @filename TokenType.php
|
||||
* @author Jerry Yan <792602257@qq.com>
|
||||
* @date 2020/12/17 15:04
|
||||
*/
|
||||
|
||||
|
||||
namespace JerryYan\DSL\Token;
|
||||
|
||||
|
||||
/**
|
||||
* Token分类Enum
|
||||
* @package JerryYan\DSL\Token
|
||||
* @author Jerry Yan <792602257@qq.com>
|
||||
* @date 2020/12/17 15:04
|
||||
*/
|
||||
final class TokenType
|
||||
{
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user