日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

Phases of translation

發布時間:2023/10/11 综合教程 65 老码农
生活随笔 收集整理的這篇文章主要介紹了 Phases of translation 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Phases of translation--翻譯階段

The C++ source file is processed by the compiler as if the following phases take place, in this exact order:

Phase 1 --96個basic source character set

  1. The individual bytes of the source code file are mapped(in implementation defined manner) to the characters of the basic source character set.In particular, OS-dependent end-of-line indicators are replaced by newline character. The basic source character set consists of 96 characters:--96個基本字符
    a) 5 whitespace characters(space, horizontal tab, vertical tab, form feed, new-line)
    b) 10 digit characters from 0 to 9
    c) 52 letters from a to z and from A to Z
    d) 29 punctuation characters:_ { } [ ] # ( ) < > % : ; . ? * + - / ^ & | ~ ! = , \ " ’
  2. Any source file character that cannot be mapped to a character in basic source character set is replaced by its universal character name (escaped with \u or \U) or by some internal form that is handled equivalently.--轉義字符
  3. Trigraph sequences are replaced by corresponding single-character representations.(until C++17)

Phase 2--backslash-反斜線

  1. Whenever backslash appears at the end of a line (immediately followed by the newline character), both backslash and newline are deleted, combining two physical source lines into one logical source line.
    This is a single-pass operation; a line ending in two backslashes followed by an empty line does not combine three lines into one. If a universal character name (\uXXX) is formed on this phase, the behavior is undefined.
  2. If a non-empty source file does not end with a newline character after this step (whether it had no newline originally, or it ended with a backslash), the behavior is undefined (until C++11) a terminating newline character is added (since C++11).

    Phase 3--header,identifiers,numbers,character and string literal

  3. The source file is decomposed into comments, sequences of whitespace characters (space, horizontal tab, new-line, vertical tab, and form-feed), and preprocessing tokens, which are the following:
  • header names such as or "myfile.h" (only recognized after #include)
  • identifiers
  • numbers
  • character and string literal(including alternative tokens),such as +, <<=, new, <%, ##, or and
  • individual non-whitespace characters that do not fit in any other category
  1. Any transformations performed during phases 1 and 2 between the initial and the final double quote of any raw string literal are reverted. (since C++11)
  2. Each comment is replaced by one space character.

Newlines are kept, and it's unspecified whether non-newline whitespace sequences may be collapsed into single space characters.

Phase 4 --preprocessor

  1. The preprocessor is executed.
  2. Each file introduced with the #include directive goes through phases 1 through 4, recursively.
  3. At the end of this phase, all preprocessor directives are removed from the source.

    Phase 5--character and string literal

  4. All characters in character literals and string literals are converted from the source character set to the execution character set (which may be a multibyte character set such as UTF-8, as long as the 96 characters of the basic source character set listed in phase 1 have single-byte representations).
  5. Escape sequences and universal character names in character literals and non-raw string literals are expanded and converted to the execution character set. If the character specified by a universal character name isn't a member of the execution character set, the result is implementation-defined, but is guaranteed not to be a null (wide) character。

    Phase 6

    Adjacent string literals are concatenated.

Phase 7-- translated as a translation unit

Compilation takes place: the tokens are syntactically and semantically analyzed and translated as a translation unit.

Phase 8 -- instantiation unit

Each translation unit is examined to produce a list of required template instantiations, including the ones requested by explicit instantiations. The definitions of the templates are located, and the required instantiations are performed to produce instantiation units.

Phase 9

Translation units, instantiation units, and library components needed to satisfy external references are collected into a program image which contains information needed for execution in its execution environment.

Some compilers don't implement instantiation units (also known as template repositories or template registries) and simply compile each template instantiation at Phase 7, storing the code in the object file where it is implicitly or explicitly requested, and then the linker collapses these compiled instantiations into one at Phase 9

總結

以上是生活随笔為你收集整理的Phases of translation的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。