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的更多相关文章

  1. How a C++ compiler implements exception handling

    Introduction One of the revolutionary features of C++ over traditional languages is its support for ...

  2. IDEA指定.class文件输出位置

    1.File > Project Structure > Project > Project compiler output  项目中的默认编译输出总目录 2.我习惯于把.class ...

  3. Chapter 4 Syntax Analysis

    Chapter 4 Syntax Analysis This chapter is devoted to parsing methods that are typically used in comp ...

  4. Day004 选择结构

    选择结构 if单选择结构(if) if双选择结构(if...else...) if多选择结构(if..else if...else) 嵌套的if结构 switch多选择结构 switch语句中的变量类 ...

  5. High-level structure of a simple compiler高級結構的簡單編譯器

    1.lexical analysis,which analyzes the character string presented to it and divides it up into tokens ...

  6. Learning to write a compiler

    http://stackoverflow.com/questions/1669/learning-to-write-a-compiler?rq=1 Big List of Resources: A N ...

  7. compiler

    http://www.lingcc.com/2012/05/16/12048/ a list of compiler books — 汗牛充栋的编译器参考资料 Posted on 2012年5月16日 ...

  8. Tcl与Design Compiler (八)——DC的逻辑综合与优化

    本文属于原创手打(有参考文献),如果有错,欢迎留言更正:此外,转载请标明出处 http://www.cnblogs.com/IClearner/  ,作者:IC_learner 对进行时序路径.工作环 ...

  9. IntelliJ IDEA(七) :Project Structure

    Project Structure “ 项目结构”对话框允许您管理项目和IDE级别的元素,例如Modules,Facets,Libraries, Artifacts和SDK. 在大多数情况下,左边部分 ...

随机推荐

  1. stm32之存储系统

    一.STM32系统结构 要想深刻理解STM32的存储器,需要首先知道STM32的系统结构. 如Figure 1,是STM32系统结构框图. 根据STM32 Reference manual (RM00 ...

  2. 【237】◀▶IEW-Unit02

    Unit 2 Sport I.状语从句在雅思写作中的运用 公式: 主句+状语从句连接词+从句 =状语从句连接词+从句,主句 1. 时间状语从句 I. when, while, as 1. When+A ...

  3. css水平居中方式

    1. text-align:center 这种方式只适合于内联元素或者文字处于块元素当中是,给块元素设置这个,那么块元素当中的文字或者内联元素则居中.兼容各种浏览器 <div class=&qu ...

  4. [cf2015ICLFinalsDiv1J]Ceizenpok’s formula

    题意:$C_n^m\% k$ 解题关键:扩展lucas+中国剩余定理裸题 #include<algorithm> #include<iostream> #include< ...

  5. Robot FrameWork基础学习(二)

    在Robot Framework中,测试套件(Test Suite)主要是存放测试案例,而资源文件(Resource)就是用来存放用户关键字. 内部资源:Resource 外部资源: External ...

  6. 25.ProfileService实现(调试)

    上一节课拿到的AccessToken和IdToken 实现ProfileService类 在服务端 添加ProfileService类 需要继承IProfileServiuce 用到的画图工具 Ipr ...

  7. eval解析字符串问题

    eval(string) 参数 描述 string 必需.要计算的字符串,其中含有要计算的 JavaScript 表达式或要执行的语句. 复制代码 var str = '{"name&quo ...

  8. 利用URL重写隐藏复杂的URL

    第一步:模拟映射页面 我们想在一个页面上点击guid.html链接,跳转到比较复杂URL的guid_{492f3e0b-848e-11da-9550-00e08161165f}.html页面.即定义一 ...

  9. MD5 不可逆加密,Des对称可逆加密 ,RSA非对称可逆加密 ,数字证书 SSL

    :MD5 不可逆加密2:Des对称可逆加密3:RSA非对称可逆加密4:数字证书 SSL Anker_张(博客园)http://www.cnblogs.com/AnkerZhang/ 1:MD5 不可逆 ...

  10. 快速发现并解决maven依赖传递冲突

    此文已由作者翟曜授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 最近在测试过程中,遇到了几次maven传递依赖冲突的问题,所以记录下解决的过程,遇到类似问题供参照. 问题现象 ...