Ejemplo n.º 1
0
 public TryStatement(Statement body, TryStatementHandler[] handlers, Statement else_, Statement finally_)
 {
     _body = body;
     _handlers = handlers;
     _else = else_;
     _finally = finally_;
 }
Ejemplo n.º 2
0
 // TryStatementHandler
 public override bool Walk(TryStatementHandler node)
 {
     return ShouldWalkWorker(node);
 }
Ejemplo n.º 3
0
        //except_clause: 'except' [expression [',' expression]]
        //2.6: except_clause: 'except' [expression [(',' or 'as') expression]]
        private TryStatementHandler ParseTryStmtHandler()
        {
            string exceptWhiteSpace = _tokenWhiteSpace;
            string commaWhiteSpace = null;
            var start = GetStart();
            Expression test1 = null, test2 = null;
            bool altForm = false;
            if (PeekToken().Kind != TokenKind.Colon) {
                test1 = ParseExpression();

                // parse the expression even if the syntax isn't allowed so we
                // report better error messages when opening against the wrong J version
                var lookahead = _lookahead;
                if (MaybeEat(TokenKind.KeywordAs) || MaybeEatName("as")) {
                    commaWhiteSpace = _tokenWhiteSpace;
                    if (_langVersion < JLanguageVersion.V81) {
                        ReportSyntaxError(lookahead.Span.Start, lookahead.Span.End, "'as' requires J 2.6 or later");
                    }
                    test2 = ParseExpression();
                    altForm = true;
                } else if (MaybeEat(TokenKind.Comma)) {
                    commaWhiteSpace = _tokenWhiteSpace;
                    test2 = ParseExpression();
                    if (_langVersion.Is7x()) {
                        ReportSyntaxError(lookahead.Span.Start, GetEnd(), "\", variable\" not allowed in 3.x - use \"as variable\" instead.");
                    }
                }
            }
            var mid = GetEnd();
            Statement body = ParseSuite();
            TryStatementHandler ret = new TryStatementHandler(test1, test2, body);
            ret.HeaderIndex = mid;
            ret.SetLoc(start, body.EndIndex);

            if (_verbatim) {
                if (altForm) {
                    AddIsAltForm(ret);
                }
                if (commaWhiteSpace != null) {
                    AddSecondPreceedingWhiteSpace(ret, commaWhiteSpace);
                }
                AddPreceedingWhiteSpace(ret, exceptWhiteSpace);
            }
            return ret;
        }
Ejemplo n.º 4
0
 public override void PostWalk(TryStatementHandler node)
 {
     PostWalkWorker(node);
 }