Daily update on 20251020-041041 by Nitload Youmu. Additional Message : Code cleanup and new design of parallel (maybe THE THENTH VERSION? Tough work!).

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-10-20 04:10:41 +08:00
parent 1927f4fdf3
commit 547ba80a01
141 changed files with 5475 additions and 6175 deletions
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.Common.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.Common"
// 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:
// 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.
//
// 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 Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Script;
@@ -53,10 +50,10 @@ namespace StgSharp.Model.Step
private StepDependencyDetector _dependencyDetector = new StepDependencyDetector();
[GeneratedRegex( @"^[A-Z0-9_]+$", RegexOptions.Singleline )]
[GeneratedRegex(@"^[A-Z0-9_]+$", RegexOptions.Singleline)]
private static partial Regex GetEntityTypeCheckPattern();
private bool IsSeparatorMatch( Token leftSeparator, Token rightSeparator )
private bool IsSeparatorMatch(Token leftSeparator, Token rightSeparator)
{
return leftSeparator.Value switch
{
@@ -68,234 +65,234 @@ namespace StgSharp.Model.Step
};
}
private bool TryAppendIndexLeft( Token t )
private bool TryAppendIndexLeft(Token t)
{
if( t.Flag != TokenFlag.Index_Left ) {
if (t.Flag != TokenFlag.Index_Left) {
return false;
}
if( _cache.TryPeekOperand( out bool isNode, out _, out ExpSyntaxNode? node ) )
if (_cache.TryPeekOperand(out bool isNode, out _, out ExpSyntaxNode? node))
{
if( node.EqualityTypeConvert is not ExpCollectionBase ) {
ExpInvalidSyntaxException.ThrowNonCollectionIndex( t );
if (node.EqualityTypeConvert is not ExpCollectionBase) {
ExpInvalidSyntaxException.ThrowNonCollectionIndex(t);
}
}
_cache.PushOperator( t );
_cache.IncreaseDepth( ( int )ExpCompileStateCode.CollectionIndex );
_cache.PushOperator(t);
_cache.IncreaseDepth((int)ExpCompileStateCode.CollectionIndex);
return true;
}
private bool TryAppendIndexRight( Token t )
private bool TryAppendIndexRight(Token t)
{
if( t.Flag != TokenFlag.Index_Right ) {
if (t.Flag != TokenFlag.Index_Right) {
return false;
}
//reverse building
ClosePrefixReverse( t );
// reverse building
ClosePrefixReverse(t);
//make index node
_cache.PopOperand( out _, out ExpSyntaxNode? expNode );
if( !_cache.PopOperand( out Token colleToken, out ExpSyntaxNode? colleNode ) ) { }
// make index node
_cache.PopOperand(out _, out ExpSyntaxNode? expNode);
if (!_cache.PopOperand(out Token colleToken, out ExpSyntaxNode? colleNode)) { }
_cache.PushOperand(
ExpCollectionIndexNode.Create(
t, ( colleNode as ExpCollectionInstanceBase )!, expNode ) );
t, (colleNode as ExpCollectionInstanceBase)!, expNode));
return true;
}
private bool TryAppendMember( Token t )
private bool TryAppendMember(Token t)
{
if( t.Flag != TokenFlag.Member ) {
if (t.Flag != TokenFlag.Member) {
return false;
}
if( TryParseConstant( t ) ) {
if (TryParseConstant(t)) {
return true;
}
if( TryParseFunction( t ) ) {
if (TryParseFunction(t)) {
return true;
}
if( TryParseInstance( t ) ) {
if (TryParseInstance(t)) {
return true;
}
if( TryParseKeyword( t ) ) {
if (TryParseKeyword(t)) {
return true;
}
if( TryParseElementName( t ) ) {
if (TryParseElementName(t)) {
return true;
}
//Many thing miss here
_cache.PushOperand( ExpElementMemberNameNode.Create( t ) );
// Many thing miss here
_cache.PushOperand(ExpElementMemberNameNode.Create(t));
return true;
}
private bool TryAppendMiddleSeparator( Token t )
private bool TryAppendMiddleSeparator(Token t)
{
if( t.Flag != TokenFlag.Separator_Middle ) {
if (t.Flag != TokenFlag.Separator_Middle) {
return false;
}
while( _cache.OperatorAheadOfDepth > 0 )
while (_cache.OperatorAheadOfDepth > 0)
{
_cache.TryPopOperator( out Token op );
ExpSyntaxNode node = ConvertAndPushOneOperator( op );
_cache.TryPopOperator(out Token op);
ExpSyntaxNode node = ConvertAndPushOneOperator(op);
}
switch( _cache.OperandAheadOfDepth )
switch (_cache.OperandAheadOfDepth)
{
case 0:
if( t.Value == ";" ) {
if (t.Value == ";") {
return true;
}
_cache.StatementsInDepth.Push( ExpSyntaxNode.Empty );
_cache.StatementsInDepth.Push(ExpSyntaxNode.Empty);
goto case 1;
case 1:
_cache.PopOperand( out _, out ExpSyntaxNode? statement );
if( t.Value == ";" )
_cache.PopOperand(out _, out ExpSyntaxNode? statement);
if (t.Value == ";")
{
StepEntityDefineSequence sequence = new StepEntityDefineSequence(
statement, _dependencyDetector.ExportAllDependencies() );
StepEntityInitStatements.Enqueue( sequence );
statement, _dependencyDetector.ExportAllDependencies());
StepEntityInitStatements.Enqueue(sequence);
} else
{
_cache.StatementsInDepth.Push( statement );
_cache.StatementsInDepth.Push(statement);
}
return true;
default:
ExpInvalidSyntaxException.ThrowNoOperator( t );
ExpInvalidSyntaxException.ThrowNoOperator(t);
break;
}
return true;
}
private bool TryAppendNumAndStrLiteral( Token t )
private bool TryAppendNumAndStrLiteral(Token t)
{
if( ( t.Flag & ( TokenFlag.String | TokenFlag.Number ) ) == 0 ) {
if ((t.Flag & (TokenFlag.String | TokenFlag.Number)) == 0) {
return false;
}
_cache.PushOperand( ExpElementInstance.CreateLiteral( t ) );
_cache.PushOperand(ExpElementInstance.CreateLiteral(t));
return true;
}
private bool TryAppendPrefixSeparator( Token t )
private bool TryAppendPrefixSeparator(Token t)
{
if( t.Flag != TokenFlag.Separator_Left ) {
if (t.Flag != TokenFlag.Separator_Left) {
return false;
}
_cache.PushOperator( t );
_cache.IncreaseDepth( ( int )ExpCompileStateCode.Common );
_cache.PushOperator(t);
_cache.IncreaseDepth((int)ExpCompileStateCode.Common);
return true;
}
private bool TryAppendPrefixSeparatorEnd( Token t )
private bool TryAppendPrefixSeparatorEnd(Token t)
{
if( t.Flag != TokenFlag.Separator_Right ) {
if (t.Flag != TokenFlag.Separator_Right) {
return false;
}
ClosePrefixReverse( t );
ClosePrefixReverse(t);
return true;
}
private bool TryAppendSymbol( Token t )
private bool TryAppendSymbol(Token t)
{
if( ( t.Flag & ( TokenFlag.Symbol_Unary | TokenFlag.Symbol_Binary ) ) == 0 ) {
if ((t.Flag & (TokenFlag.Symbol_Unary | TokenFlag.Symbol_Binary)) == 0) {
return false;
}
int cmp = -1;
processPrecedence:
if( _cache.TryPeekOperator( out Token tmp ) )
if (_cache.TryPeekOperator(out Token tmp))
{
cmp = CompareOperatorPrecedence( t, tmp );
if( cmp >= 0 )
cmp = CompareOperatorPrecedence(t, tmp);
if (cmp >= 0)
{
_cache.PopOperator();
ExpSyntaxNode node = ConvertAndPushOneOperator( tmp );
ExpSyntaxNode node = ConvertAndPushOneOperator(tmp);
goto processPrecedence;
}
}
_cache.PushOperator( t );
_cache.PushOperator(t);
return true;
}
private bool TryParseConstant( Token t )
private bool TryParseConstant(Token t)
{
switch( t.Value )
switch (t.Value)
{
case "$":
_cache.PushOperand( StepEntityInstanceNode.RegisterNull( t ) );
_cache.PushOperand(StepEntityInstanceNode.RegisterNull(t));
return true;
case "*":
_cache.PushOperand( StepEntityInstanceNode.RegisterRuntimeInference( t ) );
_cache.PushOperand(StepEntityInstanceNode.RegisterRuntimeInference(t));
return true;
case ExpKeyword.E:
_cache.PushOperand( new ExpRealNumberNode( t, MathF.E, true ) );
_cache.PushOperand(new ExpRealNumberNode(t, MathF.E, true));
return true;
case ExpKeyword.Pi:
_cache.PushOperand( new ExpRealNumberNode( t, MathF.PI, true ) );
_cache.PushOperand(new ExpRealNumberNode(t, MathF.PI, true));
return true;
default:
if( ExpElementInstance.TryCreateLiteral( t, out ExpElementInstance? node ) )
if (ExpElementInstance.TryCreateLiteral(t, out ExpElementInstance? node))
{
_cache.PushOperand( node );
_cache.PushOperand(node);
return true;
}
return false;
}
}
private bool TryParseElementName( Token t )
private bool TryParseElementName(Token t)
{
if( _context.TryGetType( t.Value, out ExpTypeSource? type ) )
if (_context.TryGetType(t.Value, out ExpTypeSource? type))
{
_cache.PushOperand( ExpMetaRefNode.RefType( t, type ) );
_cache.PushOperand(ExpMetaRefNode.RefType(t, type));
return true;
}
if( _context.TryGetEntity( t.Value, out ExpEntitySource? entity ) )
if (_context.TryGetEntity(t.Value, out ExpEntitySource? entity))
{
_cache.PushOperand( ExpMetaRefNode.RefEntity( t, entity ) );
_cache.PushOperand(ExpMetaRefNode.RefEntity(t, entity));
return true;
}
return false;
}
private bool TryParseFunction( Token t )
private bool TryParseFunction(Token t)
{
if( _entityTypeCheckPattern.IsMatch( t.Value ) )
if (_entityTypeCheckPattern.IsMatch(t.Value))
{
if( _cache.PeekOperator().Flag == TokenFlag.Member )
if (_cache.PeekOperator().Flag == TokenFlag.Member)
{
Token op = _cache.PopOperator();
ConvertAndPushOneOperator( op );
ConvertAndPushOneOperator(op);
}
_cache.PushOperator( t );
_cache.PushOperator(t);
return true;
}
return false;
}
private bool TryParseInstance( Token t )
private bool TryParseInstance(Token t)
{
if( t.Value[ 0 ] == '#' )
if (t.Value[0] == '#')
{
StepEntityInstanceNode node = StepEntityInstanceNode.Register( t );
if( t.Column != 0 ) {
_dependencyDetector.AddDependency( node );
StepEntityInstanceNode node = StepEntityInstanceNode.Register(t);
if (t.Column != 0) {
_dependencyDetector.AddDependency(node);
}
_cache.PushOperand( node );
_cache.PushOperand(node);
return true;
}
return false;
}
private bool TryParseKeyword( Token t )
private bool TryParseKeyword(Token t)
{
switch( t.Value )
switch (t.Value)
{
case ExpKeyword.Return:
_cache.PushOperator( t );
_cache.PushOperator(t);
return true;
case ExpKeyword.Skip:
_cache.PushOperand( ExpProcedureControlNode.Skip( t ) );
_cache.PushOperand(ExpProcedureControlNode.Skip(t));
return true;
default:
return false;
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.Enum.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.Enum"
// 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:
// 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.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
@@ -42,26 +39,26 @@ namespace StgSharp.Model.Step
internal partial class StepExpSyntaxAnalyzer
{
private static string ParseStepEnumLiteral( string source )
private static string ParseStepEnumLiteral(string source)
{
int length = source.Length;
ReadOnlySpan<char> span = source.AsSpan();
if( length > 2 && span[ 0 ] == '.' && span[ length - 1 ] == '.' ) {
return span.Slice( 1, length - 2 ).ToString();
if (length > 2 && span[0] == '.' && span[length - 1] == '.') {
return span.Slice(1, length - 2).ToString();
}
throw new ExpInvalidSyntaxException( $"\"{source}\" is not a valid enum syntax" );
throw new ExpInvalidSyntaxException($"\"{source}\" is not a valid enum syntax");
}
private void TryAppendEnum( Token e )
private void TryAppendEnum(Token e)
{
ExpSyntaxNode node = e.Value switch
{
".T." => new ExpBoolNode( e, true, true ),
".F." => new ExpBoolNode( e, false, true ),
".U." => new ExpLogicValueNode( e, ExpLogic.Unknown, true ),
_ => ExpEnumLiteralNode.Create( e, ParseStepEnumLiteral ),
".T." => new ExpBoolNode(e, true, true),
".F." => new ExpBoolNode(e, false, true),
".U." => new ExpLogicValueNode(e, ExpLogic.Unknown, true),
_ => ExpEnumLiteralNode.Create(e, ParseStepEnumLiteral),
};
_cache.PushOperand( node );
_cache.PushOperand(node);
}
}
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.ErrorProcess.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.ErrorProcess"
// 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:
// 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.
//
// 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;
@@ -39,9 +36,9 @@ namespace StgSharp.Model.Step
internal partial class StepExpSyntaxAnalyzer
{
public void ThrowCompileException( int errorCode )
public void ThrowCompileException(int errorCode)
{
switch( errorCode )
switch (errorCode)
{
case 0 or 1:
return;
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.OperatorParser.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.OperatorParser"
// 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:
// 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.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
@@ -44,26 +41,26 @@ namespace StgSharp.Model.Step
internal partial class StepExpSyntaxAnalyzer
{
public int CompareOperatorPrecedence( Token left, Token right )
public int CompareOperatorPrecedence(Token left, Token right)
{
ExpressCompile.TryGetOperatorPrecedence( left.Value, out int leftPrecedence );
ExpressCompile.TryGetOperatorPrecedence( right.Value, out int rightPrecedence );
ExpressCompile.TryGetOperatorPrecedence(left.Value, out int leftPrecedence);
ExpressCompile.TryGetOperatorPrecedence(right.Value, out int rightPrecedence);
return leftPrecedence - rightPrecedence;
}
public bool TryGenerateUnaryNode( Token t, out ExpSyntaxNode node )
public bool TryGenerateUnaryNode(Token t, out ExpSyntaxNode node)
{
ExpSyntaxNode operand = GetNextOperandCache();
switch( t.Value )
switch (t.Value)
{
case ExpKeyword.UnaryPlus:
node = ExpUnaryOperatorNode.UnaryPlus( t, operand );
node = ExpUnaryOperatorNode.UnaryPlus(t, operand);
return true;
case ExpKeyword.UnaryMinus:
node = ExpUnaryOperatorNode.UnaryMinus( t, operand );
node = ExpUnaryOperatorNode.UnaryMinus(t, operand);
return true;
case ExpKeyword.Not:
node = ExpUnaryOperatorNode.UnaryNot( t, operand );
node = ExpUnaryOperatorNode.UnaryNot(t, operand);
return true;
default:
node = ExpSyntaxNode.Empty;
@@ -75,43 +72,43 @@ namespace StgSharp.Model.Step
/// WARNING: This method cannot process INDEXOF, FUNCTION CALLING, LOOP and any ENDING
/// SYMBOLS.
/// </summary>
private ExpSyntaxNode ConvertAndPushOneOperator( Token op )
private ExpSyntaxNode ConvertAndPushOneOperator(Token op)
{
switch( op.Flag )
switch (op.Flag)
{
case TokenFlag.Symbol_Unary:
TryGenerateUnaryNode( op, out ExpSyntaxNode? node );
_cache.PushOperand( node );
TryGenerateUnaryNode(op, out ExpSyntaxNode? node);
_cache.PushOperand(node);
return node;
case TokenFlag.Symbol_Binary:
TryGenerateBinaryNode( op, out node );
_cache.PushOperand( node );
TryGenerateBinaryNode(op, out node);
_cache.PushOperand(node);
return node;
case TokenFlag.Member:
_cache.PopOperand( out _, out ExpSyntaxNode? p );
StepEntityInitCaller caller = StepEntityInitCaller.CreateCaller( op.Value );
node = ExpFunctionCallingNode.CallFunction( op, caller, p );
_cache.StatementsInDepth.Push( node );
_cache.PopOperand(out _, out ExpSyntaxNode? p);
StepEntityInitCaller caller = StepEntityInitCaller.CreateCaller(op.Value);
node = ExpFunctionCallingNode.CallFunction(op, caller, p);
_cache.StatementsInDepth.Push(node);
return node;
default:
throw new NotImplementedException();
}
}
private bool TryGenerateBinaryNode( Token t, out ExpSyntaxNode node )
private bool TryGenerateBinaryNode(Token t, out ExpSyntaxNode node)
{
/*
ExpSyntaxNode right = GetNextOperandCache();
ExpSyntaxNode left = GetNextOperandCache();
/**/
switch( t.Value )
switch (t.Value)
{
case "=":
ExpSyntaxNode right = GetNextOperandCache();
ExpSyntaxNode left;
if( right is ExpTupleNode tuple )
if (right is ExpTupleNode tuple)
{
right = StepComplexEntityNode.FromTuple( tuple );
right = StepComplexEntityNode.FromTuple(tuple);
left = GetNextOperandCache();
} else
{
@@ -119,7 +116,7 @@ namespace StgSharp.Model.Step
right = _cache.StatementsInDepth.Pop();
}
node = ExpBinaryOperatorNode.Assign( t, left, right );
node = ExpBinaryOperatorNode.Assign(t, left, right);
return true;
default:
node = ExpSyntaxNode.Empty;
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.PrefixReverseAnalysing.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.PrefixReverseAnalysing"
// 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:
// 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.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
@@ -45,44 +42,44 @@ namespace StgSharp.Model.Step
internal partial class StepExpSyntaxAnalyzer
{
private void ClosePrefixReverse( Token rightSeparator )
private void ClosePrefixReverse(Token rightSeparator)
{
Token op;
ExpSyntaxNode root;
if( _cache.OperatorAheadOfDepth == 0 )
if (_cache.OperatorAheadOfDepth == 0)
{
if( _cache.OperandAheadOfDepth == 1 )
if (_cache.OperandAheadOfDepth == 1)
{
_cache.PopOperand( out _, out ExpSyntaxNode? statement );
_cache.StatementsInDepth.Push( statement );
_cache.PopOperand(out _, out ExpSyntaxNode? statement);
_cache.StatementsInDepth.Push(statement);
} else
{
_cache.StatementsInDepth.Push( ExpSyntaxNode.Empty );
_cache.StatementsInDepth.Push(ExpSyntaxNode.Empty);
}
} else
{
while( _cache.TryPopOperator( out op ) )
while (_cache.TryPopOperator(out op))
{
ExpSyntaxNode node = ConvertAndPushOneOperator( op );
ExpSyntaxNode node = ConvertAndPushOneOperator(op);
}
if( _cache.OperandAheadOfDepth == 1 )
if (_cache.OperandAheadOfDepth == 1)
{
_cache.PopOperand( out _, out root );
_cache.StatementsInDepth.Push( root );
_cache.PopOperand(out _, out root);
_cache.StatementsInDepth.Push(root);
}
}
root = _cache.PackAllStatements();
_cache.DecreaseDepth();
if( IsSeparatorMatch( _cache.PeekOperator(), rightSeparator ) )
if (IsSeparatorMatch(_cache.PeekOperator(), rightSeparator))
{
_cache.PopOperator();
root = ExpTupleNode.Pack( root );
_cache.PushOperand( root );
root = ExpTupleNode.Pack(root);
_cache.PushOperand(root);
} else
{
throw new ExpCompileException(
rightSeparator, "Ending of block does not match its begging" );
rightSeparator, "Ending of block does not match its begging");
}
}
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer"
// 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:
// 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.
//
// 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 Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Script;
@@ -71,37 +68,37 @@ namespace StgSharp.Model.Step
/// Append a token to top of cache. This method will automatically convert token to node
/// if meets separators or operators.
/// </summary>
public void AppendToken( Token expToken )
public void AppendToken(Token expToken)
{
switch( expToken.Flag )
switch (expToken.Flag)
{
case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary:
TryAppendSymbol( expToken );
TryAppendSymbol(expToken);
break;
case TokenFlag.Number or TokenFlag.String:
ExpElementInstance node = ExpElementInstance.CreateLiteral( expToken );
_cache.PushOperand( node );
ExpElementInstance node = ExpElementInstance.CreateLiteral(expToken);
_cache.PushOperand(node);
break;
case TokenFlag.Separator_Left:
TryAppendPrefixSeparator( expToken );
TryAppendPrefixSeparator(expToken);
break;
case TokenFlag.Separator_Right:
TryAppendPrefixSeparatorEnd( expToken );
TryAppendPrefixSeparatorEnd(expToken);
break;
case TokenFlag.Separator_Middle:
TryAppendMiddleSeparator( expToken );
TryAppendMiddleSeparator(expToken);
break;
case TokenFlag.Index_Left:
TryAppendIndexLeft( expToken );
TryAppendIndexLeft(expToken);
break;
case TokenFlag.Index_Right:
TryAppendIndexRight( expToken );
TryAppendIndexRight(expToken);
break;
case TokenFlag.Member:
TryAppendMember( expToken );
TryAppendMember(expToken);
break;
case TokenFlag.Enum:
TryAppendEnum( expToken );
TryAppendEnum(expToken);
break;
default:
break;
@@ -110,7 +107,7 @@ namespace StgSharp.Model.Step
public ExpSyntaxNode GetNextOperandCache()
{
if( _cache.PopOperand( out Token t, out ExpSyntaxNode? n ) )
if (_cache.PopOperand(out Token t, out ExpSyntaxNode? n))
{
return n;
} else
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepDataSectionsTranmitter.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="StepDataSectionsTranmitter"
// 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:
// 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.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Script;
using System;
@@ -45,13 +42,13 @@ namespace StgSharp.Model.Step
private const string EndDataText = "ENDSEC;";
//private bool _isEmpty;
// private bool _isEmpty;
private ConcurrentQueue<string> _cache = new ConcurrentQueue<string>();
private int _line = 0;
public StepDataSectionTransmitter() { }
public StepDataSectionTransmitter( int begins )
public StepDataSectionTransmitter(int begins)
{
Begin = begins;
_line = Begin;
@@ -72,7 +69,7 @@ namespace StgSharp.Model.Step
public string ReadLine()
{
if( _cache.TryDequeue( out string? line ) )
if (_cache.TryDequeue(out string? line))
{
_line++;
return line;
@@ -80,29 +77,29 @@ namespace StgSharp.Model.Step
return string.Empty;
}
public string ReadLine( out int position )
public string ReadLine(out int position)
{
string ret = ReadLine();
position = _line;
return ret;
}
public void WriteLine( string line )
public void WriteLine(string line)
{
if( line == "DATA;" ) {
if (line == "DATA;") {
return;
}
if( line == EndDataText )
if (line == EndDataText)
{
EndWriting();
return;
}
if( IsWriting ) {
_cache.Enqueue( line );
if (IsWriting) {
_cache.Enqueue(line);
}
}
IScriptSourceProvider IScriptSourceProvider.Slice( int location, int count )
IScriptSourceProvider IScriptSourceProvider.Slice(int location, int count)
{
throw new NotSupportedException();
}
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepDataTokenReader.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="StepDataTokenReader"
// 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:
// 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.
//
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
@@ -48,15 +45,13 @@ namespace StgSharp.Model.Step
private ExpTokenReader _reader;
private HashSet<string> tokenHash = [
"T","F","UNSPECIFIED"
];
private HashSet<string> tokenHash = [ "T", "F", "UNSPECIFIED" ];
private Queue<Token> _cache = new Queue<Token>();
private StepDataSectionTransmitter _transmitter;
public StepDataTokenReader( StepDataSectionTransmitter transmitter )
public StepDataTokenReader(StepDataSectionTransmitter transmitter)
{
_reader = new ExpTokenReader( transmitter );
_reader = new ExpTokenReader(transmitter);
_reader.TokenReaderPreProcessor = new TokenPreReader();
_transmitter = transmitter;
}
@@ -65,7 +60,7 @@ namespace StgSharp.Model.Step
{
get
{
if( _reader.IsEmpty ) {
if (_reader.IsEmpty) {
return !_transmitter.IsWriting;
}
return false;
@@ -77,9 +72,9 @@ namespace StgSharp.Model.Step
return _reader.ReadToken();
}
public bool TryReadToken( out Token t )
public bool TryReadToken(out Token t)
{
return _reader.TryReadToken( out t );
return _reader.TryReadToken(out t);
}
private partial class TokenPreReader : ExpTokenReaderPreProcessor
@@ -90,61 +85,61 @@ namespace StgSharp.Model.Step
_nextEnumPattern = GetNextEnumPattern(),
_stringPattern = GetStringPattern();
public override bool Process( string codeLine, int line, ref int current, out Token t )
public override bool Process(string codeLine, int line, ref int current, out Token t)
{
ReadOnlySpan<char> chars = codeLine.AsSpan( current );
char c = chars[ 0 ];
ReadOnlySpan<char> chars = codeLine.AsSpan(current);
char c = chars[0];
Match match;
switch( c )
switch (c)
{
case '#':
match = _nextHashtagSymbolPattern.Match( codeLine, current );
if( match.Success )
match = _nextHashtagSymbolPattern.Match(codeLine, current);
if (match.Success)
{
int begin = match.Groups[ "token" ].Index;
int end = match.Groups[ "end" ].Index;
int rest = match.Groups[ "rest" ].Index;
int begin = match.Groups["token"].Index;
int end = match.Groups["end"].Index;
int rest = match.Groups["rest"].Index;
current = rest;
t = new(
ExpressCompile.PoolString( chars[ 0..( end - begin ) ] ), line,
begin, TokenFlag.Member );
ExpressCompile.PoolString(chars[0..(end - begin)]), line,
begin, TokenFlag.Member);
return true;
}
break;
case '.':
match = _nextEnumPattern.Match( codeLine, current );
if( match.Success )
match = _nextEnumPattern.Match(codeLine, current);
if (match.Success)
{
int begin = match.Groups[ "token" ].Index;
int end = match.Groups[ "end" ].Index;
int rest = match.Groups[ "rest" ].Index;
int begin = match.Groups["token"].Index;
int end = match.Groups["end"].Index;
int rest = match.Groups["rest"].Index;
current = rest;
t = new Token(
match.Groups[ "token" ].Value, line, begin, TokenFlag.Enum );
match.Groups["token"].Value, line, begin, TokenFlag.Enum);
return true;
}
break;
case '$':
t = new Token( "$", line, current, TokenFlag.Member );
t = new Token("$", line, current, TokenFlag.Member);
current++;
return true;
case '*':
t = new Token( "*", line, current, TokenFlag.Member );
t = new Token("*", line, current, TokenFlag.Member);
current++;
return true;
case '\'':
match = _stringPattern.Match( codeLine, current );
if( match.Success )
match = _stringPattern.Match(codeLine, current);
if (match.Success)
{
int begin = match.Groups[ "token" ].Index;
int end = match.Groups[ "end" ].Index;
int rest = match.Groups[ "rest" ].Index;
int begin = match.Groups["token"].Index;
int end = match.Groups["end"].Index;
int rest = match.Groups["rest"].Index;
current = rest;
string value = chars.Slice( 1, ( end - begin - 1 ) ).ToString();
if( string.IsNullOrWhiteSpace( value ) ) {
string value = chars.Slice(1, (end - begin - 1)).ToString();
if (string.IsNullOrWhiteSpace(value)) {
value = string.Empty;
}
t = new Token( value, line, begin, TokenFlag.String );
t = new Token(value, line, begin, TokenFlag.String);
return true;
}
break;
@@ -155,19 +150,13 @@ namespace StgSharp.Model.Step
return false;
}
[GeneratedRegex(
@"(?<token>#[0-9A-Za-z]+)(?<end>\s*?)(?<rest>\S|$)",
RegexOptions.Singleline )]
[GeneratedRegex(@"(?<token>#[0-9A-Za-z]+)(?<end>\s*?)(?<rest>\S|$)", RegexOptions.Singleline)]
private static partial Regex GetEntityTagSymbolPattern();
[GeneratedRegex(
@"(?<token>\.[A-Za-z_]+\.)(?<end>\s*)(?<rest>\S*)",
RegexOptions.Singleline )]
[GeneratedRegex(@"(?<token>\.[A-Za-z_]+\.)(?<end>\s*)(?<rest>\S*)", RegexOptions.Singleline)]
private static partial Regex GetNextEnumPattern();
[GeneratedRegex(
@"(?<token>')(?>\\\\|''|(?!')[^'])*(?<end>')\s*?(?<rest>\S|$)",
RegexOptions.Singleline )]
[GeneratedRegex(@"(?<token>')(?>\\\\|''|(?!')[^'])*(?<end>')\s*?(?<rest>\S|$)", RegexOptions.Singleline)]
private static partial Regex GetStringPattern();
}
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepDependencyDetector.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="StepDependencyDetector"
// 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:
// 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.
//
// 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.Model.Step;
using System;
@@ -45,9 +42,9 @@ namespace StgSharp.Model.Step
public List<int> Dependencies { get; private set; } = new();
public void AddDependency( StepEntityInstanceNode node )
public void AddDependency(StepEntityInstanceNode node)
{
Dependencies.Add( node.Id );
Dependencies.Add(node.Id);
}
public IEnumerable<int> ExportAllDependencies()
@@ -1,33 +1,30 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepEntityDefineSequence.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// -----------------------------------------------------------------------
// file="StepEntityDefineSequence"
// 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:
// 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.
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Script.Express;
using System;
@@ -41,7 +38,8 @@ namespace StgSharp.Model.Step
{
public record class StepEntityDefineSequence
{
public StepEntityDefineSequence( ExpSyntaxNode node, IEnumerable<int> dep )
public StepEntityDefineSequence(ExpSyntaxNode node, IEnumerable<int> dep)
{
Expression = node;
Dependencies = dep;
@@ -50,5 +48,6 @@ namespace StgSharp.Model.Step
public ExpSyntaxNode Expression { get; init; }
public IEnumerable<int> Dependencies { get; init; }
}
}