当前位置:网站首页>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
边栏推荐
- 关于这次通信故障,我想多说几句…
- 开源与安全的“冰与火之歌”
- 编译原理——预测表C语言实现
- EasyCVR平台通过接口编辑通道出现报错“ID不能为空”,是什么原因?
- Getting started with pytest ----- allow generate report
- Easy introduction to SQL (1): addition, deletion, modification and simple query
- EasyCVR电子地图中设备播放器loading样式的居中对齐优化
- 【Android】Kotlin代码编写规范化文档
- What is the reason why the video cannot be played normally after the easycvr access device turns on the audio?
- Jerry's watch reads the file through the file name [chapter]
猜你喜欢
Basic configuration and use of spark
STM32 key state machine 2 - state simplification and long press function addition
STM32按键状态机2——状态简化与增加长按功能
Sqoop I have everything you want
Kivy tutorial: support Chinese in Kivy to build cross platform applications (tutorial includes source code)
OliveTin能在网页上安全运行shell命令(上)
Unity小技巧 - 绘制瞄准准心
视频融合云平台EasyCVR增加多级分组,可灵活管理接入设备
Unity tips - draw aiming Center
Pourquoi Li shufu a - t - il construit son téléphone portable?
随机推荐
视频融合云平台EasyCVR增加多级分组,可灵活管理接入设备
Four processes of program operation
Debug xv6
在一台服务器上部署多个EasyCVR出现报错“Press any to exit”,如何解决?
There is a gap in traditional home decoration. VR panoramic home decoration allows you to experience the completion effect of your new house
After entering Alibaba for the interview and returning with a salary of 35K, I summarized an interview question of Alibaba test engineer
Smart street lamp based on stm32+ Huawei cloud IOT design
MySQL 8 sub database and table backup database shell script
Appium automated test scroll and drag_ and_ Drop slides according to element position
Video fusion cloud platform easycvr adds multi-level grouping, which can flexibly manage access devices
SQL statement optimization, order by desc speed optimization
node の SQLite
一体化实时 HTAP 数据库 StoneDB,如何替换 MySQL 并实现近百倍性能提升
78 year old professor Huake has been chasing dreams for 40 years, and the domestic database reaches dreams to sprint for IPO
Solid principle
重磅!蚂蚁开源可信隐私计算框架“隐语”,主流技术灵活组装、开发者友好分层设计...
kivy教程之在 Kivy 中支持中文以构建跨平台应用程序(教程含源码)
scratch疫情隔离和核酸检测模拟 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月
2022年大厂Android面试题汇总(一)(含答案)
高精度运算