This commit is contained in:
2025-10-08 09:49:37 +08:00
commit 284e764345
99 changed files with 21742 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
using Flee.PublicTypes;
namespace Flee.Parsing
{
internal abstract class CustomTokenPattern : TokenPattern
{
protected CustomTokenPattern(int id, string name, PatternType type, string pattern) : base(id, name, type, pattern)
{
}
public void Initialize(int id, string name, PatternType type, string pattern, ExpressionContext context)
{
this.ComputeToken(id, name, type, pattern, context);
}
protected abstract void ComputeToken(int id, string name, PatternType type, string pattern, ExpressionContext context);
}
internal class RealPattern : CustomTokenPattern
{
public RealPattern(int id, string name, PatternType type, string pattern) : base(id, name, type, pattern)
{
}
protected override void ComputeToken(int id, string name, PatternType type, string pattern, ExpressionContext context)
{
ExpressionParserOptions options = context.ParserOptions;
char digitsBeforePattern = (options.RequireDigitsBeforeDecimalPoint ? '+' : '*');
pattern = string.Format(pattern, digitsBeforePattern, options.DecimalSeparator);
this.SetData(id, name, type, pattern);
}
}
internal class ArgumentSeparatorPattern : CustomTokenPattern
{
public ArgumentSeparatorPattern(int id, string name, PatternType type, string pattern) : base(id, name, type, pattern)
{
}
protected override void ComputeToken(int id, string name, PatternType type, string pattern, ExpressionContext context)
{
ExpressionParserOptions options = context.ParserOptions;
this.SetData(id, name, type, options.FunctionArgumentSeparator.ToString());
}
}
}