当前位置:网站首页>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 .

边栏推荐
猜你喜欢

MATLAB Camera Calibrator相机标定

Qt 中发送自定义事件

Permission model DAC ACL RBAC ABAC

成为IEEE学生会员

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

Vscode install the remote -wsl plug-in to connect to the local WSL

ZUCC_编译语言原理与编译_实验08 语法分析 LR 分析

ZUCC_编译语言原理与编译_实验06 07 语法分析 LL 分析
![Fundamentals of 3D mathematics [17] inverse square theorem](/img/59/bef931d96883288766fc94e38e0ace.png)
Fundamentals of 3D mathematics [17] inverse square theorem

Jenkins自动化部署,连接不到所依赖的服务【已解决】
随机推荐
PHP代码加密+扩展解密实战
Easynvr and easyrtc platforms use go language to manage projects. Summary of the use of govendor and gomod
数据库迁移从PostgreSQL迁移到 MYSQL
QPS, TPS, concurrent users, throughput relationship
Matlab求解线性方程组Ax=b
Shell basic operator -- arithmetic operator
05 Ubuntu installing mysql8
AUTO PWN
Markdown to realize text link jump
数据平台简介
ZUCC_ Principles of compiling language and compilation_ Experiment 03 getting started with compiler
leetcode 1268. Search Suggestions System(搜索推荐系统)
api平台通用签名机制
Three categories of financial assets under the new standards: AMC, fvoci and FVTPL
【微服务~Nacos】Nacos服务提供者和服务消费者
IIS build wordpress5.7 manually
获取屏幕宽高工具类
JUC personal simple notes
饼状统计图,带有标注线,都可以自行设定其多种参数选项
Several ways you can't move zero (sequel)








