当前位置:网站首页>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
边栏推荐
- QT中Model-View-Delegate委托代理机制用法介绍
- Video fusion cloud platform easycvr adds multi-level grouping, which can flexibly manage access devices
- Jerry's watch deletes the existing dial file [chapter]
- Distinguish between basic disk and dynamic disk RAID disk redundant array
- OliveTin能在网页上安全运行shell命令(上)
- The art of Engineering (3): do not rely on each other between functions of code robustness
- 【Android】Kotlin代码编写规范化文档
- Today in history: the mother of Google was born; Two Turing Award pioneers born on the same day
- VR panoramic wedding helps couples record romantic and beautiful scenes
- Interview assault 63: how to remove duplication in MySQL?
猜你喜欢
Getting started with pytest ----- test case pre post, firmware
Distinguish between basic disk and dynamic disk RAID disk redundant array
历史上的今天:Google 之母出生;同一天诞生的两位图灵奖先驱
Solution qui ne peut pas être retournée après la mise à jour du navigateur Web flutter
Spark accumulator and broadcast variables and beginners of sparksql
面试突击63:MySQL 中如何去重?
There is a gap in traditional home decoration. VR panoramic home decoration allows you to experience the completion effect of your new house
Optimization of middle alignment of loading style of device player in easycvr electronic map
Grafana 9 is officially released, which is easier to use and more cool!
李书福为何要亲自挂帅造手机?
随机推荐
SQL statement optimization, order by desc speed optimization
The art of Engineering (2): the transformation from general type to specific type needs to be tested for legitimacy
TCP packet sticking problem
Unity particle special effects series - treasure chest of shining stars
《ASP.NET Core 6框架揭秘》样章发布[200页/5章]
FlutterWeb瀏覽器刷新後無法回退的解决方案
Unity粒子特效系列-闪星星的宝箱
Manifest of SAP ui5 framework json
Summary of study notes for 2022 soft exam information security engineer preparation
Kivy tutorial: support Chinese in Kivy to build cross platform applications (tutorial includes source code)
sql语句优化,order by desc速度优化
编译原理——自上而下分析与递归下降分析构造(笔记)
Jerry's access to additional information on the dial [article]
QT中Model-View-Delegate委托代理机制用法介绍
Kernel link script parsing
高精度运算
李書福為何要親自掛帥造手機?
Pourquoi Li shufu a - t - il construit son téléphone portable?
Mysqlimport imports data files into the database
SAP UI5 框架的 manifest.json