Exemple #1
0
        public TryStatement ParseTryStatement()
        {
            var tryStatement = new TryStatement {
                Token = Next()
            };

            Match(TokenType.Try);
            tryStatement.Body = ParseStatementBlock();
            if (Next().IsNot(TokenType.Rescue) && Next().IsNot(TokenType.Finally))
            {
                throw Error("Missing rescue or finally", Next());
            }

            if (Next().Is(TokenType.Rescue))
            {
                var rescueClause = new RescueClause {
                    Token = Next()
                };
                Match(TokenType.Rescue);
                if (!Next().Is(TokenType.LeftBrace))
                {
                    rescueClause.Identifier = ParseIdentifier();
                }
                rescueClause.StatementBlock = ParseStatementBlock();
                tryStatement.Rescue         = rescueClause;
            }
            if (Next().Is(TokenType.Finally))
            {
                Match(TokenType.Finally);
                tryStatement.Finally = ParseStatementBlock();
            }
            return(tryStatement);
        }
Exemple #2
0
 public virtual object Walk(RescueClause node)
 {
     if (Enter(node))
     {
         if (node.Identifier != null)
         {
             node.Identifier.Accept(this);
         }
         node.StatementBlock.Accept(this);
     }
     Exit(node);
     return(null);
 }
Exemple #3
0
 public override void Exit(RescueClause node)
 {
     level--;
 }
Exemple #4
0
 public override bool Enter(RescueClause node)
 {
     Print("RescueClause");
     level++;
     return true;
 }
 public virtual void Exit(RescueClause node)
 {
 }
 public virtual bool Enter(RescueClause node)
 {
     return true;
 }
 public virtual void Exit(RescueClause node)
 {
 }
 public virtual bool Enter(RescueClause node)
 {
     return(true);
 }
 public override void Exit(RescueClause node)
 {
     level--;
 }
 public override bool Enter(RescueClause node)
 {
     Print("RescueClause");
     level++;
     return(true);
 }
Exemple #11
0
        public TryStatement ParseTryStatement()
        {
            var tryStatement = new TryStatement { Token = Next() };
            Match(TokenType.Try);
            tryStatement.Body = ParseStatementBlock();
            if (Next().IsNot(TokenType.Rescue) && Next().IsNot(TokenType.Finally))
                throw Error("Missing rescue or finally", Next());

            if (Next().Is(TokenType.Rescue))
            {
                var rescueClause = new RescueClause { Token = Next() };
                Match(TokenType.Rescue);
                if (!Next().Is(TokenType.LeftBrace))
                {
                    rescueClause.Identifier = ParseIdentifier();
                }
                rescueClause.StatementBlock = ParseStatementBlock();
                tryStatement.Rescue = rescueClause;
            }
            if (Next().Is(TokenType.Finally))
            {
                Match(TokenType.Finally);
                tryStatement.Finally = ParseStatementBlock();
            }
            return tryStatement;
        }
Exemple #12
0
 public virtual object Walk(RescueClause node)
 {
     if (Enter(node))
     {
         if (node.Identifier != null)
             node.Identifier.Accept(this);
         node.StatementBlock.Accept(this);
     }
     Exit(node);
     return null;
 }