Example #1
0
        bool s_exp17()  // a>1?b:c;
        {
LL1:
            switch (lex.sy)
            {
            case SYMBOL.QUEST:
            {
                lex.InSymbol();

                int L1 = gen.emit(INSTYPE.LJZ);                 //JZ L2+1
                s_exp3();
                int L2 = gen.emit(INSTYPE.LJMP);                //JMP END

                expect(SYMBOL.COLON);
                s_exp3();

                gen.remit(L1, L2 + 1 - L1);
                gen.remit(L2, gen.IP - L2);                             //gen.remit(L2,END);
            }
            break;

            case SYMBOL.COLON:
                if (gen.IP > gen.Size())
                {
                    return(true);
                }

                Operand OPR = gen.IV[gen.IP - 1].operand;
                switch (OPR.ty)
                {
                case OPRTYPE.identcon:
                    OPR.ty    = OPRTYPE.numcon;
                    OPR.value = new Numeric((string)(OPR.value));
                    break;

                case OPRTYPE.numcon:
                    if (((Numeric)(OPR.value)).ty != NUMTYPE.stringcon)
                    {
                        error.OnError(SYMBOL.identsy);
                    }
                    break;

                default:
                    error.OnError(SYMBOL.identsy);
                    break;
                }
                gen.IP--;
                gen.emit(INSTYPE.MARK);
                gen.emit(INSTYPE.MOV, OPR);
                lex.InSymbol(); s_exp3();
                gen.emit(INSTYPE.END);
                break;

            default: return(true);
            }
            goto LL1;
        }