![Page 1: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/1.jpg)
Narges S. Bathaeian
طراحی کامپایلر
Top Down ParsingLL(1)
![Page 2: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/2.jpg)
Narges S. Bathaeian
top down parsingتعریف
Parse tree را از ریشه به سمت برگها می سازد .دو نوع
LL(1) , LL(k)Recursive descent
![Page 3: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/3.jpg)
Narges S. Bathaeian
مثال
G = ({S},{‘(‘, ‘)’ }, P , S)
S ( S )S ε
S
(())$
![Page 4: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/4.jpg)
Narges S. Bathaeian
مثال S ( S )S ε
(())$
![Page 5: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/5.jpg)
Narges S. Bathaeian
مثال S ( S )S ε
(())$
![Page 6: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/6.jpg)
Narges S. Bathaeian
مثال S ( S )S ε
(())$
![Page 7: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/7.jpg)
Narges S. Bathaeian
پیاده سازی StackLL(1) parsing table
![Page 8: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/8.jpg)
Narges S. Bathaeian
push S مثال
1. S ( S )2. S ε S
(())$
221S$)(N/T
S
![Page 9: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/9.jpg)
Narges S. Bathaeian
rule 1مثال
1. S ( S )2. S ε
(())$
221S$)(N/T
)
S
(
![Page 10: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/10.jpg)
Narges S. Bathaeian
) matchمثال
1. S ( S )2. S ε
(())$
221S$)(N/T
)
S
(
![Page 11: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/11.jpg)
Narges S. Bathaeian
مثال 1. S ( S )2. S ε
(())$
221S$)(N/T
)
S
![Page 12: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/12.jpg)
Narges S. Bathaeian
rule 1 مثال
1. S ( S )2. S ε
(())$
221S$)(N/T
)
)
S
(
![Page 13: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/13.jpg)
Narges S. Bathaeian
) match مثال
1. S ( S )2. S ε
(())$
221S$)(N/T
)
)
S
(
![Page 14: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/14.jpg)
Narges S. Bathaeian
مثال 1. S ( S )2. S ε
(())$
221S$)(N/T
)
)
S
![Page 15: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/15.jpg)
Narges S. Bathaeian
rule 2 مثال
1. S ( S )2. S ε
(())$
221S$)(N/T
)
)
![Page 16: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/16.jpg)
Narges S. Bathaeian
( match مثال
1. S ( S )2. S ε
(())$
221S$)(N/T
)
)
![Page 17: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/17.jpg)
Narges S. Bathaeian
( match مثال
1. S ( S )2. S ε
(())$
221S$)(N/T
)
![Page 18: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/18.jpg)
Narges S. Bathaeian
accept مثال
1. S ( S )2. S ε
(())$
221S$)(N/T
![Page 19: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/19.jpg)
Narges S. Bathaeian
چگونگی ساختن جدول 1. S ( S )2. S ε
221S
$)(N/T
First (S) Follow (S)
![Page 20: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/20.jpg)
Narges S. Bathaeian
چگونگی ساختن جدول جدولی که ستونهای آن الفبا و سطرهای آن متغیرهای
. گرامر هستند را ایجاد می کنیم هر متغیر و قانونهای مربوطه اش را پیدا firstمجموعه
. کرده و در خانه مربوطه شماره قانون را وارد می کنیم مجموعه , برای متغیرهایی که به رشته تهی می روند
follow نه دقیقا ( را پیدا می کنیم (!! .
![Page 21: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/21.jpg)
Narges S. Bathaeian
follow و firstتعریف مجموعه های
زیر مجموعه ای از الفبا که نشان می دهد : firstمجموعه رشته هایی که از یک متغیر بدست می آیند با چه حرفی
.شروع می شوند زیر مجموعه ای از الفبا که نشان می : followمجموعه
دهد رشته هایی که در دنباله یک متغیر می آیند با چه .حرفی شروع می شوند
![Page 22: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/22.jpg)
Narges S. Bathaeian
firstپیدا کردن مجموعه
A ε first(A) = {ε}A a first(A) = {a}A aβ first(A) = {a}A αβ first(A) = first(first(α)first(β))A α1 | α2 |…|αn first(A)= U first(A) A αi
![Page 23: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/23.jpg)
Narges S. Bathaeian
مثال
S aAS | bCA cc | dA | εC AS
first(S) S aAS = {a}first(S) S bC = {b}first(S)={a,b}first(A) A cc = {c}first(A dA) A dA = {d}first(A)={c,d,ε}first(C) = first(first(A)first(S))=
first({c,d,ε}{a,b})= first({ca,cb,da,db,a,b})= {c,d,a,b}
![Page 24: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/24.jpg)
Narges S. Bathaeian
followپیدا کردن مجموعه A is start symbol follow(A) ∃ $A αBβ follow(B) =
first(first(β)follow(Α))A1 α1Bβ1 | …A2 α2Bβ2 | …A3 α3Bβ3 | …
…. follow(B) = U follow(B) Ai αiBβi. هنگام افتادن در دور از محاسبه صرف نظر می کنیم
![Page 25: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/25.jpg)
Narges S. Bathaeian
مثال S aAS | bCA cc | dA | εC AS
S is start symbol
follow(S) S aAS = first(first(ε)follow(S))= first(follow(S))= follow(S)
follow(S) C AS = first(first(ε)follow(C))= first(follow(C))= follow(C)
follow(S) ∃ $
follow(S)={$} U follow(C)
![Page 26: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/26.jpg)
Narges S. Bathaeian
مثال S aAS | bCA cc | dA | εC AS
S is start symbol
follow(C) S bC = first(first(ε)follow(S))= first(follow(S))= follow(S)
Follow(S)= Follow(C)= {$}
![Page 27: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/27.jpg)
Narges S. Bathaeian
مثال
S aAS | bCA cc | dA | εC AS
S is start symbol
follow(A) A dA = first(first(ε)follow(A))= first(follow(A))= follow(A)
follow(A) S aAS = first(first(S)follow(S))= first({a,b}{$})= {a,b}
follow(A) C AS = first(first(S)follow(C))= first({a,b}{$})= {a,b}
follow(A)={a,b}
![Page 28: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/28.jpg)
Narges S. Bathaeian
مثال ساختن جدول 1. S ( S )2. S ε
S$)(N/T
![Page 29: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/29.jpg)
Narges S. Bathaeian
مثال ساختن جدول 1. S ( S )2. S ε
1S$)(N/T
first ( S) ) S (S) = { ‘(‘ }
![Page 30: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/30.jpg)
Narges S. Bathaeian
مثال ساختن جدول 1. S ( S )2. S ε
221S$)(N/T
first ( S ε ) = { ε }follow ( S ) ∃ $follow ( S ) S (S) =
first(first({ ‘)’})follow(S))=first({‘)’}follow(S))= {‘)’}
follow (S) = { $ , ‘)’}
![Page 31: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/31.jpg)
Narges S. Bathaeian
مثال دیگر block_stmt stmt stmt_seqstmt_seq ; block_stmt | εstmt s
![Page 32: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/32.jpg)
Narges S. Bathaeian
) ادامه (مثال دیگر block_stmt stmt stmt_seqstmt_seq ; block_stmt | εstmt s
first(block_stmt)= first(first(stmt)first(stmt_seq))= first({s}{; , ε})= first({s; , s}) = {s}
first(stmt_seq)= first(stmt_seq) stmt_seq ; block_stmt U first(stmt_seq) stmt_seq ε = {;} U {ε} = {; , ε}
first(stmt)= {s}
![Page 33: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/33.jpg)
Narges S. Bathaeian
) ادامه (مثال دیگر 1. block_stmt stmt stmt_seq2. stmt_seq ; block_stmt 3. | ε4. stmt s
4stmt
2stmt_seq
1block_stmt
$;s
![Page 34: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/34.jpg)
Narges S. Bathaeian
) ادامه (مثال دیگر block_stmt stmt stmt_seqstmt_seq ; block_stmt | εstmt s
follow(stmt_seq)= first(first(ε) follow(block_stmt)) = follow(block_stmt) = {$}
follow(block_stmt)= {$} U follow(block_stmt) stmt_seq ; block_stmt= {$} U first(first(ε) follow(stmt_seq)) = {$} U follow(stmt_seq)
![Page 35: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/35.jpg)
Narges S. Bathaeian
) ادامه (مثال دیگر 1. block_stmt stmt stmt_seq2. stmt_seq ; block_stmt 3. | ε4. stmt s
4stmt
32stmt_seq
1block_stmt
$;s
![Page 36: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/36.jpg)
Narges S. Bathaeian
نیستند؟ LL(1)چه گرامرهایی بیش از , گرامرهایی که در حداقل یکی از خانه های جدول
.یک قانون نوشته شده باشد : یا
A α1| α2 |…| αn first(αi) Λ first(αj) = {}
ε E first(A)first(A) Λ follow(A) = {}
![Page 37: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/37.jpg)
Narges S. Bathaeian
. نیست LL(1)مثال از گرامری که stmt if_stmt | otherif_stmt if ( exp ) stmt else_partelse_part else stmt
| εexp 0
| 1
![Page 38: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/38.jpg)
Narges S. Bathaeian
. نیست LL(1)مثال از گرامری که stmt if_stmt
| otherif_stmt if ( exp ) stmt else_partelse_part else stmt
| εexp 0
| 1
first(stmt)= first(if_stmt) U {other}= { if , other}
first(if_stmt)= {if}first(else_part)= {else , ε}first(exp)= {0,1}
follow(else_part)= follow(if_stmt)= follow(stmt)= first(first(else_part)follow(if_stmt)) U follow(else_part) U {$}= first({else, ε}follow(stmt) U {$}= {else , $ }
![Page 39: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/39.jpg)
Narges S. Bathaeian
) ادامه (. نیست LL(1)مثال از گرامری که stmt if_stmt
| otherif_stmt if ( exp ) stmt else_partelse_part else stmt
| εexp 0
| 1
first(stmt)= first(if_stmt) U {other}= { if , other}
first(if_stmt)= {if}first(else_part)= {else , ε}first(exp)= {0,1}follow(else_part)= {else , $ }
first(else_part) Λ follow(else_part) <> {}
![Page 40: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/40.jpg)
Narges S. Bathaeian
) ادامه (. نیست LL(1)مثال از گرامری که 1. stmt if_stmt 2. | other3. if_stmt if ( exp ) st else_part4. else_part else stmt 5. | ε6. exp 07. | 1
first(stmt)= first(if_stmt) U {other}= { if , other}
first(if_stmt)= {if}first(else_part)= {else , ε}first(exp)= {0,1}follow(else_part)= {else , $ }
76ex
54,5ep
3is
21s
$10else)(otif
![Page 41: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/41.jpg)
Narges S. Bathaeian
دو مشکل که با رفع آنها ممکن است گرامر به LL(1)تبدیل شود .
Left recursionبازگشتی از چپ Common factorفاکتور مشترک
![Page 42: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/42.jpg)
Narges S. Bathaeian
Left recursionبازگشتی از چپ
A Aa| b
first(A)= {b} U first(A)= ?
baa$
![Page 43: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/43.jpg)
Narges S. Bathaeian
حذف بازگشتی از چپ A Aa
| b
A Aα1| Aα2|…| Aαn|β1| β2|…| βm
A bA’A’ aA’
| ε
A β1A’| β2A’|…| βmA’A’ α1A’| α2A’|…|
αnA’ | ε
![Page 44: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/44.jpg)
Narges S. Bathaeian
مثال exp exp addop term
|term
exp term exp’exp’ addop term exp’
|ε
![Page 45: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/45.jpg)
Narges S. Bathaeian
nonحذف بازگشتی از چپ غیر مستقیم immediate
A Bα | …B Aβ | …
. از جایگزینی باید استفاده کرد از افتادن در دور هنگام جایگذاری جلوگیری , با اولویت بندی متغیرها
. می کنیم
![Page 46: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/46.jpg)
Narges S. Bathaeian
مثال A Ba | Aa | cB Bb | Ab | d
B > A اولویت-1
A حذف بازگشتی از چپ -2A BaA’ | cA’A’ aA’ | εB Bb | Ab | d
B در A جايگذاري -3A BaA’ | cA’A’ aA’ | εB Bb | BaA’b | cA’b | d
B حذف بازگشتي از چپ -4A BaA’ | cA’A’ aA’ | εB cA’bB’ | dB’B’ bB’ | aA’bB’ | ε
![Page 47: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/47.jpg)
Narges S. Bathaeian
Common factorفاکتور مشترک
A αβ1 | αβ2 | …
first(A αβ1) Λ first(A αβ2) <> {}
![Page 48: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/48.jpg)
Narges S. Bathaeian
حذف فاکتور مشترک A αβ1 | αβ2 | …
A αA’ | …A’ β1 | β2
![Page 49: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/49.jpg)
Narges S. Bathaeian
مثال exp exp addop term
| termterm term mulop
fact | fact
fact (exp) | naddop +| -mulop *
Left recursion : expterm
![Page 50: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/50.jpg)
Narges S. Bathaeian
مثال exp exp addop term
| termterm term mulop
fact | fact
fact (exp) | naddop +| -mulop *
exp term exp’exp’ addop term exp’
| εterm fact term’term’ mulop fact term’
| εfact (exp) | naddop +| -mulop *
![Page 51: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/51.jpg)
Narges S. Bathaeian
مثال block_stmt stmt ; block_stmt
| stmtstmt s
Common factor block_stmt
![Page 52: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/52.jpg)
Narges S. Bathaeian
مثال block_stmt stmt ; block_stmt
| stmtstmt s
block_stmt stmt block_stmt’block_stmt’ ; block_stmt
| εstmt s
![Page 53: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/53.jpg)
Narges S. Bathaeian
جدول پارس و پارس رشته (مثال کلی n+n*n (
exp term exp’exp’ addop term exp’
| εterm fact term’term’ mulop fact term’
| εfact (exp) | naddop +| -mulop *
![Page 54: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/54.jpg)
Narges S. Bathaeian
جدول پارس و پارس رشته (مثال کلی n+n*n (
first(exp)first(exp’) first(term)first(term’)first(fact)first(addop)first(mulop)
exp term exp’exp’ addop term exp’
| εterm fact term’term’ mulop fact term’
| εfact (exp) | naddop +| -mulop *
![Page 55: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/55.jpg)
Narges S. Bathaeian
جدول پارس و پارس رشته (مثال کلی n+n*n (
first(exp)first(exp’) first(term)first(term’)first(fact) = {(,n}first(addop) = {+,-}first(mulop) = {*}
exp term exp’exp’ addop term exp’
| εterm fact term’term’ mulop fact term’
| εfact (exp) | naddop +| -mulop *
![Page 56: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/56.jpg)
Narges S. Bathaeian
جدول پارس و پارس رشته (مثال کلی n+n*n (
first(exp)first(exp’) = {+,-,ε}first(term) = {(,n}first(term’) = {*, ε}first(fact) = {(,n}first(addop) = {+,-}first(mulop) = {*}
exp term exp’exp’ addop term exp’
| εterm fact term’term’ mulop fact term’
| εfact (exp) | naddop +| -mulop *
![Page 57: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/57.jpg)
Narges S. Bathaeian
جدول پارس و پارس رشته (مثال کلی n+n*n (
first(exp) = {(,n}first(exp’) = {+,-,ε}first(term) = {(,n}first(term’) = {*, ε}first(fact) = {(,n}first(addop) = {+,-}first(mulop) = {*}
exp term exp’exp’ addop term exp’
| εterm fact term’term’ mulop fact term’
| εfact (exp) | naddop +| -mulop *
![Page 58: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/58.jpg)
Narges S. Bathaeian
جدول پارس و پارس رشته (مثال کلی n+n*n (
follow(exp’) follow(term’)
exp term exp’exp’ addop term exp’
| εterm fact term’term’ mulop fact term’
| εfact (exp) | naddop +| -mulop *
![Page 59: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/59.jpg)
Narges S. Bathaeian
جدول پارس و پارس رشته (مثال کلی n+n*n (
follow(exp’) follow(term’) follow(exp) = {$,)}
exp term exp’exp’ addop term exp’
| εterm fact term’term’ mulop fact term’
| εfact (exp) | naddop +| -mulop *
![Page 60: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/60.jpg)
Narges S. Bathaeian
جدول پارس و پارس رشته (مثال کلی n+n*n (
follow(exp’) = {$, )}follow(term’) follow(exp) = {$,)}
exp term exp’exp’ addop term exp’
| εterm fact term’term’ mulop fact term’
| εfact (exp) | naddop +| -mulop *
![Page 61: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/61.jpg)
Narges S. Bathaeian
جدول پارس و پارس رشته (مثال کلی n+n*n (
follow(exp’) = {$, )}follow(term’) follow(exp) = {$,)} follow(term) = first({+,-
,ε}{$,)})= {+,-,$,)}
exp term exp’exp’ addop term exp’
| εterm fact term’term’ mulop fact term’
| εfact (exp) | naddop +| -mulop *
![Page 62: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/62.jpg)
Narges S. Bathaeian
جدول پارس و پارس رشته (مثال کلی n+n*n (
follow(exp’) = {$, )}follow(term’) = {+,-,$,)}follow(exp) = {$,)} follow(term) = first({+,-
,ε}{$,)})= {+,-,$,)}
exp term exp’exp’ addop term exp’
| εterm fact term’term’ mulop fact term’
| εfact (exp) | naddop +| -mulop *
![Page 63: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/63.jpg)
Narges S. Bathaeian
جدول پارس و پارس رشته (مثال کلی n+n*n (
1. exp term exp’2. exp’ addop term exp’3. | ε4. term fact term’5. term’ mulop fact term’6. | ε7. fact (exp) 8. | n9. addop +10. | -11. mulop *
11mul109add
78fact65666term’
44term3223exp’
11exp$*-+)(n
![Page 64: ﺮﻠﯾﺎﭙﻣﺎﮐ ﯽﺣاﺮﻃ - basu.ac.ir · ؟ﺪﻨﺘﺴﯿﻧ ll(1) ﯽﯾﺎﻫﺮﻣاﺮﮔ ﻪﭼ زا ﺶﯿﺑ ,لوﺪﺟ یﺎﻫ ﻪﻧﺎﺧ زا ﯽﮑﯾ](https://reader030.vdocuments.mx/reader030/viewer/2022041217/5e05be553c99ce25c97aafa9/html5/thumbnails/64.jpg)
Narges S. Bathaeian
جدول پارس و پارس رشته (مثال کلی n+n*n (
11mul
109add
78fact
65666term’
44term
3223exp’
11exp
$*-+)(n
n+n*n$exp’ term’ factn+n*n$exp’ termn+n*n$expInput Stack