当前位置:网站首页>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
边栏推荐
- [introduction to MySQL] the first sentence · first time in the "database" Mainland
- Unity小技巧 - 绘制瞄准准心
- DNS hijacking
- I want to say more about this communication failure
- Stealing others' vulnerability reports and selling them into sidelines, and the vulnerability reward platform gives rise to "insiders"
- Insert dial file of Jerry's watch [chapter]
- Interview shock 62: what are the precautions for group by?
- HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
- RB157-ASEMI整流桥RB157
- Nodejs developer roadmap 2022 zero foundation Learning Guide
猜你喜欢
Zen integration nails, bugs, needs, etc. are reminded by nails
Unity tips - draw aiming Center
STM32 key state machine 2 - state simplification and long press function addition
EasyCVR接入设备开启音频后,视频无法正常播放是什么原因?
【Android】Kotlin代码编写规范化文档
FlutterWeb瀏覽器刷新後無法回退的解决方案
Stealing others' vulnerability reports and selling them into sidelines, and the vulnerability reward platform gives rise to "insiders"
酷雷曼多种AI数字人形象,打造科技感VR虚拟展厅
kivy教程之在 Kivy 中支持中文以构建跨平台应用程序(教程含源码)
Getting started with pytest ----- test case pre post, firmware
随机推荐
Easy introduction to SQL (1): addition, deletion, modification and simple query
Shell input a string of numbers to determine whether it is a mobile phone number
容器里用systemctl运行服务报错:Failed to get D-Bus connection: Operation not permitted(解决方法)
It doesn't make sense without a distributed gateway
李書福為何要親自掛帥造手機?
Kernel link script parsing
Alibaba brand data bank: introduction to the most complete data bank
Getting started with pytest ----- allow generate report
二分(整数二分、实数二分)
EasyCVR平台通过接口编辑通道出现报错“ID不能为空”,是什么原因?
How to submit data through post
Video fusion cloud platform easycvr adds multi-level grouping, which can flexibly manage access devices
Scratch epidemic isolation and nucleic acid detection Analog Electronics Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022
The easycvr authorization expiration page cannot be logged in. How to solve it?
Pyspark operator processing spatial data full parsing (5): how to use spatial operation interface in pyspark
關於這次通信故障,我想多說幾句…
DNS hijacking
The art of Engineering (3): do not rely on each other between functions of code robustness
Getting started with pytest ----- test case pre post, firmware
Pytest learning ----- pytest operation mode and pre post packaging of interface automation testing