当前位置:网站首页>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
边栏推荐
- The art of Engineering (3): do not rely on each other between functions of code robustness
- Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
- 中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障
- 面试突击63:MySQL 中如何去重?
- The easycvr platform reports an error "ID cannot be empty" through the interface editing channel. What is the reason?
- The art of Engineering (1): try to package things that do not need to be exposed
- FlutterWeb瀏覽器刷新後無法回退的解决方案
- FlutterWeb浏览器刷新后无法回退的解决方案
- 开源与安全的“冰与火之歌”
- C # nanoframework lighting and key esp32
猜你喜欢
![[translation] principle analysis of X Window Manager (I)](/img/40/6e15e1acebb47061d6e0e4c8ff82ea.jpg)
[translation] principle analysis of X Window Manager (I)

李书福为何要亲自挂帅造手机?

C语言指针*p++、*(p++)、*++p、*(++p)、(*p)++、++(*p)对比实例

C语言通过指针交换两个数

ASEMI整流桥DB207的导通时间与参数选择
![Jerry's updated equipment resource document [chapter]](/img/6c/17bd69b34c7b1bae32604977f6bc48.jpg)
Jerry's updated equipment resource document [chapter]

编译原理——预测表C语言实现

78 year old professor Huake has been chasing dreams for 40 years, and the domestic database reaches dreams to sprint for IPO

Sqoop I have everything you want

RB157-ASEMI整流桥RB157
随机推荐
OpenCV中如何使用滚动条动态调整参数
最新财报发布+天猫618双榜第一,耐克蓄力领跑下个50年
Interview shock 62: what are the precautions for group by?
The art of Engineering
IP, subnet mask, gateway, default gateway
历史上的今天:Google 之母出生;同一天诞生的两位图灵奖先驱
[getting started with MySQL] fourth, explore operators in MySQL with Kiko
面试突击63:MySQL 中如何去重?
MSF横向之MSF端口转发+路由表+SOCKS5+proxychains
adb常用命令
F200——搭载基于模型设计的国产开源飞控系统无人机
Kernel link script parsing
Getting started with pytest ----- allow generate report
Debug and run the first xv6 program
Establishment of graphical monitoring grafana
面试突击62:group by 有哪些注意事项?
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
Principle and usage of extern
Jerry's updated equipment resource document [chapter]