Daily update on 20250420-041137 by Nitload Youmu. Additional Message : Change: pipeline nodes use port to connect instead of connctors, this make send to multi-ports and recieve from multi-ports possible.
Remove: Some types in Pipeline namepace removed sueto no need for connectors Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -37,8 +37,7 @@ using System.Xml.Schema;
|
||||
|
||||
namespace StgSharp.Script
|
||||
{
|
||||
public sealed class AbstractSyntaxTree<TNode, TType>
|
||||
where TNode: IASTNode<TNode, TType>
|
||||
public sealed class AbstractSyntaxTree<TNode, TType> where TNode: ISyntaxNode<TNode, TType>
|
||||
where TType: ITypeSource<TType>
|
||||
{
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script
|
||||
{
|
||||
public partial class CompileStack<TNode, TType> where TNode: IASTNode<TNode, TType>
|
||||
public partial class CompileStack<TNode, TType> where TNode: ISyntaxNode<TNode, TType>
|
||||
where TType: ITypeSource<TType>
|
||||
{
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ISyntaxNode.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.Collections;
|
||||
using StgSharp.Script.Express;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Script
|
||||
{
|
||||
public interface ISyntaxNode<TNode, TType> where TNode: ISyntaxNode<TNode, TType>
|
||||
where TType: ITypeSource<TType>
|
||||
{
|
||||
|
||||
long NodeFlag { get; }
|
||||
|
||||
string CodeConvertTemplate { get; }
|
||||
|
||||
TNode Previous { get; set; }
|
||||
|
||||
TNode Next { get; set; }
|
||||
|
||||
TNode Left { get; }
|
||||
|
||||
TNode Right { get; }
|
||||
|
||||
static abstract TNode Empty { get; }
|
||||
|
||||
Token Source { get; }
|
||||
|
||||
TType EqualityTypeConvert { get; }
|
||||
|
||||
void AppendNode( TNode nextToken );
|
||||
|
||||
void PrependNode( TNode previusNode );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -65,9 +65,9 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public abstract IEnumerator<ExpElementInstance> GetEnumerator();
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
|
||||
{
|
||||
memberNode = ExpNode.Empty;
|
||||
memberNode = ExpSyntaxNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public override string Name => ExpressCompile.PoolString( "ARRAY" );
|
||||
|
||||
public override ExpNode CreateInstanceNode( Token t )
|
||||
public override ExpSyntaxNode CreateInstanceNode( Token t )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -126,7 +126,7 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public override string Name => ExpressCompile.PoolString( "BAG" );
|
||||
|
||||
public override ExpNode CreateInstanceNode( Token t )
|
||||
public override ExpSyntaxNode CreateInstanceNode( Token t )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -149,7 +149,7 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public override string Name => ExpressCompile.PoolString( "LIST" );
|
||||
|
||||
public override ExpNode CreateInstanceNode( Token t )
|
||||
public override ExpSyntaxNode CreateInstanceNode( Token t )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -180,7 +180,7 @@ namespace StgSharp.Script.Express
|
||||
_collection.Add( token );
|
||||
}
|
||||
|
||||
public override ExpNode CreateInstanceNode( Token t )
|
||||
public override ExpSyntaxNode CreateInstanceNode( Token t )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public abstract class ExpCollectionInstanceBase : ExpNode
|
||||
public abstract class ExpCollectionInstanceBase : ExpSyntaxNode
|
||||
{
|
||||
|
||||
protected internal (int min, int max) _range;
|
||||
@@ -42,19 +42,16 @@ namespace StgSharp.Script.Express
|
||||
|
||||
protected ExpCollectionInstanceBase( Token source ) : base( source ) { }
|
||||
|
||||
public abstract ExpCollectionBase CollectionValue
|
||||
{
|
||||
get;
|
||||
}
|
||||
public abstract ExpCollectionBase CollectionValue { get; }
|
||||
|
||||
public ExpElementType MemberType
|
||||
{
|
||||
get => _memberType;
|
||||
}
|
||||
|
||||
public override ExpNode Left => null!;
|
||||
public override ExpSyntaxNode Left => null!;
|
||||
|
||||
public override ExpNode Right => null!;
|
||||
public override ExpSyntaxNode Right => null!;
|
||||
|
||||
public int MinCapacity => _range.min;
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace StgSharp.Script.Express
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override ExpNode MakeReference( params object[] options )
|
||||
public override ExpSyntaxNode MakeReference( params object[] options )
|
||||
{
|
||||
if( options.Length == 0 || options[ 0 ] is not string str ) {
|
||||
return null!;
|
||||
@@ -84,14 +84,14 @@ namespace StgSharp.Script.Express
|
||||
return _constants.TryGetValue( name, out instance );
|
||||
}
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
|
||||
{
|
||||
if( _constants.TryGetValue( name, out ExpElementInstance? node ) )
|
||||
{
|
||||
memberNode = node;
|
||||
return true;
|
||||
}
|
||||
memberNode = ExpNode.Empty;
|
||||
memberNode = ExpSyntaxNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace StgSharp.Script.Express
|
||||
public class ExpEntitySource : ExpInstantiableElement
|
||||
{
|
||||
|
||||
private AbstractSyntaxTree<ExpNode, IExpElementSource> _expressionTree;
|
||||
private AbstractSyntaxTree<ExpSyntaxNode, IExpElementSource> _expressionTree;
|
||||
private ScriptSourceTransmitter _source;
|
||||
private string _name;
|
||||
|
||||
@@ -58,12 +58,12 @@ namespace StgSharp.Script.Express
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override ExpNode CreateInstanceNode( Token t )
|
||||
public override ExpSyntaxNode CreateInstanceNode( Token t )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -70,12 +70,12 @@ namespace StgSharp.Script.Express
|
||||
*/
|
||||
}
|
||||
|
||||
public override ExpNode MakeReference( params object[] options )
|
||||
public override ExpSyntaxNode MakeReference( params object[] options )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
|
||||
{
|
||||
if( FuncParams.TryGetValue( name, out ExpElementInstance? param ) )
|
||||
{
|
||||
@@ -87,7 +87,7 @@ namespace StgSharp.Script.Express
|
||||
memberNode = variable;
|
||||
return true;
|
||||
}
|
||||
memberNode = ExpNode.Empty;
|
||||
memberNode = ExpSyntaxNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,12 +50,12 @@ namespace StgSharp.Script.Express
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override ExpNode MakeReference( params object[] options )
|
||||
public override ExpSyntaxNode MakeReference( params object[] options )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ namespace StgSharp.Script.Express
|
||||
public override ExpInstantiableElement EqualityTypeConvert => throw new NotImplementedException(
|
||||
);
|
||||
|
||||
public override ExpNode Left => throw new NotImplementedException();
|
||||
public override ExpSyntaxNode Left => throw new NotImplementedException();
|
||||
|
||||
public override ExpNode Right => throw new NotImplementedException();
|
||||
public override ExpSyntaxNode Right => throw new NotImplementedException();
|
||||
|
||||
public override string TypeName => _source.Name;
|
||||
|
||||
@@ -79,14 +79,14 @@ namespace StgSharp.Script.Express
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override ExpNode MakeReference( params object[] options )
|
||||
public override ExpSyntaxNode MakeReference( params object[] options )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
|
||||
{
|
||||
memberNode = ExpNode.Empty;
|
||||
memberNode = ExpSyntaxNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,9 +87,9 @@ namespace StgSharp.Script.Express
|
||||
return type == null || type == ExpVoidType.Only;
|
||||
}
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
|
||||
{
|
||||
memberNode = ExpNode.Empty;
|
||||
memberNode = ExpSyntaxNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,15 +40,15 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpBinaryOperatorNode : ExpNode
|
||||
public class ExpBinaryOperatorNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
private ExpInstantiableElement _returnType;
|
||||
|
||||
private ExpNode _left;
|
||||
private ExpNode _right;
|
||||
private ExpSyntaxNode _left;
|
||||
private ExpSyntaxNode _right;
|
||||
|
||||
private ExpBinaryOperatorNode( Token source, ExpNode left, ExpNode right )
|
||||
private ExpBinaryOperatorNode( Token source, ExpSyntaxNode left, ExpSyntaxNode right )
|
||||
: base( source )
|
||||
{
|
||||
_left = left;
|
||||
@@ -57,11 +57,14 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public override ExpInstantiableElement EqualityTypeConvert => _returnType;
|
||||
|
||||
public override ExpNode Left => _left;
|
||||
public override ExpSyntaxNode Left => _left;
|
||||
|
||||
public override ExpNode Right => _right;
|
||||
public override ExpSyntaxNode Right => _right;
|
||||
|
||||
public static ExpBinaryOperatorNode Add( Token source, ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode Add(
|
||||
Token source,
|
||||
ExpSyntaxNode left,
|
||||
ExpSyntaxNode right )
|
||||
{
|
||||
if( !left.IsNumber && !right.IsNumber ) {
|
||||
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
|
||||
@@ -77,7 +80,10 @@ namespace StgSharp.Script.Express
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpBinaryOperatorNode Assign( Token source, ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode Assign(
|
||||
Token source,
|
||||
ExpSyntaxNode left,
|
||||
ExpSyntaxNode right )
|
||||
{
|
||||
if( left.EqualityTypeConvert != right.EqualityTypeConvert ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
@@ -93,8 +99,8 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public static ExpBinaryOperatorNode CompareInstanceEqual(
|
||||
Token source,
|
||||
ExpNode left,
|
||||
ExpNode right )
|
||||
ExpSyntaxNode left,
|
||||
ExpSyntaxNode right )
|
||||
{
|
||||
return new ExpBinaryOperatorNode( source, left, right )
|
||||
{
|
||||
@@ -106,8 +112,8 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public static ExpBinaryOperatorNode CompareInstanceNotEqual(
|
||||
Token nsource,
|
||||
ExpNode left,
|
||||
ExpNode right )
|
||||
ExpSyntaxNode left,
|
||||
ExpSyntaxNode right )
|
||||
{
|
||||
return new ExpBinaryOperatorNode( nsource, left, right )
|
||||
{
|
||||
@@ -119,8 +125,8 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public static ExpBinaryOperatorNode ConvertElement(
|
||||
Token source,
|
||||
ExpNode left,
|
||||
ExpNode right )
|
||||
ExpSyntaxNode left,
|
||||
ExpSyntaxNode right )
|
||||
{
|
||||
if( right is not ExpMetaRefNode metaref ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
@@ -138,7 +144,10 @@ namespace StgSharp.Script.Express
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpBinaryOperatorNode Div( Token source, ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode Div(
|
||||
Token source,
|
||||
ExpSyntaxNode left,
|
||||
ExpSyntaxNode right )
|
||||
{
|
||||
if( !left.IsNumber && !right.IsNumber ) {
|
||||
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
|
||||
@@ -154,7 +163,10 @@ namespace StgSharp.Script.Express
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpBinaryOperatorNode EqualTo( Token source, ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode EqualTo(
|
||||
Token source,
|
||||
ExpSyntaxNode left,
|
||||
ExpSyntaxNode right )
|
||||
{
|
||||
if( left.EqualityTypeConvert != right.EqualityTypeConvert ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
@@ -168,7 +180,10 @@ namespace StgSharp.Script.Express
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpBinaryOperatorNode GreaterThan( Token source, ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode GreaterThan(
|
||||
Token source,
|
||||
ExpSyntaxNode left,
|
||||
ExpSyntaxNode right )
|
||||
{
|
||||
if( !left.IsNumber && !right.IsNumber ) {
|
||||
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
|
||||
@@ -181,7 +196,10 @@ namespace StgSharp.Script.Express
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpBinaryOperatorNode LessThan( Token source, ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode LessThan(
|
||||
Token source,
|
||||
ExpSyntaxNode left,
|
||||
ExpSyntaxNode right )
|
||||
{
|
||||
if( !left.IsNumber && !right.IsNumber ) {
|
||||
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
|
||||
@@ -194,7 +212,10 @@ namespace StgSharp.Script.Express
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpBinaryOperatorNode Mul( Token source, ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode Mul(
|
||||
Token source,
|
||||
ExpSyntaxNode left,
|
||||
ExpSyntaxNode right )
|
||||
{
|
||||
if( !left.IsNumber && !right.IsNumber ) {
|
||||
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
|
||||
@@ -210,7 +231,10 @@ namespace StgSharp.Script.Express
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpBinaryOperatorNode NotEqualTo( Token source, ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode NotEqualTo(
|
||||
Token source,
|
||||
ExpSyntaxNode left,
|
||||
ExpSyntaxNode right )
|
||||
{
|
||||
if( left.EqualityTypeConvert != right.EqualityTypeConvert ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
@@ -224,7 +248,10 @@ namespace StgSharp.Script.Express
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpBinaryOperatorNode SmallerThan( Token source, ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode SmallerThan(
|
||||
Token source,
|
||||
ExpSyntaxNode left,
|
||||
ExpSyntaxNode right )
|
||||
{
|
||||
if( !left.IsNumber && !right.IsNumber ) {
|
||||
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
|
||||
@@ -237,7 +264,10 @@ namespace StgSharp.Script.Express
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpBinaryOperatorNode Sub( Token source, ExpNode left, ExpNode right )
|
||||
public static ExpBinaryOperatorNode Sub(
|
||||
Token source,
|
||||
ExpSyntaxNode left,
|
||||
ExpSyntaxNode right )
|
||||
{
|
||||
if( !left.IsNumber && !right.IsNumber ) {
|
||||
throw new ExpInvalidTypeException( "Number", left.EqualityTypeConvert.Name );
|
||||
|
||||
@@ -36,17 +36,17 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpCollectionIndexNode : ExpNode
|
||||
public class ExpCollectionIndexNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
private ExpCollectionInstanceBase _collection;
|
||||
|
||||
private ExpNode _indexExpression;
|
||||
private ExpSyntaxNode _indexExpression;
|
||||
|
||||
private ExpCollectionIndexNode(
|
||||
Token source,
|
||||
ExpCollectionInstanceBase instance,
|
||||
ExpNode indexExpression )
|
||||
Token source,
|
||||
ExpCollectionInstanceBase instance,
|
||||
ExpSyntaxNode indexExpression )
|
||||
: base( source )
|
||||
{
|
||||
_collection = instance;
|
||||
@@ -54,23 +54,22 @@ namespace StgSharp.Script.Express
|
||||
CodeConvertTemplate = @"{0}[{1}]";
|
||||
}
|
||||
|
||||
public override ExpNode Left => _collection;
|
||||
public override ExpSyntaxNode Left => _collection;
|
||||
|
||||
public override ExpNode Right => _indexExpression;
|
||||
public override ExpSyntaxNode Right => _indexExpression;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => _collection.EqualityTypeConvert;
|
||||
|
||||
public static ExpCollectionIndexNode Create(
|
||||
Token source,
|
||||
ExpCollectionInstanceBase instance,
|
||||
ExpNode indexExpression )
|
||||
Token source,
|
||||
ExpCollectionInstanceBase instance,
|
||||
ExpSyntaxNode indexExpression )
|
||||
{
|
||||
if( !indexExpression.IsNumber ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
"Number", indexExpression.EqualityTypeConvert.Name );
|
||||
}
|
||||
return new ExpCollectionIndexNode(
|
||||
source, instance, indexExpression );
|
||||
return new ExpCollectionIndexNode( source, instance, indexExpression );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,25 +36,25 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpElementInitializingNode : ExpNode
|
||||
public class ExpElementInitializingNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
private ExpMetaRefNode _type;
|
||||
private ExpNode _init;
|
||||
private ExpSyntaxNode _init;
|
||||
|
||||
public ExpElementInitializingNode(
|
||||
Token source,
|
||||
ExpMetaRefNode type,
|
||||
ExpNode initParameter )
|
||||
ExpSyntaxNode initParameter )
|
||||
: base( source )
|
||||
{
|
||||
_type = type;
|
||||
_init = initParameter;
|
||||
}
|
||||
|
||||
public override ExpNode Left => _type;
|
||||
public override ExpSyntaxNode Left => _type;
|
||||
|
||||
public override ExpNode Right => _init;
|
||||
public override ExpSyntaxNode Right => _init;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => _type.SourceRef;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpElementMemberNameNode : ExpNode
|
||||
public class ExpElementMemberNameNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
internal ExpElementMemberNameNode( Token source )
|
||||
@@ -46,9 +46,9 @@ namespace StgSharp.Script.Express
|
||||
CodeConvertTemplate = source.Value;
|
||||
}
|
||||
|
||||
public override ExpNode Left => Empty;
|
||||
public override ExpSyntaxNode Left => Empty;
|
||||
|
||||
public override ExpNode Right => Empty;
|
||||
public override ExpSyntaxNode Right => Empty;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert
|
||||
{
|
||||
|
||||
@@ -36,31 +36,33 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpFunctionCallingNode : ExpNode
|
||||
public class ExpFunctionCallingNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
private ExpFunctionSource _function;
|
||||
|
||||
private ExpNode _parameter;
|
||||
private ExpSyntaxNode _parameter;
|
||||
|
||||
private ExpFunctionCallingNode(
|
||||
Token source,
|
||||
ExpFunctionSource function,
|
||||
ExpNode firstParameter )
|
||||
ExpSyntaxNode firstParameter )
|
||||
: base( source )
|
||||
{
|
||||
_function = function;
|
||||
_parameter = firstParameter;
|
||||
}
|
||||
|
||||
public ExpFunctionSource FunctionCaller => _function;
|
||||
|
||||
public override ExpInstantiableElement EqualityTypeConvert => throw new NotImplementedException(
|
||||
);
|
||||
|
||||
public override ExpNode Left => Empty;
|
||||
public override ExpSyntaxNode Left => Empty;
|
||||
|
||||
public override ExpNode Right => _parameter;
|
||||
public override ExpSyntaxNode Right => _parameter;
|
||||
|
||||
public void AppendParameter( ExpNode parameter )
|
||||
public void AppendParameter( ExpSyntaxNode parameter )
|
||||
{
|
||||
_parameter.AppendNode( parameter );
|
||||
}
|
||||
@@ -68,7 +70,7 @@ namespace StgSharp.Script.Express
|
||||
public static ExpFunctionCallingNode CallFunction(
|
||||
Token source,
|
||||
ExpFunctionSource function,
|
||||
ExpNode param )
|
||||
ExpSyntaxNode param )
|
||||
{
|
||||
return new ExpFunctionCallingNode( source, function, param );
|
||||
}
|
||||
|
||||
@@ -36,14 +36,14 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public sealed class ExpIfNode : ExpNode
|
||||
public sealed class ExpIfNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
private ExpNode _falseOpBegin;
|
||||
private ExpNode _rule;
|
||||
private ExpNode _trueOpBegin ;
|
||||
private ExpSyntaxNode _falseOpBegin;
|
||||
private ExpSyntaxNode _rule;
|
||||
private ExpSyntaxNode _trueOpBegin ;
|
||||
|
||||
public ExpIfNode( Token source, ExpNode rule, ExpNode trueOpBegin )
|
||||
public ExpIfNode( Token source, ExpSyntaxNode rule, ExpSyntaxNode trueOpBegin )
|
||||
: base( source )
|
||||
{
|
||||
_rule = rule;
|
||||
@@ -59,9 +59,9 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public ExpIfNode(
|
||||
Token source,
|
||||
ExpNode rule,
|
||||
ExpNode rootOperationIfTrue,
|
||||
ExpNode rootOperationIfFalse )
|
||||
ExpSyntaxNode rule,
|
||||
ExpSyntaxNode rootOperationIfTrue,
|
||||
ExpSyntaxNode rootOperationIfFalse )
|
||||
: base( source )
|
||||
{
|
||||
_rule = rule;
|
||||
@@ -78,18 +78,18 @@ namespace StgSharp.Script.Express
|
||||
""" );
|
||||
}
|
||||
|
||||
public override ExpNode Left => _trueOpBegin;
|
||||
public override ExpSyntaxNode Left => _trueOpBegin;
|
||||
|
||||
public override ExpNode Right => _falseOpBegin;
|
||||
public override ExpSyntaxNode Right => _falseOpBegin;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => null!;
|
||||
|
||||
public void AppendFalseOperation( ExpNode expressionRoot )
|
||||
public void AppendFalseOperation( ExpSyntaxNode expressionRoot )
|
||||
{
|
||||
_falseOpBegin.AppendNode( expressionRoot );
|
||||
}
|
||||
|
||||
public void AppendTrueOperation( ExpNode expressionRoot )
|
||||
public void AppendTrueOperation( ExpSyntaxNode expressionRoot )
|
||||
{
|
||||
_trueOpBegin.AppendNode( expressionRoot );
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpInstanceMemberNode : ExpNode
|
||||
public class ExpInstanceMemberNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
private ExpElementInstance _instance;
|
||||
private ExpElementMemberNameNode _memberName;
|
||||
private ExpNode _member;
|
||||
private ExpSyntaxNode _member;
|
||||
|
||||
public ExpInstanceMemberNode(
|
||||
Token source,
|
||||
@@ -56,9 +56,9 @@ namespace StgSharp.Script.Express
|
||||
_instance.TryGetMember( memberName.CodeConvertTemplate, out _member );
|
||||
}
|
||||
|
||||
public override ExpNode Left => _instance;
|
||||
public override ExpSyntaxNode Left => _instance;
|
||||
|
||||
public override ExpNode Right => _memberName;
|
||||
public override ExpSyntaxNode Right => _memberName;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => _member.EqualityTypeConvert;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpInstanceReferenceNode : ExpNode
|
||||
public class ExpInstanceReferenceNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
internal ExpInstanceReferenceNode( Token source, ExpElementInstance instance )
|
||||
@@ -58,9 +58,9 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public ExpElementInstance OriginObject { get ; private set; }
|
||||
|
||||
public override ExpNode Left => Empty;
|
||||
public override ExpSyntaxNode Left => Empty;
|
||||
|
||||
public override ExpNode Right => Empty;
|
||||
public override ExpSyntaxNode Right => Empty;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => OriginObject.EqualityTypeConvert;
|
||||
|
||||
|
||||
@@ -38,26 +38,29 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpMetaRefNode : ExpNode
|
||||
public class ExpMetaRefNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
internal ExpMetaRefNode( Token source, ExpInstantiableElement element ) : base( source )
|
||||
internal ExpMetaRefNode( Token source, ExpInstantiableElement element )
|
||||
: base( source )
|
||||
{
|
||||
SourceRef = element;
|
||||
}
|
||||
|
||||
public ExpInstantiableElement SourceRef { get; init; }
|
||||
|
||||
public override ExpNode Left => Empty;
|
||||
public override ExpSyntaxNode Left => Empty;
|
||||
|
||||
public override ExpNode Right => Empty;
|
||||
public override ExpSyntaxNode Right => Empty;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => ExpInstantiableElement.Void;
|
||||
|
||||
public static ExpMetaRefNode RefEntity( Token position, ExpEntitySource entity )
|
||||
{
|
||||
if( position.Value != entity.Name ) {
|
||||
throw new ExpCompileException( position, $"Meta data does not match, name of source to match is {entity.Name}, but token is {position.Value}" );
|
||||
throw new ExpCompileException(
|
||||
position,
|
||||
$"Meta data does not match, name of source to match is {entity.Name}, but token is {position.Value}" );
|
||||
}
|
||||
ExpMetaRefNode node = new ExpMetaRefNode( position, entity )
|
||||
{
|
||||
@@ -69,7 +72,9 @@ namespace StgSharp.Script.Express
|
||||
public static ExpMetaRefNode RefType( Token position, ExpTypeSource type )
|
||||
{
|
||||
if( position.Value != type.Name ) {
|
||||
throw new ExpCompileException( position, $"Meta data does not match, name of source to match is {type.Name}, but token is {position.Value}" );
|
||||
throw new ExpCompileException(
|
||||
position,
|
||||
$"Meta data does not match, name of source to match is {type.Name}, but token is {position.Value}" );
|
||||
}
|
||||
ExpMetaRefNode node = new ExpMetaRefNode( position, type )
|
||||
{
|
||||
|
||||
@@ -37,30 +37,33 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpProcedureCallingNode : ExpNode
|
||||
public class ExpProcedureCallingNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
private ExpNode _params;
|
||||
private ExpSyntaxNode _params;
|
||||
|
||||
public ExpProcedureCallingNode( Token source, ExpProcedureSource caller, ExpNode param )
|
||||
public ExpProcedureCallingNode(
|
||||
Token source,
|
||||
ExpProcedureSource caller,
|
||||
ExpSyntaxNode param )
|
||||
: base( source )
|
||||
{
|
||||
_params = param;
|
||||
CalledProcedure = caller;
|
||||
}
|
||||
|
||||
public override ExpNode Left => Empty;
|
||||
|
||||
public override ExpNode Right => _params;
|
||||
|
||||
public ExpProcedureSource CalledProcedure { get; init; }
|
||||
|
||||
public override ExpSyntaxNode Left => Empty;
|
||||
|
||||
public override ExpSyntaxNode Right => _params;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => ExpInstantiableElement.Void;
|
||||
|
||||
public static ExpProcedureCallingNode CallProcedure(
|
||||
Token postion,
|
||||
ExpProcedureSource caller,
|
||||
ExpNode input )
|
||||
ExpSyntaxNode input )
|
||||
{
|
||||
ExpProcedureCallingNode node = new ExpProcedureCallingNode( postion, caller, input )
|
||||
{
|
||||
|
||||
@@ -40,20 +40,20 @@ using ExpKeyword = StgSharp.Script.Express.ExpressCompile.Keyword;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpProcedureControlNode : ExpNode
|
||||
public class ExpProcedureControlNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
private ExpNode _additional;
|
||||
private ExpSyntaxNode _additional;
|
||||
|
||||
internal ExpProcedureControlNode( Token source ) : base( source ) { }
|
||||
|
||||
public override ExpNode Left => Empty;
|
||||
public override ExpSyntaxNode Left => Empty;
|
||||
|
||||
public override ExpNode Right => _additional;
|
||||
public override ExpSyntaxNode Right => _additional;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => ExpTypeSource.Void;
|
||||
|
||||
public static ExpProcedureControlNode Return( Token t, ExpNode valueToReturn )
|
||||
public static ExpProcedureControlNode Return( Token t, ExpSyntaxNode valueToReturn )
|
||||
{
|
||||
if( t.Value != ExpKeyword.Return ) {
|
||||
throw new InvalidCastException();
|
||||
|
||||
@@ -37,21 +37,21 @@ using System.Threading.Channels;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpRepeatNode : ExpNode
|
||||
public class ExpRepeatNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
private ExpElementInstance _variable;
|
||||
private ExpNode _begin, _end, _increment, _operationBegin,_untilRule,_whileRule;
|
||||
private ExpSyntaxNode _begin, _end, _increment, _operationBegin,_untilRule,_whileRule;
|
||||
|
||||
internal ExpRepeatNode(
|
||||
Token source,
|
||||
ExpElementInstance variable,
|
||||
ExpNode begin,
|
||||
ExpNode end,
|
||||
ExpNode increment,
|
||||
ExpNode operationBegin,
|
||||
ExpNode untilRule,
|
||||
ExpNode whileRule )
|
||||
ExpSyntaxNode begin,
|
||||
ExpSyntaxNode end,
|
||||
ExpSyntaxNode increment,
|
||||
ExpSyntaxNode operationBegin,
|
||||
ExpSyntaxNode untilRule,
|
||||
ExpSyntaxNode whileRule )
|
||||
: base( source )
|
||||
{
|
||||
if( variable.NodeFlag != begin.NodeFlag || begin.NodeFlag != end.NodeFlag || ( increment !=
|
||||
@@ -90,13 +90,13 @@ namespace StgSharp.Script.Express
|
||||
_whileRule = whileRule;
|
||||
}
|
||||
|
||||
public override ExpNode Left => throw new NotImplementedException();
|
||||
public override ExpSyntaxNode Left => throw new NotImplementedException();
|
||||
|
||||
public override ExpNode Right => _operationBegin;
|
||||
public override ExpSyntaxNode Right => _operationBegin;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => null!;
|
||||
|
||||
public void AppendRepeatedOperation( ExpNode node )
|
||||
public void AppendRepeatedOperation( ExpSyntaxNode node )
|
||||
{
|
||||
_operationBegin.AppendNode( node );
|
||||
}
|
||||
@@ -126,12 +126,12 @@ namespace StgSharp.Script.Express
|
||||
public static ExpRepeatNode Create(
|
||||
Token t,
|
||||
ExpInstanceReferenceNode repeatVariable,
|
||||
ExpNode begin,
|
||||
ExpNode end,
|
||||
ExpNode increment,
|
||||
ExpNode whileRule,
|
||||
ExpNode untilRule,
|
||||
ExpNode body )
|
||||
ExpSyntaxNode begin,
|
||||
ExpSyntaxNode end,
|
||||
ExpSyntaxNode increment,
|
||||
ExpSyntaxNode whileRule,
|
||||
ExpSyntaxNode untilRule,
|
||||
ExpSyntaxNode body )
|
||||
{
|
||||
untilRule = ExpBoolNode.False( null );
|
||||
whileRule = ExpBoolNode.True( null );
|
||||
@@ -163,12 +163,12 @@ namespace StgSharp.Script.Express
|
||||
public static ExpRepeatNode Create(
|
||||
Token t,
|
||||
ExpElementInstance repeatVariable,
|
||||
ExpNode begin,
|
||||
ExpNode end,
|
||||
ExpNode increment,
|
||||
ExpNode whileRule,
|
||||
ExpNode untilRule,
|
||||
ExpNode body )
|
||||
ExpSyntaxNode begin,
|
||||
ExpSyntaxNode end,
|
||||
ExpSyntaxNode increment,
|
||||
ExpSyntaxNode whileRule,
|
||||
ExpSyntaxNode untilRule,
|
||||
ExpSyntaxNode body )
|
||||
{
|
||||
whileRule = IsNullOrEmpty( whileRule ) ? ExpBoolNode.True( t ) : whileRule;
|
||||
untilRule = IsNullOrEmpty( untilRule ) ? ExpBoolNode.False( t ) : untilRule;
|
||||
|
||||
@@ -35,25 +35,26 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpSwitchNode : ExpNode
|
||||
public class ExpSwitchNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
private ExpNode _default;
|
||||
private ExpNode _target;
|
||||
private ExpSyntaxNode _default;
|
||||
private ExpSyntaxNode _target;
|
||||
|
||||
private FrozenDictionary<ExpNode, ExpNode> _cases;
|
||||
private FrozenDictionary<ExpSyntaxNode, ExpSyntaxNode> _cases;
|
||||
|
||||
public ExpSwitchNode(
|
||||
Token source,
|
||||
ExpNode target,
|
||||
ExpNode defaultCase,
|
||||
params (ExpNode label, ExpNode op)[] cases )
|
||||
ExpSyntaxNode target,
|
||||
ExpSyntaxNode defaultCase,
|
||||
params (ExpSyntaxNode label, ExpSyntaxNode op)[] cases )
|
||||
: base( source )
|
||||
{
|
||||
_target = target;
|
||||
_default = defaultCase;
|
||||
Dictionary<ExpNode, ExpNode> casesDic = new Dictionary<ExpNode, ExpNode>();
|
||||
foreach( (ExpNode label, ExpNode op ) item in cases )
|
||||
Dictionary<ExpSyntaxNode, ExpSyntaxNode> casesDic = new Dictionary<ExpSyntaxNode, ExpSyntaxNode>(
|
||||
);
|
||||
foreach( (ExpSyntaxNode label, ExpSyntaxNode op ) item in cases )
|
||||
{
|
||||
if( item.op == null )
|
||||
{
|
||||
@@ -84,9 +85,9 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public ExpSwitchNode(
|
||||
Token source,
|
||||
ExpNode target,
|
||||
ExpNode defaultCase,
|
||||
IDictionary<ExpNode, ExpNode> cases )
|
||||
ExpSyntaxNode target,
|
||||
ExpSyntaxNode defaultCase,
|
||||
IDictionary<ExpSyntaxNode, ExpSyntaxNode> cases )
|
||||
: base( source )
|
||||
{
|
||||
_target = target;
|
||||
@@ -109,24 +110,24 @@ namespace StgSharp.Script.Express
|
||||
CodeConvertTemplate = codeFormatBuilder.ToString();
|
||||
}
|
||||
|
||||
public ExpNode this[ ExpNode index ]
|
||||
public ExpSyntaxNode this[ ExpSyntaxNode index ]
|
||||
{
|
||||
get
|
||||
{
|
||||
if( _cases.TryGetValue( index, out ExpNode? ret ) ) {
|
||||
if( _cases.TryGetValue( index, out ExpSyntaxNode? ret ) ) {
|
||||
return ret;
|
||||
}
|
||||
return _default;
|
||||
}
|
||||
}
|
||||
|
||||
public override ExpNode Left => Empty;
|
||||
public override ExpSyntaxNode Left => Empty;
|
||||
|
||||
public override ExpNode Right => Empty;
|
||||
public override ExpSyntaxNode Right => Empty;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => null!;
|
||||
|
||||
public bool ContainsCase( ExpNode token )
|
||||
public bool ContainsCase( ExpSyntaxNode token )
|
||||
{
|
||||
return _cases.ContainsKey( token );
|
||||
}
|
||||
|
||||
@@ -36,35 +36,29 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public class ExpUnaryOperatorNode : ExpNode
|
||||
public class ExpUnaryOperatorNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
private ExpNode _operand;
|
||||
private ExpSyntaxNode _operand;
|
||||
|
||||
private ExpUnaryOperatorNode( Token source ) : base( source ) { }
|
||||
|
||||
public ExpUnaryOperatorNode(
|
||||
Token source,
|
||||
ExpNode operand,
|
||||
ExpSchema context )
|
||||
public ExpUnaryOperatorNode( Token source, ExpSyntaxNode operand, ExpSchema context )
|
||||
: base( source )
|
||||
{
|
||||
_operand = operand;
|
||||
}
|
||||
|
||||
public override ExpNode Left => null!;
|
||||
public override ExpSyntaxNode Left => null!;
|
||||
|
||||
public override ExpNode Right => _operand;
|
||||
public override ExpSyntaxNode Right => _operand;
|
||||
|
||||
public override IExpElementSource EqualityTypeConvert => _operand.EqualityTypeConvert;
|
||||
|
||||
public static ExpUnaryOperatorNode UnaryMinus(
|
||||
Token source,
|
||||
ExpNode operand )
|
||||
public static ExpUnaryOperatorNode UnaryMinus( Token source, ExpSyntaxNode operand )
|
||||
{
|
||||
if( !operand.IsNumber ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
"Number", operand.EqualityTypeConvert.Name );
|
||||
throw new ExpInvalidTypeException( "Number", operand.EqualityTypeConvert.Name );
|
||||
}
|
||||
bool isFloat =
|
||||
( operand._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
|
||||
@@ -75,9 +69,7 @@ namespace StgSharp.Script.Express
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpUnaryOperatorNode UnaryNot(
|
||||
Token source,
|
||||
ExpNode operand )
|
||||
public static ExpUnaryOperatorNode UnaryNot( Token source, ExpSyntaxNode operand )
|
||||
{
|
||||
if( ( operand._nodeFlag | ( ExpNodeFlag.BuiltinType_Logic | ExpNodeFlag.BuiltinType_Logic ) ) ==
|
||||
0 ) {
|
||||
@@ -91,13 +83,10 @@ namespace StgSharp.Script.Express
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpUnaryOperatorNode UnaryPlus(
|
||||
Token source,
|
||||
ExpNode operand )
|
||||
public static ExpUnaryOperatorNode UnaryPlus( Token source, ExpSyntaxNode operand )
|
||||
{
|
||||
if( !operand.IsNumber ) {
|
||||
throw new ExpInvalidTypeException(
|
||||
"Number", operand.EqualityTypeConvert.Name );
|
||||
throw new ExpInvalidTypeException( "Number", operand.EqualityTypeConvert.Name );
|
||||
}
|
||||
bool isFloat =
|
||||
( operand._nodeFlag | ExpNodeFlag.BuiltinType_Real ) == 0;
|
||||
|
||||
@@ -39,13 +39,13 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Script.Express
|
||||
{
|
||||
public abstract class ExpNode : IASTNode<ExpNode, IExpElementSource>
|
||||
public abstract class ExpSyntaxNode : ISyntaxNode<ExpSyntaxNode, IExpElementSource>
|
||||
{
|
||||
|
||||
protected internal ExpNodeFlag _nodeFlag;
|
||||
protected internal Token _source;
|
||||
|
||||
protected ExpNode( Token source )
|
||||
protected ExpSyntaxNode( Token source )
|
||||
{
|
||||
_source = source;
|
||||
Next = this;
|
||||
@@ -57,18 +57,18 @@ namespace StgSharp.Script.Express
|
||||
get { return ( _nodeFlag | ExpNodeFlag.BuiltinType_Number ) != 0; }
|
||||
}
|
||||
|
||||
public abstract ExpNode Left { get; }
|
||||
public abstract ExpSyntaxNode Left { get; }
|
||||
|
||||
public static ExpNode Empty
|
||||
public static ExpSyntaxNode Empty
|
||||
{
|
||||
get => ExpEmptyNode._only;
|
||||
}
|
||||
|
||||
public ExpNode Next { get; set; }
|
||||
public ExpSyntaxNode Next { get; set; }
|
||||
|
||||
public abstract ExpNode Right { get; }
|
||||
public abstract ExpSyntaxNode Right { get; }
|
||||
|
||||
public ExpNode Previous { get; set; }
|
||||
public ExpSyntaxNode Previous { get; set; }
|
||||
|
||||
public abstract IExpElementSource EqualityTypeConvert { get; }
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace StgSharp.Script.Express
|
||||
get => _source;
|
||||
}
|
||||
|
||||
public void AppendNode( ExpNode nextNode )
|
||||
public void AppendNode( ExpSyntaxNode nextNode )
|
||||
{
|
||||
Next.Previous = nextNode;
|
||||
nextNode.Next = Next;
|
||||
@@ -93,24 +93,24 @@ namespace StgSharp.Script.Express
|
||||
Next.Previous = this;
|
||||
}
|
||||
|
||||
public static bool IsNullOrEmpty( [AllowNull]ExpNode node )
|
||||
public static bool IsNullOrEmpty( [AllowNull]ExpSyntaxNode node )
|
||||
{
|
||||
return node == ExpEmptyNode._only || node == null;
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static ExpNode NonOperation( Token source )
|
||||
public static ExpSyntaxNode NonOperation( Token source )
|
||||
{
|
||||
return new ExpEmptyNode( source.Line, source.Column );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static ExpNode NonOperation( int line, int column )
|
||||
public static ExpSyntaxNode NonOperation( int line, int column )
|
||||
{
|
||||
return new ExpEmptyNode( line, column );
|
||||
}
|
||||
|
||||
public void PrependNode( ExpNode previousNode )
|
||||
public void PrependNode( ExpSyntaxNode previousNode )
|
||||
{
|
||||
Previous.Next = previousNode;
|
||||
previousNode.Previous = Previous;
|
||||
@@ -118,7 +118,7 @@ namespace StgSharp.Script.Express
|
||||
previousNode.Next = this;
|
||||
}
|
||||
|
||||
public static bool VerifyTypeConvertable( ExpNode left, ExpNode right )
|
||||
public static bool VerifyTypeConvertable( ExpSyntaxNode left, ExpSyntaxNode right )
|
||||
{
|
||||
IExpElementSource tLeft = left.EqualityTypeConvert,
|
||||
tRight = right.EqualityTypeConvert;
|
||||
@@ -132,7 +132,7 @@ namespace StgSharp.Script.Express
|
||||
return tLeft.IsConvertable( tRight );
|
||||
}
|
||||
|
||||
private class ExpEmptyNode : ExpNode
|
||||
private class ExpEmptyNode : ExpSyntaxNode
|
||||
{
|
||||
|
||||
internal static readonly ExpEmptyNode _only = new();
|
||||
@@ -144,9 +144,9 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public override ExpInstantiableElement EqualityTypeConvert => ExpInstantiableElement.Void;
|
||||
|
||||
public override ExpNode Left => _only;
|
||||
public override ExpSyntaxNode Left => _only;
|
||||
|
||||
public override ExpNode Right => _only;
|
||||
public override ExpSyntaxNode Right => _only;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace StgSharp.Script.Express
|
||||
|
||||
}
|
||||
|
||||
public abstract class ExpElementInstance : ExpNode
|
||||
public abstract class ExpElementInstance : ExpSyntaxNode
|
||||
{
|
||||
|
||||
protected ExpElementInstance( Token source )
|
||||
@@ -66,9 +66,9 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public ExpElementType ElementType { get; }
|
||||
|
||||
public override ExpNode Left => Empty;
|
||||
public override ExpSyntaxNode Left => Empty;
|
||||
|
||||
public override ExpNode Right => Empty;
|
||||
public override ExpSyntaxNode Right => Empty;
|
||||
|
||||
public abstract string TypeName { get; }
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace StgSharp.Script.Express
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetMember( string name, out ExpNode node )
|
||||
public bool TryGetMember( string name, out ExpSyntaxNode node )
|
||||
{
|
||||
return EqualityTypeConvert.TryGetMember( name, out node );
|
||||
}
|
||||
|
||||
@@ -45,11 +45,11 @@ namespace StgSharp.Script.Express
|
||||
|
||||
string Name { get; }
|
||||
|
||||
public void AddMember( string name, ExpNode memberNode );
|
||||
public void AddMember( string name, ExpSyntaxNode memberNode );
|
||||
|
||||
public void Analyse();
|
||||
|
||||
public bool TryGetMember( string name, out ExpNode memberNode );
|
||||
public bool TryGetMember( string name, out ExpSyntaxNode memberNode );
|
||||
|
||||
}
|
||||
|
||||
@@ -70,14 +70,14 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
public void AddMember( string name, ExpNode memberNode )
|
||||
public void AddMember( string name, ExpSyntaxNode memberNode )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public abstract void Analyse();
|
||||
|
||||
public abstract ExpNode CreateInstanceNode( Token t );
|
||||
public abstract ExpSyntaxNode CreateInstanceNode( Token t );
|
||||
|
||||
public bool IsConvertable( IExpElementSource targetType )
|
||||
{
|
||||
@@ -92,7 +92,7 @@ namespace StgSharp.Script.Express
|
||||
return element == null || element == ExpVoidElement.Only;
|
||||
}
|
||||
|
||||
public abstract bool TryGetMember( string name, out ExpNode memberNode );
|
||||
public abstract bool TryGetMember( string name, out ExpSyntaxNode memberNode );
|
||||
|
||||
private sealed class ExpVoidElement : ExpInstantiableElement
|
||||
{
|
||||
@@ -112,14 +112,14 @@ namespace StgSharp.Script.Express
|
||||
return;
|
||||
}
|
||||
|
||||
public override ExpNode CreateInstanceNode( Token t )
|
||||
public override ExpSyntaxNode CreateInstanceNode( Token t )
|
||||
{
|
||||
return ExpNode.Empty;
|
||||
return ExpSyntaxNode.Empty;
|
||||
}
|
||||
|
||||
public override bool TryGetMember( string name, out ExpNode memberNode )
|
||||
public override bool TryGetMember( string name, out ExpSyntaxNode memberNode )
|
||||
{
|
||||
memberNode = ExpNode.Empty;
|
||||
memberNode = ExpSyntaxNode.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
public void AddMember( string name, ExpNode memberNode )
|
||||
public void AddMember( string name, ExpSyntaxNode memberNode )
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -148,9 +148,9 @@ namespace StgSharp.Script.Express
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract ExpNode MakeReference( params object[] options );
|
||||
public abstract ExpSyntaxNode MakeReference( params object[] options );
|
||||
|
||||
public abstract bool TryGetMember( string name, out ExpNode memberNode );
|
||||
public abstract bool TryGetMember( string name, out ExpSyntaxNode memberNode );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace StgSharp.Script.Express
|
||||
public class ExpCaseNotFoundException : ArgumentOutOfRangeException
|
||||
{
|
||||
|
||||
public ExpCaseNotFoundException( ExpSwitchNode token, ExpNode label )
|
||||
public ExpCaseNotFoundException( ExpSwitchNode token, ExpSyntaxNode label )
|
||||
: base(
|
||||
$"Attempt to read or write the label at ({token.Line},{token.Column}), that does not exist in SWITCH expression at ({token.Line},{token.Column})" ) { }
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
@@ -43,26 +44,40 @@ namespace StgSharp.Script.Express
|
||||
public static class ExpNodeNextEnumeratorExtensions
|
||||
{
|
||||
|
||||
public static ExpNodeNextEnumerator AsCollectionEnumerator( this ExpSyntaxNode token )
|
||||
{
|
||||
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( token );
|
||||
enumerator.AssertEnumeratorCount( count );
|
||||
IExpElementSource type = token.EqualityTypeConvert;
|
||||
while( enumerator.MoveNext() )
|
||||
{
|
||||
if( enumerator. Current != type ) {
|
||||
throw new InvalidCastException();
|
||||
}
|
||||
}
|
||||
return enumerator;
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static ExpNodeNextEnumerator AsEnumerator( this ExpNode token )
|
||||
public static ExpNodeNextEnumerator ToEnumerator( this ExpSyntaxNode token )
|
||||
{
|
||||
return new ExpNodeNextEnumerator( token );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ExpNodeNextEnumerator : IEnumerator<ExpNode>
|
||||
public class ExpNodeNextEnumerator : IEnumerator<ExpSyntaxNode>
|
||||
{
|
||||
|
||||
private ExpNode _current;
|
||||
private ExpSyntaxNode _current;
|
||||
|
||||
private List<ExpNode> _begin = new List<ExpNode>();
|
||||
private List<ExpSyntaxNode> _begin = new List<ExpSyntaxNode>();
|
||||
|
||||
public ExpNodeNextEnumerator( ExpNode token )
|
||||
public ExpNodeNextEnumerator( ExpSyntaxNode token )
|
||||
{
|
||||
_begin[ 0 ] = token;
|
||||
_current = token;
|
||||
ExpNode t = token;
|
||||
ExpSyntaxNode t = token;
|
||||
while( !ReferenceEquals( t.Next, token ) && t.Next != null )
|
||||
{
|
||||
t = t.Next;
|
||||
@@ -70,7 +85,7 @@ namespace StgSharp.Script.Express
|
||||
}
|
||||
}
|
||||
|
||||
public ExpNode this[ int index ]
|
||||
public ExpSyntaxNode this[ int index ]
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -80,7 +95,9 @@ namespace StgSharp.Script.Express
|
||||
}
|
||||
}
|
||||
|
||||
public List<ExpNode> Values => _begin;
|
||||
public ExpSyntaxNode Current => _current;
|
||||
|
||||
public List<ExpSyntaxNode> Values => _begin;
|
||||
|
||||
public void AssertEnumeratorCount( int count )
|
||||
{
|
||||
@@ -90,14 +107,9 @@ namespace StgSharp.Script.Express
|
||||
}
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
public bool MoveNext()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool IEnumerator.MoveNext()
|
||||
{
|
||||
ExpNode next = _current.Next;
|
||||
ExpSyntaxNode next = _current.Next;
|
||||
if( ReferenceEquals( next, _begin ) || next == null ) {
|
||||
return false;
|
||||
}
|
||||
@@ -105,6 +117,11 @@ namespace StgSharp.Script.Express
|
||||
return true;
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void IEnumerator.Reset()
|
||||
{
|
||||
_current = _begin[ 0 ];
|
||||
@@ -112,7 +129,5 @@ namespace StgSharp.Script.Express
|
||||
|
||||
object IEnumerator.Current => _current;
|
||||
|
||||
ExpNode IEnumerator<ExpNode>.Current => _current;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,9 @@ namespace StgSharp.Script.Express
|
||||
private int _current, _lineNum;
|
||||
private IScriptSourceProvider _provider;
|
||||
|
||||
private Regex _nextWordTokenPattern = GetNextWordTokenPattern(),
|
||||
private Regex
|
||||
_nextHashtagSymbolPattern = GetHashtagSymbolPattern() ,
|
||||
_nextWordTokenPattern = GetNextWordTokenPattern(),
|
||||
_nextStringLiteralPattern = GetStringLiteralPattern(),
|
||||
_nextNumberLiteralPattern = GetNumberLiteralPattern(),
|
||||
_nextStringLiteralPatternWithSingle = GetStringLiteralPatternWithSingle(),
|
||||
@@ -59,7 +61,7 @@ namespace StgSharp.Script.Express
|
||||
private string _lineCache;
|
||||
private Token _last;
|
||||
|
||||
public ExpSourceReader(IScriptSourceProvider provider)
|
||||
public ExpSourceReader( IScriptSourceProvider provider )
|
||||
{
|
||||
_provider = provider;
|
||||
_current = 0;
|
||||
@@ -69,7 +71,7 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public bool IsEmpty
|
||||
{
|
||||
get => ((string.IsNullOrEmpty(_lineCache) || _current >= _lineCache.Length)) && _provider.IsEmpty;
|
||||
get => ( ( string.IsNullOrEmpty( _lineCache ) || _current >= _lineCache.Length ) ) && _provider.IsEmpty;
|
||||
}
|
||||
|
||||
public int LineNumber
|
||||
@@ -79,175 +81,201 @@ namespace StgSharp.Script.Express
|
||||
|
||||
public unsafe ReadOnlySpan<char> ReadLine()
|
||||
{
|
||||
bool lineOver = string.IsNullOrEmpty(_lineCache) || _current >= _lineCache.Length;
|
||||
while (lineOver || _isReadingMultiLineComment)
|
||||
bool lineOver = string.IsNullOrEmpty( _lineCache ) || _current >= _lineCache.Length;
|
||||
while( lineOver || _isReadingMultiLineComment )
|
||||
{
|
||||
if (IsEmpty)
|
||||
{
|
||||
if( IsEmpty ) {
|
||||
return ReadOnlySpan<char>.Empty;
|
||||
}
|
||||
if (lineOver)
|
||||
if( lineOver )
|
||||
{
|
||||
do
|
||||
{
|
||||
_lineCache = _provider.ReadLine(out _lineNum);
|
||||
} while (string.IsNullOrEmpty(_lineCache));
|
||||
_lineCache = _provider.ReadLine( out _lineNum );
|
||||
} while (string.IsNullOrEmpty( _lineCache ));
|
||||
_current = 0;
|
||||
}
|
||||
if (_isReadingMultiLineComment)
|
||||
if( _isReadingMultiLineComment )
|
||||
{
|
||||
int index;
|
||||
fixed (char* cPtr = _lineCache.AsSpan(_current))
|
||||
{
|
||||
fixed( char* cPtr = _lineCache.AsSpan( _current ) ) {
|
||||
index = UnsafeCompute.IndexOfCharPair(
|
||||
cPtr, MultiLineEnd, _lineCache.Length);
|
||||
cPtr, MultiLineEnd, _lineCache.Length );
|
||||
}
|
||||
if (index == -1)
|
||||
if( index == -1 )
|
||||
{
|
||||
_lineCache = string.Empty;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
_isReadingMultiLineComment = false;
|
||||
_current += index + 2;
|
||||
}
|
||||
}
|
||||
lineOver = string.IsNullOrEmpty(_lineCache) || _current >= _lineCache.Length;
|
||||
lineOver = string.IsNullOrEmpty( _lineCache ) || _current >= _lineCache.Length;
|
||||
}
|
||||
return _lineCache.AsSpan().Slice(_current);
|
||||
return _lineCache.AsSpan().Slice( _current );
|
||||
}
|
||||
|
||||
public unsafe Token ReadToken()
|
||||
{
|
||||
int begin, end, rest;
|
||||
readLine:
|
||||
readLine:
|
||||
ReadOnlySpan<char> source;
|
||||
if (!TryReadLine(out source))
|
||||
{
|
||||
if( !TryReadLine( out source ) ) {
|
||||
return Token.Empty;
|
||||
}
|
||||
char c = source[0];
|
||||
char c = source[ 0 ];
|
||||
|
||||
if (char.IsLetter(c))
|
||||
if( char.IsLetter( c ) )
|
||||
{
|
||||
Match match = _nextWordTokenPattern.Match(_lineCache, _current);
|
||||
if (match.Success)
|
||||
Match match = _nextWordTokenPattern.Match( _lineCache, _current );
|
||||
if( match.Success )
|
||||
{
|
||||
begin = match.Groups[TokenMark].Index;
|
||||
end = match.Groups[EndMark].Index;
|
||||
rest = match.Groups[RestMark].Index;
|
||||
begin = match.Groups[ TokenMark ].Index;
|
||||
end = match.Groups[ EndMark ].Index;
|
||||
rest = match.Groups[ RestMark ].Index;
|
||||
_current = rest;
|
||||
_last = new(
|
||||
ExpressCompile.PoolString(source[..(end - begin)]), _lineNum, begin,
|
||||
TokenFlag.Member);
|
||||
ExpressCompile.PoolString( source[ ..( end - begin ) ] ), _lineNum, begin,
|
||||
TokenFlag.Member );
|
||||
return _last;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
throw new ExpInvalidCharException(_current);
|
||||
throw new ExpInvalidCharException( _current );
|
||||
}
|
||||
}
|
||||
else if (char.IsPunctuation(c) || char.IsSymbol(c))
|
||||
} else if( char.IsPunctuation( c ) || char.IsSymbol( c ) )
|
||||
{
|
||||
switch (c)
|
||||
Match match;
|
||||
switch( c )
|
||||
{
|
||||
case '#':
|
||||
match = _nextHashtagSymbolPattern.Match( _lineCache, _current );
|
||||
if( match.Success )
|
||||
{
|
||||
begin = match.Groups[ "token" ].Index;
|
||||
end = match.Groups[ "end" ].Index;
|
||||
rest = match.Groups[ "rest" ].Index;
|
||||
_current = rest;
|
||||
_last = new(
|
||||
ExpressCompile.PoolString( source[ 1..( end - begin ) ] ), _lineNum,
|
||||
begin, TokenFlag.Member );
|
||||
return _last;
|
||||
} else
|
||||
{
|
||||
throw new ExpInvalidCharException( '#' );
|
||||
}
|
||||
case '\'':
|
||||
|
||||
case '"':
|
||||
char cNext = source[1];
|
||||
if (cNext == '\"') //empty string
|
||||
char cNext = source[ 1 ];
|
||||
if( cNext == '\'' ) //empty string
|
||||
{
|
||||
begin = _current;
|
||||
_current += 2;
|
||||
return new(string.Empty, _lineNum, begin, TokenFlag.String);
|
||||
return new( string.Empty, _lineNum, begin, TokenFlag.String );
|
||||
}
|
||||
Match match = _nextStringLiteralPattern.Match(_lineCache, _current);
|
||||
if (match.Success)
|
||||
match = _nextStringLiteralPatternWithSingle.Match( _lineCache, _current );
|
||||
if( match.Success )
|
||||
{
|
||||
begin = match.Groups["token"].Index;
|
||||
end = match.Groups["end"].Index;
|
||||
rest = match.Groups["rest"].Index;
|
||||
begin = match.Groups[ "token" ].Index;
|
||||
end = match.Groups[ "end" ].Index;
|
||||
rest = match.Groups[ "rest" ].Index;
|
||||
_current = rest;
|
||||
_last = new(
|
||||
ExpressCompile.PoolString(source[1..(end - begin)]), _lineNum,
|
||||
begin, TokenFlag.String);
|
||||
ExpressCompile.PoolString( source[ 1..( end - begin ) ] ), _lineNum,
|
||||
begin, TokenFlag.String );
|
||||
return _last;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
throw new ExpInvalidCharException('\"');
|
||||
throw new ExpInvalidCharException( '\"' );
|
||||
}
|
||||
case '"':
|
||||
cNext = source[ 1 ];
|
||||
if( cNext == '\"' ) //empty string
|
||||
{
|
||||
begin = _current;
|
||||
_current += 2;
|
||||
return new( string.Empty, _lineNum, begin, TokenFlag.String );
|
||||
}
|
||||
match = _nextStringLiteralPattern.Match( _lineCache, _current );
|
||||
if( match.Success )
|
||||
{
|
||||
begin = match.Groups[ "token" ].Index;
|
||||
end = match.Groups[ "end" ].Index;
|
||||
rest = match.Groups[ "rest" ].Index;
|
||||
_current = rest;
|
||||
_last = new(
|
||||
ExpressCompile.PoolString( source[ 1..( end - begin ) ] ), _lineNum,
|
||||
begin, TokenFlag.String );
|
||||
return _last;
|
||||
} else
|
||||
{
|
||||
throw new ExpInvalidCharException( '\"' );
|
||||
}
|
||||
case '(':
|
||||
cNext = source[1];
|
||||
if (cNext == '*')
|
||||
cNext = source[ 1 ];
|
||||
if( cNext == '*' )
|
||||
{
|
||||
_isReadingMultiLineComment = true;
|
||||
_current += 2;
|
||||
goto readLine;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
begin = _current;
|
||||
_current++;
|
||||
_last = new(
|
||||
ExpressCompile.PoolString(source[..1]), _lineNum, begin,
|
||||
TokenFlag.Separator_Left);
|
||||
ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
|
||||
TokenFlag.Separator_Left );
|
||||
return _last;
|
||||
}
|
||||
case ')' or '}':
|
||||
begin = _current;
|
||||
_current++;
|
||||
_last = new Token(
|
||||
ExpressCompile.PoolString(source[..1]), _lineNum, begin,
|
||||
TokenFlag.Separator_Right);
|
||||
ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
|
||||
TokenFlag.Separator_Right );
|
||||
return _last;
|
||||
case '-':
|
||||
|
||||
// 1. - number
|
||||
// 2. -- comment
|
||||
// 3. - number type param(UNARY)
|
||||
// 4. param - param(BINARY)
|
||||
cNext = source[1];
|
||||
if (char.IsNumber(cNext))
|
||||
// 4. param - param(BINARY)
|
||||
cNext = source[ 1 ];
|
||||
if( char.IsNumber( cNext ) )
|
||||
{
|
||||
match = _nextNumberLiteralPattern.Match(_lineCache, _current);
|
||||
if (match.Success)
|
||||
match = _nextNumberLiteralPattern.Match( _lineCache, _current );
|
||||
if( match.Success )
|
||||
{
|
||||
begin = match.Groups[TokenMark].Index;
|
||||
end = match.Groups[EndMark].Index;
|
||||
rest = match.Groups[RestMark].Index;
|
||||
begin = match.Groups[ TokenMark ].Index;
|
||||
end = match.Groups[ EndMark ].Index;
|
||||
rest = match.Groups[ RestMark ].Index;
|
||||
_current = rest;
|
||||
return new(
|
||||
ExpressCompile.PoolString(source[..(end - begin)]),
|
||||
_lineNum, begin, TokenFlag.Number);
|
||||
}
|
||||
else
|
||||
ExpressCompile.PoolString( source[ ..( end - begin ) ] ),
|
||||
_lineNum, begin, TokenFlag.Number );
|
||||
} else
|
||||
{
|
||||
throw new ExpInvalidCharException(_current);
|
||||
throw new ExpInvalidCharException( _current );
|
||||
}
|
||||
}
|
||||
else if (cNext == '-')
|
||||
} else if( cNext == '-' )
|
||||
{
|
||||
_lineCache = string.Empty;
|
||||
_current = 0;
|
||||
goto readLine;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
begin = _current;
|
||||
_current++;
|
||||
if (_last.Flag == TokenFlag.Member || _last.Flag ==
|
||||
TokenFlag.Index_Right || _last.Flag == TokenFlag.Separator_Right)
|
||||
if( _last.Flag == TokenFlag.Member || _last.Flag ==
|
||||
TokenFlag.Index_Right || _last.Flag == TokenFlag.Separator_Right )
|
||||
{
|
||||
_last = new(
|
||||
ExpressCompile.PoolString(source[..1]), _lineNum, begin,
|
||||
TokenFlag.Symbol_Binary);
|
||||
}
|
||||
else
|
||||
ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
|
||||
TokenFlag.Symbol_Binary );
|
||||
} else
|
||||
{
|
||||
_last = new(
|
||||
ExpressCompile.PoolString(source[..1]), _lineNum, begin,
|
||||
TokenFlag.Symbol_Unary);
|
||||
ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
|
||||
TokenFlag.Symbol_Unary );
|
||||
}
|
||||
return _last;
|
||||
}
|
||||
@@ -255,145 +283,144 @@ namespace StgSharp.Script.Express
|
||||
begin = _current;
|
||||
_current++;
|
||||
_last = new Token(
|
||||
ExpressCompile.PoolString("{"), _lineNum, begin,
|
||||
TokenFlag.Separator_Left);
|
||||
ExpressCompile.PoolString( "{" ), _lineNum, begin,
|
||||
TokenFlag.Separator_Left );
|
||||
return _last;
|
||||
case '[':
|
||||
begin = _current;
|
||||
_current++;
|
||||
_last = new Token(
|
||||
ExpressCompile.PoolString("["), _lineNum, begin,
|
||||
TokenFlag.Index_Left);
|
||||
ExpressCompile.PoolString( "[" ), _lineNum, begin,
|
||||
TokenFlag.Index_Left );
|
||||
return _last;
|
||||
case ']':
|
||||
begin = _current;
|
||||
_current++;
|
||||
_last = new Token(
|
||||
ExpressCompile.PoolString("]"), _lineNum, begin,
|
||||
TokenFlag.Index_Right);
|
||||
ExpressCompile.PoolString( "]" ), _lineNum, begin,
|
||||
TokenFlag.Index_Right );
|
||||
return _last;
|
||||
case ';' or ',':
|
||||
begin = _current;
|
||||
_current++;
|
||||
_last = new Token(
|
||||
ExpressCompile.PoolString(source[..1]), _lineNum, begin,
|
||||
TokenFlag.Separator_Middle);
|
||||
ExpressCompile.PoolString( source[ ..1 ] ), _lineNum, begin,
|
||||
TokenFlag.Separator_Middle );
|
||||
return _last;
|
||||
case ':':
|
||||
match = _nextSymbolPattern.Match(_lineCache, _current);
|
||||
begin = match.Groups[TokenMark].Index;
|
||||
end = match.Groups[EndMark].Index;
|
||||
rest = match.Groups[RestMark].Index;
|
||||
match = _nextSymbolPattern.Match( _lineCache, _current );
|
||||
begin = match.Groups[ TokenMark ].Index;
|
||||
end = match.Groups[ EndMark ].Index;
|
||||
rest = match.Groups[ RestMark ].Index;
|
||||
_current = rest;
|
||||
if (end - begin == 1)
|
||||
if( end - begin == 1 )
|
||||
{
|
||||
_last = new Token(
|
||||
ExpressCompile.Keyword.Colon, _lineNum, begin,
|
||||
TokenFlag.Separator_Middle);
|
||||
}
|
||||
else
|
||||
TokenFlag.Separator_Middle );
|
||||
} else
|
||||
{
|
||||
_last = new Token(
|
||||
ExpressCompile.PoolString(source[..(end - begin)]), _lineNum,
|
||||
begin, TokenFlag.Symbol_Binary);
|
||||
ExpressCompile.PoolString( source[ ..( end - begin ) ] ), _lineNum,
|
||||
begin, TokenFlag.Symbol_Binary );
|
||||
}
|
||||
return _last;
|
||||
case '+' or '/' or '\\' or '*' or '.':
|
||||
match = _nextSymbolPattern.Match(_lineCache, _current);
|
||||
begin = match.Groups[TokenMark].Index;
|
||||
end = match.Groups[EndMark].Index;
|
||||
rest = match.Groups[RestMark].Index;
|
||||
match = _nextSymbolPattern.Match( _lineCache, _current );
|
||||
begin = match.Groups[ TokenMark ].Index;
|
||||
end = match.Groups[ EndMark ].Index;
|
||||
rest = match.Groups[ RestMark ].Index;
|
||||
_current = rest;
|
||||
_last = new Token(
|
||||
ExpressCompile.PoolString(source[..(end - begin)]), _lineNum,
|
||||
begin, TokenFlag.Symbol_Binary);
|
||||
ExpressCompile.PoolString( source[ ..( end - begin ) ] ), _lineNum,
|
||||
begin, TokenFlag.Symbol_Binary );
|
||||
return _last;
|
||||
case '=':
|
||||
begin = _current;
|
||||
_current++;
|
||||
_last = new Token(
|
||||
ExpressCompile.Keyword.Equal, _lineNum, begin,
|
||||
TokenFlag.Symbol_Binary);
|
||||
TokenFlag.Symbol_Binary );
|
||||
return _last;
|
||||
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);
|
||||
if (match.Success)
|
||||
Match match = _nextNumberLiteralPattern.Match( _lineCache, _current );
|
||||
if( match.Success )
|
||||
{
|
||||
begin = match.Groups[TokenMark].Index;
|
||||
end = match.Groups[EndMark].Index;
|
||||
rest = match.Groups[RestMark].Index;
|
||||
begin = match.Groups[ TokenMark ].Index;
|
||||
end = match.Groups[ EndMark ].Index;
|
||||
rest = match.Groups[ RestMark ].Index;
|
||||
_current = rest;
|
||||
string str = ExpressCompile.PoolString(source[..(end - begin)]);
|
||||
return new(str, _lineNum, begin, TokenFlag.Number);
|
||||
}
|
||||
else
|
||||
string str = ExpressCompile.PoolString( source[ ..( end - begin ) ] );
|
||||
return new( str, _lineNum, begin, TokenFlag.Number );
|
||||
} else
|
||||
{
|
||||
throw new ExpInvalidCharException(_current);
|
||||
throw new ExpInvalidCharException( _current );
|
||||
}
|
||||
}
|
||||
else if (char.IsWhiteSpace(c))
|
||||
} else if( char.IsWhiteSpace( c ) )
|
||||
{
|
||||
Match match = _skipBlankPattern.Match(_lineCache, _current);
|
||||
if (match.Success)
|
||||
Match match = _skipBlankPattern.Match( _lineCache, _current );
|
||||
if( match.Success )
|
||||
{
|
||||
rest = match.Groups[RestMark].Index;
|
||||
rest = match.Groups[ RestMark ].Index;
|
||||
_current = rest;
|
||||
goto readLine;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
throw new ExpInvalidCharException(_current);
|
||||
throw new ExpInvalidCharException( _current );
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
throw new ExpInvalidCharException(c);
|
||||
throw new ExpInvalidCharException( c );
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryReadLine(out ReadOnlySpan<char> line)
|
||||
public bool TryReadLine( out ReadOnlySpan<char> line )
|
||||
{
|
||||
line = ReadLine();
|
||||
return line != ReadOnlySpan<char>.Empty;
|
||||
}
|
||||
|
||||
public bool TryReadToken(out Token t)
|
||||
public bool TryReadToken( out Token t )
|
||||
{
|
||||
t = ReadToken();
|
||||
return !IsEmpty;
|
||||
}
|
||||
|
||||
[GeneratedRegex(
|
||||
@"(?<token>#[0-9A-Za-z]+)(?<end>\s*?)(?<rest>\S|$)",
|
||||
RegexOptions.Singleline )]
|
||||
private static partial Regex GetHashtagSymbolPattern();
|
||||
|
||||
[GeneratedRegex(
|
||||
@"(?<token>[a-zA-Z][a-zA-Z0-9_]*)(?<end>\s*?)(?<rest>\S|$)",
|
||||
RegexOptions.Singleline)]
|
||||
RegexOptions.Singleline )]
|
||||
private static partial Regex GetNextWordTokenPattern();
|
||||
|
||||
[GeneratedRegex(
|
||||
@"(?<token>-?\s*?[0-9]+(?:\.[0-9]*)?E?(?:[+-]?[0-9]+)?)(?<end>\s*?)(?<rest>\S|$)",
|
||||
RegexOptions.Singleline)]
|
||||
RegexOptions.Singleline )]
|
||||
private static partial Regex GetNumberLiteralPattern();
|
||||
|
||||
[GeneratedRegex(@"(?:\s+?)(?<rest>\S|$)", RegexOptions.Singleline)]
|
||||
[GeneratedRegex( @"(?:\s+?)(?<rest>\S|$)", RegexOptions.Singleline )]
|
||||
private static partial Regex GetSkipBlankPattern();
|
||||
|
||||
[GeneratedRegex(
|
||||
@"(?<token>"")(?>\\\\|\\""|(?!')[^""])*(?<end>""|$)\s*?(?<rest>\S|$)",
|
||||
RegexOptions.Singleline)]
|
||||
RegexOptions.Singleline )]
|
||||
private static partial Regex GetStringLiteralPattern();
|
||||
|
||||
[GeneratedRegex(
|
||||
@"(?<token>')(?>\\\\|\\'|''|(?!')[^'])*(?<end>')\s*?(?<rest>\S|$)",
|
||||
RegexOptions.Singleline)]
|
||||
RegexOptions.Singleline )]
|
||||
private static partial Regex GetStringLiteralPatternWithSingle();
|
||||
|
||||
[GeneratedRegex(
|
||||
@"(?<token>[:<>=+\-*\/]+)(?<end>\s?)\s*?(?<rest>\S|$)",
|
||||
RegexOptions.Singleline)]
|
||||
RegexOptions.Singleline )]
|
||||
private static partial Regex GetSymbolPattern();
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace StgSharp.Script.Express
|
||||
private bool AppendToken_CaseOf( Token t )
|
||||
{
|
||||
Token op;
|
||||
ExpNode root;
|
||||
ExpSyntaxNode root;
|
||||
switch( t.Value )
|
||||
{
|
||||
case ExpKeyword.Case:
|
||||
@@ -108,19 +108,20 @@ namespace StgSharp.Script.Express
|
||||
Begin = t;
|
||||
}
|
||||
|
||||
public Dictionary<ExpNode, ExpNode> Cases { get; } = new Dictionary<ExpNode, ExpNode>();
|
||||
public Dictionary<ExpSyntaxNode, ExpSyntaxNode> Cases { get; } = new Dictionary<ExpSyntaxNode, ExpSyntaxNode>(
|
||||
);
|
||||
|
||||
public ExpNode CaseExpression { get; set; }
|
||||
public ExpSyntaxNode CaseExpression { get; set; }
|
||||
|
||||
public ExpNode DefaultCase { get; set; }
|
||||
public ExpSyntaxNode DefaultCase { get; set; }
|
||||
|
||||
public ExpNode CurrentCase { get; set; }
|
||||
public ExpSyntaxNode CurrentCase { get; set; }
|
||||
|
||||
public string CurrentState { get; set; }
|
||||
|
||||
public Token Begin { get; init; }
|
||||
|
||||
public void CloseCurrentCase( ExpNode root )
|
||||
public void CloseCurrentCase( ExpSyntaxNode root )
|
||||
{
|
||||
Cases.Add( CurrentCase, root );
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace StgSharp.Script.Express
|
||||
if( t.Flag != TokenFlag.Index_Left ) {
|
||||
return false;
|
||||
}
|
||||
if( _cache.TryPeekOperand( out bool isNode, out _, out ExpNode? node ) )
|
||||
if( _cache.TryPeekOperand( out bool isNode, out _, out ExpSyntaxNode? node ) )
|
||||
{
|
||||
if( node.EqualityTypeConvert is not ExpCollectionBase ) {
|
||||
ExpInvalidSyntaxException.ThrowNonCollectionIndex( t );
|
||||
@@ -83,8 +83,8 @@ namespace StgSharp.Script.Express
|
||||
ClosePrefixReverse( t );
|
||||
|
||||
//make index node
|
||||
_cache.PopOperand( out _, out ExpNode? expNode );
|
||||
if( !_cache.PopOperand( out Token colleToken, out ExpNode? colleNode ) ) { }
|
||||
_cache.PopOperand( out _, out ExpSyntaxNode? expNode );
|
||||
if( !_cache.PopOperand( out Token colleToken, out ExpSyntaxNode? colleNode ) ) { }
|
||||
_cache.PushOperand(
|
||||
ExpCollectionIndexNode.Create(
|
||||
t, ( colleNode as ExpCollectionInstanceBase )!, expNode ) );
|
||||
@@ -126,7 +126,7 @@ namespace StgSharp.Script.Express
|
||||
while( _cache.OperatorAheadOfDepth > 0 )
|
||||
{
|
||||
_cache.TryPopOperator( out Token op );
|
||||
ExpNode node = ConvertAndPushOneOperator( op );
|
||||
ExpSyntaxNode node = ConvertAndPushOneOperator( op );
|
||||
}
|
||||
switch( _cache.OperandAheadOfDepth )
|
||||
{
|
||||
@@ -134,10 +134,10 @@ namespace StgSharp.Script.Express
|
||||
if( t.Value == ";" ) {
|
||||
return true;
|
||||
}
|
||||
_cache.StatementsInDepth.Push( ExpNode.Empty );
|
||||
_cache.StatementsInDepth.Push( ExpSyntaxNode.Empty );
|
||||
goto case 1;
|
||||
case 1:
|
||||
_cache.PopOperand( out _, out ExpNode? statement );
|
||||
_cache.PopOperand( out _, out ExpSyntaxNode? statement );
|
||||
_cache.StatementsInDepth.Push( statement );
|
||||
return true;
|
||||
default:
|
||||
@@ -189,7 +189,7 @@ namespace StgSharp.Script.Express
|
||||
if( cmp >= 0 )
|
||||
{
|
||||
_cache.PopOperator();
|
||||
ExpNode node = ConvertAndPushOneOperator( tmp );
|
||||
ExpSyntaxNode node = ConvertAndPushOneOperator( tmp );
|
||||
goto processPrecedence;
|
||||
}
|
||||
}
|
||||
@@ -249,7 +249,7 @@ namespace StgSharp.Script.Express
|
||||
private bool TryParseInstance( Token t )
|
||||
{
|
||||
if( _local.TryGetMember( t.Value,
|
||||
out ExpNode? node ) && node is ExpElementInstance instance )
|
||||
out ExpSyntaxNode? node ) && node is ExpElementInstance instance )
|
||||
{
|
||||
_cache.PushOperand( ExpInstanceReferenceNode.MakeReferenceFrom( t, instance ) );
|
||||
return true;
|
||||
@@ -260,7 +260,7 @@ namespace StgSharp.Script.Express
|
||||
} else if( _cache.IsLastAddedOperator )
|
||||
{
|
||||
if( _cache.PeekOperand( out _,
|
||||
out ExpNode? typenode ) && typenode is ExpMetaRefNode typeRef )
|
||||
out ExpSyntaxNode? typenode ) && typenode is ExpMetaRefNode typeRef )
|
||||
{
|
||||
_cache.PopOperand( out _, out _ );
|
||||
_local.AddMember( t.Value, typeRef.SourceRef.CreateInstanceNode( t ) );
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace StgSharp.Script.Express
|
||||
while( _cache.TryPopOperator( out Token op ) ) {
|
||||
ConvertAndPushOneOperator( op );
|
||||
}
|
||||
_cache.PopOperand( out _, out ExpNode? node );
|
||||
_cache.PopOperand( out _, out ExpSyntaxNode? node );
|
||||
state.CurrentState = t.Value;
|
||||
state.BoolExpression = node;
|
||||
} else
|
||||
@@ -71,7 +71,7 @@ namespace StgSharp.Script.Express
|
||||
state = _cache.StateOfCurrentDepth<IfBranchStateCache>();
|
||||
if( state.CurrentState == ExpKeyword.Then )
|
||||
{
|
||||
ExpNode node = _cache.PackAllStatements();
|
||||
ExpSyntaxNode node = _cache.PackAllStatements();
|
||||
state.CurrentState = t.Value;
|
||||
state.ExpressionIfTrue = node;
|
||||
} else
|
||||
@@ -85,13 +85,13 @@ namespace StgSharp.Script.Express
|
||||
state = _cache.StateOfCurrentDepth<IfBranchStateCache>();
|
||||
if( state.CurrentState == ExpKeyword.Then )
|
||||
{
|
||||
ExpNode trueNode = _cache.PackAllStatements();
|
||||
ExpSyntaxNode trueNode = _cache.PackAllStatements();
|
||||
state.CurrentState = t.Value;
|
||||
state.ExpressionIfTrue = trueNode;
|
||||
state.ExpressionIfFalse = ExpNode.Empty;
|
||||
state.ExpressionIfFalse = ExpSyntaxNode.Empty;
|
||||
} else if( state.CurrentState == ExpKeyword.Else )
|
||||
{
|
||||
ExpNode falseNode = _cache.PackAllStatements();
|
||||
ExpSyntaxNode falseNode = _cache.PackAllStatements();
|
||||
state.CurrentState = t.Value;
|
||||
state.ExpressionIfFalse = falseNode;
|
||||
} else
|
||||
@@ -115,11 +115,11 @@ namespace StgSharp.Script.Express
|
||||
private class IfBranchStateCache : ICompileDepthState
|
||||
{
|
||||
|
||||
public ExpNode BoolExpression { get; set; }
|
||||
public ExpSyntaxNode BoolExpression { get; set; }
|
||||
|
||||
public ExpNode ExpressionIfTrue { get; set; }
|
||||
public ExpSyntaxNode ExpressionIfTrue { get; set; }
|
||||
|
||||
public ExpNode ExpressionIfFalse { get; set; }
|
||||
public ExpSyntaxNode ExpressionIfFalse { get; set; }
|
||||
|
||||
public string CurrentState { get; set; }
|
||||
|
||||
|
||||
@@ -48,9 +48,9 @@ namespace StgSharp.Script.Express
|
||||
return leftPrecedence - rightPrecedence;
|
||||
}
|
||||
|
||||
public bool TryGenerateUnaryNode( Token t, out ExpNode node )
|
||||
public bool TryGenerateUnaryNode( Token t, out ExpSyntaxNode node )
|
||||
{
|
||||
ExpNode operand = GetNextOperandCache();
|
||||
ExpSyntaxNode operand = GetNextOperandCache();
|
||||
switch( t.Value )
|
||||
{
|
||||
case ExpKeyword.UnaryPlus:
|
||||
@@ -63,7 +63,7 @@ namespace StgSharp.Script.Express
|
||||
node = ExpUnaryOperatorNode.UnaryNot( t, operand );
|
||||
return true;
|
||||
default:
|
||||
node = ExpNode.Empty;
|
||||
node = ExpSyntaxNode.Empty;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -72,12 +72,12 @@ namespace StgSharp.Script.Express
|
||||
/// WARNING: This method cannot process INDEXOF, FUNCTION CALLING, LOOP and any ENDING
|
||||
/// SYMBOLS.
|
||||
/// </summary>
|
||||
private ExpNode ConvertAndPushOneOperator( Token op )
|
||||
private ExpSyntaxNode ConvertAndPushOneOperator( Token op )
|
||||
{
|
||||
switch( op.Flag )
|
||||
{
|
||||
case TokenFlag.Symbol_Unary:
|
||||
TryGenerateUnaryNode( op, out ExpNode? node );
|
||||
TryGenerateUnaryNode( op, out ExpSyntaxNode? node );
|
||||
_cache.PushOperand( node );
|
||||
return node;
|
||||
case TokenFlag.Symbol_Binary:
|
||||
@@ -87,7 +87,7 @@ namespace StgSharp.Script.Express
|
||||
case TokenFlag.Member:
|
||||
if( _context.TryGetFunction( op.Value, out ExpFunctionSource? f ) )
|
||||
{
|
||||
if( !_cache.PopOperand( out Token t, out ExpNode? p ) )
|
||||
if( !_cache.PopOperand( out Token t, out ExpSyntaxNode? p ) )
|
||||
{
|
||||
node = ExpFunctionCallingNode.CallFunction( op, f, p );
|
||||
return node;
|
||||
@@ -99,7 +99,7 @@ namespace StgSharp.Script.Express
|
||||
}
|
||||
} else if( _context.TryGetProcedure( op.Value, out ExpProcedureSource? p ) )
|
||||
{
|
||||
if( !_cache.PopOperand( out Token t, out ExpNode? param ) )
|
||||
if( !_cache.PopOperand( out Token t, out ExpSyntaxNode? param ) )
|
||||
{
|
||||
node = ExpProcedureCallingNode.CallProcedure( op, p, param );
|
||||
return node;
|
||||
@@ -111,7 +111,7 @@ namespace StgSharp.Script.Express
|
||||
}
|
||||
} else if( ExpSchema.BuiltinSchema.TryGetFunction( op.Value, out f ) )
|
||||
{
|
||||
if( !_cache.PopOperand( out Token t, out ExpNode? param ) )
|
||||
if( !_cache.PopOperand( out Token t, out ExpSyntaxNode? param ) )
|
||||
{
|
||||
node = ExpFunctionCallingNode.CallFunction( op, f, param );
|
||||
return node;
|
||||
@@ -132,10 +132,10 @@ namespace StgSharp.Script.Express
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryGenerateBinaryNode( Token t, out ExpNode node )
|
||||
private bool TryGenerateBinaryNode( Token t, out ExpSyntaxNode node )
|
||||
{
|
||||
ExpNode right = GetNextOperandCache();
|
||||
ExpNode left = GetNextOperandCache();
|
||||
ExpSyntaxNode right = GetNextOperandCache();
|
||||
ExpSyntaxNode left = GetNextOperandCache();
|
||||
switch( t.Value )
|
||||
{
|
||||
case ExpKeyword.Add:
|
||||
@@ -172,7 +172,7 @@ namespace StgSharp.Script.Express
|
||||
node = ExpBinaryOperatorNode.CompareInstanceNotEqual( t, left, right );
|
||||
return true;
|
||||
default:
|
||||
node = ExpNode.Empty;
|
||||
node = ExpSyntaxNode.Empty;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@ namespace StgSharp.Script.Express
|
||||
private void ClosePrefixReverse( Token rightSeparator )
|
||||
{
|
||||
Token op;
|
||||
ExpNode root;
|
||||
ExpSyntaxNode root;
|
||||
if( _cache.OperatorAheadOfDepth == 0 )
|
||||
{
|
||||
if( _cache.OperandAheadOfDepth == 1 )
|
||||
{
|
||||
_cache.PopOperand( out _, out ExpNode? statement );
|
||||
_cache.PopOperand( out _, out ExpSyntaxNode? statement );
|
||||
_cache.StatementsInDepth.Push( statement );
|
||||
} else
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace StgSharp.Script.Express
|
||||
AppendToken_common( t );
|
||||
return false;
|
||||
}
|
||||
ExpNode root = _cache.PackAllStatements();
|
||||
ExpSyntaxNode root = _cache.PackAllStatements();
|
||||
state.Body = root;
|
||||
_cache.DecreaseDepth();
|
||||
if( ExpTypeSource.IsNullOrVoid( state.IncrementVariableType ) )
|
||||
@@ -114,7 +114,7 @@ namespace StgSharp.Script.Express
|
||||
while( _cache.TryPopOperator( out Token op ) ) {
|
||||
ConvertAndPushOneOperator( op );
|
||||
}
|
||||
_cache.PopOperand( out _, out ExpNode? root );
|
||||
_cache.PopOperand( out _, out ExpSyntaxNode? root );
|
||||
state.Begin = root;
|
||||
return true;
|
||||
default:
|
||||
@@ -143,7 +143,7 @@ namespace StgSharp.Script.Express
|
||||
while( _cache.TryPopOperator( out Token op ) ) {
|
||||
ConvertAndPushOneOperator( op );
|
||||
}
|
||||
_cache.PopOperand( out _, out ExpNode? root );
|
||||
_cache.PopOperand( out _, out ExpSyntaxNode? root );
|
||||
state.End = root;
|
||||
return true;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ namespace StgSharp.Script.Express
|
||||
while( _cache.TryPopOperator( out Token op ) ) {
|
||||
ConvertAndPushOneOperator( op );
|
||||
}
|
||||
_cache.PopOperand( out _, out ExpNode? root );
|
||||
_cache.PopOperand( out _, out ExpSyntaxNode? root );
|
||||
state.StepIncrement = root;
|
||||
return true;
|
||||
}
|
||||
@@ -187,7 +187,7 @@ namespace StgSharp.Script.Express
|
||||
while( _cache.TryPopOperator( out Token op ) ) {
|
||||
ConvertAndPushOneOperator( op );
|
||||
}
|
||||
_cache.PopOperand( out _, out ExpNode? root );
|
||||
_cache.PopOperand( out _, out ExpSyntaxNode? root );
|
||||
state.UntilExpression = root;
|
||||
return true;
|
||||
}
|
||||
@@ -210,7 +210,7 @@ namespace StgSharp.Script.Express
|
||||
if( ExpTypeSource.IsNullOrVoid( state.IncrementVariableType ) )
|
||||
{
|
||||
if( ( _local.TryGetMember( t.Value,
|
||||
out ExpNode? node ) && node is ExpElementInstance instance ) || _tempVariableInLoops.TryGetValue(
|
||||
out ExpSyntaxNode? node ) && node is ExpElementInstance instance ) || _tempVariableInLoops.TryGetValue(
|
||||
t.Value, out instance ) )
|
||||
{
|
||||
state.IncrementVariable = ExpInstanceReferenceNode.MakeReferenceFrom(
|
||||
@@ -247,7 +247,7 @@ namespace StgSharp.Script.Express
|
||||
while( _cache.TryPopOperator( out Token op ) ) {
|
||||
ConvertAndPushOneOperator( op );
|
||||
}
|
||||
_cache.PopOperand( out _, out ExpNode? root );
|
||||
_cache.PopOperand( out _, out ExpSyntaxNode? root );
|
||||
state.WhileExpression = root;
|
||||
return true;
|
||||
}
|
||||
@@ -258,23 +258,23 @@ namespace StgSharp.Script.Express
|
||||
public RepeatLoopState( Token t )
|
||||
{
|
||||
Position = t;
|
||||
UntilExpression = ExpNode.Empty;
|
||||
WhileExpression = ExpNode.Empty;
|
||||
UntilExpression = ExpSyntaxNode.Empty;
|
||||
WhileExpression = ExpSyntaxNode.Empty;
|
||||
}
|
||||
|
||||
public ExpInstanceReferenceNode IncrementVariable { get; set; }
|
||||
|
||||
public ExpNode StepIncrement { get; set; }
|
||||
public ExpSyntaxNode StepIncrement { get; set; }
|
||||
|
||||
public ExpNode Begin { get; set; }
|
||||
public ExpSyntaxNode Begin { get; set; }
|
||||
|
||||
public ExpNode End { get; set; }
|
||||
public ExpSyntaxNode End { get; set; }
|
||||
|
||||
public ExpNode UntilExpression { get; set; }
|
||||
public ExpSyntaxNode UntilExpression { get; set; }
|
||||
|
||||
public ExpNode WhileExpression { get; set; }
|
||||
public ExpSyntaxNode WhileExpression { get; set; }
|
||||
|
||||
public ExpNode Body { get; set; }
|
||||
public ExpSyntaxNode Body { get; set; }
|
||||
|
||||
public ExpTypeSource IncrementVariableType { get; set; }
|
||||
|
||||
|
||||
@@ -51,19 +51,19 @@ namespace StgSharp.Script.Express
|
||||
private const int TokenGenerated = 0;
|
||||
private const int TokenTypeNotMatch = -1;
|
||||
|
||||
private CompileStack<ExpNode, IExpElementSource> _cache;
|
||||
private ExpNode _lastStatement;
|
||||
private CompileStack<ExpSyntaxNode, IExpElementSource> _cache;
|
||||
private ExpSchema _context;
|
||||
private ExpSyntaxNode _lastStatement;
|
||||
private IExpElementSource _local;
|
||||
|
||||
public ExpSyntaxAnalyzer()
|
||||
{
|
||||
_cache = new CompileStack<ExpNode, IExpElementSource>();
|
||||
_cache = new CompileStack<ExpSyntaxNode, IExpElementSource>();
|
||||
}
|
||||
|
||||
public ExpSyntaxAnalyzer( ExpSchema context, IExpElementSource local )
|
||||
{
|
||||
_cache = new CompileStack<ExpNode, IExpElementSource>();
|
||||
_cache = new CompileStack<ExpSyntaxNode, IExpElementSource>();
|
||||
ArgumentNullException.ThrowIfNull( context );
|
||||
if( context is not ExpSchema_Builtin )
|
||||
{
|
||||
@@ -95,9 +95,9 @@ namespace StgSharp.Script.Express
|
||||
}
|
||||
}
|
||||
|
||||
public ExpNode GetNextOperandCache()
|
||||
public ExpSyntaxNode GetNextOperandCache()
|
||||
{
|
||||
if( _cache.PopOperand( out Token t, out ExpNode? n ) )
|
||||
if( _cache.PopOperand( out Token t, out ExpSyntaxNode? n ) )
|
||||
{
|
||||
return n;
|
||||
} else
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace StgSharp.Script.Express
|
||||
public interface IExpMarshalType<TSelf>
|
||||
{
|
||||
|
||||
static abstract TSelf Create( string name, ExpNode node );
|
||||
static abstract TSelf Create( string name, ExpSyntaxNode node );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"C:\\Program Files\\dotnet\\library-packs": {},
|
||||
"D:\\Programmer\\NugetLocal": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
@@ -103,7 +102,6 @@
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"C:\\Program Files\\dotnet\\library-packs": {},
|
||||
"D:\\Programmer\\NugetLocal": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
|
||||
@@ -1255,7 +1255,6 @@
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"C:\\Program Files\\dotnet\\library-packs": {},
|
||||
"D:\\Programmer\\NugetLocal": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
|
||||
@@ -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+9457309c5ab188ce824a10ab60e572553986b6eb")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c29993fd8497704d2ddeab3e1a3f8bfa5caa8d90")]
|
||||
[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/2692495dc8460e1f60a2d073f162c5f526e1ba1b/*"}}
|
||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/c29993fd8497704d2ddeab3e1a3f8bfa5caa8d90/*"}}
|
||||
Reference in New Issue
Block a user