基础内容

This commit is contained in:
Jerry Yan 2020-12-17 16:13:32 +08:00
parent 31009d24c6
commit 9484b3c098
21 changed files with 343 additions and 1 deletions

12
README.md Normal file
View File

@ -0,0 +1,12 @@
# Jerry-DSL
一个
## src目录解析
- `Grammar` 语法解析器,验证语法及拆分语法
- `Output` 输出器,将解析的内容输出(并不执行)
- `Parser` 解析器,使用`Grammar`将内容解析成`Tokenizer`用的东西
- `Reader` 读取器,供`Tokenizer`读取使用
- `Token` 所有的Token
- `Tokenizer` Token生成器生成Token用的

View File

@ -1,7 +1,8 @@
{
"name": "q792602257/jerry_dsl",
"name": "jerryyan/dsl",
"description": "My DSL Thing",
"license": "GPL-3.0-or-later",
"type": "library",
"authors": [
{
"name": "q792602257",
@ -9,5 +10,12 @@
}
],
"require": {
"php": ">=7.1",
"ext-mbstring": "*"
},
"autoload": {
"psr-4": {
"JerryYan\\DSL\\": "src"
}
}
}

15
src/Grammar/Grammar.php Normal file
View File

@ -0,0 +1,15 @@
<?php
/**
* @filename Grammar.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 14:13
*/
namespace JerryYan\DSL\Grammar;
class Grammar extends GrammarInterface
{
}

View File

@ -0,0 +1,15 @@
<?php
/**
* @filename GrammarInterface.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 14:11
*/
namespace JerryYan\DSL\Grammar;
abstract class GrammarInterface
{
}

View File

@ -0,0 +1,21 @@
<?php
/**
* @filename CnTextOutput.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:33
*/
namespace JerryYan\DSL\Output;
/**
* 又以中文形式重新输出一遍
* @package JerryYan\DSL\Output
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 16:12
*/
class CnTextOutput extends OutputInterface
{
}

View File

@ -0,0 +1,15 @@
<?php
/**
* @filename DiagramOutput.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:30
*/
namespace JerryYan\DSL\Output;
class DiagramOutput extends OutputInterface
{
}

15
src/Output/HTMLOutput.php Normal file
View File

@ -0,0 +1,15 @@
<?php
/**
* @filename HTMLOutput.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:09
*/
namespace JerryYan\DSL\Output;
class HTMLOutput extends OutputInterface
{
}

View File

@ -0,0 +1,15 @@
<?php
/**
* @filename OutputInterface.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:08
*/
namespace JerryYan\DSL\Output;
abstract class OutputInterface
{
}

15
src/Parser/Parser.php Normal file
View File

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

View File

@ -0,0 +1,15 @@
<?php
/**
* @filename ParserInterface.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:35
*/
namespace JerryYan\DSL\Parser;
abstract class ParserInterface
{
}

15
src/Reader/FileReader.php Normal file
View File

@ -0,0 +1,15 @@
<?php
/**
* @filename FileReader.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 14:58
*/
namespace JerryYan\DSL\Reader;
class FileReader extends ReaderInterface
{
}

View File

@ -0,0 +1,44 @@
<?php
/**
* @filename ReaderInterface.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 14:58
*/
namespace JerryYan\DSL\Reader;
/**
* 解析器需要使用到的读取类
* @package JerryYan\DSL\Reader
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:37
*/
abstract class ReaderInterface
{
protected $currentLine = 0;
protected $currentPosition = 0;
protected $currentLinePosition = 0;
#abstract public function getNextChar(): ?string;
#abstract public function getCurrentToken(): ?string;
#abstract public function getNextToken(): ?string;
#abstract public function moveToNextToken(): ?string;
/**
* 跳过当前行
* @return bool
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:43
*/
#abstract public function skipCurrentLine(): bool;
/**
* 从当前位置跳到结束位置
* @param string $end
* @return bool
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:43
*/
#abstract public function skipUntil(string $end="*/"): bool;
}

View File

@ -0,0 +1,15 @@
<?php
/**
* @filename StreamReader.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 14:58
*/
namespace JerryYan\DSL\Reader;
class StreamReader extends ReaderInterface
{
}

22
src/Token/Token.php Normal file
View File

@ -0,0 +1,22 @@
<?php
/**
* @filename Token.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 14:51
*/
namespace JerryYan\DSL\Token;
/**
* Token实体分类Enum
* @package JerryYan\DSL\Token
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:11
*/
final class Token
{
const AND = "And";
const OR = "Or";
}

15
src/Token/TokenAnd.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 TokenAnd
{
}

View File

@ -0,0 +1,19 @@
<?php
/**
* @filename TokenFactory.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 14:48
*/
namespace JerryYan\DSL\Token;
class TokenFactory
{
/** @var array<string, string> Token类型及映射类 */
#private $tokenMap = [
# Token::AND => TokenAnd::class,
#];
}

View File

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

21
src/Token/TokenType.php Normal file
View File

@ -0,0 +1,21 @@
<?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
{
}

View File

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

View File

@ -0,0 +1,15 @@
<?php
/**
* @filename TokenizerInterface.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:22
*/
namespace JerryYan\DSL\Tokenizer;
abstract class TokenizerInterface
{
}