no much coding work, mainly on theory work
This commit is contained in:
@@ -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<TElement, TValue, TEvaluator>(
|
||||
TEvaluator evaluator
|
||||
) where TEvaluator : IMixEvaluator<TElement, TValue>
|
||||
{
|
||||
|
||||
public TValue Weight { get; private set; } = default!;
|
||||
|
||||
private TEvaluator Evaluator { get; init; } = evaluator;
|
||||
|
||||
public TValue Evaluate(
|
||||
Span<Relation<TElement, TValue>> relations
|
||||
)
|
||||
{
|
||||
Weight = Evaluator.Evaluate(relations);
|
||||
return Weight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public sealed class Mix<TElement, TValue>(
|
||||
IMixEvaluator<TElement, TValue> evaluator
|
||||
) : Mix<TElement, TValue, IMixEvaluator<TElement, TValue>>(evaluator) { }
|
||||
|
||||
public interface IMixEvaluator<TElement, TValue>
|
||||
{
|
||||
|
||||
public Relation<TElement, TValue, IRelationEvaluator<TElement, TValue>>[] DownstreamPorts { get; }
|
||||
|
||||
TValue Evaluate(
|
||||
Span<Relation<TElement, TValue>> relations
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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<TElement, TValue, TEvaluator>(
|
||||
TEvaluator evaluator
|
||||
) where TEvaluator : IRelationEvaluator<TElement, TValue>
|
||||
{
|
||||
|
||||
public TEvaluator Evaluator { get; init; } = evaluator;
|
||||
|
||||
public TValue Weight { get; private set; } = default!;
|
||||
|
||||
public TValue Evaluate(
|
||||
ReadOnlySpan<TElement> sequence
|
||||
)
|
||||
{
|
||||
Weight = Evaluate(sequence);
|
||||
return Weight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Relation<TElement, TValue>(
|
||||
IRelationEvaluator<TElement, TValue> evaluator
|
||||
) : Relation<TElement, TValue, IRelationEvaluator<TElement, TValue>>(evaluator) { }
|
||||
|
||||
public interface IRelationEvaluator<TElement, TValue>
|
||||
{
|
||||
|
||||
TValue Evaluate(
|
||||
ReadOnlySpan<TElement> sequence
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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<T> : IRelationEvaluator<T, PropertyMatchState>
|
||||
{
|
||||
|
||||
public abstract PropertyMatchState Evaluate(
|
||||
ReadOnlySpan<T> sequence
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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<T>
|
||||
{
|
||||
|
||||
private readonly List<Mix<T, PropertyMatchState>> _nodes = [];
|
||||
private readonly List<Relation<T, PropertyMatchState, PropertyEvaluator<T>>> _relations = [];
|
||||
|
||||
}
|
||||
|
||||
public class FrozenPropertyMatchEngine<T>
|
||||
{
|
||||
|
||||
private readonly Mix<T, PropertyMatchState>[] _nodes;
|
||||
private readonly Relation<T, PropertyMatchState, PropertyEvaluator<T>>[] _relations;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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 { }
|
||||
}
|
||||
Reference in New Issue
Block a user