diff --git a/StgSharp.Common/State/ISimpleStateMachine.cs b/StgSharp.Common/State/ISimpleStateMachine.cs index b022a65a..6e7e7f95 100644 --- a/StgSharp.Common/State/ISimpleStateMachine.cs +++ b/StgSharp.Common/State/ISimpleStateMachine.cs @@ -1,4 +1,4 @@ -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // ----------------------------------------------------------------------- // file="ISimpleStateMachine" // Project: StgSharp @@ -28,24 +28,29 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Numerics; using System.Text; using System.Threading.Tasks; namespace StgSharp.State { public interface ISimpleStateMachine - where TStateNode: ISimpleStateMachineNode - where TStateLabel: unmanaged, Enum - where TStateContext: StateContext + where TStateNode : ISimpleStateMachineNode + where TStateLabel : unmanaged, IEquatable + where TStateContext : StateContext { - ref readonly TStateNode this[TStateLabel label] { get; } + ref readonly TStateNode this[ + TStateLabel label + ] { get; } ref readonly TStateNode GetCurrentStateNode(); void Reset(); - bool TryMoveNext(TStateContext ctx); + bool TryMoveNext( + TStateContext ctx + ); } } diff --git a/StgSharp.Common/State/ISimpleStateMachineNode.cs b/StgSharp.Common/State/ISimpleStateMachineNode.cs index 46473ff6..355dfecd 100644 --- a/StgSharp.Common/State/ISimpleStateMachineNode.cs +++ b/StgSharp.Common/State/ISimpleStateMachineNode.cs @@ -1,9 +1,9 @@ -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // ----------------------------------------------------------------------- // file="ISimpleStateMachineNode" // Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// AuthorGroup: Nitload +// Copyright (c) Nitload. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -28,18 +28,28 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Numerics; using System.Text; using System.Threading.Tasks; namespace StgSharp.State { - public interface ISimpleStateMachineNode where TLabel: unmanaged, Enum - where TStateContext: StateContext + public abstract class SimpleStateMachineNode + where TLabel : unmanaged, IEquatable + where TStateContext : StateContext { - public ICollection AvailableStateLabels { get; } + private List, SimpleStateMachineNode, TStateContext, bool>> + _jumpRule; + private List<(int, SimpleStateMachineNode)> _jumpTable; - bool TryGetNextStateLabel(TLabel label, TStateContext context, out TLabel nextLabel); + public IReadOnlyCollection<(int, SimpleStateMachineNode)> + AvailableNodes => _jumpTable; + + public abstract bool TryTransaction( + TStateContext context, + out TLabel label + ); } } diff --git a/StgSharp.RegularAnalysis/RegularExpression.StateMachine.cs b/StgSharp.RegularAnalysis/RegularExpression.StateMachine.cs index 7ef625ca..4c96107b 100644 --- a/StgSharp.RegularAnalysis/RegularExpression.StateMachine.cs +++ b/StgSharp.RegularAnalysis/RegularExpression.StateMachine.cs @@ -1,9 +1,9 @@ -//----------------------------------------------------------------------- +//----------------------------------------------------------------------- // ----------------------------------------------------------------------- // file="RegularExpression.StateMachine" // Project: StgSharp -// AuthorGroup: Nitload Space -// Copyright (c) Nitload Space. All rights reserved. +// AuthorGroup: Nitload +// Copyright (c) Nitload. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -41,9 +41,49 @@ namespace StgSharp.RegularAnalysis private readonly RegularExpressionState _state; - private class RegularExpressionState : ISimpleStateMachine<, RegularExpressionCases, RegularExpressionStateContext> { } + private class RegularExpressionState : ISimpleStateMachine + { - private enum RegularExpressionCases { } + public ref readonly RegularExpressionStateNode this[ + int label + ] => throw new NotImplementedException(); + + public ref readonly RegularExpressionStateNode GetCurrentStateNode() + { + throw new NotImplementedException(); + } + + public void Reset() + { + throw new NotImplementedException(); + } + + public bool TryMoveNext( + RegularExpressionStateContext ctx + ) + { + throw new NotImplementedException(); + } + + } + + private struct RegularExpressionStateNode : ISimpleStateMachineNode + { + + public ICollection AvailableStateLabels => throw new NotImplementedException(); + + public SimpleStateMachineNodeTransition + Transition => throw new NotImplementedException(); + + public bool TryTransaction( + RegularExpressionStateContext context, + out int label + ) + { + throw new NotImplementedException(); + } + + } private class RegularExpressionStateContext : StateContext {