当前位置:网站首页>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
边栏推荐
- Stealing others' vulnerability reports and selling them into sidelines, and the vulnerability reward platform gives rise to "insiders"
- There is a gap in traditional home decoration. VR panoramic home decoration allows you to experience the completion effect of your new house
- Jerry's setting currently uses the dial. Switch the dial through this function [chapter]
- Selected technical experts from China Mobile, ant, SF, and Xingsheng will show you the guarantee of architecture stability
- Interview assault 63: how to remove duplication in MySQL?
- Summary of study notes for 2022 soft exam information security engineer preparation
- Four processes of program operation
- FlutterWeb瀏覽器刷新後無法回退的解决方案
- 酷雷曼多种AI数字人形象,打造科技感VR虚拟展厅
- Grafana 9 is officially released, which is easier to use and more cool!
猜你喜欢
Distinguish between basic disk and dynamic disk RAID disk redundant array
偷窃他人漏洞报告变卖成副业,漏洞赏金平台出“内鬼”
Open source and safe "song of ice and fire"
李书福为何要亲自挂帅造手机?
Getting started with pytest ----- test case pre post, firmware
Kivy tutorial: support Chinese in Kivy to build cross platform applications (tutorial includes source code)
Zen integration nails, bugs, needs, etc. are reminded by nails
[rapid environment construction] openharmony 10 minute tutorial (cub pie)
RB157-ASEMI整流桥RB157
Four processes of program operation
随机推荐
Easy introduction to SQL (1): addition, deletion, modification and simple query
最新财报发布+天猫618双榜第一,耐克蓄力领跑下个50年
Kernel link script parsing
JMeter interface test response data garbled
Solution qui ne peut pas être retournée après la mise à jour du navigateur Web flutter
Binary search strategy
EasyCVR平台通过接口编辑通道出现报错“ID不能为空”,是什么原因?
RepPoints:可形变卷积的进阶
Flet教程之 13 ListView最常用的滚动控件 基础入门(教程含源码)
Pytorch extract middle layer features?
The easycvr platform reports an error "ID cannot be empty" through the interface editing channel. What is the reason?
[getting started with MySQL] fourth, explore operators in MySQL with Kiko
FlutterWeb瀏覽器刷新後無法回退的解决方案
Interview shock 62: what are the precautions for group by?
Jielizhi obtains the currently used dial information [chapter]
Summary of Android interview questions of Dachang in 2022 (I) (including answers)
带你穿越古罗马,元宇宙巴士来啦 #Invisible Cities
78 岁华科教授逐梦 40 载,国产数据库达梦冲刺 IPO
[rapid environment construction] openharmony 10 minute tutorial (cub pie)
MSF横向之MSF端口转发+路由表+SOCKS5+proxychains