Antlr3.Analysis.DecisionProbe.GetSampleInputSequenceUsingStateSet C# (CSharp) Method

GetSampleInputSequenceUsingStateSet() protected method

protected GetSampleInputSequenceUsingStateSet ( Antlr3.Analysis.State startState, Antlr3.Analysis.State targetState, HashSet states, IList labels ) : void
startState Antlr3.Analysis.State
targetState Antlr3.Analysis.State
states HashSet
labels IList
return void
        protected virtual void GetSampleInputSequenceUsingStateSet( State startState,
                                                           State targetState,
                                                           HashSet<object> states,
                                                           IList<Label> labels )
        {
            _statesVisitedDuringSampleSequence.Add( startState.StateNumber );

            // pick the first edge in states as the one to traverse
            for ( int i = 0; i < startState.NumberOfTransitions; i++ )
            {
                Transition t = startState.GetTransition( i );
                DFAState edgeTarget = (DFAState)t.Target;
                if ( states.Contains( edgeTarget ) &&
                     !_statesVisitedDuringSampleSequence.Contains( edgeTarget.StateNumber ) )
                {
                    labels.Add( t.Label ); // traverse edge and track label
                    if ( edgeTarget != targetState )
                    {
                        // get more labels if not at target
                        GetSampleInputSequenceUsingStateSet( edgeTarget,
                                                            targetState,
                                                            states,
                                                            labels );
                    }
                    // done with this DFA state as we've found a good path to target
                    return;
                }
            }
            labels.Add( new Label( Label.EPSILON ) ); // indicate no input found
            // this happens on a : {p1}? a | A ;
            //ErrorManager.error(ErrorManager.MSG_CANNOT_COMPUTE_SAMPLE_INPUT_SEQ);
        }