1.2 the structure of a compiler
Compiler
1.2 the structure of a compiler
Compiler : analysis and synthesis
syntactically 语法上的
semantically 语意上的
The analysis part breaks up the source program into constituent pieces and imposes a grammatical structure on them.
The analysis part also collects information about the source program and stores it in a data structure called a symbol table, which is passed along with the intermediate representation to the synthesis part.
The synthesis part constructs the desired target program from the intermediate representstion and the information in the symbol table .
The analysis part is often called the front end of the compiler ;the synthesis part is the back end .
A typical decomposition of a compiler into phases is shown :
1.2.1 lexical analysis
lexemes .
<token-name, attribute-value>
1.2.2 syntax analysis
The parser uses the first components of the tokens produced by the lexical analyzer to create a tree-like intermediate representation that depicts the grammatical structure of the token steam . A typical representation is a syntax teee in which each interior node represents an operation and the children of the node represent the arguments of the operation .
1.2.3 semantic analysis
The semantic analysis uses the syntax tree and the information in the symbol table to check the source program for semantic consistency with the language definition .
Type checking :
coercions: the language specification may permit some type conversions called coercions
1.2.4 intermediate code generation
This intermediate representation should have two important properties : it should be easy to produce and it should be easy to translate into the target machine .
three-address code .
1.2.5 code optimization
The machine -independent code -optimization phase attempts to improve the intermediate code so that better target code will result .
12.6 Code generation
The code generator takes as input an intermediate representation of the source program and maps it into the target language .
A crucial aspect of code generation is the judicious assignment of registers to hold variables .
ldf :load float
mulf:multiplies float
addf : add float
stf :store float
1.2.7 symbol-table management
an essential function of a compiler is to record the variable names used in the source program and collect information about various attributes of each name .
The symbol table is a data structure containing a record for each variable name ,with fields for the attributes of the name .
1.2.8 The grouping of phases into passes
the discussion of phases deals with the logical organization of a compiler . In an implementation ,activities from several phase may be grouped together into a pass
With these collections ,we can produce compilers for different source languages for one target machine by combining different front ends with the back end for that target machine . Similarly ,we can produce compilers for different target machines ,by combining a front end with back ends for different target machines .
1.2.9 compiler-construction tools
some commonly used compiler-construction tools includes
1. parser generators that automatically produce syntax analyzers from a grammatical description of a programming language .
1.2 the structure of a compiler的更多相关文章
- How a C++ compiler implements exception handling
Introduction One of the revolutionary features of C++ over traditional languages is its support for ...
- IDEA指定.class文件输出位置
1.File > Project Structure > Project > Project compiler output 项目中的默认编译输出总目录 2.我习惯于把.class ...
- Chapter 4 Syntax Analysis
Chapter 4 Syntax Analysis This chapter is devoted to parsing methods that are typically used in comp ...
- Day004 选择结构
选择结构 if单选择结构(if) if双选择结构(if...else...) if多选择结构(if..else if...else) 嵌套的if结构 switch多选择结构 switch语句中的变量类 ...
- High-level structure of a simple compiler高級結構的簡單編譯器
1.lexical analysis,which analyzes the character string presented to it and divides it up into tokens ...
- Learning to write a compiler
http://stackoverflow.com/questions/1669/learning-to-write-a-compiler?rq=1 Big List of Resources: A N ...
- compiler
http://www.lingcc.com/2012/05/16/12048/ a list of compiler books — 汗牛充栋的编译器参考资料 Posted on 2012年5月16日 ...
- Tcl与Design Compiler (八)——DC的逻辑综合与优化
本文属于原创手打(有参考文献),如果有错,欢迎留言更正:此外,转载请标明出处 http://www.cnblogs.com/IClearner/ ,作者:IC_learner 对进行时序路径.工作环 ...
- IntelliJ IDEA(七) :Project Structure
Project Structure “ 项目结构”对话框允许您管理项目和IDE级别的元素,例如Modules,Facets,Libraries, Artifacts和SDK. 在大多数情况下,左边部分 ...
随机推荐
- python3+selenium使用浏览器IE的时候,无法打开IE浏览器,老是报错: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones
python3+selenium使用浏览器IE的时候,老是报错: Unexpected error launching Internet Explorer. Protected Mode settin ...
- 【opencv学习笔记一】opencv下载安装与VS2017开发环境配置
本文章摘录自浅墨博客,原文链接http://blog.csdn.net/poem_qianmo/article/details/19809337 目录 1.opencv下载与安装 2.计算机环境变量配 ...
- sublime text3设置
我的sublime的设置,ps:这个博文只是为了我自己的一个记录 { "color_scheme": "Packages/Theme - Solarized Flat/S ...
- DL杂谈
好久不写了,几点这次项目经验吧,本次训练位多任务训练,主要目的训练人脸角度,具体公司项目不细谈. 讲一下主要碰到的坑: 1 最主要问题,网络结构不对称,导致主任务与辅助任务之间的梯度关系不平衡从而导致 ...
- 面试题: 数据库 oracle数据库 已看1 意义不大 有用
Oracle数据库面试题总结 2017年04月27日 22:41:44 阅读数:9271 1.SQL语句分类 DQL(数据查询语言)select DML(数据操作语言)insert.delete.up ...
- RPC原理与实践(二)----Thrift分层模型
这一节我们从一下几个方面来讲一下Thrift的分层架构,按照官方的定义这是Thrift的网络栈,其中网络栈中分为一下几个部分,(由栈顶到栈底)server,processor,protocol,tra ...
- 在element-ui的表格组件中为表头添加Tooltip 文字提示
在使用表格组件的时候经常遇到的问题,列数很多,而表头的文字描述长度很长 <el-table-column v-if="!column.event" v-for="( ...
- Fenwick Tree / Binary Indexed Tree
Motivation: Given a 1D array of n elements. [2, 5, -1, 3, 6] range sum query: what's the sum from 2n ...
- 关于/proc/cpuinfo文件
以上输出项的含义如下: processor :系统中逻辑处理核的编号.对于单核处理器,则课认为是其CPU编号,对于多核处理器则可以是物理核.或者使用超线程技术虚拟的逻辑核 vendor_id :CPU ...
- codeforces1009G Allowed Letters【贪心+hall定理】
因为是字典序所以贪心选当前能选的最小的,所以问题就在于怎么快速计算当前这个位置能不能选枚举的字母 重排之后的序列是可以和原序列完美匹配的,而完美匹配需要满足hall定理,也就是左边任意k个集合一定和右 ...