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. ios之Block研究

    Block的好处,我总结了下主要有2点:1.用于回调特别方便,2.可以延长对象的作用区域.但是,Block的内存管理这个模块一直不是很清楚,这个周末好好的看了下Block的原理,有些许心得. 为了性能 ...

  2. js关于为DOM对象添加自定义属性的方式和区别

    DOM对象的三种在添加自定义属性的方式 一是 通过 “.”+“属性名” 二是 setAttribute()(getAttribute()获取) 三是 直接在元素标签上加属性  如:<div  n ...

  3. ACM-ICPC2018焦作网络赛 Transport Ship(二进制背包+方案数)

    Transport Ship 25.78% 1000ms 65536K   There are NN different kinds of transport ships on the port. T ...

  4. 如何升级一个JavaWeb应用

    准备db变更 准备整个war包或变更的文件 上传文件至云盘​(通常直接上传文件较慢,建议先传到云盘,然后下载) 从云盘下载 执行db变更 解压war到指定目录或替换变更的文件 修改设计IP地址的配置文 ...

  5. Coreseek 安装问题

    Ubuntu下安装coreseek mmseg出现了cannot find input file: src/Makefile.in 解决方法如下 >autoheader >automake ...

  6. 19个很有用的 JavaScript库推荐

    流行的 JavaScript 库有jQuery,MooTools,Prototype,Dojo和YUI等,这些 JavaScript 库功能丰富,加上它们众多的插件,几乎能实现任何你需要的功能 然而需 ...

  7. 洛谷P3182 [HAOI2016]放棋子

    P3182 [HAOI2016]放棋子 题目描述 给你一个N*N的矩阵,每行有一个障碍,数据保证任意两个障碍不在同一行,任意两个障碍不在同一列,要求你在这个矩阵上放N枚棋子(障碍的位置不能放棋子),要 ...

  8. 关于HTML5画布canvas的功能

    一.画布的使用 1.首先创建一个画布(canvas) <canvas id=”myCanvas” width=”200” height=”100” style=”border:1px solid ...

  9. 洛谷 P1070 道路游戏(noip 2009 普及组 第四题)

    题目描述 小新正在玩一个简单的电脑游戏. 游戏中有一条环形马路,马路上有 nn个机器人工厂,两个相邻机器人工厂之间由一小段马路连接.小新以某个机器人工厂为起点,按顺时针顺序依次将这 nn个机器人工厂编 ...

  10. tinkphp5使用中碰到的问题 持续更新

    1.使用助手函数(如controller(),model(),validate())进行实例化时只需要引入think\Controller或think\Model或think\Validate即可,无 ...