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
- 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 from0to9
c) 52 letters fromatozand fromAtoZ
d) 29 punctuation characters:_ { } [ ] # ( ) < > % : ; . ? * + - / ^ & | ~ ! = , \ " ’ - 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.--转义字符
- Trigraph sequences are replaced by corresponding single-character representations.(until C++17)
Phase 2--backslash-反斜线
- 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. 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
- 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
- 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)
- 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
- The preprocessor is executed.
- Each file introduced with the #include directive goes through phases 1 through 4, recursively.
At the end of this phase, all preprocessor directives are removed from the source.
Phase 5--character and string literal
- 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).
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的更多相关文章
- C++预处理详解
本文在参考ISO/IEC 14882:2003和cppreference.com的C++ Preprocessor的基础上,对C++预处理做一个全面的总结讲解.如果没有特殊说明,所列内容均依据C++9 ...
- C++ 字面量
https://docs.microsoft.com/en-us/cpp/cpp/string-and-character-literals-cpp?view=vs-2017 C++ supports ...
- The C Programming Language Second Edition
%12d at least #include <stdio.h> main() { ,sum=,w=; ; ; w<=end; w++ ) { sum+=w; // for(wb= ...
- 浅谈C++编译原理 ------ C++编译器与链接器工作原理
原文:https://blog.csdn.net/zyh821351004/article/details/46425823 第一篇: 首先是预编译,这一步可以粗略的认为只做了一件事情,那就 ...
- Logical query-processing phases
Logical query-processing phases in brief (1) FROM This phase identifies the query’s source tables an ...
- Introduction to Neural Machine Translation - part 1
The Noise Channel Model \(p(e)\): the language Model \(p(f|e)\): the translation model where, \(e\): ...
- Datatypes translation between Oracle and SQL Server
Datatypes translation between Oracle and SQL Server part 1: character, binary strings Datatypes tran ...
- Network Address Translation(转载)
Network Address Translation 来源:http://alexanderlaw.blog.hexun.com/9791596_d.html 地址转换用来改变源/目的 ...
- [Google Translation API v2 for Java]
Reference:https://cloud.google.com/translate/docs/reference/libraries#java-resources QuickstartSampl ...
随机推荐
- HTML标签解释大全
一.HTML标记 标签:!DOCTYPE 说明:指定了 HTML 文档遵循的文档类型定义(DTD). 标签:a 说明:标明超链接的起始或目的位置. 标签:acronym 说明:标明缩写词. ...
- 终于懂了:两个UI组件同时在操作是不可能实现的
// 目的:从某个对话框里,选择一些路径,然后用Tree自动展开这些路径,但至少需要几秒钟时间 // 问题:在这几秒钟期间,显示一个等待对话框,只能开多线程,因为后台继续要处理tree的一些事情.等待 ...
- CCNA实验(2) -- Static Route
1.静态路由R1:ip route 22.1.1.0 255.255.255.0 12.1.1.2 2.静态汇总路由R1:ip route 22.1.0.0 255.255.0.0 12.1.1.2 ...
- 自己动手写RTP服务器——传输所有格式的视频
上一篇文章我们介绍了如何用一个简单的UDP socket搭建一个RTP服务器.我把这份80行的代码呈现到客户面前的时候,就有人不满意了. 还有人在参考的时候会问:“楼主你的TS格式的文件是哪里来的?应 ...
- openStack centos6.4
http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/repodata/repomd.xml: [Errno ...
- kbengine FAQ(3)
官方FAQ 下面是我遇到的一些问题: 1.服务端 "strtof" 未定义的标示符 对于我这个c++入门级都不算的新手,这个错误很挠头,这个错误是由于vc++版本问题,新版的语 ...
- php使用mysql扩展库链接mysql数据库(查询)
php链接数据库可以使用mysql扩展库,mysqli,pdo这几种方式,相比java而言要麻烦一点,因为它不像java那么统一.从代码的难易程度来说php的确要简单许多.步骤大体如下 1.打开数据库 ...
- 用JS判断两个数字的大小
js中的var定义的变量默认是字符串,如果单纯的比较字符串的话,会出现错误,需要先转化为int类型在做比较. [备注:110和18在你写的程序中是18大的,因为 这两个数都是字符串,而1和1相等之后比 ...
- ajax_异步交互-get/post方式
Ajax的异步交互: 客户端向服务器端发送请求,直到服务器端进行响应,这个过程中,用户可以做任何其他事情(不等). 实现Ajax的异步交互步骤(举例说明): get方式: 1.创建XMLHttpReq ...
- ASP.NET MVC Framework
ASP.NET MVC Framework是微软在ASP.NET中所添加的一组类库,这组类库可以使用Model-View-Controller的设计模式来开发ASP.NET的应用程序.它与现有的ASP ...