diff --git a/src/Nitload.RegularAnalysis/Abstraction/Mix.cs b/src/Nitload.RegularAnalysis/Abstraction/Mix.cs new file mode 100644 index 00000000..7418472e --- /dev/null +++ b/src/Nitload.RegularAnalysis/Abstraction/Mix.cs @@ -0,0 +1,49 @@ +// ----------------------------------------------------------------------------- +// 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 + { + + public Relation>[] DownstreamPorts { get; } + + 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/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/PropertyRegex/PropertyMatchState.cs b/src/Nitload.RegularAnalysis/PropertyRegex/PropertyMatchState.cs new file mode 100644 index 00000000..e1fb96d4 --- /dev/null +++ b/src/Nitload.RegularAnalysis/PropertyRegex/PropertyMatchState.cs @@ -0,0 +1,17 @@ +// ----------------------------------------------------------------------------- +// file="PropertyMatchState" +// 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.PropertyRegex +{ + internal class PropertyMatchState { } +}