Daily update on 20250323-151439 by Nitload Youmu. Additional Message : none
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Model")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Model")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6788bc4a0065508d7afa5f740da1b4ca6dd1efef")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+528d0c5462b4d3da107ad29b859f9c8006fb675a")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Model")]
|
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Model")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Model")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Model")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/6788bc4a0065508d7afa5f740da1b4ca6dd1efef/*"}}
|
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/528d0c5462b4d3da107ad29b859f9c8006fb675a/*"}}
|
||||||
@@ -103,7 +103,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public override int Count => _collection.Length;
|
public override int Count => _collection.Length;
|
||||||
|
|
||||||
public override string Name => ExpCompile.PoolString( "ARRAY" );
|
public override string Name => ExpressCompile.PoolString( "ARRAY" );
|
||||||
|
|
||||||
public override ExpNode CreateInstanceNode()
|
public override ExpNode CreateInstanceNode()
|
||||||
{
|
{
|
||||||
@@ -128,7 +128,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public override int Count => _collection.Count;
|
public override int Count => _collection.Count;
|
||||||
|
|
||||||
public override string Name => ExpCompile.PoolString( "BAG" );
|
public override string Name => ExpressCompile.PoolString( "BAG" );
|
||||||
|
|
||||||
public override ExpNode CreateInstanceNode()
|
public override ExpNode CreateInstanceNode()
|
||||||
{
|
{
|
||||||
@@ -152,7 +152,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public override int Count => _collection.Count;
|
public override int Count => _collection.Count;
|
||||||
|
|
||||||
public override string Name => ExpCompile.PoolString( "LIST" );
|
public override string Name => ExpressCompile.PoolString( "LIST" );
|
||||||
|
|
||||||
public override ExpNode CreateInstanceNode()
|
public override ExpNode CreateInstanceNode()
|
||||||
{
|
{
|
||||||
@@ -175,7 +175,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public override int Count => _collection.Count;
|
public override int Count => _collection.Count;
|
||||||
|
|
||||||
public override string Name => ExpCompile.PoolString( "SET" );
|
public override string Name => ExpressCompile.PoolString( "SET" );
|
||||||
|
|
||||||
public void Add( ExpElementInstanceBase token )
|
public void Add( ExpElementInstanceBase token )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StgSharp.Script.Express
|
namespace StgSharp.Script.Express
|
||||||
{
|
{
|
||||||
public static partial class ExpCompile
|
public static partial class ExpressCompile
|
||||||
{
|
{
|
||||||
|
|
||||||
public static ExpTypeSource ExpInt
|
public static ExpTypeSource ExpInt
|
||||||
|
|||||||
@@ -34,23 +34,23 @@ using System.Collections.Frozen;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using static StgSharp.Script.Express.ExpCompile;
|
using static StgSharp.Script.Express.ExpressCompile;
|
||||||
|
|
||||||
namespace StgSharp.Script.Express
|
namespace StgSharp.Script.Express
|
||||||
{
|
{
|
||||||
internal partial class ExpSchema_Nitload : ExpSchema
|
internal partial class ExpSchema_Builtin : ExpSchema
|
||||||
{
|
{
|
||||||
|
|
||||||
private static readonly ExpSchema_Nitload _onlyInstance = new ExpSchema_Nitload(
|
private static readonly ExpSchema_Builtin _onlyInstance = new ExpSchema_Builtin(
|
||||||
);
|
);
|
||||||
|
|
||||||
private ExpSchema_Nitload()
|
private ExpSchema_Builtin()
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
Name = "Nitload";
|
Name = "Nitload";
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static ExpSchema_Nitload Only
|
internal static ExpSchema_Builtin Only
|
||||||
{
|
{
|
||||||
get => _onlyInstance;
|
get => _onlyInstance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// file="ExpCompile.cs"
|
// file="ExpressCompile.cs"
|
||||||
// Project: StgSharp
|
// Project: StgSharp
|
||||||
// AuthorGroup: Nitload Space
|
// AuthorGroup: Nitload Space
|
||||||
// Copyright (c) Nitload Space. All rights reserved.
|
// Copyright (c) Nitload Space. All rights reserved.
|
||||||
@@ -42,7 +42,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace StgSharp.Script.Express
|
namespace StgSharp.Script.Express
|
||||||
{
|
{
|
||||||
public static partial class ExpCompile
|
public static partial class ExpressCompile
|
||||||
{
|
{
|
||||||
|
|
||||||
private static string[] _operatorsWithLetter;
|
private static string[] _operatorsWithLetter;
|
||||||
@@ -82,7 +82,7 @@ namespace StgSharp.Script.Express
|
|||||||
_compileStringCache = new StringPool();
|
_compileStringCache = new StringPool();
|
||||||
_multiplexer = new ConcurrentStringHashMultiplexer();
|
_multiplexer = new ConcurrentStringHashMultiplexer();
|
||||||
|
|
||||||
ExpSchema_Nitload.Only.Init();
|
ExpSchema_Builtin.Only.Init();
|
||||||
|
|
||||||
PoolKeywords();
|
PoolKeywords();
|
||||||
InitPrecedence();
|
InitPrecedence();
|
||||||
@@ -99,18 +99,18 @@ namespace StgSharp.Script.Express
|
|||||||
KeyWord.Not,
|
KeyWord.Not,
|
||||||
];
|
];
|
||||||
|
|
||||||
ExpSchema_Nitload.Only
|
ExpSchema_Builtin.Only
|
||||||
.TryGetType(
|
.TryGetType(
|
||||||
PoolString( KeyWord.Integer ),
|
PoolString( KeyWord.Integer ),
|
||||||
out ExpTypeSource? _expInt );
|
out ExpTypeSource? _expInt );
|
||||||
ExpInt = _expInt;
|
ExpInt = _expInt;
|
||||||
|
|
||||||
ExpSchema_Nitload.Only
|
ExpSchema_Builtin.Only
|
||||||
.TryGetType(
|
.TryGetType(
|
||||||
PoolString( KeyWord.Real ),
|
PoolString( KeyWord.Real ),
|
||||||
out ExpTypeSource? _expReal );
|
out ExpTypeSource? _expReal );
|
||||||
ExpReal = _expReal;
|
ExpReal = _expReal;
|
||||||
ExpSchema_Nitload.Only
|
ExpSchema_Builtin.Only
|
||||||
.TryGetType(
|
.TryGetType(
|
||||||
PoolString( KeyWord.Boolean ),
|
PoolString( KeyWord.Boolean ),
|
||||||
out ExpTypeSource? _expBool );
|
out ExpTypeSource? _expBool );
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StgSharp.Script.Express
|
namespace StgSharp.Script.Express
|
||||||
{
|
{
|
||||||
public static partial class ExpCompile
|
public static partial class ExpressCompile
|
||||||
{
|
{
|
||||||
|
|
||||||
public static bool TryGetOperatorPrecedence(
|
public static bool TryGetOperatorPrecedence(
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StgSharp.Script.Express
|
namespace StgSharp.Script.Express
|
||||||
{
|
{
|
||||||
public static partial class ExpCompile
|
public static partial class ExpressCompile
|
||||||
{
|
{
|
||||||
|
|
||||||
private static HashSet<string> _keywordSet;
|
private static HashSet<string> _keywordSet;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
_sourceProvider = sourceProvider;
|
_sourceProvider = sourceProvider;
|
||||||
_constants = new Dictionary<string, ExpElementInstanceBase>(
|
_constants = new Dictionary<string, ExpElementInstanceBase>(
|
||||||
ExpCompile.Multiplexer );
|
ExpressCompile.Multiplexer );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ExpElementType ElementType => ExpElementType.Const;
|
public override ExpElementType ElementType => ExpElementType.Const;
|
||||||
@@ -59,7 +59,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public override string Name
|
public override string Name
|
||||||
{
|
{
|
||||||
get => ExpCompile.KeyWord.Constant;
|
get => ExpressCompile.KeyWord.Constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Analyse()
|
public override void Analyse()
|
||||||
|
|||||||
@@ -48,6 +48,18 @@ namespace StgSharp.Script.Express
|
|||||||
_transmitter = transmitter;
|
_transmitter = transmitter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, ExpElementInstanceBase> FuncParams
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
init;
|
||||||
|
} = new Dictionary<string, ExpElementInstanceBase>();
|
||||||
|
|
||||||
|
public Dictionary<string, ExpElementInstanceBase> LocalVariables
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
init;
|
||||||
|
} = new Dictionary<string, ExpElementInstanceBase>();
|
||||||
|
|
||||||
public override ExpElementType ElementType => ExpElementType.Function;
|
public override ExpElementType ElementType => ExpElementType.Function;
|
||||||
|
|
||||||
public override IScriptSourceProvider SourceProvider => _transmitter;
|
public override IScriptSourceProvider SourceProvider => _transmitter;
|
||||||
@@ -77,6 +89,16 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||||
{
|
{
|
||||||
|
if( FuncParams.TryGetValue(
|
||||||
|
name, out ExpElementInstanceBase? param ) ) {
|
||||||
|
memberNode = param;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if( LocalVariables.TryGetValue(
|
||||||
|
name, out ExpElementInstanceBase? variable ) ) {
|
||||||
|
memberNode = variable;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
memberNode = ExpNode.Empty;
|
memberNode = ExpNode.Empty;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ namespace StgSharp.Script.Express
|
|||||||
0;
|
0;
|
||||||
return new ExpBinaryOperatorNode( source )
|
return new ExpBinaryOperatorNode( source )
|
||||||
{
|
{
|
||||||
_returnType = isFloat ? ExpCompile.ExpReal : ExpCompile.ExpInt,
|
_returnType = isFloat ?
|
||||||
|
ExpressCompile.ExpReal : ExpressCompile.ExpInt,
|
||||||
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
|
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
|
||||||
CodeConvertTemplate = "{0} + {1}",
|
CodeConvertTemplate = "{0} + {1}",
|
||||||
};
|
};
|
||||||
@@ -106,7 +107,8 @@ namespace StgSharp.Script.Express
|
|||||||
0;
|
0;
|
||||||
return new ExpBinaryOperatorNode( source )
|
return new ExpBinaryOperatorNode( source )
|
||||||
{
|
{
|
||||||
_returnType = isFloat ? ExpCompile.ExpReal : ExpCompile.ExpInt,
|
_returnType = isFloat ?
|
||||||
|
ExpressCompile.ExpReal : ExpressCompile.ExpInt,
|
||||||
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
|
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
|
||||||
CodeConvertTemplate = "{0} / {1}",
|
CodeConvertTemplate = "{0} / {1}",
|
||||||
};
|
};
|
||||||
@@ -124,7 +126,7 @@ namespace StgSharp.Script.Express
|
|||||||
}
|
}
|
||||||
return new ExpBinaryOperatorNode( source )
|
return new ExpBinaryOperatorNode( source )
|
||||||
{
|
{
|
||||||
_returnType = ExpCompile.ExpBool,
|
_returnType = ExpressCompile.ExpBool,
|
||||||
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
|
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
|
||||||
CodeConvertTemplate = "{0} == {1}",
|
CodeConvertTemplate = "{0} == {1}",
|
||||||
};
|
};
|
||||||
@@ -141,7 +143,7 @@ namespace StgSharp.Script.Express
|
|||||||
}
|
}
|
||||||
return new ExpBinaryOperatorNode( source )
|
return new ExpBinaryOperatorNode( source )
|
||||||
{
|
{
|
||||||
_returnType = ExpCompile.ExpBool,
|
_returnType = ExpressCompile.ExpBool,
|
||||||
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
|
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
|
||||||
CodeConvertTemplate = "{0} > {1}",
|
CodeConvertTemplate = "{0} > {1}",
|
||||||
};
|
};
|
||||||
@@ -158,7 +160,7 @@ namespace StgSharp.Script.Express
|
|||||||
}
|
}
|
||||||
return new ExpBinaryOperatorNode( source )
|
return new ExpBinaryOperatorNode( source )
|
||||||
{
|
{
|
||||||
_returnType = ExpCompile.ExpBool,
|
_returnType = ExpressCompile.ExpBool,
|
||||||
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
|
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
|
||||||
CodeConvertTemplate = "{0} < {1}",
|
CodeConvertTemplate = "{0} < {1}",
|
||||||
};
|
};
|
||||||
@@ -178,7 +180,8 @@ namespace StgSharp.Script.Express
|
|||||||
0;
|
0;
|
||||||
return new ExpBinaryOperatorNode( source )
|
return new ExpBinaryOperatorNode( source )
|
||||||
{
|
{
|
||||||
_returnType = isFloat ? ExpCompile.ExpReal : ExpCompile.ExpInt,
|
_returnType = isFloat ?
|
||||||
|
ExpressCompile.ExpReal : ExpressCompile.ExpInt,
|
||||||
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
|
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
|
||||||
CodeConvertTemplate = "{0} * {1}",
|
CodeConvertTemplate = "{0} * {1}",
|
||||||
};
|
};
|
||||||
@@ -196,7 +199,7 @@ namespace StgSharp.Script.Express
|
|||||||
}
|
}
|
||||||
return new ExpBinaryOperatorNode( source )
|
return new ExpBinaryOperatorNode( source )
|
||||||
{
|
{
|
||||||
_returnType = ExpCompile.ExpBool,
|
_returnType = ExpressCompile.ExpBool,
|
||||||
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
|
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
|
||||||
CodeConvertTemplate = "{0} != {1}",
|
CodeConvertTemplate = "{0} != {1}",
|
||||||
};
|
};
|
||||||
@@ -213,7 +216,7 @@ namespace StgSharp.Script.Express
|
|||||||
}
|
}
|
||||||
return new ExpBinaryOperatorNode( source )
|
return new ExpBinaryOperatorNode( source )
|
||||||
{
|
{
|
||||||
_returnType = ExpCompile.ExpBool,
|
_returnType = ExpressCompile.ExpBool,
|
||||||
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
|
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Operator_Binary,
|
||||||
CodeConvertTemplate = "{0} < {1}",
|
CodeConvertTemplate = "{0} < {1}",
|
||||||
};
|
};
|
||||||
@@ -233,7 +236,8 @@ namespace StgSharp.Script.Express
|
|||||||
0;
|
0;
|
||||||
return new ExpBinaryOperatorNode( source )
|
return new ExpBinaryOperatorNode( source )
|
||||||
{
|
{
|
||||||
_returnType = isFloat ? ExpCompile.ExpReal : ExpCompile.ExpInt,
|
_returnType = isFloat ?
|
||||||
|
ExpressCompile.ExpReal : ExpressCompile.ExpInt,
|
||||||
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
|
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
|
||||||
CodeConvertTemplate = "{0} - {1}",
|
CodeConvertTemplate = "{0} - {1}",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace StgSharp.Script.Express
|
|||||||
{
|
{
|
||||||
ExpSchema.BuiltinSchema
|
ExpSchema.BuiltinSchema
|
||||||
.TryGetType(
|
.TryGetType(
|
||||||
ExpCompile.KeyWord.String,
|
ExpressCompile.KeyWord.String,
|
||||||
out ExpTypeSource? strType );
|
out ExpTypeSource? strType );
|
||||||
return strType;
|
return strType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,13 +51,13 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||||
.TryGetType(
|
.TryGetType(
|
||||||
ExpCompile.KeyWord.Integer,
|
ExpressCompile.KeyWord.Integer,
|
||||||
out ExpTypeSource? type ) ?
|
out ExpTypeSource? type ) ?
|
||||||
type : throw new ExpCompileNotInitializedException();
|
type : throw new ExpCompileNotInitializedException();
|
||||||
|
|
||||||
public int Value => _value;
|
public int Value => _value;
|
||||||
|
|
||||||
public override string TypeName => ExpCompile.KeyWord.Integer;
|
public override string TypeName => ExpressCompile.KeyWord.Integer;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||||
.TryGetType(
|
.TryGetType(
|
||||||
ExpCompile.KeyWord.String,
|
ExpressCompile.KeyWord.String,
|
||||||
out ExpTypeSource? type ) ?
|
out ExpTypeSource? type ) ?
|
||||||
type : throw new ExpCompileNotInitializedException();
|
type : throw new ExpCompileNotInitializedException();
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||||
.TryGetType(
|
.TryGetType(
|
||||||
ExpCompile.KeyWord.Boolean,
|
ExpressCompile.KeyWord.Boolean,
|
||||||
out ExpTypeSource? type ) ?
|
out ExpTypeSource? type ) ?
|
||||||
type : throw new ExpCompileNotInitializedException();
|
type : throw new ExpCompileNotInitializedException();
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||||
.TryGetType(
|
.TryGetType(
|
||||||
ExpCompile.KeyWord.String,
|
ExpressCompile.KeyWord.String,
|
||||||
out ExpTypeSource? type ) ?
|
out ExpTypeSource? type ) ?
|
||||||
type : throw new ExpCompileNotInitializedException();
|
type : throw new ExpCompileNotInitializedException();
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||||
.TryGetType(
|
.TryGetType(
|
||||||
ExpCompile.KeyWord.Logical,
|
ExpressCompile.KeyWord.Logical,
|
||||||
out ExpTypeSource? type ) ?
|
out ExpTypeSource? type ) ?
|
||||||
type : throw new ExpCompileNotInitializedException();
|
type : throw new ExpCompileNotInitializedException();
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace StgSharp.Script.Express
|
namespace StgSharp.Script.Express
|
||||||
{
|
{
|
||||||
public class ExpRepeatToken : ExpNode
|
public class ExpRepeatNode : ExpNode
|
||||||
{
|
{
|
||||||
|
|
||||||
//TODO: Current code cannot represent full functionality defined in ISO10303, need rewrite.
|
//TODO: Current code cannot represent full functionality defined in ISO10303, need rewrite.
|
||||||
@@ -45,7 +45,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
private ExpNode _operationBegin;
|
private ExpNode _operationBegin;
|
||||||
|
|
||||||
public ExpRepeatToken(
|
public ExpRepeatNode(
|
||||||
Token source,
|
Token source,
|
||||||
ExpNode operationBegin,
|
ExpNode operationBegin,
|
||||||
ExpElementInstanceBase variable,
|
ExpElementInstanceBase variable,
|
||||||
@@ -64,14 +64,14 @@ namespace StgSharp.Script.Express
|
|||||||
case ExpNodeFlag.BuiltinType_Real:
|
case ExpNodeFlag.BuiltinType_Real:
|
||||||
increment = new ExpRealNumberNode(
|
increment = new ExpRealNumberNode(
|
||||||
new Token(
|
new Token(
|
||||||
ExpCompile.PoolString( "1.0f" ), source.Line,
|
ExpressCompile.PoolString( "1.0f" ), source.Line,
|
||||||
-1, TokenFlag.Number ),
|
-1, TokenFlag.Number ),
|
||||||
1.0f );
|
1.0f );
|
||||||
break;
|
break;
|
||||||
case ExpNodeFlag.BuiltinType_Int:
|
case ExpNodeFlag.BuiltinType_Int:
|
||||||
increment = new ExpIntNode(
|
increment = new ExpIntNode(
|
||||||
new Token(
|
new Token(
|
||||||
ExpCompile.PoolString( "1" ), source.Line, -1,
|
ExpressCompile.PoolString( "1" ), source.Line, -1,
|
||||||
TokenFlag.Number ),
|
TokenFlag.Number ),
|
||||||
1 );
|
1 );
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using ExpKeyword = StgSharp.Script.Express.ExpCompile.KeyWord;
|
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.KeyWord;
|
||||||
|
|
||||||
namespace StgSharp.Script.Express
|
namespace StgSharp.Script.Express
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using ExpKeyword = StgSharp.Script.Express.ExpCompile.KeyWord;
|
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.KeyWord;
|
||||||
|
|
||||||
namespace StgSharp.Script.Express
|
namespace StgSharp.Script.Express
|
||||||
{
|
{
|
||||||
@@ -43,9 +43,9 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public int CompareOperatorPrecedence( Token left, Token right )
|
public int CompareOperatorPrecedence( Token left, Token right )
|
||||||
{
|
{
|
||||||
ExpCompile.TryGetOperatorPrecedence(
|
ExpressCompile.TryGetOperatorPrecedence(
|
||||||
left.Value, out int leftPrecedence );
|
left.Value, out int leftPrecedence );
|
||||||
ExpCompile.TryGetOperatorPrecedence(
|
ExpressCompile.TryGetOperatorPrecedence(
|
||||||
right.Value, out int rightPrecedence );
|
right.Value, out int rightPrecedence );
|
||||||
return leftPrecedence - rightPrecedence;
|
return leftPrecedence - rightPrecedence;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using ExpKeyword = StgSharp.Script.Express.ExpCompile.KeyWord;
|
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.KeyWord;
|
||||||
|
|
||||||
namespace StgSharp.Script.Express
|
namespace StgSharp.Script.Express
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using ExpKeyword = StgSharp.Script.Express.ExpCompile.KeyWord;
|
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.KeyWord;
|
||||||
|
|
||||||
namespace StgSharp.Script.Express
|
namespace StgSharp.Script.Express
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using ExpKeyword = StgSharp.Script.Express.ExpCompile.KeyWord;
|
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.KeyWord;
|
||||||
|
|
||||||
namespace StgSharp.Script.Express
|
namespace StgSharp.Script.Express
|
||||||
{
|
{
|
||||||
@@ -55,7 +55,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
private ExpNode _lastStatement;
|
private ExpNode _lastStatement;
|
||||||
|
|
||||||
private GeneratedExpSchema _context;
|
private ExpSchema _context;
|
||||||
private IExpElementSource _local;
|
private IExpElementSource _local;
|
||||||
|
|
||||||
public ExpNodeGenerator()
|
public ExpNodeGenerator()
|
||||||
@@ -63,6 +63,18 @@ namespace StgSharp.Script.Express
|
|||||||
_cache = new CompileStack<ExpNode, IExpElementSource>();
|
_cache = new CompileStack<ExpNode, IExpElementSource>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ExpNodeGenerator( ExpSchema context, IExpElementSource local )
|
||||||
|
{
|
||||||
|
_cache = new CompileStack<ExpNode, IExpElementSource>();
|
||||||
|
ArgumentNullException.ThrowIfNull( context );
|
||||||
|
if( context is not ExpSchema_Builtin ) {
|
||||||
|
_context = context;
|
||||||
|
} else {
|
||||||
|
throw new InvalidCastException( "Not a valid Schema type" );
|
||||||
|
}
|
||||||
|
_local = local;
|
||||||
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public static ExpSchema BuiltinSchema
|
public static ExpSchema BuiltinSchema
|
||||||
{
|
{
|
||||||
get => ExpSchema_Nitload.Only;
|
get => ExpSchema_Builtin.Only;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
@@ -93,7 +93,7 @@ namespace StgSharp.Script.Express
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ConcurrentStringHashMultiplexer StringMultiplexer => ExpCompile.Multiplexer;
|
protected ConcurrentStringHashMultiplexer StringMultiplexer => ExpressCompile.Multiplexer;
|
||||||
|
|
||||||
protected FrozenDictionary<string, ExpRuleSource> RuleDict
|
protected FrozenDictionary<string, ExpRuleSource> RuleDict
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace StgSharp.Script.Express
|
|||||||
private const int
|
private const int
|
||||||
MultiLineEnd = 0x0029002A; // *)
|
MultiLineEnd = 0x0029002A; // *)
|
||||||
|
|
||||||
private const string Token = "token", End = "end", Rest = "rest";
|
private const string TokenMark = "token", EndMark = "end", RestMark = "rest";
|
||||||
|
|
||||||
private bool _isReadingMultiLineComment;
|
private bool _isReadingMultiLineComment;
|
||||||
private int _current, _lineNum;
|
private int _current, _lineNum;
|
||||||
@@ -67,8 +67,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public bool IsEmpty
|
public bool IsEmpty
|
||||||
{
|
{
|
||||||
get => ( ( string.IsNullOrEmpty( _lineCache ) || _current >=
|
get => ( ( string.IsNullOrEmpty( _lineCache ) || _current >= _lineCache.Length ) ) && _provider.IsEmpty;
|
||||||
_lineCache.Length ) ) && _provider.IsEmpty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int LineNumber
|
public int LineNumber
|
||||||
@@ -77,38 +76,44 @@ namespace StgSharp.Script.Express
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para> Read code until end of a line. Lines in multi-line comment will be ignored. Line
|
/// <para> Read code until end of a line. Lines in multi-line comment will be ignored.
|
||||||
/// begins with part of multi-line comment will automatically remove the comment part, but
|
/// Line begins with part of multi-line comment will automatically remove the comment
|
||||||
/// beginning with a full multi-line comment will not causing removing. </para> <para>(*Just
|
/// part, but beginning with a full multi-line comment will not causing removing. </para>
|
||||||
/// Like The Comment Here*) Will Not Be Removed</para>
|
/// <para> (*Just Like The Comment Here*) Will Not Be Removed</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns>
|
||||||
|
///
|
||||||
|
/// </returns>
|
||||||
public unsafe ReadOnlySpan<char> ReadLine()
|
public unsafe ReadOnlySpan<char> ReadLine()
|
||||||
{
|
{
|
||||||
bool lineOver = string.IsNullOrEmpty( _lineCache ) || _current >=
|
bool lineOver = string.IsNullOrEmpty( _lineCache ) || _current >= _lineCache.Length;
|
||||||
_lineCache.Length;
|
while( lineOver || _isReadingMultiLineComment )
|
||||||
while( lineOver || _isReadingMultiLineComment ) {
|
{
|
||||||
if( lineOver ) {
|
if( lineOver )
|
||||||
do {
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
_lineCache = _provider.ReadLine( out _lineNum );
|
_lineCache = _provider.ReadLine( out _lineNum );
|
||||||
} while (string.IsNullOrEmpty( _lineCache ));
|
} while (string.IsNullOrEmpty( _lineCache ));
|
||||||
_current = 0;
|
_current = 0;
|
||||||
}
|
}
|
||||||
if( _isReadingMultiLineComment ) {
|
if( _isReadingMultiLineComment )
|
||||||
|
{
|
||||||
int index;
|
int index;
|
||||||
fixed( char* cPtr = _lineCache.AsSpan( _current ) ) {
|
fixed( char* cPtr = _lineCache.AsSpan( _current ) ) {
|
||||||
index = UnsafeCompute.IndexOfCharPair(
|
index = UnsafeCompute.IndexOfCharPair(
|
||||||
cPtr, MultiLineEnd, _lineCache.Length );
|
cPtr, MultiLineEnd, _lineCache.Length );
|
||||||
}
|
}
|
||||||
if( index == -1 ) {
|
if( index == -1 )
|
||||||
|
{
|
||||||
_lineCache = string.Empty;
|
_lineCache = string.Empty;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
_isReadingMultiLineComment = false;
|
_isReadingMultiLineComment = false;
|
||||||
_current += index + 2;
|
_current += index + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lineOver = string.IsNullOrEmpty( _lineCache ) || _current >=
|
lineOver = string.IsNullOrEmpty( _lineCache ) || _current >= _lineCache.Length;
|
||||||
_lineCache.Length;
|
|
||||||
}
|
}
|
||||||
return _lineCache.AsSpan().Slice( _current );
|
return _lineCache.AsSpan().Slice( _current );
|
||||||
}
|
}
|
||||||
@@ -120,67 +125,71 @@ namespace StgSharp.Script.Express
|
|||||||
ReadOnlySpan<char> source = ReadLine();
|
ReadOnlySpan<char> source = ReadLine();
|
||||||
char c = source[ 0 ];
|
char c = source[ 0 ];
|
||||||
|
|
||||||
if( char.IsLetter( c ) ) {
|
if( char.IsLetter( c ) )
|
||||||
Match match = _nextWordTokenPattern.Match(
|
{
|
||||||
_lineCache, _current );
|
Match match = _nextWordTokenPattern.Match( _lineCache, _current );
|
||||||
if( match.Success ) {
|
if( match.Success )
|
||||||
begin = match.Groups[ Token ].Index;
|
{
|
||||||
end = match.Groups[ End ].Index;
|
begin = match.Groups[ TokenMark ].Index;
|
||||||
rest = match.Groups[ Rest ].Index;
|
end = match.Groups[ EndMark ].Index;
|
||||||
|
rest = match.Groups[ RestMark ].Index;
|
||||||
_current = rest;
|
_current = rest;
|
||||||
_last = new(
|
_last = new(
|
||||||
ExpCompile.PoolString( source[ .. ( end - begin ) ] ),
|
ExpressCompile.PoolString( source[ .. ( end - begin ) ] ), _lineNum, begin,
|
||||||
_lineNum, begin, TokenFlag.Member );
|
TokenFlag.Member );
|
||||||
return _last;
|
return _last;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
throw new ExpInvalidTokenException( _current );
|
throw new ExpInvalidTokenException( _current );
|
||||||
}
|
}
|
||||||
} else if( char.IsPunctuation( c ) || char.IsSymbol( c ) ) {
|
} else if( char.IsPunctuation( c ) || char.IsSymbol( c ) )
|
||||||
switch( c ) {
|
{
|
||||||
|
switch( c )
|
||||||
|
{
|
||||||
case '"':
|
case '"':
|
||||||
char cNext = source[ 1 ];
|
char cNext = source[ 1 ];
|
||||||
if( cNext == '\"' ) //empty string
|
if( cNext == '\"' ) //empty string
|
||||||
{
|
{
|
||||||
begin = _current;
|
begin = _current;
|
||||||
_current += 2;
|
_current += 2;
|
||||||
return new(
|
return new( string.Empty, _lineNum, begin, TokenFlag.String );
|
||||||
string.Empty, _lineNum, begin,
|
|
||||||
TokenFlag.String );
|
|
||||||
}
|
}
|
||||||
Match match = _nextStringLiteralPattern.Match(
|
Match match = _nextStringLiteralPattern.Match( _lineCache, _current );
|
||||||
_lineCache, _current );
|
if( match.Success )
|
||||||
if( match.Success ) {
|
{
|
||||||
begin = match.Groups[ "token" ].Index;
|
begin = match.Groups[ "token" ].Index;
|
||||||
end = match.Groups[ "end" ].Index;
|
end = match.Groups[ "end" ].Index;
|
||||||
rest = match.Groups[ "rest" ].Index;
|
rest = match.Groups[ "rest" ].Index;
|
||||||
_current = rest;
|
_current = rest;
|
||||||
_last = new(
|
_last = new(
|
||||||
ExpCompile.PoolString(
|
ExpressCompile.PoolString( source[ 1..( end - begin ) ] ), _lineNum,
|
||||||
source[ 1..( end - begin ) ] ),
|
begin, TokenFlag.String );
|
||||||
_lineNum, begin, TokenFlag.String );
|
|
||||||
return _last;
|
return _last;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
throw new ExpInvalidCharException( '\"' );
|
throw new ExpInvalidCharException( '\"' );
|
||||||
}
|
}
|
||||||
case '(':
|
case '(':
|
||||||
cNext = source[ 1 ];
|
cNext = source[ 1 ];
|
||||||
if( cNext == '*' ) {
|
if( cNext == '*' )
|
||||||
|
{
|
||||||
_isReadingMultiLineComment = true;
|
_isReadingMultiLineComment = true;
|
||||||
_current += 2;
|
_current += 2;
|
||||||
goto readLine;
|
goto readLine;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
begin = _current;
|
begin = _current;
|
||||||
_current++;
|
_current++;
|
||||||
_last = new(
|
_last = new(
|
||||||
ExpCompile.PoolString( source[ ..1 ] ),
|
ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
|
||||||
_lineNum, begin, TokenFlag.Separator_Left );
|
TokenFlag.Separator_Left );
|
||||||
return _last;
|
return _last;
|
||||||
}
|
}
|
||||||
case ')' or '}':
|
case ')' or '}':
|
||||||
begin = _current;
|
begin = _current;
|
||||||
_current++;
|
_current++;
|
||||||
_last = new Token(
|
_last = new Token(
|
||||||
ExpCompile.PoolString( ")" ), _lineNum, begin,
|
ExpressCompile.PoolString( ")" ), _lineNum, begin,
|
||||||
TokenFlag.Separator_Right );
|
TokenFlag.Separator_Right );
|
||||||
return _last;
|
return _last;
|
||||||
case '-':
|
case '-':
|
||||||
@@ -190,36 +199,41 @@ namespace StgSharp.Script.Express
|
|||||||
// 3. - number type param(UNARY)
|
// 3. - number type param(UNARY)
|
||||||
// 4. param - param(BINARY)
|
// 4. param - param(BINARY)
|
||||||
cNext = source[ 1 ];
|
cNext = source[ 1 ];
|
||||||
if( char.IsNumber( cNext ) ) {
|
if( char.IsNumber( cNext ) )
|
||||||
match = _nextNumberLiteralPattern.Match(
|
{
|
||||||
_lineCache, _current );
|
match = _nextNumberLiteralPattern.Match( _lineCache, _current );
|
||||||
if( match.Success ) {
|
if( match.Success )
|
||||||
begin = match.Groups[ Token ].Index;
|
{
|
||||||
end = match.Groups[ End ].Index;
|
begin = match.Groups[ TokenMark ].Index;
|
||||||
rest = match.Groups[ Rest ].Index;
|
end = match.Groups[ EndMark ].Index;
|
||||||
|
rest = match.Groups[ RestMark ].Index;
|
||||||
_current = rest;
|
_current = rest;
|
||||||
return new(
|
return new(
|
||||||
ExpCompile.PoolString(
|
ExpressCompile.PoolString( source[ ..( end - begin ) ] ),
|
||||||
source[ ..( end - begin ) ] ),
|
|
||||||
_lineNum, begin, TokenFlag.Number );
|
_lineNum, begin, TokenFlag.Number );
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
throw new ExpInvalidTokenException( _current );
|
throw new ExpInvalidTokenException( _current );
|
||||||
}
|
}
|
||||||
} else if( cNext == '-' ) {
|
} else if( cNext == '-' )
|
||||||
|
{
|
||||||
_lineCache = string.Empty;
|
_lineCache = string.Empty;
|
||||||
_current = 0;
|
_current = 0;
|
||||||
goto readLine;
|
goto readLine;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
begin = _current;
|
begin = _current;
|
||||||
_current++;
|
_current++;
|
||||||
if( _last.Flag != TokenFlag.Member ) {
|
if( _last.Flag != TokenFlag.Member )
|
||||||
|
{
|
||||||
_last = new(
|
_last = new(
|
||||||
ExpCompile.PoolString( source[ ..1 ] ),
|
ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
|
||||||
_lineNum, begin, TokenFlag.Symbol_Unary );
|
TokenFlag.Symbol_Unary );
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
_last = new(
|
_last = new(
|
||||||
ExpCompile.PoolString( source[ ..1 ] ),
|
ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
|
||||||
_lineNum, begin, TokenFlag.Symbol_Binary );
|
TokenFlag.Symbol_Binary );
|
||||||
}
|
}
|
||||||
return _last;
|
return _last;
|
||||||
}
|
}
|
||||||
@@ -227,70 +241,101 @@ namespace StgSharp.Script.Express
|
|||||||
begin = _current;
|
begin = _current;
|
||||||
_current++;
|
_current++;
|
||||||
return new Token(
|
return new Token(
|
||||||
ExpCompile.PoolString( "{" ), _lineNum, begin,
|
ExpressCompile.PoolString( "{" ), _lineNum, begin,
|
||||||
TokenFlag.Separator_Left );
|
TokenFlag.Separator_Left );
|
||||||
case '[':
|
case '[':
|
||||||
begin = _current;
|
begin = _current;
|
||||||
_current++;
|
_current++;
|
||||||
return new Token(
|
return new Token(
|
||||||
ExpCompile.PoolString( "[" ), _lineNum, begin,
|
ExpressCompile.PoolString( "[" ), _lineNum, begin,
|
||||||
TokenFlag.Index_Left );
|
TokenFlag.Index_Left );
|
||||||
case ']':
|
case ']':
|
||||||
begin = _current;
|
begin = _current;
|
||||||
_current++;
|
_current++;
|
||||||
return new Token(
|
return new Token(
|
||||||
ExpCompile.PoolString( "]" ), _lineNum, begin,
|
ExpressCompile.PoolString( "]" ), _lineNum, begin,
|
||||||
TokenFlag.Index_Right );
|
TokenFlag.Index_Right );
|
||||||
case ';' or ',':
|
case ';' or ',':
|
||||||
begin = _current;
|
begin = _current;
|
||||||
_current++;
|
_current++;
|
||||||
return new Token(
|
return new Token(
|
||||||
ExpCompile.PoolString( source[ ..1 ] ), _lineNum,
|
ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
|
||||||
begin, TokenFlag.Separator_Middle );
|
TokenFlag.Separator_Middle );
|
||||||
case ':' or '+' or '/' or '\\' or '*' or '.':
|
case ':':
|
||||||
|
if( source[ 1 ] == '=' )
|
||||||
|
{
|
||||||
|
begin = _current;
|
||||||
|
_current += 2;
|
||||||
|
return new Token(
|
||||||
|
ExpressCompile.KeyWord.Assignment, _lineNum, begin,
|
||||||
|
TokenFlag.Index_Right );
|
||||||
|
}
|
||||||
|
begin = _current;
|
||||||
|
_current++;
|
||||||
|
return new Token(
|
||||||
|
ExpressCompile.KeyWord.Colon, _lineNum, begin, TokenFlag.Index_Right );
|
||||||
|
case '+' or '/' or '\\' or '*' or '.':
|
||||||
begin = _current;
|
begin = _current;
|
||||||
_current++;
|
_current++;
|
||||||
return new(
|
return new(
|
||||||
ExpCompile.PoolString( source[ ..1 ] ), _lineNum,
|
ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
|
||||||
begin, TokenFlag.Symbol_Binary );
|
TokenFlag.Symbol_Binary );
|
||||||
default:
|
default:
|
||||||
throw new ExpInvalidCharException( c );
|
throw new ExpInvalidCharException( c );
|
||||||
}
|
}
|
||||||
} else if( char.IsNumber( c ) ) {
|
} else if( char.IsNumber( c ) )
|
||||||
Match match = _nextNumberLiteralPattern.Match(
|
{
|
||||||
_lineCache, _current );
|
Match match = _nextNumberLiteralPattern.Match( _lineCache, _current );
|
||||||
if( match.Success ) {
|
if( match.Success )
|
||||||
begin = match.Groups[ Token ].Index;
|
{
|
||||||
end = match.Groups[ End ].Index;
|
begin = match.Groups[ TokenMark ].Index;
|
||||||
rest = match.Groups[ Rest ].Index;
|
end = match.Groups[ EndMark ].Index;
|
||||||
|
rest = match.Groups[ RestMark ].Index;
|
||||||
_current = rest;
|
_current = rest;
|
||||||
string str = ExpCompile.PoolString(
|
string str = ExpressCompile.PoolString( source[ ..( end - begin ) ] );
|
||||||
source[ ..( end - begin ) ] );
|
|
||||||
TokenFlag flag;
|
TokenFlag flag;
|
||||||
if( ReferenceEquals( str, ExpCompile.KeyWord.Not ) ) {
|
if( ReferenceEquals( str, ExpressCompile.KeyWord.Not ) )
|
||||||
|
{
|
||||||
flag = TokenFlag.Symbol_Unary;
|
flag = TokenFlag.Symbol_Unary;
|
||||||
} else {
|
} else
|
||||||
flag = ExpCompile.LetterIsOperator( str ) ?
|
{
|
||||||
|
flag = ExpressCompile.LetterIsOperator( str ) ?
|
||||||
TokenFlag.Symbol_Binary : TokenFlag.Member;
|
TokenFlag.Symbol_Binary : TokenFlag.Member;
|
||||||
}
|
}
|
||||||
return new( str, _lineNum, begin, flag );
|
return new( str, _lineNum, begin, flag );
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
throw new ExpInvalidTokenException( _current );
|
throw new ExpInvalidTokenException( _current );
|
||||||
}
|
}
|
||||||
} else if( char.IsWhiteSpace( c ) ) {
|
} else if( char.IsWhiteSpace( c ) )
|
||||||
|
{
|
||||||
Match match = _skipBlankPattern.Match( _lineCache, _current );
|
Match match = _skipBlankPattern.Match( _lineCache, _current );
|
||||||
if( match.Success ) {
|
if( match.Success )
|
||||||
rest = match.Groups[ Rest ].Index;
|
{
|
||||||
|
rest = match.Groups[ RestMark ].Index;
|
||||||
_current = rest;
|
_current = rest;
|
||||||
goto readLine;
|
goto readLine;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
throw new ExpInvalidTokenException( _current );
|
throw new ExpInvalidTokenException( _current );
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
throw new ExpInvalidCharException( c );
|
throw new ExpInvalidCharException( c );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TryReadToken( out Token t )
|
||||||
|
{
|
||||||
|
if( IsEmpty )
|
||||||
|
{
|
||||||
|
t = Token.Empty;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
t = ReadToken();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
[GeneratedRegex(
|
[GeneratedRegex(
|
||||||
@"(?<token>[a-zA-Z][a-zA-Z0-9_]*)(?<end>\s*?)(?<rest>\S|$)",
|
@"(?<token>[a-zA-Z][a-zA-Z0-9_]*)(?<end>\s*?)(?<rest>\S|$)",
|
||||||
RegexOptions.Singleline )]
|
RegexOptions.Singleline )]
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace StgSharp.Script.Express
|
|||||||
|
|
||||||
public static ExpSchema DefaultSchema
|
public static ExpSchema DefaultSchema
|
||||||
{
|
{
|
||||||
get => ExpSchema_Nitload.Only;
|
get => ExpSchema_Builtin.Only;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpTypeSource GetExpType( string typeName )
|
public ExpTypeSource GetExpType( string typeName )
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Script")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Script")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e73d2fd7fb4e601c32cee66e276f219fc9b4a377")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+528d0c5462b4d3da107ad29b859f9c8006fb675a")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Script")]
|
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Script")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Script")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Script")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/e73d2fd7fb4e601c32cee66e276f219fc9b4a377/*"}}
|
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/528d0c5462b4d3da107ad29b859f9c8006fb675a/*"}}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="ExpLinearExpressionTest.cs"
|
||||||
|
// Project: StgSharp
|
||||||
|
// AuthorGroup: Nitload Space
|
||||||
|
// Copyright (c) Nitload Space. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the “Software”), to deal in the Software without restriction,
|
||||||
|
// including without limitation the rights to use, copy, modify, merge,
|
||||||
|
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
// and to permit persons to whom the Software is furnished to do so,
|
||||||
|
// subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and
|
||||||
|
// this permission notice shall be included in all copies
|
||||||
|
// or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||||
|
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||||
|
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
using StgSharp.Script;
|
||||||
|
using StgSharp.Script.Express;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StgSharp
|
||||||
|
{
|
||||||
|
internal class ExpTestFuncSource : ExpFunctionSource
|
||||||
|
{
|
||||||
|
|
||||||
|
public ExpTestFuncSource( string name, ScriptSourceTransmitter source )
|
||||||
|
: base( name, source )
|
||||||
|
{
|
||||||
|
LocalVariables.Add(
|
||||||
|
"a",
|
||||||
|
ExpElementInstanceBase.CreateLiteral( new Token( "1", 0, 0, TokenFlag.Number ) ) );
|
||||||
|
LocalVariables.Add(
|
||||||
|
"b",
|
||||||
|
ExpElementInstanceBase.CreateLiteral( new Token( "1", 0, 0, TokenFlag.Number ) ) );
|
||||||
|
LocalVariables.Add(
|
||||||
|
"c",
|
||||||
|
ExpElementInstanceBase.CreateLiteral( new Token( "1", 0, 0, TokenFlag.Number ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static partial class Program
|
||||||
|
{
|
||||||
|
|
||||||
|
public static void ExpLinearExpressionTest()
|
||||||
|
{
|
||||||
|
ExpressCompile.InitCompile();
|
||||||
|
ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter( "END", 0 );
|
||||||
|
transmitter.WriteLine( @"a := b + c;" );
|
||||||
|
transmitter.EndWriting();
|
||||||
|
ExpSourceReader reader = new ExpSourceReader( transmitter );
|
||||||
|
/*
|
||||||
|
ExpNodeGenerator generator = new ExpNodeGenerator(
|
||||||
|
, new ExpTestFuncSource( "test", transmitter ) );
|
||||||
|
/**/
|
||||||
|
while( reader.TryReadToken( out Token t ) )
|
||||||
|
{
|
||||||
|
Console.WriteLine( t.Value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -58,37 +58,7 @@ namespace StgSharp
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
StgSharp.Init();
|
StgSharp.Init();
|
||||||
|
ExpLinearExpressionTest();
|
||||||
CompileStack<ExpNode, IExpElementSource> stack = new CompileStack<ExpNode, IExpElementSource>(
|
|
||||||
);
|
|
||||||
|
|
||||||
for( int i = 0; i < 10; i++ ) {
|
|
||||||
stack.PushOperand(
|
|
||||||
new Token( $"{i}", 0, 0, TokenFlag.Number ) );
|
|
||||||
}
|
|
||||||
for( int i = 0; i < 10; i++ ) {
|
|
||||||
stack.PushOperator(
|
|
||||||
new Token( $"op_{i}", 0, 0, TokenFlag.Member ) );
|
|
||||||
}
|
|
||||||
stack.IncreaseDepth( 0 );
|
|
||||||
|
|
||||||
for( int i = 0; i < 10; i++ ) {
|
|
||||||
stack.PushOperand(
|
|
||||||
new Token( $"{i}", 0, 0, TokenFlag.Number ) );
|
|
||||||
}
|
|
||||||
for( int i = 0; i < 10; i++ ) {
|
|
||||||
stack.PushOperator(
|
|
||||||
new Token( $"op_{i}", 0, 0, TokenFlag.Member ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
while( stack.TryPopOperand(
|
|
||||||
out bool isNode, out Token t, out ExpNode n ) ) {
|
|
||||||
Console.WriteLine( t.Value );
|
|
||||||
}
|
|
||||||
while( stack.TryPopOperator( out Token op ) ) {
|
|
||||||
Console.WriteLine( op.Value );
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch( Exception ex ) {
|
catch( Exception ex ) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace StgSharp
|
|||||||
|
|
||||||
private static void TestFileRead()
|
private static void TestFileRead()
|
||||||
{
|
{
|
||||||
ExpCompile.InitCompile();
|
ExpressCompile.InitCompile();
|
||||||
ExpFileSource reader = new ExpFileSource( testExpPath );
|
ExpFileSource reader = new ExpFileSource( testExpPath );
|
||||||
ExpSchemaSource schemaSource = new ExpSchemaSource();
|
ExpSchemaSource schemaSource = new ExpSchemaSource();
|
||||||
schemaSource.ReadSchema( reader );
|
schemaSource.ReadSchema( reader );
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharpDebug")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharpDebug")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6788bc4a0065508d7afa5f740da1b4ca6dd1efef")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+528d0c5462b4d3da107ad29b859f9c8006fb675a")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharpDebug")]
|
[assembly: System.Reflection.AssemblyProductAttribute("StgSharpDebug")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharpDebug")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharpDebug")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/6788bc4a0065508d7afa5f740da1b4ca6dd1efef/*"}}
|
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/528d0c5462b4d3da107ad29b859f9c8006fb675a/*"}}
|
||||||
Reference in New Issue
Block a user