Daily update on 20250310-064733 by Nitload Youmu. Additional Message : Change: Generic node removed, five non-generic node as replacement
Change: Preprocess to token scheduled, less dependency on type prediction, which put to LINK or C# compiling pase Design: the EXPRESS lang feature "FIXED" keyword not supported, builtin type binary not supported, not used in STEP AP203 and much too complex to make a full marshal implementation in C#. Add: Node generating method to generate literal node Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -43,16 +43,6 @@ namespace StgSharp.Script
|
||||
where TType: ITypeSource<TType>
|
||||
{
|
||||
|
||||
int Line
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
int Column
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
long NodeFlag
|
||||
{
|
||||
get;
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace StgSharp.Script
|
||||
public enum TokenFlag : int
|
||||
{
|
||||
|
||||
None = 0,
|
||||
Symbol_Unary = 1,
|
||||
Symbol_Binary = 2,
|
||||
Number = 3,
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace StgSharp.Script.Express
|
||||
protected internal (int min, int max) _range;
|
||||
protected internal ExpElementType _memberType;
|
||||
|
||||
protected ExpCollectionInstanceBase( string name ) : base( name ) { }
|
||||
protected ExpCollectionInstanceBase( Token source ) : base( source ) { }
|
||||
|
||||
public abstract ExpCollectionBase CollectionValue
|
||||
{
|
||||
@@ -67,8 +67,8 @@ namespace StgSharp.Script.Express
|
||||
|
||||
private ExpSet _collection;
|
||||
|
||||
public ExpSetInstance( string name, ExpSet set, ExpSchema context )
|
||||
: base( name )
|
||||
public ExpSetInstance( Token source, ExpSet set )
|
||||
: base( source )
|
||||
{
|
||||
_collection = set;
|
||||
}
|
||||
@@ -85,8 +85,8 @@ namespace StgSharp.Script.Express
|
||||
|
||||
private ExpBag _collection;
|
||||
|
||||
public ExpBagInstance( string name, ExpBag bag, ExpSchema context )
|
||||
: base( name )
|
||||
public ExpBagInstance( Token source, ExpBag bag )
|
||||
: base( source )
|
||||
{
|
||||
_collection = bag;
|
||||
}
|
||||
@@ -103,8 +103,8 @@ namespace StgSharp.Script.Express
|
||||
|
||||
private ExpList _collection;
|
||||
|
||||
public ExpListInstance( string name, ExpList list, ExpSchema context )
|
||||
: base( name )
|
||||
public ExpListInstance( Token source, ExpList list )
|
||||
: base( source )
|
||||
{
|
||||
_collection = list;
|
||||
}
|
||||
@@ -121,11 +121,8 @@ namespace StgSharp.Script.Express
|
||||
|
||||
private ExpArray _collection;
|
||||
|
||||
public ExpArrayInstance(
|
||||
string name,
|
||||
ExpArray array,
|
||||
ExpSchema context )
|
||||
: base( name )
|
||||
public ExpArrayInstance( Token source, ExpArray array )
|
||||
: base( source )
|
||||
{
|
||||
_collection = array;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,18 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public override string ToString() => _value.ToString();
|
||||
|
||||
public static bool TryParse(
|
||||
ReadOnlySpan<char> value,
|
||||
out ExpLogic result )
|
||||
{
|
||||
if( Enum.TryParse<ExpLogicValue>( value, out ExpLogicValue e ) ) {
|
||||
result = new ExpLogic( e );
|
||||
return true;
|
||||
}
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
// NOT !
|
||||
public static ExpLogic operator !( ExpLogic a )
|
||||
{
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="BuiltinType.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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public static partial class ExpCompile
|
||||
{
|
||||
|
||||
public static ExpTypeSource ExpInt
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public static ExpTypeSource ExpReal
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ namespace StgSharp.Script.Express
|
||||
Name = "Nitload";
|
||||
}
|
||||
|
||||
public static ExpSchema Only
|
||||
internal static ExpSchema_Nitload Only
|
||||
{
|
||||
get => _onlyInstance;
|
||||
}
|
||||
@@ -128,10 +128,12 @@ namespace StgSharp.Script.Express
|
||||
|
||||
ConstDict = new Dictionary<string, ExpElementInstanceBase>(
|
||||
Multiplexer ) {
|
||||
{ PoolString( "PI" ), new ExpLiteralGenericNode<float>(
|
||||
PoolString( "PI" ), MathF.PI ) },
|
||||
{ PoolString( "E" ), new ExpLiteralGenericNode<float>(
|
||||
PoolString( "E" ), MathF.E ) },
|
||||
{ PoolString( "PI" ), new ExpRealNumberNode(
|
||||
new Token( PoolString( "PI" ), -1, -1, TokenFlag.Number ),
|
||||
MathF.PI ) },
|
||||
{ PoolString( "E" ), new ExpRealNumberNode(
|
||||
new Token( PoolString( "E" ), -1, -1, TokenFlag.Number ),
|
||||
MathF.E ) },
|
||||
}.ToFrozenDictionary();
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,8 @@ namespace StgSharp.Script.Express
|
||||
_compileStringCache = new StringPool();
|
||||
_multiplexer = new ConcurrentStringHashMultiplexer();
|
||||
|
||||
ExpSchema_Nitload.Only.Init();
|
||||
|
||||
PoolKeywords();
|
||||
InitPrecedence();
|
||||
|
||||
@@ -96,6 +98,17 @@ namespace StgSharp.Script.Express
|
||||
KeyWord.ANDOR,
|
||||
KeyWord.NOT,
|
||||
];
|
||||
|
||||
ExpSchema_Nitload.Only
|
||||
.TryGetType(
|
||||
PoolString( KeyWord.Int ), out ExpTypeSource? _expInt );
|
||||
ExpInt = _expInt;
|
||||
|
||||
ExpSchema_Nitload.Only
|
||||
.TryGetType(
|
||||
PoolString( KeyWord.Real ),
|
||||
out ExpTypeSource? _expReal );
|
||||
ExpReal = _expReal;
|
||||
}
|
||||
|
||||
public static bool LetterIsOperator( string str )
|
||||
|
||||
@@ -34,20 +34,6 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpEntity : ExpNode
|
||||
{
|
||||
|
||||
public ExpEntity( string name, ExpSchema context ) : base( name ) { }
|
||||
|
||||
public override ExpNode Left => throw new NotImplementedException();
|
||||
|
||||
public override ExpNode Right => throw new NotImplementedException();
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => throw new NotImplementedException(
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public class ExpEntitySource : ExpInstantiableElement
|
||||
{
|
||||
|
||||
|
||||
@@ -34,30 +34,6 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpFunction : ExpNode
|
||||
{
|
||||
|
||||
private ExpFunctionSource _source;
|
||||
|
||||
private readonly ExpNode _return;
|
||||
private readonly List<KeyValuePair<string, ExpNode>> _parameterList
|
||||
= new List<KeyValuePair<string, ExpNode>>();
|
||||
|
||||
public ExpFunction( string name, ExpSchema context ) : base( name ) { }
|
||||
|
||||
public ExpElementType ElementType => ExpElementType.Function;
|
||||
|
||||
public override ExpInstantiableElement EqualityTypeConvert => throw new NotImplementedException(
|
||||
);
|
||||
|
||||
public override ExpNode Left => throw new NotImplementedException();
|
||||
|
||||
public override ExpNode Right => throw new NotImplementedException();
|
||||
|
||||
public void CallThisFunction( params ExpNode[] parameters ) { }
|
||||
|
||||
}
|
||||
|
||||
public class ExpFunctionSource : ExpImmutableElement
|
||||
{
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace StgSharp.Script.Express
|
||||
|
||||
private ExpRuleSource _source;
|
||||
|
||||
public ExpRule( string name, ExpSchema context ) : base( name ) { }
|
||||
public ExpRule( Token source ) : base( source ) { }
|
||||
|
||||
public object? value => throw new NotImplementedException();
|
||||
|
||||
|
||||
@@ -35,23 +35,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpTypeInstance : ExpElementInstanceBase
|
||||
{
|
||||
|
||||
public ExpTypeInstance( string name ) : base( name ) { }
|
||||
|
||||
public override ExpInstantiableElement EqualityTypeConvert => throw new NotImplementedException(
|
||||
);
|
||||
|
||||
public override ExpNode Left => throw new NotImplementedException();
|
||||
|
||||
public override ExpNode Right => throw new NotImplementedException();
|
||||
|
||||
public override string TypeName => throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
public class ExpTypeSource : IExpElementSource
|
||||
public class ExpTypeSource : ExpInstantiableElement
|
||||
{
|
||||
|
||||
private ScriptSourceTransmitter _transmitter;
|
||||
@@ -77,23 +61,23 @@ namespace StgSharp.Script.Express
|
||||
get => _isBuiltinType;
|
||||
}
|
||||
|
||||
public ExpElementType ElementType => ExpElementType.Type;
|
||||
public override ExpElementType ElementType => ExpElementType.Type;
|
||||
|
||||
public ExpTypeSource Void
|
||||
{
|
||||
get => ExpVoidType.Only;
|
||||
}
|
||||
|
||||
public IScriptSourceProvider SourceProvider => _transmitter;
|
||||
public override IScriptSourceProvider SourceProvider => _transmitter;
|
||||
|
||||
public string Name => _name;
|
||||
public override string Name => _name;
|
||||
|
||||
public virtual void Analyse()
|
||||
public override void Analyse()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsConvertable( IExpElementSource targetType )
|
||||
public override ExpNode CreateInstanceNode()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
@@ -45,7 +46,7 @@ namespace StgSharp.Script.Express
|
||||
private ExpNode _left;
|
||||
private ExpNode _right;
|
||||
|
||||
private ExpBinaryOperatorNode( string name ) : base( name ) { }
|
||||
private ExpBinaryOperatorNode( Token source ) : base( source ) { }
|
||||
|
||||
public override ExpInstantiableElement EqualityTypeConvert => _returnType;
|
||||
|
||||
@@ -53,24 +54,28 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public override ExpNode Right => _right;
|
||||
|
||||
public static ExpBinaryOperatorNode Add( ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode Add(
|
||||
Token source,
|
||||
ExpNode left,
|
||||
ExpNode right )
|
||||
{
|
||||
if( !left.IsNumber && !right.IsNumber ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
"Number", left.EqualityTypeConvert.Name );
|
||||
}
|
||||
bool isFloat =
|
||||
( left._nodeFlag | ExpNodeFlag.BuiltinType_Float ) == 0 || ( right._nodeFlag | ExpNodeFlag.BuiltinType_Float ) ==
|
||||
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || ( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) ==
|
||||
0;
|
||||
return new ExpBinaryOperatorNode( ExpCompile.KeyWord.ADD )
|
||||
return new ExpBinaryOperatorNode( source )
|
||||
{
|
||||
_returnType = isFloat ? null : null,
|
||||
_returnType = isFloat ? ExpCompile.ExpReal : ExpCompile.ExpInt,
|
||||
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
|
||||
CodeConvertTemplate = "{0} + {1}",
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpBinaryOperatorNode Assign(
|
||||
Token source,
|
||||
ExpNode left,
|
||||
ExpNode right )
|
||||
{
|
||||
@@ -79,7 +84,7 @@ namespace StgSharp.Script.Express
|
||||
left.EqualityTypeConvert.Name,
|
||||
right.EqualityTypeConvert.Name );
|
||||
}
|
||||
return new ExpBinaryOperatorNode( ExpCompile.KeyWord.Assignment )
|
||||
return new ExpBinaryOperatorNode( source )
|
||||
{
|
||||
_returnType = ExpInstantiableElement.Void,
|
||||
_nodeFlag = ExpNodeFlag.Operator_Binary | left._nodeFlag,
|
||||
@@ -87,52 +92,61 @@ namespace StgSharp.Script.Express
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpBinaryOperatorNode Div( ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode Div(
|
||||
Token source,
|
||||
ExpNode left,
|
||||
ExpNode right )
|
||||
{
|
||||
if( !left.IsNumber && !right.IsNumber ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
"Number", left.EqualityTypeConvert.Name );
|
||||
}
|
||||
bool isFloat =
|
||||
( left._nodeFlag | ExpNodeFlag.BuiltinType_Float ) == 0 || ( right._nodeFlag | ExpNodeFlag.BuiltinType_Float ) ==
|
||||
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || ( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) ==
|
||||
0;
|
||||
return new ExpBinaryOperatorNode( ExpCompile.KeyWord.DIV )
|
||||
return new ExpBinaryOperatorNode( source )
|
||||
{
|
||||
_returnType = isFloat ? null : null,
|
||||
_returnType = isFloat ? ExpCompile.ExpReal : ExpCompile.ExpInt,
|
||||
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
|
||||
CodeConvertTemplate = "{0} / {1}",
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpBinaryOperatorNode Mul( ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode Mul(
|
||||
Token source,
|
||||
ExpNode left,
|
||||
ExpNode right )
|
||||
{
|
||||
if( !left.IsNumber && !right.IsNumber ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
"Number", left.EqualityTypeConvert.Name );
|
||||
}
|
||||
bool isFloat =
|
||||
( left._nodeFlag | ExpNodeFlag.BuiltinType_Float ) == 0 || ( right._nodeFlag | ExpNodeFlag.BuiltinType_Float ) ==
|
||||
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || ( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) ==
|
||||
0;
|
||||
return new ExpBinaryOperatorNode( ExpCompile.KeyWord.MUL )
|
||||
return new ExpBinaryOperatorNode( source )
|
||||
{
|
||||
_returnType = isFloat ? null : null,
|
||||
_returnType = isFloat ? ExpCompile.ExpReal : ExpCompile.ExpInt,
|
||||
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
|
||||
CodeConvertTemplate = "{0} * {1}",
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpBinaryOperatorNode Sub( ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode Sub(
|
||||
Token source,
|
||||
ExpNode left,
|
||||
ExpNode right )
|
||||
{
|
||||
if( !left.IsNumber && !right.IsNumber ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
"Number", left.EqualityTypeConvert.Name );
|
||||
}
|
||||
bool isFloat =
|
||||
( left._nodeFlag | ExpNodeFlag.BuiltinType_Float ) == 0 || ( right._nodeFlag | ExpNodeFlag.BuiltinType_Float ) ==
|
||||
( left._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0 || ( right._nodeFlag | ExpNodeFlag.BuiltinType_Real ) ==
|
||||
0;
|
||||
return new ExpBinaryOperatorNode( ExpCompile.KeyWord.SUB )
|
||||
return new ExpBinaryOperatorNode( source )
|
||||
{
|
||||
_returnType = isFloat ? : null,
|
||||
_returnType = isFloat ? ExpCompile.ExpReal : ExpCompile.ExpInt,
|
||||
_nodeFlag = ExpNodeFlag.Operator_Binary | ExpNodeFlag.BuiltinType_Number,
|
||||
CodeConvertTemplate = "{0} - {1}",
|
||||
};
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace StgSharp.Script.Express
|
||||
private ExpInstantiableElement _element;
|
||||
|
||||
public ExpElementInstanceNode(
|
||||
string varName,
|
||||
Token source,
|
||||
ExpInstantiableElement element )
|
||||
: base( varName )
|
||||
: base( source )
|
||||
{
|
||||
_element = element;
|
||||
}
|
||||
|
||||
@@ -34,13 +34,12 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express.ExpAstNode
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpElementMemberNameNode : ExpNode
|
||||
{
|
||||
|
||||
public ExpElementMemberNameNode( string memberName )
|
||||
: base( memberName ) { }
|
||||
public ExpElementMemberNameNode( Token source ) : base( source ) { }
|
||||
|
||||
public override ExpNode Left => Empty;
|
||||
|
||||
|
||||
@@ -44,9 +44,10 @@ namespace StgSharp.Script.Express
|
||||
private ExpNode _parameter;
|
||||
|
||||
public ExpFunctionCallingNode(
|
||||
Token source,
|
||||
ExpFunctionSource function,
|
||||
ExpNode firstParameter )
|
||||
: base( $"{function.Name}_call" )
|
||||
: base( source )
|
||||
{
|
||||
_function = function;
|
||||
_parameter = firstParameter;
|
||||
|
||||
@@ -44,12 +44,12 @@ namespace StgSharp.Script.Express
|
||||
private ExpNode _trueOpBegin ;
|
||||
|
||||
public ExpIfNode(
|
||||
string name,
|
||||
Token source,
|
||||
ExpSchema context,
|
||||
ExpNode rule,
|
||||
ExpNode rootOperationIfTrue,
|
||||
ExpNode rootOperationIfFalse )
|
||||
: base( name )
|
||||
: base( source )
|
||||
{
|
||||
_rule = rule;
|
||||
_trueOpBegin = rootOperationIfFalse;
|
||||
|
||||
@@ -44,9 +44,10 @@ namespace StgSharp.Script.Express
|
||||
private ExpNode _indexExpression;
|
||||
|
||||
private ExpIndexOfNode(
|
||||
Token source,
|
||||
ExpCollectionInstanceBase instance,
|
||||
ExpNode indexExpression )
|
||||
: base( ExpCompile.PoolString( "[" ) )
|
||||
: base( source )
|
||||
{
|
||||
_collection = instance;
|
||||
_indexExpression = indexExpression;
|
||||
@@ -60,6 +61,7 @@ namespace StgSharp.Script.Express
|
||||
public override IExpElementSource EqualityTypeConvert => _collection.EqualityTypeConvert;
|
||||
|
||||
public static ExpIndexOfNode Create(
|
||||
Token source,
|
||||
ExpCollectionInstanceBase instance,
|
||||
ExpNode indexExpression )
|
||||
{
|
||||
@@ -67,7 +69,7 @@ namespace StgSharp.Script.Express
|
||||
throw new ExpInvalidTypeException(
|
||||
"Number", indexExpression.EqualityTypeConvert.Name );
|
||||
}
|
||||
return new ExpIndexOfNode( instance, indexExpression );
|
||||
return new ExpIndexOfNode( source, instance, indexExpression );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ExpInstanceReferenceNode.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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpInstanceReferenceNode : ExpNode
|
||||
{
|
||||
|
||||
public override ExpNode Left => throw new NotImplementedException();
|
||||
|
||||
public override ExpNode Right => throw new NotImplementedException();
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => throw new NotImplementedException(
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -37,71 +37,121 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpLiteralNode
|
||||
public class ExpIntNode : ExpElementInstanceBase
|
||||
{
|
||||
|
||||
private readonly IValueBox box;
|
||||
private int _value;
|
||||
|
||||
}
|
||||
|
||||
public class ExpLiteralGenericNode<T> : ExpElementInstanceBase
|
||||
{
|
||||
|
||||
private readonly ExpBuiltinType _type;
|
||||
private readonly T _value;
|
||||
|
||||
public ExpLiteralGenericNode( string name, T value )
|
||||
: base( name )
|
||||
public ExpIntNode( Token source, int value )
|
||||
: base( source )
|
||||
{
|
||||
_value = value;
|
||||
switch( value ) {
|
||||
case float f:
|
||||
ExpSchema.BuiltinSchema
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_Int | ExpNodeFlag.Element_Type;
|
||||
}
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||
.TryGetType(
|
||||
ExpCompile.KeyWord.Real,
|
||||
out ExpTypeSource? type );
|
||||
_type = ( type as ExpBuiltinType )!;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_Float | ExpNodeFlag.Element_Const;
|
||||
break;
|
||||
case int i:
|
||||
ExpSchema.BuiltinSchema
|
||||
.TryGetType( ExpCompile.KeyWord.Int, out type );
|
||||
_type = ( type as ExpBuiltinType )!;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_Int | ExpNodeFlag.Element_Const;
|
||||
break;
|
||||
case BitArray b:
|
||||
ExpSchema.BuiltinSchema
|
||||
.TryGetType( ExpCompile.KeyWord.Binary, out type );
|
||||
_type = ( type as ExpBuiltinType )!;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_Binary | ExpNodeFlag.Element_Const;
|
||||
break;
|
||||
case string s:
|
||||
ExpSchema.BuiltinSchema
|
||||
.TryGetType( ExpCompile.KeyWord.String, out type );
|
||||
_type = ( type as ExpBuiltinType )!;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_Int | ExpNodeFlag.Element_Const;
|
||||
break;
|
||||
case ExpLogic l:
|
||||
ExpSchema.BuiltinSchema
|
||||
.TryGetType( ExpCompile.KeyWord.Logic, out type );
|
||||
_type = ( type as ExpBuiltinType )!;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_Int | ExpNodeFlag.Element_Const;
|
||||
break;
|
||||
default:
|
||||
throw new ExpInvalidTypeException(
|
||||
"Builtin Type", value!.GetType().Name );
|
||||
}
|
||||
ExpCompile.KeyWord.Int, out ExpTypeSource? type ) ?
|
||||
type : throw new ExpCompileNotInitializedException();
|
||||
|
||||
public int Value => _value;
|
||||
|
||||
public override string TypeName => ExpCompile.KeyWord.Int;
|
||||
|
||||
}
|
||||
|
||||
public override ExpNode Left => Empty;
|
||||
public class ExpStringNode : ExpElementInstanceBase
|
||||
{
|
||||
|
||||
public override ExpNode Right => throw new NotImplementedException();
|
||||
private readonly string _value;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => _type;
|
||||
public ExpStringNode( Token source, string value )
|
||||
: base( source )
|
||||
{
|
||||
_value = value;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_String | ExpNodeFlag.Element_Type;
|
||||
}
|
||||
|
||||
public override string TypeName => _type.Name;
|
||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||
.TryGetType(
|
||||
ExpCompile.KeyWord.String,
|
||||
out ExpTypeSource? type ) ?
|
||||
type : throw new ExpCompileNotInitializedException();
|
||||
|
||||
public T value => _value;
|
||||
public override string TypeName => EqualityTypeConvert.Name;
|
||||
|
||||
public string Value => _value;
|
||||
|
||||
}
|
||||
|
||||
public class ExpBoolNode : ExpElementInstanceBase
|
||||
{
|
||||
|
||||
private readonly bool _value;
|
||||
|
||||
public ExpBoolNode( Token source, bool value )
|
||||
: base( source )
|
||||
{
|
||||
_value = value;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_Boolean | ExpNodeFlag.Element_Type;
|
||||
}
|
||||
|
||||
public bool Value => _value;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||
.TryGetType(
|
||||
ExpCompile.KeyWord.Bool, out ExpTypeSource? type ) ?
|
||||
type : throw new ExpCompileNotInitializedException();
|
||||
|
||||
public override string TypeName => EqualityTypeConvert.Name;
|
||||
|
||||
}
|
||||
|
||||
public class ExpRealNumberNode : ExpElementInstanceBase
|
||||
{
|
||||
|
||||
private readonly float _value;
|
||||
|
||||
public ExpRealNumberNode( Token source, float value )
|
||||
: base( source )
|
||||
{
|
||||
_value = value;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_Real | ExpNodeFlag.Element_Type;
|
||||
}
|
||||
|
||||
public float Value => _value;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||
.TryGetType(
|
||||
ExpCompile.KeyWord.String,
|
||||
out ExpTypeSource? type ) ?
|
||||
type : throw new ExpCompileNotInitializedException();
|
||||
|
||||
public override string TypeName => EqualityTypeConvert.Name;
|
||||
|
||||
}
|
||||
|
||||
public class ExpLogicValueNode : ExpElementInstanceBase
|
||||
{
|
||||
|
||||
private readonly ExpLogic _value;
|
||||
|
||||
public ExpLogicValueNode( Token source, ExpLogic value )
|
||||
: base( source )
|
||||
{
|
||||
_value = value;
|
||||
_nodeFlag = ExpNodeFlag.BuiltinType_Logic | ExpNodeFlag.Element_Type;
|
||||
}
|
||||
|
||||
public ExpLogic Value => _value;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => ExpSchema.BuiltinSchema
|
||||
.TryGetType(
|
||||
ExpCompile.KeyWord.Logic,
|
||||
out ExpTypeSource? type ) ?
|
||||
type : throw new ExpCompileNotInitializedException();
|
||||
|
||||
public override string TypeName => EqualityTypeConvert.Name;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,14 +46,13 @@ namespace StgSharp.Script.Express
|
||||
private ExpNode _operationBegin;
|
||||
|
||||
public ExpRepeatToken(
|
||||
string name,
|
||||
ExpSchema context,
|
||||
Token source,
|
||||
ExpNode operationBegin,
|
||||
ExpElementInstanceBase variable,
|
||||
ExpElementInstanceBase begin,
|
||||
ExpElementInstanceBase end,
|
||||
ExpElementInstanceBase increment )
|
||||
: base( name )
|
||||
: base( source )
|
||||
{
|
||||
if( variable.NodeFlag != begin.NodeFlag || begin.NodeFlag !=
|
||||
end.NodeFlag || ( increment != null && end.NodeFlag !=
|
||||
@@ -62,13 +61,19 @@ namespace StgSharp.Script.Express
|
||||
}
|
||||
if( increment == null ) {
|
||||
switch( ( ExpNodeFlag )variable.NodeFlag | ExpNodeFlag.BuiltinType_Any ) {
|
||||
case ExpNodeFlag.BuiltinType_Float:
|
||||
case ExpNodeFlag.BuiltinType_Real:
|
||||
increment = new ExpLiteralGenericNode<float>(
|
||||
$"{name}_defaultIncrement", 1.0f );
|
||||
new Token(
|
||||
ExpCompile.PoolString( "1.0f" ), source.Line,
|
||||
-1, TokenFlag.Number ),
|
||||
1.0f );
|
||||
break;
|
||||
case ExpNodeFlag.BuiltinType_Int:
|
||||
increment = new ExpLiteralGenericNode<int>(
|
||||
$"{name}_defaultIncrement", 1 );
|
||||
new Token(
|
||||
ExpCompile.PoolString( "1" ), source.Line, -1,
|
||||
TokenFlag.Number ),
|
||||
1 );
|
||||
break;
|
||||
default:
|
||||
throw new ExpInvalidTypeException(
|
||||
|
||||
@@ -42,12 +42,11 @@ namespace StgSharp.Script.Express
|
||||
private ExpNode _target;
|
||||
|
||||
public ExpSwitchNode(
|
||||
string name,
|
||||
ExpSchema context,
|
||||
Token source,
|
||||
ExpNode target,
|
||||
ExpNode defaultCase,
|
||||
params (ExpNode label, ExpNode op)[] cases )
|
||||
: base( name )
|
||||
: base( source )
|
||||
{
|
||||
_target = target;
|
||||
_default = defaultCase;
|
||||
|
||||
@@ -41,13 +41,13 @@ namespace StgSharp.Script.Express
|
||||
|
||||
private ExpNode _operand;
|
||||
|
||||
private ExpUnaryOperatorNode( string name ) : base( name ) { }
|
||||
private ExpUnaryOperatorNode( Token source ) : base( source ) { }
|
||||
|
||||
public ExpUnaryOperatorNode(
|
||||
string name,
|
||||
Token source,
|
||||
ExpNode operand,
|
||||
ExpSchema context )
|
||||
: base( name )
|
||||
: base( source )
|
||||
{
|
||||
_operand = operand;
|
||||
}
|
||||
@@ -58,44 +58,50 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => _operand.EqualityTypeConvert;
|
||||
|
||||
public static ExpUnaryOperatorNode UnaryMinus( ExpNode operand )
|
||||
public static ExpUnaryOperatorNode UnaryMinus(
|
||||
Token source,
|
||||
ExpNode operand )
|
||||
{
|
||||
if( !operand.IsNumber ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
"Number", operand.EqualityTypeConvert.Name );
|
||||
}
|
||||
bool isFloat =
|
||||
( operand._nodeFlag | ExpNodeFlag.BuiltinType_Float ) == 0;
|
||||
return new ExpUnaryOperatorNode( ExpCompile.KeyWord.SUB )
|
||||
( operand._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
|
||||
return new ExpUnaryOperatorNode( source )
|
||||
{
|
||||
_nodeFlag = ExpNodeFlag.Operator_Unary | ExpNodeFlag.BuiltinType_Number,
|
||||
CodeConvertTemplate = "- {0}",
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpUnaryOperatorNode UnaryNot( ExpNode operand )
|
||||
public static ExpUnaryOperatorNode UnaryNot(
|
||||
Token source,
|
||||
ExpNode operand )
|
||||
{
|
||||
if( ( operand._nodeFlag | ( ExpNodeFlag.BuiltinType_Logic | ExpNodeFlag.BuiltinType_Logic ) ) ==
|
||||
0 ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
"Bool or Logic", operand.EqualityTypeConvert.Name );
|
||||
}
|
||||
return new ExpUnaryOperatorNode( ExpCompile.KeyWord.NOT )
|
||||
return new ExpUnaryOperatorNode( source )
|
||||
{
|
||||
_nodeFlag = ExpNodeFlag.Operator_Unary | ExpNodeFlag.BuiltinType_Logic,
|
||||
CodeConvertTemplate = "! {0}",
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpUnaryOperatorNode UnaryPlus( ExpNode operand )
|
||||
public static ExpUnaryOperatorNode UnaryPlus(
|
||||
Token source,
|
||||
ExpNode operand )
|
||||
{
|
||||
if( !operand.IsNumber ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
"Number", operand.EqualityTypeConvert.Name );
|
||||
}
|
||||
bool isFloat =
|
||||
( operand._nodeFlag | ExpNodeFlag.BuiltinType_Float ) == 0;
|
||||
return new ExpUnaryOperatorNode( ExpCompile.KeyWord.SUB )
|
||||
( operand._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
|
||||
return new ExpUnaryOperatorNode( source )
|
||||
{
|
||||
_nodeFlag = ExpNodeFlag.Operator_Unary | ExpNodeFlag.BuiltinType_Number,
|
||||
CodeConvertTemplate = "+ {0}",
|
||||
|
||||
@@ -41,11 +41,11 @@ namespace StgSharp.Script.Express
|
||||
{
|
||||
|
||||
protected internal ExpNodeFlag _nodeFlag;
|
||||
protected internal string _name;
|
||||
protected internal Token _source;
|
||||
|
||||
protected ExpNode( string name )
|
||||
protected ExpNode( Token source )
|
||||
{
|
||||
_name = name;
|
||||
_source = source;
|
||||
Next = this;
|
||||
Previous = this;
|
||||
}
|
||||
@@ -87,6 +87,10 @@ namespace StgSharp.Script.Express
|
||||
get;
|
||||
}
|
||||
|
||||
public int Line => _source.Line;
|
||||
|
||||
public int Column => _source.Column;
|
||||
|
||||
public long NodeFlag => ( long )_nodeFlag;
|
||||
|
||||
public string CodeConvertTemplate
|
||||
@@ -114,9 +118,15 @@ namespace StgSharp.Script.Express
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static ExpNode NonOperation( string name )
|
||||
public static ExpNode NonOperation( Token source )
|
||||
{
|
||||
return new ExpEmptyNode( name );
|
||||
return new ExpEmptyNode( source.Line, source.Column );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static ExpNode NonOperation( int line, int column )
|
||||
{
|
||||
return new ExpEmptyNode( line, column );
|
||||
}
|
||||
|
||||
public void PrependNode( ExpNode previousNode )
|
||||
@@ -146,9 +156,11 @@ namespace StgSharp.Script.Express
|
||||
|
||||
internal static readonly ExpEmptyNode _only = new();
|
||||
|
||||
public ExpEmptyNode() : base( string.Empty ) { }
|
||||
public ExpEmptyNode() : base( Token.Empty ) { }
|
||||
|
||||
public ExpEmptyNode( string name ) : base( name ) { }
|
||||
public ExpEmptyNode( int line, int column )
|
||||
: base(
|
||||
new Token( string.Empty, line, column, TokenFlag.None ) ) { }
|
||||
|
||||
public override ExpInstantiableElement EqualityTypeConvert => ExpInstantiableElement.Void;
|
||||
|
||||
|
||||
@@ -56,17 +56,36 @@ namespace StgSharp.Script.Express
|
||||
public abstract class ExpElementInstanceBase : ExpNode
|
||||
{
|
||||
|
||||
protected ExpElementInstanceBase( string name ) : base( name ) { }
|
||||
protected ExpElementInstanceBase( Token source ) : base( source ) { }
|
||||
|
||||
public ExpElementType ElementType
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public override ExpNode Left => Empty;
|
||||
|
||||
public override ExpNode Right => Empty;
|
||||
|
||||
public abstract string TypeName
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public static ExpElementInstanceBase CreateLiteral( Token t )
|
||||
{
|
||||
if( int.TryParse( t.Value, out int _int ) ) {
|
||||
return new ExpIntNode( t, _int );
|
||||
} else if( float.TryParse( t.Value, out float _float ) ) {
|
||||
return new ExpRealNumberNode( t, _float );
|
||||
} else if( bool.TryParse( t.Value, out bool _bool ) ) {
|
||||
return new ExpBoolNode( t, _bool );
|
||||
} else if( ExpLogic.TryParse( t.Value, out ExpLogic _logic ) ) {
|
||||
return new ExpLogicValueNode( t, _logic );
|
||||
} else {
|
||||
return new ExpStringNode( t, t.Value );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public ExpCaseNotFoundException( ExpSwitchNode token, ExpNode label )
|
||||
: base(
|
||||
$"Attempt to read or write the label {label.Name} not exist in SWITCH expression {token.Name}" ) { }
|
||||
$"Attempt to read or write the label at ({token.Line},{token.Column}), that does not exist in SWITCH expression at ({token.Line},{token.Column})" ) { }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -66,13 +66,13 @@ namespace StgSharp.Script.Express
|
||||
|
||||
//variable is one of these builtin type
|
||||
BuiltinType_Int = 16384,
|
||||
BuiltinType_Float = 32768,
|
||||
BuiltinType_Real = 32768,
|
||||
BuiltinType_String = 65536,
|
||||
BuiltinType_Boolean = 0x2000,
|
||||
BuiltinType_Binary = 0x4000,
|
||||
BuiltinType_Logic = 0x8000,
|
||||
BuiltinType_Number = BuiltinType_Float | BuiltinType_Int,
|
||||
BuiltinType_Any = BuiltinType_Int | BuiltinType_Float | BuiltinType_String | BuiltinType_Boolean | BuiltinType_Binary | BuiltinType_Logic,
|
||||
BuiltinType_Number = BuiltinType_Real | BuiltinType_Int,
|
||||
BuiltinType_Any = BuiltinType_Int | BuiltinType_Real | BuiltinType_String | BuiltinType_Boolean | BuiltinType_Binary | BuiltinType_Logic,
|
||||
|
||||
//the token is root of a branch
|
||||
Branch_If = 0x1_000,
|
||||
|
||||
@@ -65,27 +65,23 @@ namespace StgSharp.Script.Express
|
||||
/// <summary>
|
||||
/// Compile a parameter expression and add it to head of function parameter node list.
|
||||
/// </summary>
|
||||
private void MergeFunctionCallingParameter()
|
||||
private void MergeFunctionCallingParameter( Token currentSeparator )
|
||||
{
|
||||
if( _cache.OperandAheadOfDepth == 1 ) {
|
||||
if( _cache.PopOperand( out Token t, out ExpNode? n ) ) {
|
||||
n!.PrependNode(
|
||||
ExpNode.NonOperation( PoolString( "FuncParam" ) ) );
|
||||
n!.PrependNode( ExpNode.NonOperation( currentSeparator ) );
|
||||
} else {
|
||||
switch( t.Flag ) {
|
||||
case TokenFlag.Number:
|
||||
if( int.TryParse( t.Value, out int intVal ) ) {
|
||||
n = new ExpLiteralGenericNode<int>(
|
||||
t.Value, intVal );
|
||||
n = new ExpIntNode( t, intVal );
|
||||
} else if( float.TryParse(
|
||||
t.Value, out float floatVal ) ) {
|
||||
n = new ExpLiteralGenericNode<float>(
|
||||
t.Value, floatVal );
|
||||
n = new ExpRealNumberNode( t, floatVal );
|
||||
}
|
||||
break;
|
||||
case TokenFlag.String:
|
||||
n = new ExpLiteralGenericNode<string>(
|
||||
t.Value, t.Value );
|
||||
n = new ExpStringNode( t, t.Value );
|
||||
break;
|
||||
case TokenFlag.Member:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="GenerateOperatorToken.cs"
|
||||
// file="ExpNodeGenerator.Operator.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -54,16 +54,16 @@ namespace StgSharp.Script.Express
|
||||
ExpNode right = GetNextOperandCache();
|
||||
switch( t.Value ) {
|
||||
case ExpCompile.KeyWord.ADD:
|
||||
node = ExpBinaryOperatorNode.Add( left, right );
|
||||
node = ExpBinaryOperatorNode.Add( t, left, right );
|
||||
return true;
|
||||
case ExpCompile.KeyWord.SUB:
|
||||
node = ExpBinaryOperatorNode.Sub( left, right );
|
||||
node = ExpBinaryOperatorNode.Sub( t, left, right );
|
||||
return true;
|
||||
case ExpCompile.KeyWord.MUL:
|
||||
node = ExpBinaryOperatorNode.Mul( left, right );
|
||||
node = ExpBinaryOperatorNode.Mul( t, left, right );
|
||||
return true;
|
||||
case ExpCompile.KeyWord.DIV:
|
||||
node = ExpBinaryOperatorNode.Div( left, right );
|
||||
node = ExpBinaryOperatorNode.Div( t, left, right );
|
||||
return true;
|
||||
default:
|
||||
node = ExpNode.Empty;
|
||||
@@ -76,13 +76,13 @@ namespace StgSharp.Script.Express
|
||||
ExpNode operand = GetNextOperandCache();
|
||||
switch( t.Value ) {
|
||||
case ExpCompile.KeyWord.UnaryPlus:
|
||||
node = ExpUnaryOperatorNode.UnaryPlus( operand );
|
||||
node = ExpUnaryOperatorNode.UnaryPlus( t, operand );
|
||||
return true;
|
||||
case ExpCompile.KeyWord.UnaryMinus:
|
||||
node = ExpUnaryOperatorNode.UnaryMinus( operand );
|
||||
node = ExpUnaryOperatorNode.UnaryMinus( t, operand );
|
||||
return true;
|
||||
case ExpCompile.KeyWord.NOT:
|
||||
node = ExpUnaryOperatorNode.UnaryNot( operand );
|
||||
node = ExpUnaryOperatorNode.UnaryNot( t, operand );
|
||||
return true;
|
||||
default:
|
||||
node = ExpNode.Empty;
|
||||
|
||||
@@ -80,7 +80,8 @@ namespace StgSharp.Script.Express
|
||||
_cache.PushOperand( expToken );
|
||||
break;
|
||||
case TokenFlag.Separator_Single: //a , ; found
|
||||
//if operator stack is not empty, convert all operators to node until meet a separator
|
||||
// if operator stack is not empty, convert all operators to node until meet a same separator
|
||||
// or OperandAheadOfSeparator property is less than certain value
|
||||
break;
|
||||
case TokenFlag.Separator_Left: //a ( [ { found
|
||||
_cache.PushOperator( expToken );
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Script")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+df321a3bae3d97d043473f4595cc8d229d0f2722")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6f494f25eff44526a1e002d5ebeab8cf7b86a51d")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Script")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Script")]
|
||||
[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/df321a3bae3d97d043473f4595cc8d229d0f2722/*"}}
|
||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/6f494f25eff44526a1e002d5ebeab8cf7b86a51d/*"}}
|
||||
Reference in New Issue
Block a user