1. Си / Говнокод #21491

    −16

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    /*! Brainfuck Update based on Symbol */
    #define BF_UPDATE_SYM($, S, X) JOIN(BF_UPDATE_SYM_, S)($, X)
    #define BF_UPDATE_SYM_R($, X) (INC(BF_IP(X)), INC(BF_DP(X)), BF_IA(X), BF_DA(X))      /*!< Increment Data Pointer             */
    #define BF_UPDATE_SYM_L($, X) (INC(BF_IP(X)), DEC(BF_DP(X)), BF_IA(X), BF_DA(X))      /*!< Decrement Data Pointer             */
    #define BF_UPDATE_SYM_U($, X) (INC(BF_IP(X)), BF_DP(X), BF_IA(X), BF_DATA_INC($, X))  /*!< Increment Item at Data Pointer     */
    #define BF_UPDATE_SYM_D($, X) (INC(BF_IP(X)), BF_DP(X), BF_IA(X), BF_DATA_DEC($, X))  /*!< Decrement Item at Data Pointer     */
    #define BF_UPDATE_SYM_O($, X) (INC(BF_IP(X)), BF_DP(X), BF_IA(X), BF_DA(X))           /*!< Do Nothing (Output as side effect) */
    #define BF_UPDATE_SYM_F($, X) (BF_JUMP_F($, X), BF_DP(X), BF_IA(X), BF_DA(X))         /*!< Conditional Jump Forwards          */
    #define BF_UPDATE_SYM_B($, X) (BF_JUMP_B($, X), BF_DP(X), BF_IA(X), BF_DA(X))         /*!< Conditional Jump Backwards           */
    #define BF_UPDATE_SYM_($, X)  (INC(BF_IP(X)), BF_DP(X), BF_IA(X), BF_DA(X))           /*!< Do Nothing on empty instruction    */
    
    /*! Main Brainfuck loop */
    #define BF_COND($, X) NOT(BF_IS_BLANK(BF_INSTR($, X)))                        /*!< Terminate on end of input          */
    #define BF_MACRO($, X) IF(BF_IS_OUTPUT(BF_INSTR($, X)), CHAR(BF_DATA($, X)))  /*!< Output on O instruction            */
    #define BF_UPDATE($, X) BF_UPDATE_SYM($, BF_INSTR($, X), X)                   /*!< Update based on instruction symbol */
    #define BF_FINALLY($, X)                                                      /*!< Do nothing on termination          */
    #define BF_RECR($, X) JOIN(RECR_D, $)(INC($), BF_COND, BF_MACRO, BF_UPDATE, BF_FINALLY, X)
    
    /*! Empty Data Array - Extend for more Cells */
    #define BF_DATA_EMPTY() (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)

    https://github.com/orangeduck/CPP_COMPLETE/ A Brainfuck interpreter written in the C preprocessor.

    Запостил: j123123, 19 Октября 2016

    Комментарии (14) RSS

    Добавить комментарий