Exemplo n.º 1
0
 public override void Visit(CaseClause node)
 {
     VisitNode(node.Comparison);
     VisitNode(node.Expression);
     VisitNode(node.Body);
     Visit((Node)node);
 }
        public CSharpSyntaxNode Convert(CaseClause node)
        {
            SwitchSectionSyntax csSwitchSection = SyntaxFactory.SwitchSection();

            csSwitchSection = csSwitchSection.AddLabels(SyntaxFactory.CaseSwitchLabel(node.Expression.ToCsNode <ExpressionSyntax>()));
            csSwitchSection = csSwitchSection.AddStatements(node.Statements.ToCsNodes <StatementSyntax>());

            return(csSwitchSection);
        }
        public void TestSwitchStatement()
        {
            var             caseClause2 = new CaseClause(GetExpression2(), GetStatementList(), DefaultLineInfo);
            SwitchStatement node        = new SwitchStatement(GetExpression1(), new List <CaseClause> {
                GetCaseClause(), caseClause2
            }, new DefaultClause(GetStatementList(), DefaultLineInfo), DefaultLineInfo);

            CheckSerializationRoundTrip(node);
        }
Exemplo n.º 4
0
 public override void Visit(CaseClause node)
 {
     VisitNode(node.Comparison);
     VisitNode(node.Expression);
     VisitNode(node.Body);
     Visit((Node)node);
     WriteEdge(node, node.Comparison, "comparison");
     WriteEdge(node, node.Expression, "expression");
     WriteEdge(node, node.Body, "body");
 }
Exemplo n.º 5
0
        public override object Walk(CaseClause node)
        {
            object result = null;

            foreach (var statement in node.Body)
            {
                result = statement.Accept(this);
            }
            return(result);
        }
