mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 08:10:47 +08:00
1. 移除了FlipflopContext,统一流程API
2. Script项目脚本修复了 RawString 原始字符串存在的问题 3. Script使用了ValueNode统一了值类型节点,为后续扩展更多的值类型做准备 4. TypeHelper.ToTypeOfString()方法中添加了部分值类型的"Type[]”与“List<Type>”的显式定义,用于脚本在类型中定义数组成员 5. Script项目脚本默认挂载的json方法拆分为jsonObj(String)与jsonStr(Object)以支持序列化与反序列化 6. 项目保存为dnf项目文件时,将不再保存名称为”Default"并且没有节点的画布,避免重复保存时默认画布增多。
This commit is contained in:
@@ -112,9 +112,9 @@ namespace Serein.Script
|
||||
isAssignment = true;
|
||||
break;
|
||||
}
|
||||
if(peekCount > 19999)
|
||||
if(peekCount > 3999)
|
||||
{
|
||||
throw new Exception("解析异常,peek次数过多,请减少脚本代码");
|
||||
throw new Exception("解析异常,peek次数过多,可能是解析器出了bug");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -122,16 +122,19 @@ namespace Serein.Script
|
||||
#region 生成赋值语句/一般语句的ASTNode
|
||||
if (isAssignment)
|
||||
{
|
||||
|
||||
// 以赋值语句的形式进行处理
|
||||
var assignmentNode = ParseAssignmentNode(); // 解析复制表达式
|
||||
NextToken();// 消耗 ";"
|
||||
//if(_currentToken.Type == TokenType.Semicolon)
|
||||
NextToken();// 消耗 ";"
|
||||
return assignmentNode;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 以一般语句的形式进行处理,可当作表达式进行解析
|
||||
var targetNode = ParserExpression();
|
||||
NextToken();// 消耗 ";"
|
||||
var targetNode = ParserExpression();
|
||||
//if (_currentToken.Type == TokenType.Semicolon)
|
||||
NextToken();// 消耗 ";"
|
||||
return targetNode;
|
||||
}
|
||||
#endregion
|
||||
@@ -308,6 +311,7 @@ namespace Serein.Script
|
||||
}
|
||||
else
|
||||
{
|
||||
var c = _currentToken;
|
||||
// 反转赋值。
|
||||
NextToken(); // 消耗 "=" 并获取赋值语句的右值表达式。
|
||||
ASTNode valueNode = ParserExpression();
|
||||
@@ -515,6 +519,13 @@ namespace Serein.Script
|
||||
fieldTypeName = $"{fieldTypeName}.{_currentToken.Value}"; // 向后扩充
|
||||
continue;
|
||||
}
|
||||
else if (peekToken.Type == TokenType.SquareBracketsLeft)
|
||||
{
|
||||
NextToken(); // 消耗数组类型定义的 "["
|
||||
NextToken(); // 消耗数组类型定义的 "]"
|
||||
fieldTypeName += "[]";
|
||||
continue;
|
||||
}
|
||||
else if (peekToken.Type == TokenType.Identifier)
|
||||
{
|
||||
// 尝试解析变量名称
|
||||
@@ -677,7 +688,7 @@ namespace Serein.Script
|
||||
}
|
||||
else if (_currentToken.Type == TokenType.BraceRight)
|
||||
{
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1009,6 +1020,7 @@ namespace Serein.Script
|
||||
if(peekToken.Type == TokenType.ParenthesisRight // 可能解析完了方法参数
|
||||
|| peekToken.Type == TokenType.Comma // 可能解析完了方法参数
|
||||
|| peekToken.Type == TokenType.Operator // 可能解析完了方法参数
|
||||
|| peekToken.Type == TokenType.BraceRight // 可能解析完了方法参数
|
||||
|| peekToken.Type == TokenType.ParenthesisRight) // 可能解析完了下标索引
|
||||
{
|
||||
return source;
|
||||
@@ -1065,6 +1077,13 @@ namespace Serein.Script
|
||||
NextToken(); // 消耗布尔量
|
||||
return new BooleanNode(value).SetTokenInfo(factorToken);
|
||||
}
|
||||
else if (_currentToken.Type == TokenType.RawString)
|
||||
{
|
||||
var value = _currentToken.Value;
|
||||
NextToken(); // 消耗字符串
|
||||
var node = new RawStringNode(value).SetTokenInfo(factorToken);
|
||||
return node;
|
||||
}
|
||||
else if (_currentToken.Type == TokenType.String)
|
||||
{
|
||||
var value = _currentToken.Value;
|
||||
@@ -1076,7 +1095,8 @@ namespace Serein.Script
|
||||
{
|
||||
var value = _currentToken.Value;
|
||||
NextToken(); ; // 消耗Char
|
||||
return new CharNode(value).SetTokenInfo(factorToken);
|
||||
var @char = char.Parse(value);
|
||||
return new CharNode(@char).SetTokenInfo(factorToken);
|
||||
}
|
||||
else if (_currentToken.Type == TokenType.InterpolatedString)
|
||||
{
|
||||
@@ -1186,4 +1206,6 @@ namespace Serein.Script
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user