StringReader部分

This commit is contained in:
2020-12-18 18:12:47 +08:00
parent 9484b3c098
commit 9a0e925f6e
13 changed files with 338 additions and 28 deletions

View File

@ -9,7 +9,7 @@
namespace JerryYan\DSL\Token;
class TokenAnd
class TokenAnd extends TokenInterface
{
}

View File

@ -12,8 +12,24 @@ namespace JerryYan\DSL\Token;
class TokenFactory
{
/** @var array<string, string> Token类型及映射类 */
#private $tokenMap = [
# Token::AND => TokenAnd::class,
#];
private $tokenMap = [
Token::AND => TokenAnd::class,
Token::OR => TokenOr::class,
];
protected $tokenNameMap = [
];
public function getTokenByName(string $name): TokenInterface
{
if (!isset($this->tokenNameMap[$name])) {
return new TokenUndefined();
}
$tokenType = $this->tokenNameMap[$name];
if (!isset($this->tokenMap[$tokenType])) {
return new TokenUndefined();
}
return new $this->tokenMap[$tokenType];
}
}

15
src/Token/TokenOr.php Normal file
View File

@ -0,0 +1,15 @@
<?php
/**
* @filename TokenAnd.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:20
*/
namespace JerryYan\DSL\Token;
class TokenOr extends TokenInterface
{
}

View File

@ -0,0 +1,15 @@
<?php
/**
* @filename TokenUndefined.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/18 12:15
*/
namespace JerryYan\DSL\Token;
class TokenUndefined extends TokenInterface
{
}