编译原理笔记(龙书) Compiler Construction Chapter 1

Chapter 1

定义(Definition) 

A compiler is a program that reads a program written in one programming language (the source language ) and translates it into an equivalent program in another programming language (the target language ).
The source program may contain some errors .
If errors occur, the compiler must detect and report all errors.

结构(Structure)  

A compiler is not one big piece of software.
It has a sequence of phases 步骤/时期 .
On the high level:
Input: source program
Source code analysis分析  ( front end前端 )
Intermediate code generator
Synthesis综合 ( back end后端 )
output: target program

分析(Analysis----front end)

三个步骤

  1. lexical analysis (词法分析或者叫做扫描scanning)
  2. syntax analysis
  3. semantic analysis

 词法分析(Lexical analysis)

 

 

 语法分析(Syntax analysis)

 语义分析(Semantic analysis)

错误类型(Error) 

个人观点:

       lexcial 可以看作是单词的错误,例如拼写等

       syntax 则更多是结构上的错误,正如英语上的语法有误,缺少了哪些成分

       semantic 就是偏理解文本意思的错误,逻辑困乱,类型不适配等

源代码分析的其他应用程序(了解)

 

中间代码生成(Intermediate Code Generator

三地址代码(Three-address code)----一种中间表示形式 

综合(Synthesis----back end) 

代码优化(Code optimization)

代码生成(Code generation) 

 指令选择(Instruction selection)

指令调度(Instruction scheduling) 

 寄存器分配(Register allocation)

 把值传给内存需要地址的转换等故需要增加运算

 其他组成成分(Other components)

符号表管理(symbol table manager) 

错误处理器(Error handler) 

总流程(Overall flow) 

其他步骤(Other phases) 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值