private void ExecuteTryCatchStmt(Ast.TryCatchStmt stmt, ScriptEnv env)
 {
     ExecuteBlock(stmt.TryBlock, env);
     if (env.DidThrow)
     {
         env.DidThrow = false;
         ExecuteBlock(stmt.CatchBlock, env);
     }
 }
Esempio n. 2
0
        private Ast.Stmt ParseTryCatchStmt(TokenQueue q)
        {
            var stmt = new Ast.TryCatchStmt {
                SourceToken = q.SourceToken
            };

            q.Take("begin");
            q.Take("try");
            stmt.TryBlock = new Ast.Block {
                SourceToken = q.SourceToken
            };
            while (q.Peek() != "end")
            {
                var tryStmt = ParseStmt(q);
                if (tryStmt != null)
                {
                    stmt.TryBlock.Statements.Add(tryStmt);
                }
            }
            q.Take("end");
            q.Take("try");

            q.Take("begin");
            q.Take("catch");
            stmt.CatchBlock = new Ast.Block {
                SourceToken = q.SourceToken
            };
            while (q.Peek() != "end")
            {
                var catchStmt = ParseStmt(q);
                if (catchStmt != null)
                {
                    stmt.CatchBlock.Statements.Add(catchStmt);
                }
            }
            q.Take("end");
            q.Take("catch");
            return(stmt);
        }