From 273f6ba2e8dc8b31b5cee1828881f4d35b640e76 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Fri, 19 Feb 2021 11:17:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=8E=B7=E5=8F=96=E5=A4=B4=E5=B0=BE=E5=85=83?= =?UTF-8?q?=E7=B4=A0=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Reader/FileReader.php | 4 ++-- src/Token/TokenInterface.php | 22 +++++++++++++++------- src/Token/TokenType.php | 21 --------------------- 3 files changed, 17 insertions(+), 30 deletions(-) delete mode 100644 src/Token/TokenType.php diff --git a/src/Reader/FileReader.php b/src/Reader/FileReader.php index 85bee76..b808a78 100644 --- a/src/Reader/FileReader.php +++ b/src/Reader/FileReader.php @@ -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 */ diff --git a/src/Token/TokenInterface.php b/src/Token/TokenInterface.php index d6667cf..4f361c2 100644 --- a/src/Token/TokenInterface.php +++ b/src/Token/TokenInterface.php @@ -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; + } } \ No newline at end of file diff --git a/src/Token/TokenType.php b/src/Token/TokenType.php deleted file mode 100644 index abea02f..0000000 --- a/src/Token/TokenType.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @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 -{ - -} \ No newline at end of file