⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treebuilder24.java

📁 Python Development Environment (Python IDE plugin for Eclipse). Features editor, code completion, re
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            last.test = test;
            last.body = body;
            last.orelse = orelse;
            addSpecialsAndClearOriginal(suite, last);
            
            for (int i = 0; i < (arity / 3)-1; i++) {
                //arity--;//because of the beg if stmt

                suite = (Suite)stack.popNode();
                body = suite.body;
                test = (exprType) stack.popNode();
                stmtType[] newOrElse = new stmtType[] { last };
                last = (If) stack.popNode();
                last.test = test;
                last.body = body;
                last.orelse = newOrElse;
                addSpecialsAndClearOriginal(suite, last);
            }
            return last;
        case JJTPASS_STMT:
            return new Pass();
        case JJTBREAK_STMT:
            return new Break();
        case JJTCONTINUE_STMT:
            return new Continue();
        case JJTBEGIN_DECORATOR:
            return new decoratorsType(null,null,null,null, null);
        case JJTDECORATORS:
            ArrayList<SimpleNode> list2 = new ArrayList<SimpleNode>();
            ArrayList<SimpleNode> listArgs = new ArrayList<SimpleNode>();
            while(stack.nodeArity() > 0){
                SimpleNode node = stack.popNode();
                while(!(node instanceof decoratorsType)){
                    if(node instanceof comprehensionType){
                        listArgs.add(node);
                        listArgs.add(stack.popNode()); //target
                        
                    }else{
                        listArgs.add(node);
                    }
                    node = stack.popNode();
                }
                listArgs.add(node);//the decoratorsType
                list2.add(0,makeDecorator(listArgs));
                listArgs.clear();
            }
            return new Decorators((decoratorsType[]) list2.toArray(new decoratorsType[0]), JJTDECORATORS);
        case JJTCALL_OP:
            exprType starargs = null;
            exprType kwargs = null;

            l = arity - 1;
            if (l > 0 && stack.peekNode().getId() == JJTEXTRAKEYWORDVALUELIST) {
                ExtraArgValue nkwargs = (ExtraArgValue) stack.popNode();
                kwargs = nkwargs.value;
                this.addSpecialsAndClearOriginal(nkwargs, kwargs);
                l--;
            }
            if (l > 0 && stack.peekNode().getId() == JJTEXTRAARGVALUELIST) {
                ExtraArgValue nstarargs = (ExtraArgValue) stack.popNode();
                starargs = nstarargs.value;
                this.addSpecialsAndClearOriginal(nstarargs, starargs);
                l--;
            }
            
            int nargs = l;

            SimpleNode[] tmparr = new SimpleNode[l]; 
            for (int i = l - 1; i >= 0; i--) {
                tmparr[i] = stack.popNode();
                if (tmparr[i] instanceof keywordType) {
                    nargs = i;
                }
            }
            
            exprType[] args = new exprType[nargs];
            for (int i = 0; i < nargs; i++) {
                //what can happen is something like print sum(x for x in y), where we have already passed x in the args, and then get 'for x in y'
                if(tmparr[i] instanceof comprehensionType){
                    args = new exprType[]{
                        new ListComp(args[0], new comprehensionType[]{
                                (comprehensionType)tmparr[i]
                            })
                        };
                }else{
                    args[i] = (exprType) tmparr[i];
                }
            }

            keywordType[] keywords = new keywordType[l - nargs];
            for (int i = nargs; i < l; i++) {
                if (!(tmparr[i] instanceof keywordType))
                    throw new ParseException(
                        "non-keyword argument following keyword", tmparr[i]);
                keywords[i - nargs] = (keywordType) tmparr[i];
            }
            exprType func = (exprType) stack.popNode();
            Call c = new Call(func, args, keywords, starargs, kwargs);
            addSpecialsAndClearOriginal(n, c);
            return c;
        case JJTFUNCDEF:
            //get the decorators
            //and clear them for the next call (they always must be before a function def)
            Suite s = (Suite) stack.popNode();
            body = s.body;
            
            argumentsType arguments = makeArguments(stack.nodeArity() - 2);
            NameTok nameTok = makeName(NameTok.FunctionName);
            Decorators decs = (Decorators) stack.popNode() ;
            decoratorsType[] decsexp = decs.exp;
            FunctionDef funcDef = new FunctionDef(nameTok, arguments, body, decsexp);
            if(decs.exp.length == 0){
                addSpecialsBefore(decs, funcDef);
            }
            addSpecialsAndClearOriginal(s, funcDef);
            setParentForFuncOrClass(body, funcDef);
            return funcDef;
        case JJTDEFAULTARG:
            value = (arity == 1) ? null : ((exprType) stack.popNode());
            return new DefaultArg(((exprType) stack.popNode()), value);
        case JJTEXTRAARGLIST:
            return new ExtraArg(makeName(NameTok.VarArg), JJTEXTRAARGLIST);
        case JJTEXTRAKEYWORDLIST:
            return new ExtraArg(makeName(NameTok.KwArg), JJTEXTRAKEYWORDLIST);
