当前位置:网站首页>编译原理——自上而下分析与递归下降分析构造(笔记)
编译原理——自上而下分析与递归下降分析构造(笔记)
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] 编译原理教程以及课件
边栏推荐
- OpenEuler 会长久吗
- Pytorch extract middle layer features?
- 基本磁盘与动态磁盘 RAID磁盘冗余阵列区分
- Spark accumulator and broadcast variables and beginners of sparksql
- Xin'an Second Edition: Chapter 24 industrial control safety demand analysis and safety protection engineering learning notes
- Distinguish between basic disk and dynamic disk RAID disk redundant array
- It doesn't make sense without a distributed gateway
- Mysqlimport imports data files into the database
- MySQL error reporting solution
- Kivy tutorial: support Chinese in Kivy to build cross platform applications (tutorial includes source code)
猜你喜欢
![[elastic] elastic lacks xpack and cannot create template unknown setting index lifecycle. name index. lifecycle. rollover_ alias](/img/03/ece7f7b28cd9caea4240635548c77f.jpg)
[elastic] elastic lacks xpack and cannot create template unknown setting index lifecycle. name index. lifecycle. rollover_ alias

Getting started with pytest ----- test case rules

Uipath browser performs actions in the new tab

【MySQL入门】第三话 · MySQL中常见的数据类型

重磅!蚂蚁开源可信隐私计算框架“隐语”,主流技术灵活组装、开发者友好分层设计...

Pyspark operator processing spatial data full parsing (4): let's talk about spatial operations first

The easycvr platform reports an error "ID cannot be empty" through the interface editing channel. What is the reason?

Smart street lamp based on stm32+ Huawei cloud IOT design
![[introduction to MySQL] third, common data types in MySQL](/img/11/66b4908ed8f253d599942f35bde96a.png)
[introduction to MySQL] third, common data types in MySQL

Video fusion cloud platform easycvr adds multi-level grouping, which can flexibly manage access devices
随机推荐
MySQL stored procedure
C语言指针*p++、*(p++)、*++p、*(++p)、(*p)++、++(*p)对比实例
8位MCU跑RTOS有没有意义?
The art of Engineering (2): the transformation from general type to specific type needs to be tested for legitimacy
BearPi-HM_ Nano development environment
基于STM32+华为云IOT设计的智能路灯
Why should Li Shufu personally take charge of building mobile phones?
Summary of study notes for 2022 soft exam information security engineer preparation
Xin'an Second Edition: Chapter 25 mobile application security requirements analysis and security protection engineering learning notes
Basic configuration and use of spark
C # nanoframework lighting and key esp32
【MySQL入门】第一话 · 初入“数据库”大陆
Hongmeng introduction and development environment construction
面试突击62:group by 有哪些注意事项?
78 岁华科教授逐梦 40 载,国产数据库达梦冲刺 IPO
MySQL error reporting solution
EasyCVR授权到期页面无法登录,该如何解决?
李书福为何要亲自挂帅造手机?
Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
PySpark算子处理空间数据全解析(5): 如何在PySpark里面使用空间运算接口