daily update on 20250220 by nitload youmu, building AST generator, correct type naming

This commit is contained in:
Nitload
2025-02-21 08:11:26 +08:00
parent ccef0de6f6
commit 83bde12d22
98 changed files with 4182 additions and 1855 deletions
@@ -40,42 +40,67 @@ namespace StgSharp.Script.Express
public static partial class ExpCompile
{
private static FrozenDictionary<string, int> _operatorPrecedence;
public static bool TryGetOperatorPrecedence(
string operatorName,
out int precedence )
{
return _operatorPrecedence.TryGetValue(
operatorName, out precedence );
}
public static bool TryGetSuperTypeOperatorPrecedence(
string operatorName,
out int precedence )
{
return _superTypeOperatorPrecedent.TryGetValue(
operatorName, out precedence );
}
private static void InitPrecedence()
{
KeyValuePair<string, int>[] source = [
new KeyValuePair<string, int>( "[]", 1 ),
new KeyValuePair<string, int>( ".", 1 ),
new KeyValuePair<string, int>( "\\", 1 ),
new KeyValuePair<string, int>( "unary+", 2 ),
new KeyValuePair<string, int>( "unary-", 2 ),
new KeyValuePair<string, int>( "NOT", 2 ),
new KeyValuePair<string, int>( "**", 3 ),
new KeyValuePair<string, int>( "*", 4 ),
new KeyValuePair<string, int>( "/", 4 ),
new KeyValuePair<string, int>( "AND", 4 ),
new KeyValuePair<string, int>( "MOD", 4 ),
new KeyValuePair<string, int>( "DIV", 4 ),
new KeyValuePair<string, int>( "||", 4 ),
new KeyValuePair<string, int>( "+", 5 ),
new KeyValuePair<string, int>( "-", 5 ),
new KeyValuePair<string, int>( "OR", 5 ),
new KeyValuePair<string, int>( "XOR", 5 ),
new KeyValuePair<string, int>( "=", 6 ),
new KeyValuePair<string, int>( "<>", 6 ),
new KeyValuePair<string, int>( "<=", 6 ),
new KeyValuePair<string, int>( ">=", 6 ),
new KeyValuePair<string, int>( ">", 6 ),
new KeyValuePair<string, int>( "<", 6 ),
new KeyValuePair<string, int>( ":=:", 6 ),
new KeyValuePair<string, int>( ":<>:", 6 ),
new KeyValuePair<string, int>( "IN", 6 ),
new KeyValuePair<string, int>( "LIKE", 6 ),
new KeyValuePair<string, int>( PoolString( "[" ), 1 ),
new KeyValuePair<string, int>( PoolString( "." ), 1 ),
new KeyValuePair<string, int>( PoolString( "\\" ), 1 ),
new KeyValuePair<string, int>( PoolString( "unary+" ), 2 ),
new KeyValuePair<string, int>( PoolString( "unary-" ), 2 ),
new KeyValuePair<string, int>( PoolString( "NOT" ), 2 ),
new KeyValuePair<string, int>( PoolString( "**" ), 3 ),
new KeyValuePair<string, int>( PoolString( "*" ), 4 ),
new KeyValuePair<string, int>( PoolString( "/" ), 4 ),
new KeyValuePair<string, int>( PoolString( "AND" ), 4 ),
new KeyValuePair<string, int>( PoolString( "MOD" ), 4 ),
new KeyValuePair<string, int>( PoolString( "DIV" ), 4 ),
new KeyValuePair<string, int>( PoolString( "||" ), 4 ),
new KeyValuePair<string, int>( PoolString( "+" ), 5 ),
new KeyValuePair<string, int>( PoolString( "-" ), 5 ),
new KeyValuePair<string, int>( PoolString( "OR" ), 5 ),
new KeyValuePair<string, int>( PoolString( "XOR" ), 5 ),
new KeyValuePair<string, int>( PoolString( "=" ), 6 ),
new KeyValuePair<string, int>( PoolString( "<>" ), 6 ),
new KeyValuePair<string, int>( PoolString( "<=" ), 6 ),
new KeyValuePair<string, int>( PoolString( ">=" ), 6 ),
new KeyValuePair<string, int>( PoolString( ">" ), 6 ),
new KeyValuePair<string, int>( PoolString( "<" ), 6 ),
new KeyValuePair<string, int>( PoolString( ":=:" ), 6 ),
new KeyValuePair<string, int>( PoolString( ":<>:" ), 6 ),
new KeyValuePair<string, int>( PoolString( "IN" ), 6 ),
new KeyValuePair<string, int>( PoolString( "LIKE" ), 6 ),
];
_operatorPrecedence = new Dictionary<string, int>(
source, _multiplexer ).ToFrozenDictionary();
source = [
new KeyValuePair<string, int>( "ONEOF", 1 ),
new KeyValuePair<string, int>( "AND", 2 ),
new KeyValuePair<string, int>( "ANDOR", 3 ),
];
_superTypeOperatorPrecedent = new Dictionary<string, int>(
source, _multiplexer ).ToFrozenDictionary();
}
#pragma warning disable CS8618
private static FrozenDictionary<string, int> _superTypeOperatorPrecedent;
private static FrozenDictionary<string, int> _operatorPrecedence;
#pragma warning restore CS8618
}
}