Daily update on 20250305-052510 by Nitload Youmu. Additional Message : message

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-03-05 05:25:11 +08:00
parent 5d4f516a28
commit c5777f4bfe
8 changed files with 171 additions and 69 deletions
@@ -66,88 +66,55 @@ namespace StgSharp.Script.Express
/// meets separators or operators.
/// </summary>
/// <param name="expToken"></param>
public void AppendToken( Token expToken )
public ExpNode AppendToken( Token expToken )
{
switch( expToken.Flag ) {
case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary:
_operandsToken.Push( expToken );
break;
case TokenFlag.Number or TokenFlag.String or TokenFlag.Member:
break;
case TokenFlag.Separator_Single:
case TokenFlag.Separator_Single: // a , ; found
break;
case TokenFlag.Separator_Left:
case TokenFlag.Separator_Left: //a ( [ { found
break;
case TokenFlag.Separator_Right:
case TokenFlag.Separator_Right: //a } ] ) found
break;
case TokenFlag.Index_Left:
case TokenFlag.Index_Left: // a [ found
break;
case TokenFlag.Index_Right:
case TokenFlag.Index_Right: // a ] found
break;
default:
break;
}
}
public void CacheNextOperandNode( ExpNode node )
public ExpNode GetNextOperandCache()
{
_operandsNode.Push( node );
if( _operandsNode.Count != 0 ) {
return _operandsNode.Pop();
}
if( _operandsToken.Count != 0 ) {
Token token = _operandsToken.Pop();
}
return ExpNode.Empty;
}
public AbstractSyntaxTree<ExpNode, IExpElementSource> CloseAndDispose()
//ConvertOneOperator not finish
private void ConvertOneOperator()
{
if( _operandsToken.Count != 0 ) {
// convert rest to AST
}
return new AbstractSyntaxTree<ExpNode, IExpElementSource>();
}
/*
public ExpNode GenerateNode( Token t )
{
switch( t.Flag ) {
Token @operator = _operators.Pop();
switch( @operator.Flag ) {
case TokenFlag.Symbol_Unary:
break;
case TokenFlag.Symbol_Binary:
break;
case TokenFlag.Number:
break;
case TokenFlag.String:
break;
case TokenFlag.Member:
break;
case TokenFlag.Separator_Single:
break;
case TokenFlag.Separator_Left:
break;
case TokenFlag.Separator_Right:
break;
case TokenFlag.Index_Left:
break;
case TokenFlag.Index_Right:
break;
default:
break;
}
}
/**/
public int GetNextOperandCache( out Token? token, out ExpNode? node )
{
if( _operandsNode.Count != 0 ) {
node = _operandsNode.Pop();
token = null!;
return 2;
}
if( _operandsToken.Count != 0 ) {
token = _operandsToken.Pop();
node = null!;
return 1;
}
token = null;
node = null!;
return 0;
}
}
}
@@ -0,0 +1,74 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="FunctionCallingGenerator.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static StgSharp.Script.Express.ExpCompile;
namespace StgSharp.Script.Express
{
public partial class ExpNodeGenerator
{
private bool _isCallingFunction = false;
private Stack<int> _callDepth = new Stack<int>();
private void EnterFunctionCalling( Token funcNameToken )
{
_isCallingFunction = true;
_callDepth.Push( _operandsToken.Count );
}
private void ExitFunctionCalling()
{
_callDepth.Pop();
if( _callDepth.Count == 0 ) {
_isCallingFunction = false;
}
}
//TODO cannot process occasion of void input or null at first
private void MergeFunctionCallingParameter()
{
if( _callDepth.Peek() == _operandsToken.Count ) {
_operandsNode.Peek()
.PrependNode(
ExpNode.NonOperation( PoolString( "FuncParam" ) ) );
} else {
//TODO compile the param expression
}
}
}
}
@@ -38,21 +38,48 @@ namespace StgSharp.Script.Express
{
public partial class ExpNodeGenerator
{
/*
public ExpNode GenerateUnaryToken( Token t )
public bool TryGenerateBinaryNode( Token t, out ExpNode node )
{
ExpNode left = GetNextOperandCache();
ExpNode right = GetNextOperandCache();
switch( t.Value ) {
case ExpCompile.KeyWord.UnaryAdd:
break;
case ExpCompile.KeyWord.UnarySub:
break;
case ExpCompile.KeyWord.NOT:
break;
case ExpCompile.KeyWord.ADD:
node = ExpBinaryOperatorNode.Add( left, right );
return true;
case ExpCompile.KeyWord.SUB:
node = ExpBinaryOperatorNode.Sub( left, right );
return true;
case ExpCompile.KeyWord.MUL:
node = ExpBinaryOperatorNode.Mul( left, right );
return true;
case ExpCompile.KeyWord.DIV:
node = ExpBinaryOperatorNode.Div( left, right );
return true;
default:
break;
node = ExpNode.Empty;
return false;
}
}
public bool TryGenerateUnaryNode( Token t, out ExpNode node )
{
ExpNode operand = GetNextOperandCache();
switch( t.Value ) {
case ExpCompile.KeyWord.UnaryPlus:
node = ExpUnaryOperatorNode.UnaryPlus( operand );
return true;
case ExpCompile.KeyWord.UnaryMinus:
node = ExpUnaryOperatorNode.UnaryMinus( operand );
return true;
case ExpCompile.KeyWord.NOT:
node = ExpUnaryOperatorNode.UnaryNot( operand );
return true;
default:
node = ExpNode.Empty;
return false;
}
}
/**/
}
}