scanning min scan length
This commit is contained in:
@@ -31,8 +31,6 @@ namespace StgSharp.RegularAnalysis.Abstraction
|
||||
|
||||
long NodeFlag { get; }
|
||||
|
||||
string CodeConvertTemplate { get; }
|
||||
|
||||
TLabel EqualityTypeConvert { get; }
|
||||
|
||||
TNode Previous { get; set; }
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)Generated</CompilerGeneratedFilesOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="bin\**" />
|
||||
<EmbeddedResource Remove="bin\**" />
|
||||
<None Remove="bin\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\StgSharp.Common\StgSharp.Common.csproj" />
|
||||
</ItemGroup>
|
||||
@@ -16,10 +22,17 @@
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.13.0" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="bin\x64\Debug\net8.0\StgSharp.RegularAnalysis.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="$(OutputPath)$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
|
||||
<None Remove="bin\x64\Debug\net8.0\StgSharp.RegularAnalysis.pdb" />
|
||||
<None Include="$(OutputPath)$(AssemblyName).pdb" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" Condition="Exists('$(OutputPath)$(AssemblyName).pdb')" />
|
||||
<None Remove="bin\x64\Debug\net8.0\StgSharp.Common.dll" />
|
||||
<None Include="$(OutputPath)StgSharp.Common.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" Condition="Exists('$(OutputPath)StgSharp.Common.dll')" />
|
||||
<None Remove="bin\x64\Debug\net8.0\StgSharp.Common.pdb" />
|
||||
<None Include="$(OutputPath)StgSharp.Common.pdb" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" Condition="Exists('$(OutputPath)StgSharp.Common.pdb')" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -137,8 +137,7 @@ namespace StgSharp.RegularAnalysis.Text
|
||||
}
|
||||
|
||||
private static void OptimizeTree(
|
||||
AbstractSyntaxTree<RegexAstNode, RegexElementLabel> tree,
|
||||
ref RegexInfo info
|
||||
AbstractSyntaxTree<RegexAstNode, RegexElementLabel> tree
|
||||
)
|
||||
{
|
||||
// phase0: scan container and remove no parent nodes
|
||||
@@ -194,40 +193,6 @@ namespace StgSharp.RegularAnalysis.Text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
info.MinPredictLength = ComputeMinLength(tree.Root);
|
||||
|
||||
static int ComputeMinLength(
|
||||
RegexAstNode node
|
||||
)
|
||||
{
|
||||
if (node.EqualityTypeConvert is RegexElementLabel.UNIT_SPAN or
|
||||
RegexElementLabel.UNIT)
|
||||
{
|
||||
return node.Value.Length;
|
||||
} else if (node.EqualityTypeConvert == RegexElementLabel.CONCAT)
|
||||
{
|
||||
return ComputeMinLength(node.Left) + ComputeMinLength(node.Right);
|
||||
} else if (node.EqualityTypeConvert == RegexElementLabel.ALT)
|
||||
{
|
||||
RegexAstNode case_0 = node.Right;
|
||||
int length = int.MaxValue;
|
||||
do
|
||||
{
|
||||
length = int.Min(ComputeMinLength(case_0), length);
|
||||
case_0 = case_0.Next;
|
||||
} while (!RegexAstNode.IsNullOrEmpty(case_0));
|
||||
return length;
|
||||
} else if (node.EqualityTypeConvert == RegexElementLabel.COUNT)
|
||||
{
|
||||
string source = node.Source.Value;
|
||||
int single_count = ComputeMinLength(node.Right);
|
||||
return 0;
|
||||
} else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void RotateConcat(
|
||||
|
||||
@@ -65,8 +65,6 @@ namespace StgSharp.RegularAnalysis.Text
|
||||
|
||||
public string Value => Source.Value;
|
||||
|
||||
public string CodeConvertTemplate { get; }
|
||||
|
||||
public Token<RegexElementLabel> Source { get; private protected set; }
|
||||
|
||||
public void AppendNode(
|
||||
|
||||
Reference in New Issue
Block a user