before merge

This commit is contained in:
Nitload
2026-06-27 00:49:01 +08:00
parent 062ffacf88
commit 2a6fc7b633
17 changed files with 184 additions and 121 deletions
@@ -35,7 +35,7 @@ using System.Text;
using System.Threading.Tasks;
namespace StgSharp.RegularAnalysis.TextRegex
namespace StgSharp.RegularAnalysis.Text
{
public partial class RegexInterpreter
{
@@ -58,9 +58,7 @@ namespace StgSharp.RegularAnalysis.TextRegex
}
}
public static RegexInterpreter Analyze(
string regex
)
public static RegexInterpreter Analyze(string regex)
{
RegexInterpreter interpreter = new();
interpreter._source = regex;
@@ -222,14 +220,11 @@ namespace StgSharp.RegularAnalysis.TextRegex
// TODO enum AST again , do ALT tail merge and simple ALT front merge
}
private void ProcessOperator(
RegexAstNode op
)
private void ProcessOperator(RegexAstNode op)
{
if (op.EqualityTypeConvert == RegexElementLabel.CONCAT)
{
if (_stack.TryPopOperand(out RegexAstNode? _1) &&
_stack.TryPopOperand(out RegexAstNode? _2))
if (_stack.TryPopOperand(out RegexAstNode? _1) && _stack.TryPopOperand(out RegexAstNode? _2))
{
op.Left = _2;
op.Right = _1;
@@ -255,8 +250,7 @@ namespace StgSharp.RegularAnalysis.TextRegex
}
} else if (op.EqualityTypeConvert == RegexElementLabel.ALT)
{
if (_stack.TryPopOperand(out RegexAstNode? _1) &&
_stack.TryPopOperand(out RegexAstNode? _2))
if (_stack.TryPopOperand(out RegexAstNode? _1) && _stack.TryPopOperand(out RegexAstNode? _2))
{
op.Left = _2;
op.Right = _1;