コード例 #1
0
ファイル: State.cs プロジェクト: jw56578/WooCompiler
 public State(State[] states, string regexPattern, bool isAcceptedState, Automaton automaton)
 {
     this.automaton = automaton;
     this.states = states == null ? null : new List<State>(states);
     this.pattern = regexPattern;
     this.isAcceptedState = isAcceptedState;
 }
コード例 #2
0
        public OnlyAcceptsSingle1()
        {
            //must always have an accepted state
            //1 means that this state can be transitioned to if its a 1
            var acceptedState = new State(null, "1", true, this);

            //must always have a start state
            //null means that this state cannot be transitioned to
            var startState = new State(new State[]{
                            acceptedState
                        }, null, false, this);

            //is there a better way to set the starting state, probably not, what else would you do
            this.startState = this.currentState = startState;
        }
コード例 #3
0
        void Init(char input)
        {
            //must always have an accepted state
            //0 means that this state can be transitioned to if its a 0
            var acceptedState = new State(null,input.ToString(), true, this);
            //must always have a start state
            //this state can transition to itself, is there a better way to code this
            State startState = null;
            startState = new State(new State[]{
                            acceptedState
                        }, null, false, this);

            //is there a better way to set the starting state, probably not, what else would you do
            this.startState = this.currentState = startState;
        }
コード例 #4
0
        public AcceptsAnyNumberof1sFollowedBySingleZero()
        {
            //must always have an accepted state
            //0 means that this state can be transitioned to if its a 0
            var acceptedState = new State(null, "0", true, this);

            //must always have a start state
            //this state can transition to itself, is there a better way to code this
            State startState = null;
            startState = new State(new State[]{
                            acceptedState
                        }, "1", false, this);
            startState.AddState(startState);

            //is there a better way to set the starting state, probably not, what else would you do
            this.startState = this.currentState = startState;
        }
コード例 #5
0
ファイル: State.cs プロジェクト: jw56578/WooCompiler
 public void AddState(State state)
 {
     this.states.Add(state);
 }