Daily update on 20250324-100332 by Nitload Youmu. Additional Message : Single line syntax analyzer ok, gonging on unit test of multi line, func call. Then building branch, loop, area syntax analyzer. Some of descriptors not supported.

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-03-24 10:03:32 +08:00
parent 148b0fed4a
commit ffd5825a05
52 changed files with 522 additions and 560 deletions
+72 -4
View File
@@ -36,6 +36,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Schema;
namespace StgSharp
{
@@ -54,6 +55,67 @@ namespace StgSharp
LocalVariables.Add(
"c",
ExpElementInstanceBase.CreateLiteral( new Token( "1", 0, 0, TokenFlag.Number ) ) );
LocalVariables.Add(
"d",
ExpElementInstanceBase.CreateLiteral( new Token( "1", 0, 0, TokenFlag.Number ) ) );
}
}
internal class TestSchema : ExpSchema
{
internal ExpTestFuncSource source;
public TestSchema( ExpTestFuncSource testType )
{
source = testType;
}
public override void LoadFromSource( ExpSchemaSource source )
{
return;
}
public override bool TryGetConst( string name, out ExpElementInstanceBase c )
{
c = null;
return false;
}
public override bool TryGetEntity( string name, out ExpEntitySource e )
{
e = null;
return false;
}
public override bool TryGetFunction( string name, out ExpFunctionSource f )
{
if( name == "TestFunc" )
{
f = source;
return true;
}
f = null;
return false;
}
public override bool TryGetRule( string name, out ExpRuleSource r )
{
r = null;
return false;
}
public override bool TryGetSchemaInclude( string name, out ExpSchema include )
{
include = null;
return false;
}
public override bool TryGetType( string name, out ExpTypeSource t )
{
t = null;
return false;
}
}
@@ -65,17 +127,23 @@ namespace StgSharp
{
ExpressCompile.InitCompile();
ScriptSourceTransmitter transmitter = new ScriptSourceTransmitter( "END", 0 );
transmitter.WriteLine( @"a := b + c;" );
transmitter.WriteLine( @"a := ( b + c + d * 2 ) * d;" );
//transmitter.WriteLine( @"a := b + (c + d) * a;" );
transmitter.EndWriting();
ExpSourceReader reader = new ExpSourceReader( transmitter );
/*
ExpNodeGenerator generator = new ExpNodeGenerator(
, new ExpTestFuncSource( "test", transmitter ) );
/**/
ExpTestFuncSource func = new ExpTestFuncSource( "test", transmitter );
TestSchema testSchema = new TestSchema( func );
ExpNodeGenerator generator = new ExpNodeGenerator( testSchema, func );
/**/
while( reader.TryReadToken( out Token t ) )
{
Console.WriteLine( t.Value );
generator.AppendToken( t );
}
Console.WriteLine( "OK" );
}
}