Exemplo n.º 6
0
        SqlExpression PivotCaseExpression(PivotColumn col, PivotColumnValue val)
        {
            CaseClause caseClause = new CaseClause();

            caseClause.ElseValue = SqlExpression.Null();

            CaseTerm term = new CaseTerm(PivotCaseCondition(col, val), SqlExpression.Field(valueField));

            caseClause.Terms.Add(term);
            return(SqlExpression.Case(caseClause));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Renders a CaseCluase
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="clause"></param>
        protected virtual void CaseClause(StringBuilder builder, CaseClause clause)
        {
            builder.Append(" case ");
            foreach (CaseTerm term in clause.Terms)
            {
                CaseTerm(builder, term);
            }
            if (clause.ElseValue != null)
            {
                builder.Append(" else ");
                Expression(builder, clause.ElseValue);
            }

            builder.Append(" end ");
        }
Exemplo n.º 8
0
 public virtual object Walk(CaseClause node)
 {
     if (Enter(node))
     {
         if (node.Expression != null)
         {
             node.Expression.Accept(this);
         }
         foreach (var statement in node.Body)
         {
             statement.Accept(this);
         }
     }
     Exit(node);
     return(null);
 }
Exemplo n.º 9
0
        private bool CaseMatch(CaseClause caseClause, object o)
        {
            var conditions = caseClause.Expression.Accept(this);

            if (caseClause.Expression is Expression)
            {
                foreach (var condition in (object[])conditions)
                {
                    if (OpEqual(condition, o).Value)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            return(OpEqual(conditions, o).Value);
        }
Exemplo n.º 10
0
        public CaseClause ParseCaseClause()
        {
            var caseClause = new CaseClause {
                Token = Next()
            };

            if (Next().Is(TokenType.Case))
            {
                Match(TokenType.Case);
                caseClause.Expression = ParseExpression();
                Match(TokenType.Colon);
            }
            else if (Next().Is(TokenType.Default))
            {
                Match(TokenType.Default);
                Match(TokenType.Colon);
            }
            caseClause.Body = ParseCaseStatementList();
            return(caseClause);
        }
Exemplo n.º 11
0
 private bool CaseMatch(CaseClause caseClause, object o)
 {
     var conditions = caseClause.Expression.Accept(this);
     if (caseClause.Expression is Expression)
     {
         foreach (var condition in (object[])conditions)
         {
             if (OpEqual(condition, o).Value)
                 return true;
         }
         return false;
     }
     return OpEqual(conditions, o).Value;
 }
Exemplo n.º 12
0
 public override void Visit(CaseClause node)
 {
     VisitNode(node.Body);
 }
        public void TestCaseClause()
        {
            CaseClause node = GetCaseClause();

            CheckSerializationRoundTrip(node);
        }
Exemplo n.º 14
0
 public CaseClause ParseCaseClause()
 {
     var caseClause = new CaseClause { Token = Next() };
     if (Next().Is(TokenType.Case))
     {
         Match(TokenType.Case);
         caseClause.Expression = ParseExpression();
         Match(TokenType.Colon);
     }
     else if (Next().Is(TokenType.Default))
     {
         Match(TokenType.Default);
         Match(TokenType.Colon);
     }
     caseClause.Body = ParseCaseStatementList();
     return caseClause;
 }
Exemplo n.º 15
0
 public override bool Enter(CaseClause node)
 {
     Print("CaseClause");
     level++;
     return true;
 }
Exemplo n.º 16
0
 public virtual bool Enter(CaseClause node)
 {
     return true;
 }
 public virtual bool Enter(CaseClause node)
 {
     return(true);
 }
Exemplo n.º 18
0
 public override void Visit(CaseClause node)
 {
 }
Exemplo n.º 19
0
 public override object Walk(CaseClause node)
 {
     object result = null;
     foreach (var statement in node.Body)
     {
         result = statement.Accept(this);
     }
     return result;
 }
Exemplo n.º 20
0
    // $ANTLR start "caseClause"
    // JavaScript.g:180:1: caseClause : 'case' ( LT )* expression ( LT )* ':' ( ( 'case' | 'default' | '}' )=> () | ( LT )* statementList ) ;
    public JavaScriptParser.caseClause_return caseClause() // throws RecognitionException [1]
    {   
        JavaScriptParser.caseClause_return retval = new JavaScriptParser.caseClause_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken string_literal196 = null;
        IToken LT197 = null;
        IToken LT199 = null;
        IToken char_literal200 = null;
        IToken LT201 = null;
        JavaScriptParser.expression_return expression198 = default(JavaScriptParser.expression_return);

        JavaScriptParser.statementList_return statementList202 = default(JavaScriptParser.statementList_return);


        object string_literal196_tree=null;
        object LT197_tree=null;
        object LT199_tree=null;
        object char_literal200_tree=null;
        object LT201_tree=null;

        try 
    	{
            // JavaScript.g:181:2: ( 'case' ( LT )* expression ( LT )* ':' ( ( 'case' | 'default' | '}' )=> () | ( LT )* statementList ) )
            // JavaScript.g:181:4: 'case' ( LT )* expression ( LT )* ':' ( ( 'case' | 'default' | '}' )=> () | ( LT )* statementList )
            {
            	root_0 = (object)adaptor.GetNilNode();

            	string_literal196=(IToken)Match(input,60,FOLLOW_60_in_caseClause1493); if (state.failed) return retval;
            	if ( state.backtracking == 0 )
            	{string_literal196_tree = new CaseClause(string_literal196) ;
            		root_0 = (object)adaptor.BecomeRoot(string_literal196_tree, root_0);
            	}
            	// JavaScript.g:181:26: ( LT )*
            	do 
            	{
            	    int alt102 = 2;
            	    int LA102_0 = input.LA(1);

            	    if ( (LA102_0 == LT) )
            	    {
            	        alt102 = 1;
            	    }


            	    switch (alt102) 
            		{
            			case 1 :
            			    // JavaScript.g:181:26: LT
            			    {
            			    	LT197=(IToken)Match(input,LT,FOLLOW_LT_in_caseClause1499); if (state.failed) return retval;

            			    }
            			    break;

            			default:
            			    goto loop102;
            	    }
            	} while (true);

            	loop102:
            		;	// Stops C# compiler whining that label 'loop102' has no statements

            	PushFollow(FOLLOW_expression_in_caseClause1503);
            	expression198 = expression();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, expression198.Tree);
            	// JavaScript.g:181:42: ( LT )*
            	do 
            	{
            	    int alt103 = 2;
            	    int LA103_0 = input.LA(1);

            	    if ( (LA103_0 == LT) )
            	    {
            	        alt103 = 1;
            	    }


            	    switch (alt103) 
            		{
            			case 1 :
            			    // JavaScript.g:181:42: LT
            			    {
            			    	LT199=(IToken)Match(input,LT,FOLLOW_LT_in_caseClause1505); if (state.failed) return retval;

            			    }
            			    break;

            			default:
            			    goto loop103;
            	    }
            	} while (true);

            	loop103:
            		;	// Stops C# compiler whining that label 'loop103' has no statements

            	char_literal200=(IToken)Match(input,58,FOLLOW_58_in_caseClause1509); if (state.failed) return retval;
            	// JavaScript.g:181:50: ( ( 'case' | 'default' | '}' )=> () | ( LT )* statementList )
            	int alt105 = 2;
            	alt105 = dfa105.Predict(input);
            	switch (alt105) 
            	{
            	    case 1 :
            	        // JavaScript.g:181:51: ( 'case' | 'default' | '}' )=> ()
            	        {
            	        	// JavaScript.g:181:75: ()
            	        	// JavaScript.g:181:76: 
            	        	{
            	        	}


            	        }
            	        break;
            	    case 2 :
            	        // JavaScript.g:181:79: ( LT )* statementList
            	        {
            	        	// JavaScript.g:181:81: ( LT )*
            	        	do 
            	        	{
            	        	    int alt104 = 2;
            	        	    int LA104_0 = input.LA(1);

            	        	    if ( (LA104_0 == LT) )
            	        	    {
            	        	        alt104 = 1;
            	        	    }


            	        	    switch (alt104) 
            	        		{
            	        			case 1 :
            	        			    // JavaScript.g:181:81: LT
            	        			    {
            	        			    	LT201=(IToken)Match(input,LT,FOLLOW_LT_in_caseClause1525); if (state.failed) return retval;

            	        			    }
            	        			    break;

            	        			default:
            	        			    goto loop104;
            	        	    }
            	        	} while (true);

            	        	loop104:
            	        		;	// Stops C# compiler whining that label 'loop104' has no statements

            	        	PushFollow(FOLLOW_statementList_in_caseClause1529);
            	        	statementList202 = statementList();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return retval;
            	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, statementList202.Tree);

            	        }
            	        break;

            	}


            }

            retval.Stop = input.LT(-1);

            if ( (state.backtracking==0) )
            {	retval.Tree = (object)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);}
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (object)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
Exemplo n.º 21
0
 /// <nodoc />
 public virtual void Visit(CaseClause caseClause)
 {
 }
Exemplo n.º 22
0
        public void VisitCaseClause(CaseClause caseLabel)
        {
            if (caseLabel.Label != null) {
                VisitExpression(caseLabel.Label);
            }

            VisitStatements(caseLabel.Statements);
        }
Exemplo n.º 23
0
 public override bool Enter(CaseClause node)
 {
     Print("CaseClause");
     level++;
     return(true);
 }
 public virtual void Exit(CaseClause node)
 {
 }
Exemplo n.º 25
0
 public override void Exit(CaseClause node)
 {
     level--;
 }
Exemplo n.º 26
0
 public virtual void Exit(CaseClause node)
 {
 }
Exemplo n.º 27
0
 public override void Visit(CaseClause node)
 {
     result = new CaseClause(GetCloneOf(node.Expression), GetCloneOf(node.Body));
 }
Exemplo n.º 28
0
 public override void Exit(CaseClause node)
 {
     level--;
 }
Exemplo n.º 29
0
 public virtual object Walk(CaseClause node)
 {
     if (Enter(node))
     {
         if (node.Expression != null)
             node.Expression.Accept(this);
         foreach (var statement in node.Body)
         {
             statement.Accept(this);
         }
     }
     Exit(node);
     return null;
 }