当前位置:网站首页>Self made compiler learning 2: compilation process
Self made compiler learning 2: compilation process
2022-06-09 08:25:00 【I_ belong_ to_ jesus】
compile 4 Stages
Narrow sense compilation can be roughly divided into 4 Stages : Syntax analysis -> Semantic analysis -> Generate intermediate code -> Code generation
Syntax analysis (syntax analyzing)
The first step in compiling is to... The code analysis (parse) Also known as Syntax analysis (syntax analyzing), The program module that parses the code is called Parser (parser) or parsers (syntax analyzer). The final result of parsing is the syntax tree , As shown in the figure below :

Semantic analysis
Syntax analysis Just analyze the appearance of the code , Semantic analysis (semantic analysis) Is to analyze the part beyond the representation , for example : Distinguish between local variables and global variables 、 Distinguish whether a variable is declared or referenced 、 Whether the variable is initialized, etc . The syntax tree just copies the structure of the code , Semantic analysis generates Abstract syntax tree (Abstract Syntax Tree, AST) It also includes Semantic information , Links are added before the references and definitions of variables , Add commands such as type conversion to make the expression types consistent , in addition , Parentheses outside the expression 、 Semicolon at the end of line, etc , stay Abstract syntax tree Are omitted from .
Generate intermediate code
Intermediate code (Intermediate Representation, IR) Mainly to support multi programming languages and multi machine languages , Generating uniform intermediate code will greatly simplify the subsequent operations .
Code generation
Intermediate code to assembly code .
边栏推荐
猜你喜欢

Elk+filebeat deployment and installation

Dell iDRAC Express版本的共享网口设置
Twitter的最新功能让商家预告即将推出的产品 提醒顾客去购物
![[penetration test] summary of conditional competition vulnerabilities](/img/8b/d365d7c1f16fa1be392770209c6454.jpg)
[penetration test] summary of conditional competition vulnerabilities

ELK+Filebeat 部署安装

C language review 8
![Nacos startup error [db load error]load jdbc properties error](/img/e0/e511da6cd6821ffb315d118a2feae9.png)
Nacos startup error [db load error]load jdbc properties error

C language review 9

Question about Oracle: why can't the DBMS be linked according to the evening tutorial and output results

图解知识点:leakcanary
随机推荐
自制编译器学习3:Flex和Bison简介
GC学习笔记
RMAN备份概念_在线备份和备份模式
Twitter的最新功能让商家预告即将推出的产品 提醒顾客去购物
【TeXstudio】【3】较为完整的论文排版模板与bib文件引用方法
About Matrix Decompositions
Alibaba Cloud ACK Access Enterprise version ACR Mirror
Blow up the idea artifact in use recently
配置RMAN备份的环境_配置通道(Channel)
Quarkus practical learning I
Kibana:Kibana 入门 (一)
Heavyweight! Wuhan university students made a successful satellite launch!
Graphic knowledge points: leakcanary
CV learning notes cnn-vgg
自制编译器学习2:编译的过程
Go questions / knowledge gathering - 2
Market Research - current market situation and future development trend of cosmetic grade ethylhexyl glycerol in the world and China
leetcodeSQL:1070. Product sales analysis III
Oracle partition table paging query SQL optimization
小米官网移动端布局