private ScenarioStep Clone(ScenarioStep step)
        {
            ScenarioStep newStep = null;
            if (step is Given)
                newStep = new Given();
            else if (step is When)
                newStep = new When();
            else if (step is Then)
                newStep = new Then();
            else if (step is And)
                newStep = new And();
            else if (step is But)
                newStep = new But();

            Debug.Assert(newStep != null);

            newStep.Text = step.Text;
            newStep.MultiLineTextArgument = step.MultiLineTextArgument;
            newStep.TableArg = Clone(step.TableArg);
            return newStep;
        }
Esempio n. 2
0
        public ScenarioStep CreateStep(string keyword, StepKeyword stepKeyword, string text, FilePosition position, ScenarioBlock scenarioBlock)
        {
            ScenarioStep step;
            switch (stepKeyword)
            {
                case StepKeyword.Given:
                    step = new Given();
                    break;
                case StepKeyword.When:
                    step = new When();
                    break;
                case StepKeyword.Then:
                    step = new Then();
                    break;
                case StepKeyword.And:
                    step = new And();
                    break;
                case StepKeyword.But:
                    step = new But();
                    break;
                default:
                    throw new NotSupportedException();
            }

            step.Keyword = keyword;
            step.Text = text;
            step.FilePosition = position;
            step.ScenarioBlock = scenarioBlock;
            step.StepKeyword = stepKeyword;
            return step;
        }
