LINUX.ORG.RU

История изменений

Исправление wandrien, (текущая версия) :

Есть еще промежуточный вариант, как первый, но с ключевым словом loop вместо repeat.

Пока склоняюсь к этому варианту.

Примеры кода.

Текущее состояние:

    /* Check the cases for the operands arrived in swapped order: */
    if fSwap==1 then
        do
            /* We can handle it by changing the operation ID */
            word swappedID = CheckOperationSwappable(ID);
            if swappedID != 0 then
                ID = swappedID;
                exit;
            end:if

            /* We can handle it by swapping operands back. */
            switch ID of
            case iSUB, iDIV, iMOD:
                Emit(@CodeCmdRegReg(@Buff, "xchg", Reg_TARGET, 4, rightReg, 4));
                exit;
            end:switch

            /* If the operation is commutative, we don't care about the order. */
            when IsOperationCommutative(ID):
                exit;

            /* In other cases, swapped operands shouldn't happen. */
            StopInternalCodegen(__FILE__, __LINE__);
        end:do
    end:if

Планируемое после устаканивания синтаксиса управляющих структур:

    /* Check the cases for the operands arrived in swapped order: */
    if fSwap==1 then
        block
            /* We can handle it by changing the operation ID */
            word swappedID = CheckOperationSwappable(ID);
            if swappedID != 0 then
                ID = swappedID;
                exit block;
            end:if

            /* We can handle it by swapping operands back. */
            switch ID of
            case iSUB, iDIV, iMOD:
                Emit(@CodeCmdRegReg(@Buff, "xchg", Reg_TARGET, 4, rightReg, 4));
                exit block;
            end:switch

            /* If the operation is commutative, we don't care about the order. */
            when IsOperationCommutative(ID):
                exit block;

            /* In other cases, swapped operands shouldn't happen. */
            StopInternalCodegen(__FILE__, __LINE__);
        end:block
    end:if

Текущее состояние:

    Scan(@Buff);
    while strcmp(@Buff,")")!=0 do
        word pType = Find(@Buff);
        when pType >= nDICT | Dict[pType].Class != cTYPE:
            Stop(@eTYPEEXP);

        do
            Scan(@Buff);
            word nPtr=ReadPtrs(@Buff);

            when pType == st_void & nPtr<1:
                Stop(@eNOVOID);
            when Dict[pType].Sub == sFUNCTYPE & nPtr<1:
                Stop(@eNOVAL);

            word pARG = FindInNamespace(@Buff, pARGS);
            when pARG < nDICT:
                StopWithSubject(@eDUPLICATE, @Buff);

            pARG = DictAlloc();
            DictSetName(pARG, @Buff);
            Dict[pARG].Class = cARG;
            Dict[pARG].pType = T_nPtrTo(nPtr, pType);
            DictAddToNamespace(pARG, pARGS);

            when strcmp(@Scan(@Buff),",")!=0:
                exit;
        end

        if strcmp(@Buff,")")!=0 then
            when strcmp(@Buff,";") != 0:
                Stop(@eSEMICOLONEXP);
            when strcmp(@Scan(@Buff),")") == 0:
                Stop(@eTYPEEXP);
        end

    end:while

Планируемое после устаканивания синтаксиса управляющих структур:

    Scan(@Buff);
    while strcmp(@Buff,")")!=0 do
        word pType = Find(@Buff);
        when pType >= nDICT | Dict[pType].Class != cTYPE:
            Stop(@eTYPEEXP);

        do
            Scan(@Buff);
            word nPtr=ReadPtrs(@Buff);

            when pType == st_void & nPtr<1:
                Stop(@eNOVOID);
            when Dict[pType].Sub == sFUNCTYPE & nPtr<1:
                Stop(@eNOVAL);

            word pARG = FindInNamespace(@Buff, pARGS);
            when pARG < nDICT:
                StopWithSubject(@eDUPLICATE, @Buff);

            pARG = DictAlloc();
            DictSetName(pARG, @Buff);
            Dict[pARG].Class = cARG;
            Dict[pARG].pType = T_nPtrTo(nPtr, pType);
            DictAddToNamespace(pARG, pARGS);

        loop until strcmp(@Scan(@Buff),",")!=0;

        if strcmp(@Buff,")")!=0 then
            when strcmp(@Buff,";") != 0:
                Stop(@eSEMICOLONEXP);
            when strcmp(@Scan(@Buff),")") == 0:
                Stop(@eTYPEEXP);
        end

    end:while

