From 2c17f6c108d7acd51a7806144568d435de7b6fb9 Mon Sep 17 00:00:00 2001 From: Youmu Liu <105042599+Nitload-NSI@users.noreply.github.com> Date: Sun, 20 Sep 2026 18:29:44 +0800 Subject: [PATCH 1/3] start nfa afterall --- .../Abstraction/Mix.cs | 47 +++++++++++++++++++ .../Abstraction/Relation.cs | 47 +++++++++++++++++++ .../AttributeRegex/PropertyMatchEngine.cs | 12 +++++ 3 files changed, 106 insertions(+) create mode 100644 src/Nitload.RegularAnalysis/Abstraction/Mix.cs create mode 100644 src/Nitload.RegularAnalysis/Abstraction/Relation.cs create mode 100644 src/Nitload.RegularAnalysis/AttributeRegex/PropertyMatchEngine.cs diff --git a/src/Nitload.RegularAnalysis/Abstraction/Mix.cs b/src/Nitload.RegularAnalysis/Abstraction/Mix.cs new file mode 100644 index 00000000..df1ab372 --- /dev/null +++ b/src/Nitload.RegularAnalysis/Abstraction/Mix.cs @@ -0,0 +1,47 @@ +// ----------------------------------------------------------------------------- +// file="Mix" +// Project: StgSharp +// Copyright (c) Nitload. +// SPDX-License-Identifier: MIT +// ----------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Nitload.RegularAnalysis.Abstraction +{ + public class Mix( + TEvaluator evaluator + ) where TEvaluator : IMixEvaluator + { + + public TValue Weight { get; private set; } = default!; + + private TEvaluator Evaluator { get; init; } = evaluator; + + public TValue Evaluate( + Span> relations + ) + { + Weight = Evaluator.Evaluate(relations); + return Weight; + } + + } + + public sealed class Mix( + IMixEvaluator evaluator + ) : Mix>(evaluator) { } + + public interface IMixEvaluator + { + + TValue Evaluate( + Span> relations + ); + + } +} diff --git a/src/Nitload.RegularAnalysis/Abstraction/Relation.cs b/src/Nitload.RegularAnalysis/Abstraction/Relation.cs new file mode 100644 index 00000000..5ffe0a8b --- /dev/null +++ b/src/Nitload.RegularAnalysis/Abstraction/Relation.cs @@ -0,0 +1,47 @@ +// ----------------------------------------------------------------------------- +// file="Relation" +// Project: StgSharp +// Copyright (c) Nitload. +// SPDX-License-Identifier: MIT +// ----------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Nitload.RegularAnalysis.Abstraction +{ + public class Relation( + TEvaluator evaluator + ) where TEvaluator : IRelationEvaluator + { + + public TEvaluator Evaluator { get; init; } = evaluator; + + public TValue Weight { get; private set; } = default!; + + public TValue Evaluate( + ReadOnlySpan sequence + ) + { + Weight = Evaluate(sequence); + return Weight; + } + + } + + public class Relation( + IRelationEvaluator evaluator + ) : Relation>(evaluator) { } + + public interface IRelationEvaluator + { + + TValue Evaluate( + ReadOnlySpan sequence + ); + + } +} diff --git a/src/Nitload.RegularAnalysis/AttributeRegex/PropertyMatchEngine.cs b/src/Nitload.RegularAnalysis/AttributeRegex/PropertyMatchEngine.cs new file mode 100644 index 00000000..fe45b589 --- /dev/null +++ b/src/Nitload.RegularAnalysis/AttributeRegex/PropertyMatchEngine.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Nitload.RegularAnalysis.AttibuteRegex +{ + internal class PropertyMatchEngine + { + } +} From 7ddfc36ac5ec2950daf5605b18357ee603dbd1bb Mon Sep 17 00:00:00 2001 From: Youmu Liu <105042599+Nitload-NSI@users.noreply.github.com> Date: Mon, 21 Sep 2026 20:39:43 +0800 Subject: [PATCH 2/3] few adit --- .../AttributeRegex/PropertyMatchEngine.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Nitload.RegularAnalysis/AttributeRegex/PropertyMatchEngine.cs b/src/Nitload.RegularAnalysis/AttributeRegex/PropertyMatchEngine.cs index fe45b589..8ae52ead 100644 --- a/src/Nitload.RegularAnalysis/AttributeRegex/PropertyMatchEngine.cs +++ b/src/Nitload.RegularAnalysis/AttributeRegex/PropertyMatchEngine.cs @@ -1,12 +1,17 @@ -using System; +// ----------------------------------------------------------------------------- +// file="PropertyMatchEngine" +// Project: StgSharp +// Copyright (c) Nitload. +// SPDX-License-Identifier: MIT +// ----------------------------------------------------------------------------- + +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Nitload.RegularAnalysis.AttibuteRegex +namespace Nitload.RegularAnalysis.AttributeRegex { - internal class PropertyMatchEngine - { - } + internal class PropertyMatchEngine { } } From 194e86972425fbe6bc9dbf8955af13493dcbc279 Mon Sep 17 00:00:00 2001 From: Youmu Liu <105042599+Nitload-NSI@users.noreply.github.com> Date: Wed, 23 Sep 2026 18:19:33 +0800 Subject: [PATCH 3/3] few adit --- .../Abstraction/Mix.cs | 2 ++ .../PropertyRegex/PropertyEvaluator.cs | 25 +++++++++++++++ .../PropertyRegex/PropertyMatchEngine.cs | 32 +++++++++++++++++++ .../PropertyMatchState.cs} | 6 ++-- 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 src/Nitload.RegularAnalysis/PropertyRegex/PropertyEvaluator.cs create mode 100644 src/Nitload.RegularAnalysis/PropertyRegex/PropertyMatchEngine.cs rename src/Nitload.RegularAnalysis/{AttributeRegex/PropertyMatchEngine.cs => PropertyRegex/PropertyMatchState.cs} (74%) diff --git a/src/Nitload.RegularAnalysis/Abstraction/Mix.cs b/src/Nitload.RegularAnalysis/Abstraction/Mix.cs index df1ab372..7418472e 100644 --- a/src/Nitload.RegularAnalysis/Abstraction/Mix.cs +++ b/src/Nitload.RegularAnalysis/Abstraction/Mix.cs @@ -39,6 +39,8 @@ namespace Nitload.RegularAnalysis.Abstraction public interface IMixEvaluator { + public Relation>[] DownstreamPorts { get; } + TValue Evaluate( Span> relations ); diff --git a/src/Nitload.RegularAnalysis/PropertyRegex/PropertyEvaluator.cs b/src/Nitload.RegularAnalysis/PropertyRegex/PropertyEvaluator.cs new file mode 100644 index 00000000..87f7c92a --- /dev/null +++ b/src/Nitload.RegularAnalysis/PropertyRegex/PropertyEvaluator.cs @@ -0,0 +1,25 @@ +// ----------------------------------------------------------------------------- +// file="PropertyEvaluator" +// Project: StgSharp +// Copyright (c) Nitload. +// SPDX-License-Identifier: MIT +// ----------------------------------------------------------------------------- + +using Nitload.RegularAnalysis.Abstraction; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Nitload.RegularAnalysis.PropertyRegex +{ + internal abstract class PropertyEvaluator : IRelationEvaluator + { + + public abstract PropertyMatchState Evaluate( + ReadOnlySpan sequence + ); + + } +} diff --git a/src/Nitload.RegularAnalysis/PropertyRegex/PropertyMatchEngine.cs b/src/Nitload.RegularAnalysis/PropertyRegex/PropertyMatchEngine.cs new file mode 100644 index 00000000..b95123f7 --- /dev/null +++ b/src/Nitload.RegularAnalysis/PropertyRegex/PropertyMatchEngine.cs @@ -0,0 +1,32 @@ +// ----------------------------------------------------------------------------- +// file="PropertyMatchEngine" +// Project: StgSharp +// Copyright (c) Nitload. +// SPDX-License-Identifier: MIT +// ----------------------------------------------------------------------------- + +using Nitload.RegularAnalysis.Abstraction; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Nitload.RegularAnalysis.PropertyRegex +{ + public class PropertyMatchEngine + { + + private readonly List> _nodes = []; + private readonly List>> _relations = []; + + } + + public class FrozenPropertyMatchEngine + { + + private readonly Mix[] _nodes; + private readonly Relation>[] _relations; + + } +} diff --git a/src/Nitload.RegularAnalysis/AttributeRegex/PropertyMatchEngine.cs b/src/Nitload.RegularAnalysis/PropertyRegex/PropertyMatchState.cs similarity index 74% rename from src/Nitload.RegularAnalysis/AttributeRegex/PropertyMatchEngine.cs rename to src/Nitload.RegularAnalysis/PropertyRegex/PropertyMatchState.cs index 8ae52ead..e1fb96d4 100644 --- a/src/Nitload.RegularAnalysis/AttributeRegex/PropertyMatchEngine.cs +++ b/src/Nitload.RegularAnalysis/PropertyRegex/PropertyMatchState.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------------- -// file="PropertyMatchEngine" +// file="PropertyMatchState" // Project: StgSharp // Copyright (c) Nitload. // SPDX-License-Identifier: MIT @@ -11,7 +11,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Nitload.RegularAnalysis.AttributeRegex +namespace Nitload.RegularAnalysis.PropertyRegex { - internal class PropertyMatchEngine { } + internal class PropertyMatchState { } }