当前位置:网站首页>ZUCC_ Principles of compiling language and compilation_ Experiment 0607 grammar analysis ll analysis
ZUCC_ Principles of compiling language and compilation_ Experiment 0607 grammar analysis ll analysis
2022-06-24 08:43:00 【The stars don't want to roll】
Compiling language principle and compiling experiment report
| Course name | Programming language principle and compilation |
|---|---|
| Experimental projects | Syntax analysis LL analysis |
Experimental content
One . read ppt Related content , Read textbook No 3 Chapter
1、 understand Nullable Set 、First Set 、 Follow Set Concept
- Nullable Set : A set of nonterminal characters of an empty string can be derived ( Belong to NULLABLE Collection means that the non terminator can be skipped without accepting any input )
- notes : Only when the formulas on the right side of the production are all non terminators and can be derived ε, To add the symbol on the left of the production to NULLABLE Collection .
- FIRST Set :FIRST(α) Defined as from α The set of the first symbols of the derived sentence ,α Is an arbitrary string of grammatical symbols .
- It can be understood as :FIRST The set is the first character after the arrow , If this character is a non Terminator ( Capital ), Just keep looking for something that this capital letter can deduce , Let's see if there is a non terminal character , If still , Keep looking , If it is a Terminator ( Lowercase letters ) Or empty string , Then put the terminator or empty string into the corresponding FIRST Collection .
- Follow Set : For non terminators A,FOLLOW(A) Is defined as the possibility of following in some sentence patterns A The set of terminations on the right .
- It can be understood as :
- For the start symbol , Put... Directly # Added with the start symbol FOLLOW aggregate
- Which symbol is required FOLLOW aggregate , Just find out all the formulas that contain this symbol , But only the symbol to the right of the arrow is useful
- If this symbol is in the last , Take the symbol to the left of the arrow of the formula where this symbol is located FOLLOW Set add in
- If the required symbol is followed by a non Terminator , Just take this non terminal FIRST Set minus empty string plus , Besides , If the non terminator after the required symbol is the same as the symbol to the left of the arrow , Put the arrow to the left FOLLOW Set is added to the required symbol FOLLOW Collection
- If the required symbol is followed by a Terminator , Just add this terminator to FOLLOW Collection
- The non terminator after the first production arrow , We should put the beginning symbol FOLLOW Sets are added to the corresponding FOLLOW Collection
- It can be understood as :
- read
NullableFirstFollow.pdf - understand The construction method of each set
- https://blog.csdn.net/YyjYsj/article/details/106379238
2、 understand Top down analysis , The difference between bottom-up analysis
- Top down analysis :
- The analysis tree is built from root to leaf nodes
- Find the leftmost derivation sequence from the beginning symbol to the final sentence
- Analyzer input Token Sequence
- Bottom up analysis :
- The analysis tree is built from the leaf node to the root node
- Find the leftmost reduction sequence from the sentence to the starting symbol
3、 Understand deterministic top-down analysis ,LL(1) analysis
LL(1) Analysis method is also called prediction analysis method , yes A kind of Non recursive top-down without backtracking analysis .
first L the second L, Numbers 1 What does each mean
LL(1)Prediction analysis table construction , in AndFirstSetFollowRelation of sets ,read
NullableFirstFollow.pdfUnderstand the construction of analysis tables
4、 understand Calculate through the diagram First Set Follow Set method
- Graph calculation First Set
- Graph calculation Follow Set
5、 understand The correspondence between recursive descent analysis program and grammar
https://blog.csdn.net/qq_45180475/article/details/107845953
6、 By learning visualization tools , understand LL(1) Analysis of algorithm
Two . With grammar
S -> a | ^ |( T )
T -> T , S | S
Please eliminate the left recursion of grammar .

3、 ... and . With grammar
E -> T | T ^ E
T -> int * T | ( E ) | ( S )
S -> int T
Please extract the left common factor of grammar .

Four . The following grammar is provided
S -> A
A -> B | A i B
B -> C | B + C
C -> ) A * | (
Decide if you can change the grammar to LL(1) Grammar
Find the of each non terminator
FirstSet AndFollowSetstructure LL(1) Forecast analysis table , Conclusion is given.
- Revised as follows :
- Revised as follows :
5、 ... and . Given the following grammar
S -> + S S
S -> * S S
S -> a
The prediction analysis table of the grammar is given
Extract left common factor :
S -> S' S | a
S' -> + | *

Use the prediction analyzer algorithm to analyze +*aaa, Judge whether the sentence belongs to the language of the grammar above .

边栏推荐
- Pyqt common system events
- jwt(json web token)
- 饼状统计图,带有标注线,都可以自行设定其多种参数选项
- [life thinking] planning and self-discipline
- Introduction to NC machine tool programming [G-code]
- [xinliu-s6 new model +sa 3-star Xinghai] the new two-way server of the third generation chip was launched and the product was updated~
- 更改SSH端口号
- orb slam build bug: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv‘
- Detailed explanation of Base64 coding and its variants (to solve the problem that the plus sign changes into a space in the URL)
- RuntimeError: Missing dependencies:XXX
猜你喜欢

成为IEEE学生会员

【关于运维和网工的差别,一文说透】

liunx服务器 telnet 带用户名 端口登陆方法

New technology practice, encapsulating the permission application library step by step with the activity results API

Redis的Cluster集群数据倾斜

ZUCC_编译语言原理与编译_实验01 语言分析与简介

js中通过key查找和更新对象中指定值的方法

关于ETL看这篇文章就够了,三分钟让你明白什么是ETL

Opencv实现图像的基本变换

教程篇(5.0) 08. Fortinet安全架构集成与FortiXDR * FortiEDR * Fortinet 网络安全专家 NSE 5
随机推荐
ZUCC_ Principles of compiling language and compilation_ Experiment 01 language analysis and introduction
RuntimeError: Missing dependencies:XXX
ZUCC_编译语言原理与编译_实验06 07 语法分析 LL 分析
IIS build wordpress5.7 manually
教程篇(5.0) 08. Fortinet安全架构集成与FortiXDR * FortiEDR * Fortinet 网络安全专家 NSE 5
ZUCC_ Principles of compiling language and compilation_ Experiment 03 getting started with compiler
Introduction to data platform
jwt(json web token)
【力扣10天SQL入门】Day3
K8S部署高可用postgresql集群 —— 筑梦之路
Blue screen error UNMOUNTABLE boot volume of the solution
New technology practice, encapsulating the permission application library step by step with the activity results API
orb slam build bug: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv‘
[micro services ~nacos] Nacos service providers and service consumers
ZUCC_编译语言原理与编译_大作业
[acnoi2022] not a structure, more like a structure
Using sonar for code checking
[life thinking] planning and self-discipline
ZUCC_编译语言原理与编译_实验05 正则表达式、有限自动机、词法分析
获取屏幕宽高工具类








