Working on tree optimizer
This commit is contained in:
@@ -33,6 +33,7 @@ using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace StgSharp.RegularAnalysis.TextRegex
|
||||
{
|
||||
@@ -52,10 +53,8 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
|
||||
public long NodeFlag => (long)Source.Flag;
|
||||
|
||||
public static RegexAstNode Empty
|
||||
{
|
||||
get => new EmptyRegexAstNode();
|
||||
}
|
||||
public static RegexAstNode Empty { get; }
|
||||
= new EmptyRegexAstNode();
|
||||
|
||||
public RegexAstNode Previous { get; set; }
|
||||
|
||||
@@ -68,7 +67,7 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
get;
|
||||
set
|
||||
{
|
||||
field?.Parent = null;
|
||||
field?.Parent = Empty;
|
||||
field = value;
|
||||
value.Parent = this;
|
||||
}
|
||||
@@ -79,7 +78,7 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
get;
|
||||
set
|
||||
{
|
||||
field?.Parent = null;
|
||||
field?.Parent = Empty;
|
||||
field = value;
|
||||
value.Parent = this;
|
||||
}
|
||||
@@ -90,13 +89,19 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
get => Source.Flag;
|
||||
}
|
||||
|
||||
public string Value => Source.Value;
|
||||
|
||||
public string CodeConvertTemplate { get; }
|
||||
|
||||
public Token<RegexElementLabel> Source { get; }
|
||||
|
||||
public void AppendNode(
|
||||
RegexAstNode nextToken
|
||||
) { }
|
||||
)
|
||||
{
|
||||
Next = nextToken;
|
||||
nextToken.Previous = this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static (bool Valid,int Value) ComparePrecedence(
|
||||
@@ -113,9 +118,33 @@ namespace StgSharp.RegularAnalysis.TextRegex
|
||||
return (true,v_left - v_right);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsNullOrEmpty(
|
||||
RegexAstNode node
|
||||
)
|
||||
{
|
||||
return node is null || node.Equals(Empty);
|
||||
}
|
||||
|
||||
public void PrependNode(
|
||||
RegexAstNode previousNode
|
||||
) { }
|
||||
)
|
||||
{
|
||||
Previous = previousNode;
|
||||
previousNode.Next = this;
|
||||
}
|
||||
|
||||
public void RemoveChild(
|
||||
RegexAstNode node
|
||||
)
|
||||
{
|
||||
if (Left == node)
|
||||
{
|
||||
Left = Empty;
|
||||
} else if (Right == node) {
|
||||
Right = Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryMergeUnit(
|
||||
RegexAstNode prev,
|
||||
|
||||
Reference in New Issue
Block a user