Poster with the 8 phases of translation in the C language

后端 未结 2 1885
無奈伤痛
無奈伤痛 2020-11-27 03:20

Does anyone have a reference to a poster/one-page pdf or something similar with a list of the eight phases of translation for the C language (the first one being trigraph tr

2条回答
  •  孤城傲影
    2020-11-27 03:38

    ASCII art for the win:

                           ANSI C translation phases
                           =========================
    
              +-------------------------------------------------+
              | map physical characters to source character set |
              |     replace line terminators with newlines      |
              |           decode trigraph sequences             |
              +-------------------------------------------------+
                                       |
                                       V
                   +---------------------------------------+
                   | join lines along trailing backslashes |
                   +---------------------------------------+
                                       |
                                       V
         +-------------------------------------------------------------+
         | decompose into preprocessing tokens and whitespace/comments |
         |                      strip comments                         |
         |                      retain newlines                        |
         +-------------------------------------------------------------+        
                                       |
                                       V
              +------------------------------------------------+
              | execute preprocessing directives/invoke macros |
              |              process included files            |
              +------------------------------------------------+
                                       |
                                       V
       +----------------------------------------------------------------+
       | decode escape sequences in character constants/string literals |
       +----------------------------------------------------------------+
                                       |
                                       V
                    +--------------------------------------+
                    | concatenate adjacent string literals |
                    +--------------------------------------+
                                       |
                                       V
                  +------------------------------------------+
                  | convert preprocessing tokens to C tokens |
                  |       analyze and translate tokens       |
                  +------------------------------------------+
                                       |
                                       V
                        +-----------------------------+
                        | resolve external references |
                        |        link libraries       |
                        |      build program image    |
                        +-----------------------------+
    

提交回复
热议问题