当前位置:网站首页>Compilation principle - top-down analysis and recursive descent analysis construction (notes)
Compilation principle - top-down analysis and recursive descent analysis construction (notes)
2022-07-06 17:59:00 【yjx23332】
Catalog
Purpose
Construct a top-down analysis program without backtracking
- To eliminate the left recursion of grammar
- Overcoming backtracking
Main idea
- The parser consists of a set of recursive procedures , For each syntax variable ( non-terminal ) Construct a corresponding subroutine , Identify the corresponding grammatical unit
- The recognition of input string is realized through the mutual call between subroutines
- Such an analyzer is called a recursive descent analyzer ( Because the definition of grammar
Usually recursive )
Process and variable
ADVANCE: Input string indicator IP Point to the next input symbol , That is, read a single word symbol ( Call lexical analyzer , Take down a symbol )
SYM:IP The currently indicated input symbol ( Obtained symbol )
ERROR : Error handling subroutine
example

Each non terminator has the definition of the corresponding subroutine , First, in the analysis process , When you need to start from a non terminal ( deduction ) when , Call the subroutine corresponding to this non terminator .
That is to say , Each subroutine corresponds to a non terminator ( Grammatical units ), When you encounter this grammatical unit , Use the corresponding subroutine .
Such as ,E There is a subroutine , be responsible for E The identification of 、 deduction . This program is responsible for calling T and E’.T By the same token, such as .
Be careful , Grammar must be LL(1) Grammar can ( The action is unique ).
Templates

1


2

The first way to write it ,
ELSE IF What we checked was , Whether it is a Terminator , Yes, it's over , Either it is an error .
another 
There is no problem with either .
The second kind , Although there is no inspection follow aggregate , But the next character will be checked first aggregate . In other words , That is, let the following program check whether the current result is correct .
This leads to , The difference between program error reporting positions .
The main program is the start character , Yes, start .
Bakos normal form grammar
In the meta symbol “→” and “ |” On the basis of , Expand a few metalanguage symbols
Such as 


Drawing

reference
[1] 《 Programming language compilation principle 》 The third edition Chen Huowang
[2] Compiling principle tutorial and courseware
边栏推荐
- ASEMI整流桥DB207的导通时间与参数选择
- Jielizhi obtains the customized background information corresponding to the specified dial [chapter]
- 2022年大厂Android面试题汇总(二)(含答案)
- Solution qui ne peut pas être retournée après la mise à jour du navigateur Web flutter
- Unity tips - draw aiming Center
- Nodejs 开发者路线图 2022 零基础学习指南
- Growth of operation and maintenance Xiaobai - week 7
- The shell generates JSON arrays and inserts them into the database
- TCP packet sticking problem
- Video fusion cloud platform easycvr adds multi-level grouping, which can flexibly manage access devices
猜你喜欢

编译原理——自上而下分析与递归下降分析构造(笔记)

C # nanoframework lighting and key esp32

Distinguish between basic disk and dynamic disk RAID disk redundant array

J'aimerais dire quelques mots de plus sur ce problème de communication...

李书福为何要亲自挂帅造手机?

Unity tips - draw aiming Center

面试突击62:group by 有哪些注意事项?

Open source and safe "song of ice and fire"

The integrated real-time HTAP database stonedb, how to replace MySQL and achieve nearly a hundredfold performance improvement

EasyCVR电子地图中设备播放器loading样式的居中对齐优化
随机推荐
微信小程序中给event对象传递数据
Summary of Android interview questions of Dachang in 2022 (I) (including answers)
重磅!蚂蚁开源可信隐私计算框架“隐语”,主流技术灵活组装、开发者友好分层设计...
李書福為何要親自掛帥造手機?
Mysqlimport imports data files into the database
The art of Engineering (3): do not rely on each other between functions of code robustness
How to use scroll bars to dynamically adjust parameters in opencv
2022年大厂Android面试题汇总(二)(含答案)
Pytorch extract middle layer features?
FlutterWeb瀏覽器刷新後無法回退的解决方案
Jerry's watch reading setting status [chapter]
Four processes of program operation
编译原理——自上而下分析与递归下降分析构造(笔记)
BearPi-HM_ Nano development environment
MarkDown语法——更好地写博客
The difference between parallelism and concurrency
Establishment of graphical monitoring grafana
TCP packet sticking problem
10 advanced concepts that must be understood in learning SQL
[ASM] introduction and use of bytecode operation classwriter class