当前位置:网站首页>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
边栏推荐
- 2022年大厂Android面试题汇总(一)(含答案)
- Pytest learning ----- detailed explanation of the request for interface automation test
- 二分(整数二分、实数二分)
- PyTorch 提取中间层特征?
- Jerry's watch reading setting status [chapter]
- Guidelines for preparing for the 2022 soft exam information security engineer exam
- Summary of Android interview questions of Dachang in 2022 (II) (including answers)
- Cool Lehman has a variety of AI digital human images to create a vr virtual exhibition hall with a sense of technology
- 李书福为何要亲自挂帅造手机?
- node の SQLite
猜你喜欢
Heavy! Ant open source trusted privacy computing framework "argot", flexible assembly of mainstream technologies, developer friendly layered design
李書福為何要親自掛帥造手機?
Is it meaningful for 8-bit MCU to run RTOS?
[getting started with MySQL] fourth, explore operators in MySQL with Kiko
Zen integration nails, bugs, needs, etc. are reminded by nails
在一台服务器上部署多个EasyCVR出现报错“Press any to exit”,如何解决?
scratch疫情隔离和核酸检测模拟 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月
OpenCV中如何使用滚动条动态调整参数
Selected technical experts from China Mobile, ant, SF, and Xingsheng will show you the guarantee of architecture stability
偷窃他人漏洞报告变卖成副业,漏洞赏金平台出“内鬼”
随机推荐
The latest financial report release + tmall 618 double top, Nike energy leads the next 50 years
Unity粒子特效系列-闪星星的宝箱
Guidelines for preparing for the 2022 soft exam information security engineer exam
重磅!蚂蚁开源可信隐私计算框架“隐语”,主流技术灵活组装、开发者友好分层设计...
OpenEuler 会长久吗
adb常用命令
Jerry's watch deletes the existing dial file [chapter]
VR全景婚礼,帮助新人记录浪漫且美好的场景
STM32按键状态机2——状态简化与增加长按功能
Heavy! Ant open source trusted privacy computing framework "argot", flexible assembly of mainstream technologies, developer friendly layered design
视频融合云平台EasyCVR增加多级分组,可灵活管理接入设备
The art of Engineering (1): try to package things that do not need to be exposed
二分(整数二分、实数二分)
The art of Engineering (2): the transformation from general type to specific type needs to be tested for legitimacy
Nodejs 开发者路线图 2022 零基础学习指南
2022年大厂Android面试题汇总(二)(含答案)
DNS hijacking
The easycvr platform reports an error "ID cannot be empty" through the interface editing channel. What is the reason?
FMT开源自驾仪 | FMT中间件:一种高实时的分布式日志模块Mlog
Scratch epidemic isolation and nucleic acid detection Analog Electronics Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022