Esempio n. 3
0
        private static ScenarioStep ConvertToCompatibleStep(SpecFlowStep step)
        {
            ScenarioStep result = null;
            if (step.StepKeyword == StepKeyword.Given)
                result = new Given {StepKeyword = step.StepKeyword };
            else if (step.StepKeyword == StepKeyword.When)
                result = new When {StepKeyword = step.StepKeyword };
            else if (step.StepKeyword == StepKeyword.Then)
                result = new Then {StepKeyword = step.StepKeyword };
            else if (step.StepKeyword == StepKeyword.And)
                result = new And { StepKeyword = step.StepKeyword };
            else if (step.StepKeyword == StepKeyword.But)
                result = new But {StepKeyword = step.StepKeyword };

            if (result == null)
                throw new NotSupportedException();

            result.Keyword = step.Keyword;
            result.Text = step.Text;
            result.ScenarioBlock = step.ScenarioBlock;
            result.MultiLineTextArgument = step.Argument is global::Gherkin.Ast.DocString ? ((global::Gherkin.Ast.DocString) step.Argument).Content : null;
            result.TableArg = step.Argument is global::Gherkin.Ast.DataTable ? ConvertToCompatibleTable(((global::Gherkin.Ast.DataTable) step.Argument).Rows) : null;
            result.FilePosition = ConvertToCompatibleFilePosition(step.Location);

            return result;
        }
    // $ANTLR end "steps"


    // $ANTLR start "step"
    // SpecFlowLangWalker.g:156:1: step returns [ScenarioStep step] : ( ^( GIVEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( WHEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( THEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( AND text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( BUT text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) );
    public ScenarioStep step() // throws RecognitionException [1]
    {   
        ScenarioStep step = default(ScenarioStep);

        Text text_ = default(Text);

        MultilineText mlt_ = default(MultilineText);

        Table table_ = default(Table);

        FilePosition fp_ = default(FilePosition);


        try 
    	{
            // SpecFlowLangWalker.g:160:5: ( ^( GIVEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( WHEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( THEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( AND text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( BUT text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) )
            int alt24 = 5;
            switch ( input.LA(1) ) 
            {
            case GIVEN:
            	{
                alt24 = 1;
                }
                break;
            case WHEN:
            	{
                alt24 = 2;
                }
                break;
            case THEN:
            	{
                alt24 = 3;
                }
                break;
            case AND:
            	{
                alt24 = 4;
                }
                break;
            case BUT:
            	{
                alt24 = 5;
                }
                break;
            	default:
            	    NoViableAltException nvae_d24s0 =
            	        new NoViableAltException("", 24, 0, input);

            	    throw nvae_d24s0;
            }

            switch (alt24) 
            {
                case 1 :
                    // SpecFlowLangWalker.g:160:9: ^( GIVEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition )
                    {
                    	Match(input,GIVEN,FOLLOW_GIVEN_in_step1055); 

                    	Match(input, Token.DOWN, null); 
                    	PushFollow(FOLLOW_text_in_step1071);
                    	text_ = text();
                    	state.followingStackPointer--;

                    	// SpecFlowLangWalker.g:162:17: (mlt_= multilineText )?
                    	int alt14 = 2;
                    	int LA14_0 = input.LA(1);

                    	if ( (LA14_0 == MULTILINETEXT) )
                    	{
                    	    alt14 = 1;
                    	}
                    	switch (alt14) 
                    	{
                    	    case 1 :
                    	        // SpecFlowLangWalker.g:162:17: mlt_= multilineText
                    	        {
                    	        	PushFollow(FOLLOW_multilineText_in_step1087);
                    	        	mlt_ = multilineText();
                    	        	state.followingStackPointer--;


                    	        }
                    	        break;

                    	}

                    	// SpecFlowLangWalker.g:163:19: (table_= table )?
                    	int alt15 = 2;
                    	int LA15_0 = input.LA(1);

                    	if ( (LA15_0 == TABLE) )
                    	{
                    	    alt15 = 1;
                    	}
                    	switch (alt15) 
                    	{
                    	    case 1 :
                    	        // SpecFlowLangWalker.g:163:19: table_= table
                    	        {
                    	        	PushFollow(FOLLOW_table_in_step1104);
                    	        	table_ = table();
                    	        	state.followingStackPointer--;


                    	        }
                    	        break;

                    	}

                    	PushFollow(FOLLOW_fileposition_in_step1121);
                    	fp_ = fileposition();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 

                    				step =  new Given(text_, mlt_, table_);
                    	        

                    }
                    break;
                case 2 :
                    // SpecFlowLangWalker.g:169:9: ^( WHEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition )
                    {
                    	Match(input,WHEN,FOLLOW_WHEN_in_step1152); 

                    	Match(input, Token.DOWN, null); 
                    	PushFollow(FOLLOW_text_in_step1168);
                    	text_ = text();
                    	state.followingStackPointer--;

                    	// SpecFlowLangWalker.g:171:17: (mlt_= multilineText )?
                    	int alt16 = 2;
                    	int LA16_0 = input.LA(1);

                    	if ( (LA16_0 == MULTILINETEXT) )
                    	{
                    	    alt16 = 1;
                    	}
                    	switch (alt16) 
                    	{
                    	    case 1 :
                    	        // SpecFlowLangWalker.g:171:17: mlt_= multilineText
                    	        {
                    	        	PushFollow(FOLLOW_multilineText_in_step1184);
                    	        	mlt_ = multilineText();
                    	        	state.followingStackPointer--;


                    	        }
                    	        break;

                    	}

                    	// SpecFlowLangWalker.g:172:19: (table_= table )?
                    	int alt17 = 2;
                    	int LA17_0 = input.LA(1);

                    	if ( (LA17_0 == TABLE) )
                    	{
                    	    alt17 = 1;
                    	}
                    	switch (alt17) 
                    	{
                    	    case 1 :
                    	        // SpecFlowLangWalker.g:172:19: table_= table
                    	        {
                    	        	PushFollow(FOLLOW_table_in_step1201);
                    	        	table_ = table();
                    	        	state.followingStackPointer--;


                    	        }
                    	        break;

                    	}

                    	PushFollow(FOLLOW_fileposition_in_step1218);
                    	fp_ = fileposition();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 

                    				step =  new When(text_, mlt_, table_);
                    	        

                    }
                    break;
                case 3 :
                    // SpecFlowLangWalker.g:178:9: ^( THEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition )
                    {
                    	Match(input,THEN,FOLLOW_THEN_in_step1249); 

                    	Match(input, Token.DOWN, null); 
                    	PushFollow(FOLLOW_text_in_step1265);
                    	text_ = text();
                    	state.followingStackPointer--;

                    	// SpecFlowLangWalker.g:180:17: (mlt_= multilineText )?
                    	int alt18 = 2;
                    	int LA18_0 = input.LA(1);

                    	if ( (LA18_0 == MULTILINETEXT) )
                    	{
                    	    alt18 = 1;
                    	}
                    	switch (alt18) 
                    	{
                    	    case 1 :
                    	        // SpecFlowLangWalker.g:180:17: mlt_= multilineText
                    	        {
                    	        	PushFollow(FOLLOW_multilineText_in_step1281);
                    	        	mlt_ = multilineText();
                    	        	state.followingStackPointer--;


                    	        }
                    	        break;

                    	}

                    	// SpecFlowLangWalker.g:181:19: (table_= table )?
                    	int alt19 = 2;
                    	int LA19_0 = input.LA(1);

                    	if ( (LA19_0 == TABLE) )
                    	{
                    	    alt19 = 1;
                    	}
                    	switch (alt19) 
                    	{
                    	    case 1 :
                    	        // SpecFlowLangWalker.g:181:19: table_= table
                    	        {
                    	        	PushFollow(FOLLOW_table_in_step1298);
                    	        	table_ = table();
                    	        	state.followingStackPointer--;


                    	        }
                    	        break;

                    	}

                    	PushFollow(FOLLOW_fileposition_in_step1315);
                    	fp_ = fileposition();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 

                    				step =  new Then(text_, mlt_, table_);
                    	        

                    }
                    break;
                case 4 :
                    // SpecFlowLangWalker.g:187:9: ^( AND text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition )
                    {
                    	Match(input,AND,FOLLOW_AND_in_step1346); 

                    	Match(input, Token.DOWN, null); 
                    	PushFollow(FOLLOW_text_in_step1362);
                    	text_ = text();
                    	state.followingStackPointer--;

                    	// SpecFlowLangWalker.g:189:17: (mlt_= multilineText )?
                    	int alt20 = 2;
                    	int LA20_0 = input.LA(1);

                    	if ( (LA20_0 == MULTILINETEXT) )
                    	{
                    	    alt20 = 1;
                    	}
                    	switch (alt20) 
                    	{
                    	    case 1 :
                    	        // SpecFlowLangWalker.g:189:17: mlt_= multilineText
                    	        {
                    	        	PushFollow(FOLLOW_multilineText_in_step1378);
                    	        	mlt_ = multilineText();
                    	        	state.followingStackPointer--;


                    	        }
                    	        break;

                    	}

                    	// SpecFlowLangWalker.g:190:19: (table_= table )?
                    	int alt21 = 2;
                    	int LA21_0 = input.LA(1);

                    	if ( (LA21_0 == TABLE) )
                    	{
                    	    alt21 = 1;
                    	}
                    	switch (alt21) 
                    	{
                    	    case 1 :
                    	        // SpecFlowLangWalker.g:190:19: table_= table
                    	        {
                    	        	PushFollow(FOLLOW_table_in_step1395);
                    	        	table_ = table();
                    	        	state.followingStackPointer--;


                    	        }
                    	        break;

                    	}

                    	PushFollow(FOLLOW_fileposition_in_step1412);
                    	fp_ = fileposition();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 

                    				step =  new And(text_, mlt_, table_);
                    	        

                    }
                    break;
                case 5 :
                    // SpecFlowLangWalker.g:196:9: ^( BUT text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition )
                    {
                    	Match(input,BUT,FOLLOW_BUT_in_step1443); 

                    	Match(input, Token.DOWN, null); 
                    	PushFollow(FOLLOW_text_in_step1459);
                    	text_ = text();
                    	state.followingStackPointer--;

                    	// SpecFlowLangWalker.g:198:17: (mlt_= multilineText )?
                    	int alt22 = 2;
                    	int LA22_0 = input.LA(1);

                    	if ( (LA22_0 == MULTILINETEXT) )
                    	{
                    	    alt22 = 1;
                    	}
                    	switch (alt22) 
                    	{
                    	    case 1 :
                    	        // SpecFlowLangWalker.g:198:17: mlt_= multilineText
                    	        {
                    	        	PushFollow(FOLLOW_multilineText_in_step1475);
                    	        	mlt_ = multilineText();
                    	        	state.followingStackPointer--;


                    	        }
                    	        break;

                    	}

                    	// SpecFlowLangWalker.g:199:19: (table_= table )?
                    	int alt23 = 2;
                    	int LA23_0 = input.LA(1);

                    	if ( (LA23_0 == TABLE) )
                    	{
                    	    alt23 = 1;
                    	}
                    	switch (alt23) 
                    	{
                    	    case 1 :
                    	        // SpecFlowLangWalker.g:199:19: table_= table
                    	        {
                    	        	PushFollow(FOLLOW_table_in_step1492);
                    	        	table_ = table();
                    	        	state.followingStackPointer--;


                    	        }
                    	        break;

                    	}

                    	PushFollow(FOLLOW_fileposition_in_step1509);
                    	fp_ = fileposition();
                    	state.followingStackPointer--;


                    	Match(input, Token.UP, null); 

                    				step =  new But(text_, mlt_, table_);
                    	        

                    }
                    break;

            }

                step.FilePosition = fp_;

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return step;
    }