Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Poster with the 8 phases of translation in the C language

Tags:

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 translation)? I want to have one printed hanging on my wall next to my pc.

Update: Sorry for forgetting to specify. I am interested in C90 (although C99 probably is pretty close, _Pragma as mentioned in pmg's answer is C99 specific and I would like to avoid that).

like image 441
hlovdal Avatar asked Sep 25 '09 11:09

hlovdal


1 Answers

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    |
                    +-----------------------------+
like image 113
Christoph Avatar answered Oct 25 '22 15:10

Christoph