当前位置:网站首页>编译原理——自上而下分析与递归下降分析构造(笔记)
编译原理——自上而下分析与递归下降分析构造(笔记)
2022-07-06 09:59:00 【yjx23332】
目的
构造不带回溯的自上而下分析程序
- 要消除文法的左递归性
- 克服回溯
主要思路
- 分析程序由一组递归过程组成, 对每一语法变量 ( 非终结符 ) 构造一个相应的子程序,识别对应的语法单位
- 通过子程序间的相互调用实现对输入串的识别
- 这样的分析程序称为递归下降分析器 ( 因为文法的定义
通常是递归的 )
过程与变量
ADVANCE:把输入串指示器 IP 指向下一个输入符号,即读入一个单字符号(调用词法分析器,取下一个符号)
SYM:IP 当前所指的输入符号(取得的符号)
ERROR :出错处理子程序
实例
每个非终结符有对应的子程序的定义,首先在分析过程中,当需要从某个非终结符出发进行展开 ( 推导 ) 时,就调用这个非终结符对应的子程序。
也即是,每个子程序对应一个非终结符(语法单位),遇到这个语法单位时,就掉用对应的子程序。
如,E就有一个子程序,负责E的识别、推导。该则程序负责调用T和E’。T等同理。
注意,文法必须是LL(1)文法才可以(动作唯一)。
模板
1
2
第一种写法,
ELSE IF检查的是,是否为终结符,是就结束,不是就是报错。
另外一种
两种都没有问题。
第二种,虽然没有检查follow集合,但下一个字符的会检查first集合。换言之,即是让后面的程序去检查当前的结果是否正确。
这样导致的是,程序报错位置的区别。
主程序就是开始符,是就开始。
巴科斯范式文法
在元符号“→”和“ |” 的基础上,扩充几个元语言符号
如
成图
参考文献
[1] 《程序设计语言编译原理》第三版 陈火旺
[2] 编译原理教程以及课件
边栏推荐
- 视频融合云平台EasyCVR增加多级分组,可灵活管理接入设备
- Xin'an Second Edition: Chapter 25 mobile application security requirements analysis and security protection engineering learning notes
- OpenCV中如何使用滚动条动态调整参数
- 面试突击63:MySQL 中如何去重?
- Xin'an Second Edition; Chapter 11 learning notes on the principle and application of network physical isolation technology
- Easy introduction to SQL (1): addition, deletion, modification and simple query
- node の SQLite
- Sqoop I have everything you want
- Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
- Pytest learning ----- pytest confitest of interface automation test Py file details
猜你喜欢
How to use scroll bars to dynamically adjust parameters in opencv
The easycvr platform reports an error "ID cannot be empty" through the interface editing channel. What is the reason?
Kivy tutorial: support Chinese in Kivy to build cross platform applications (tutorial includes source code)
Easy introduction to SQL (1): addition, deletion, modification and simple query
Virtual machine startup prompt probing EDD (edd=off to disable) error
EasyCVR平台通过接口编辑通道出现报错“ID不能为空”,是什么原因?
李書福為何要親自掛帥造手機?
TCP connection is more than communicating with TCP protocol
Wordcloud colormap color set and custom colors
Selected technical experts from China Mobile, ant, SF, and Xingsheng will show you the guarantee of architecture stability
随机推荐
Appium automated test scroll and drag_ and_ Drop slides according to element position
Xin'an Second Edition: Chapter 24 industrial control safety demand analysis and safety protection engineering learning notes
TCP connection is more than communicating with TCP protocol
Basic configuration and use of spark
It doesn't make sense without a distributed gateway
Smart street lamp based on stm32+ Huawei cloud IOT design
Interview shock 62: what are the precautions for group by?
VR全景婚礼,帮助新人记录浪漫且美好的场景
分布式不来点网关都说不过去
MarkDown语法——更好地写博客
Run xv6 system
Grafana 9 is officially released, which is easier to use and more cool!
EasyCVR电子地图中设备播放器loading样式的居中对齐优化
历史上的今天:Google 之母出生;同一天诞生的两位图灵奖先驱
Summary of study notes for 2022 soft exam information security engineer preparation
Single responsibility principle
Hongmeng introduction and development environment construction
基本磁盘与动态磁盘 RAID磁盘冗余阵列区分
The art of Engineering (3): do not rely on each other between functions of code robustness
【Elastic】Elastic缺少xpack无法创建模板 unknown setting index.lifecycle.name index.lifecycle.rollover_alias