当前位置:网站首页>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
边栏推荐
- FMT开源自驾仪 | FMT中间件:一种高实时的分布式日志模块Mlog
- 关于这次通信故障,我想多说几句…
- 面试突击62:group by 有哪些注意事项?
- C # nanoframework lighting and key esp32
- 编译原理——自上而下分析与递归下降分析构造(笔记)
- 高精度运算
- Jerry's updated equipment resource document [chapter]
- Reppoints: advanced order of deformable convolution
- Solution qui ne peut pas être retournée après la mise à jour du navigateur Web flutter
- The easycvr authorization expiration page cannot be logged in. How to solve it?
猜你喜欢

How to use scroll bars to dynamically adjust parameters in opencv

ASEMI整流桥DB207的导通时间与参数选择

EasyCVR电子地图中设备播放器loading样式的居中对齐优化

分布式不来点网关都说不过去

Awk command exercise

node の SQLite

Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)

STM32 key state machine 2 - state simplification and long press function addition

视频融合云平台EasyCVR增加多级分组,可灵活管理接入设备

开源与安全的“冰与火之歌”
随机推荐
FlutterWeb瀏覽器刷新後無法回退的解决方案
SQL statement optimization, order by desc speed optimization
李书福为何要亲自挂帅造手机?
Distinguish between basic disk and dynamic disk RAID disk redundant array
Nodejs developer roadmap 2022 zero foundation Learning Guide
Summary of Android interview questions of Dachang in 2022 (I) (including answers)
PyTorch 提取中间层特征?
Unity小技巧 - 绘制瞄准准心
The difference between parallelism and concurrency
78 岁华科教授逐梦 40 载,国产数据库达梦冲刺 IPO
What is the reason why the video cannot be played normally after the easycvr access device turns on the audio?
Shell input a string of numbers to determine whether it is a mobile phone number
EasyCVR平台通过接口编辑通道出现报错“ID不能为空”,是什么原因?
重磅!蚂蚁开源可信隐私计算框架“隐语”,主流技术灵活组装、开发者友好分层设计...
酷雷曼多种AI数字人形象,打造科技感VR虚拟展厅
MySQL 8 sub database and table backup database shell script
Appium automated test scroll and drag_ and_ Drop slides according to element position
[getting started with MySQL] fourth, explore operators in MySQL with Kiko
STM32按键状态机2——状态简化与增加长按功能
分布式不来点网关都说不过去