Исходная версия wandrien, :

Есть еще промежуточный вариант, как первый, но с ключевым словом loop вместо repeat.

Пока склоняюсь к этому варианту.

Примеры кода.

Текущее состояние:

    /* Check the cases for the operands arrived in swapped order: */
    if fSwap==1 then
        do
            /* We can handle it by changing the operation ID */
            word swappedID = CheckOperationSwappable(ID);
            if swappedID != 0 then
                ID = swappedID;
                exit;
            end:if

            /* We can handle it by swapping operands back. */
            switch ID of
            case iSUB, iDIV, iMOD:
                Emit(@CodeCmdRegReg(@Buff, "xchg", Reg_TARGET, 4, rightReg, 4));
                exit;
            end:switch

            /* If the operation is commutative, we don't care about the order. */
            when IsOperationCommutative(ID):
                exit;

            /* In other cases, swapped operands shouldn't happen. */
            StopInternalCodegen(__FILE__, __LINE__);
        end:do
    end:if

Планируемое после устаканивания синтаксиса управляющих структур:

    /* Check the cases for the operands arrived in swapped order: */
    if fSwap==1 then
        block
            /* We can handle it by changing the operation ID */
            word swappedID = CheckOperationSwappable(ID);
            if swappedID != 0 then
                ID = swappedID;
                exit block;
            end:if

            /* We can handle it by swapping operands back. */
            switch ID of
            case iSUB, iDIV, iMOD:
                Emit(@CodeCmdRegReg(@Buff, "xchg", Reg_TARGET, 4, rightReg, 4));
                exit block;
            end:switch

            /* If the operation is commutative, we don't care about the order. */
            when IsOperationCommutative(ID):
                exit block;

            /* In other cases, swapped operands shouldn't happen. */
            StopInternalCodegen(__FILE__, __LINE__);
        end:block
    end:if

Текущее состояние:

    Scan(@Buff);
    while strcmp(@Buff,")")!=0 do
        word pType = Find(@Buff);
        when pType >= nDICT | Dict[pType].Class != cTYPE:
            Stop(@eTYPEEXP);

        do
            Scan(@Buff);
            word nPtr=ReadPtrs(@Buff);

            when pType == st_void & nPtr<1:
                Stop(@eNOVOID);
            when Dict[pType].Sub == sFUNCTYPE & nPtr<1:
                Stop(@eNOVAL);

            word pARG = FindInNamespace(@Buff, pARGS);
            when pARG < nDICT:
                StopWithSubject(@eDUPLICATE, @Buff);

            pARG = DictAlloc();
            DictSetName(pARG, @Buff);
            Dict[pARG].Class = cARG;
            Dict[pARG].pType = T_nPtrTo(nPtr, pType);
            DictAddToNamespace(pARG, pARGS);

            when strcmp(@Scan(@Buff),",")!=0:
                exit;
        end

        if strcmp(@Buff,")")!=0 then
            when strcmp(@Buff,";") != 0:
                Stop(@eSEMICOLONEXP);
            when strcmp(@Scan(@Buff),")") == 0:
                Stop(@eTYPEEXP);
        end

    end:while

Планируемое после устаканивания синтаксиса управляющих структур:

    Scan(@Buff);
    while strcmp(@Buff,")")!=0 do
        word pType = Find(@Buff);
        when pType >= nDICT | Dict[pType].Class != cTYPE:
            Stop(@eTYPEEXP);

        do
            Scan(@Buff);
            word nPtr=ReadPtrs(@Buff);

            when pType == st_void & nPtr<1:
                Stop(@eNOVOID);
            when Dict[pType].Sub == sFUNCTYPE & nPtr<1:
                Stop(@eNOVAL);

            word pARG = FindInNamespace(@Buff, pARGS);
            when pARG < nDICT:
                StopWithSubject(@eDUPLICATE, @Buff);

            pARG = DictAlloc();
            DictSetName(pARG, @Buff);
            Dict[pARG].Class = cARG;
            Dict[pARG].pType = T_nPtrTo(nPtr, pType);
            DictAddToNamespace(pARG, pARGS);

        loop until strcmp(@Scan(@Buff),",")!=0

        if strcmp(@Buff,")")!=0 then
            when strcmp(@Buff,";") != 0:
                Stop(@eSEMICOLONEXP);
            when strcmp(@Scan(@Buff),")") == 0:
                Stop(@eTYPEEXP);
        end

    end:while