/*
        case JJTFPLIST:
            fpdefType[] list = new fpdefType[arity];
            for (int i = arity-1; i >= 0; i--) {
                list[i] = popFpdef();
            }
            return new FpList(list);
*/
        case JJTCLASSDEF:
            s = (Suite) stack.popNode();
            body = s.body;
            exprType[] bases = makeExprs(stack.nodeArity() - 1);
            nameTok = makeName(NameTok.ClassName);
            ClassDef classDef = new ClassDef(nameTok, bases, body);
            addSpecialsAndClearOriginal(s, classDef);
            setParentForFuncOrClass(body, classDef);
            return classDef;
        case JJTBEGIN_RETURN_STMT:
            return new Return(null);
        case JJTRETURN_STMT:
            value = arity == 2 ? ((exprType) stack.popNode()) : null;
            Return ret = (Return) stack.popNode();
            ret.value = value;
            return ret;
        case JJTYIELD_STMT:
            return new Yield(((exprType) stack.popNode()));
        case JJTRAISE_STMT:
            exprType tback = arity >= 3 ? ((exprType) stack.popNode()) : null;
            exprType inst = arity >= 2 ? ((exprType) stack.popNode()) : null;
            exprType type = arity >= 1 ? ((exprType) stack.popNode()) : null;
            return new Raise(type, inst, tback);
        case JJTGLOBAL_STMT:
            Global global = new Global(makeIdentifiers(NameTok.GlobalName));
            return global;
        case JJTEXEC_STMT:
            exprType globals = arity >= 3 ? ((exprType) stack.popNode()) : null;
            exprType locals = arity >= 2 ? ((exprType) stack.popNode()) : null;
            value = (exprType) stack.popNode();
            return new Exec(value, locals, globals);
        case JJTASSERT_STMT:
            exprType msg = arity == 2 ? ((exprType) stack.popNode()) : null;
            test = (exprType) stack.popNode();
            return new Assert(test, msg);
        case JJTBEGIN_TRY_STMT:
            //we do that just to get the specials
            return new TryExcept(null, null, null);
        case JJTTRY_STMT:
            orelseSuite = null;
            if (stack.peekNode() instanceof Suite) {
                arity--;
                arity--;
                
                orelseSuite = popSuiteAndSuiteType();
            }
            l = arity - 1;
            excepthandlerType[] handlers = new excepthandlerType[l];
            for (int i = l - 1; i >= 0; i--) {
                handlers[i] = (excepthandlerType) stack.popNode();
            }
            s = (Suite)stack.popNode();
            TryExcept tryExc = (TryExcept) stack.popNode();
            tryExc.body = s.body;
            tryExc.handlers = handlers;
            tryExc.orelse = orelseSuite;
            addSpecials(s, tryExc);
            return tryExc;
        case JJTBEGIN_TRY_ELSE_STMT:
            //we do that just to get the specials
            return new suiteType(null);
        case JJTBEGIN_EXCEPT_CLAUSE:
            return new excepthandlerType(null,null,null);
        case JJTEXCEPT_CLAUSE:
            s = (Suite) stack.popNode();
            body = s.body;
            exprType excname = arity == 4 ? ((exprType) stack.popNode()) : null;
            if (excname != null){    
                ctx.setStore(excname);
            }
            type = arity >= 3 ? ((exprType) stack.popNode()) : null;
            excepthandlerType handler = (excepthandlerType) stack.popNode(); 
            handler.type = type;
            handler.name = excname;
            handler.body = body;
            addSpecials(s, handler);
            return handler;
        case JJTBEGIN_FINALLY_STMT:
            //we do that just to get the specials
            return new suiteType(null);
        case JJTTRYFINALLY_STMT:
            suiteType finalBody = popSuiteAndSuiteType();
            body = popSuite();
            //We have a try..except in the stack, but we will change it for a try..finally
            //This is because we recognize a try..except in the 'try:' token, but actually end up with a try..finally
            TryExcept tryExcept = (TryExcept) stack.popNode();
            TryFinally tryFinally = new TryFinally(body, finalBody);
            addSpecialsAndClearOriginal(tryExcept, tryFinally);
            return tryFinally;
            
        case JJTOR_BOOLEAN:
            return new BoolOp(BoolOp.Or, makeExprs());
        case JJTAND_BOOLEAN:
            return new BoolOp(BoolOp.And, makeExprs());
        case JJTCOMPARISION:
            l = arity / 2;
            exprType[] comparators = new exprType[l];
            int[] ops = new int[l];
            for (int i = l-1; i >= 0; i--) {
                comparators[i] = (exprType) stack.popNode();
                SimpleNode op = stack.popNode();
                switch (op.getId()) {
                case JJTLESS_CMP:          ops[i] = Compare.Lt; break;
                case JJTGREATER_CMP:       ops[i] = Compare.Gt; break;
                case JJTEQUAL_CMP:         ops[i] = Compare.Eq; break;
                case JJTGREATER_EQUAL_CMP: ops[i] = Compare.GtE; break;
                case JJTLESS_EQUAL_CMP:    ops[i] = Compare.LtE; break;
                case JJTNOTEQUAL_CMP:      ops[i] = Compare.NotEq; break;
                case JJTIN_CMP:            ops[i] = Compare.In; break;
                case JJTNOT_IN_CMP:        ops[i] = Compare.NotIn; break;
                case JJTIS_NOT_CMP:        ops[i] = Compare.IsNot; break;
                case JJTIS_CMP:            ops[i] = Compare.Is; break;
                default:
                    throw new RuntimeException("Unknown cmp op:" + op.getId());
                }
            }
            return new Compare(((exprType) stack.popNode()), ops, comparators);
        case JJTLESS_CMP:
        case JJTGREATER_CMP:
        case JJTEQUAL_CMP:
        case JJTGREATER_EQUAL_CMP:
        case JJTLESS_EQUAL_CMP:
        case JJTNOTEQUAL_CMP:
        case JJTIN_CMP:
        case JJTNOT_IN_CMP:
        case JJTIS_NOT_CMP:
        case JJTIS_CMP:
            return n;
        case JJTOR_2OP:
            return makeBinOp(BinOp.BitOr);
        case JJTXOR_2OP:
            return makeBinOp(BinOp.BitXor);
        case JJTAND_2OP:
            return makeBinOp(BinOp.BitAnd);
        case JJTLSHIFT_2OP:
            return makeBinOp(BinOp.LShift);
        case JJTRSHIFT_2OP:
            return makeBinOp(BinOp.RShift);
        case JJTADD_2OP:  
            return makeBinOp(BinOp.Add);
        case JJTSUB_2OP: 
            return makeBinOp(BinOp.Sub);
        case JJTMUL_2OP:
            return makeBinOp(BinOp.Mult);
        case JJTDIV_2OP: 
            return makeBinOp(BinOp.Div);
        case JJTMOD_2OP:
            return makeBinOp(BinOp.Mod);
        case JJTPOW_2OP:
            return makeBinOp(BinOp.Pow);
        case JJTFLOORDIV_2OP:
            return makeBinOp(BinOp.FloorDiv);
        case JJTPOS_1OP:
            return new UnaryOp(UnaryOp.UAdd, ((exprType) stack.popNode()));
        case JJTNEG_1OP:
            return new UnaryOp(UnaryOp.USub, ((exprType) stack.popNode()));
        case JJTINVERT_1OP:
            return new UnaryOp(UnaryOp.Invert, ((exprType) stack.popNode()));
        case JJTNOT_1OP:
            return new UnaryOp(UnaryOp.Not, ((exprType) stack.popNode()));
        case JJTEXTRAKEYWORDVALUELIST:
            return new ExtraArgValue(((exprType) stack.popNode()), JJTEXTRAKEYWORDVALUELIST);
        case JJTEXTRAARGVALUELIST:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -