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. 在大多数情况下,左边部分 ...
随机推荐
- cocos2dx 3.0 用ClippingNode做游戏的新手引导
转自:http://blog.csdn.net/star530/article/details/20851263 本篇介绍的是用ClippingNode 做游戏的新手引导,额,或者说是做新手引导的一种 ...
- js中push(),pop(),unshift(),shift()的用法
js中push(),pop(),unshift(),shift()的用法小结 1.push().pop()和unshift().shift() 这两组同为对数组的操作,并且会改变数组的本身的长度及 ...
- linux 下 .o 文件, .a文件,.so文件的区别
最近在unbuntu环境下开发代码,由于很少使用linux开发环境,所以对linux编译方面了解更少,关于.o, .a, .so文件和可执行文件一直很困惑 今天特意查了一下关于它们的区分: .o 就相 ...
- Windows Error Codes
http://www.briandunning.com/error-codes/?source=Windows Windows Error Codes List All Error Codes | S ...
- 异步和多线程,委托异步调用,Thread,ThreadPool,Task,Parallel,CancellationTokenSource
1 进程-线程-多线程,同步和异步2 异步使用和回调3 异步参数4 异步等待5 异步返回值 5 多线程的特点:不卡主线程.速度快.无序性7 thread:线程等待,回调,前台线程/后台线程, 8 th ...
- html页面渲染过程
1.解析html文件,创建DOM树 自上而下解析,遇到任何样式(link.style)和脚本(script)都会阻塞 1)css加载不会阻塞html文件的解析,但会阻塞dom的渲染 2)css加载会阻 ...
- 洛谷P2292 [HNOI2004]L语言
传送门 建好trie树 当$dp[j]==1$当且仅当存在$dp[k]=1$且$T[k+1,j]==word[i]$ 然后乱搞就行了 //minamoto #include<iostream&g ...
- jQuery EasyUI/TopJUI创建树形表格下拉框
jQuery EasyUI/TopJUI创建树形表格下拉框 第一种方法(纯HTML创建) <div class="topjui-row"> <div class= ...
- 【T-BABY 夜谈大数据】基于内容的推荐算法
这个系列主要也是自己最近在研究大数据方向,所以边研究.开发也边整理相关的资料.网上的资料经常是碎片式的,如果要完整的看完可能需要同时看好几篇文章,所以我希望有兴趣的人能够更轻松和快速地学习相关的知识. ...
- Tomcat 指定jdk
Windows 下 修改 tomcat根目录/bin/setclasspath.bat 文件 如下: rem Otherwise either JRE or JDK are fine set JAVA ...