SlideShare a Scribd company logo
1 of 12
BOTTOM-UP PARSING
Bottom-Up Parsing
o Bottom-Up Parser : Constructs a parse tree for an input string
beginning at the leaves(the bottom) and working up towards the
root(the top)
o We can think of this process as one of “reducing” a string w to the start
symbol of a grammar
o Bottom-up parsing is also known as shift-reduce parsing because its
two main actions are shift and reduce.
 At each shift action, the current symbol in the input string is pushed to
a stack.
At each reduction step, the symbols at the top of the stack (this symbol
sequence is the right side of a production) will replaced by the non-
terminal at the left side of that production.
Shift-Reduce Parsing
o A shift-reduce parser tries to reduce the given input string into the
starting symbol.
a string  the starting symbol
reduced to
o At each reduction step, a substring of the input matching to the right
side of a production rule is replaced by the non-terminal at the left side
of that production rule.
o If the substring is chosen correctly, the right most derivation of that
string is created in the reverse order.
Rightmost Derivation: S  
Shift-Reduce Parser finds:   ...  S
rm
rm
rm
*
Shift–Reduce Parsing-Example
o Consider the grammar Input string : abbcde
S aABe aAbcde
A Abc | b aAde  reduction
B d aABe
S
We can scan abbcde looking for a substring that matches the right side of some
production.The substrings b and d qualify.Let us choose left most b and replace it by
A,the left side of the production Ab;we thus obtain the string aAbcde.Now the
substrings Abc,b and d match the right side of some production.Although b is the
leftmost substring that matches the right side of the some production,we choose to
replace the substring Abc by A,the left side of the production AAbc.We obtain
aAde.Then replacing d by B,and then replacing the entire string by S.Thus,by a
sequence of four reductions we are able to reduce abbcde to S
Shift–Reduce Parsing-Example
o These reductions infact trace out the following right-most derivation in
reverse
S  aABe  aAde  aAbcde  abbcde
o How do we know which substring to be replaced at each reduction step?
rm rm rm rm
Right Sentential Forms
Handle
rm rm
*
o Informally, a “handle” of a string is a substring that matches the right side
of the production,and whose reduction to nonterminal on the left side of the
production represents one step along the reverse of a rightmost derivation
▫ But not every substring matches the right side of a production rule is handle.
o Formally , a “handle” of a right sentential form γ ( ) is a production
rule A   and a position of  where the string  may be found and replaced
by A to produce the previous right-sentential form in a rightmost
derivation of .
S  A  
then Aβ in the position following α is a handle of αβω
o The string  to the right of the handle contains only terminal symbols.
Example
o Consider the example discussed in the beginning,abbcde is a right
sentential form whose handle is Ab at position 2.Likewise,aAbcde is a
right sentential form whose handle is AAbc at position 2.
o Sometimes we say “the substring β is a handle of αβω” if the
position of β and the production Aβ we have in mind are clear.
Handle Pruning
o A rightmost derivation in reverse can be obtained by “handle pruning”.That
is,we start with a string of terminals w that we wish to parse.If ω is a
sentence of grammar at hand,then ω = γ,where γn is the nth right-sentential
form of some as yet unknown rightmost derivation
S = 0  1  2  ...  n-1  n= 
Input string
rm rm rm rm rm
Handle Pruning
S = 0  1  2  ...  n-1  n= 
o Start from n, find a handle Ann in n,
and replace n in by An to get n-1.
o Then find a handle An-1n-1 in n-1,
and replace n-1 in by An-1 to get n-2.
o Repeat this, until we reach S.
rm rm rm rm
rm
A Shift-Reduce Parser
E  E+T | T Right-Most Derivation of id+id*id
T  T*F | F E  E+T  E+T*F  E+T*id  E+F*id
F  (E) | id  E+id*id  T+id*id  F+id*id  id+id*id
Right-Most Sentential form HANDLE Reducing Production
id+id*id
F+id*id
T+id*id
E+id*id
E+F*id
E+T*id
E+T*F
E+T
E
id
F
T
id
F
Id
T*F
E+T
Fid
TF
ET
Fid
TF
Fid
TT*F
EE+T
A Stack Implementation of a Shift-Reduce Parser
o There are four possible actions of a shift-parser action:
1.Shift : The next input symbol is shifted onto the top of the stack.
2.Reduce: Replace the handle on the top of the stack by the non-terminal.
3.Accept: Successful completion of parsing.
4.Error: Parser discovers a syntax error, and calls an error recovery routine.
o Initial stack just contains only the end-marker $.
o The end of the input string is marked by the end-marker $.
A Stack Implementation of A Shift-Reduce Parser
Stack Input Action
$
$id
$F
$T
$E
$E+
$E+id
$E+F
$E+T
$E+T*
$E+T*id
$E+T*F
$E+T
$E
id+id*id$shift
+id*id$
+id*id$
+id*id$
+id*id$
Id*id$
*id$
*id$
*id$
id$
$
$
$
$
Reduce by Fid
Reduce by TF
Reduce by ET
Shift
Shift
Reduce by Fid
Reduce by TF
Shift
Shift
Reduce by Fid
Reduce by TT*F
Reduce by E E+T
Accept
Parse Tree
E 8
E 3 T 7
+
T 5 F 6
*
F 4
F 1
T 2
id id
id

More Related Content

Similar to parsing in compiler design presentation .pptx

Similar to parsing in compiler design presentation .pptx (20)

Reduction & Handle Pruning
Reduction & Handle PruningReduction & Handle Pruning
Reduction & Handle Pruning
 
Compiler Design Material 2
Compiler Design Material 2Compiler Design Material 2
Compiler Design Material 2
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
Pcd(Mca)
Pcd(Mca)Pcd(Mca)
Pcd(Mca)
 
PCD ?s(MCA)
PCD ?s(MCA)PCD ?s(MCA)
PCD ?s(MCA)
 
Principles of Compiler Design
Principles of Compiler DesignPrinciples of Compiler Design
Principles of Compiler Design
 
Pcd(Mca)
Pcd(Mca)Pcd(Mca)
Pcd(Mca)
 
Assignment7
Assignment7Assignment7
Assignment7
 
Ch06
Ch06Ch06
Ch06
 
Lecture9 syntax analysis_5
Lecture9 syntax analysis_5Lecture9 syntax analysis_5
Lecture9 syntax analysis_5
 
Cd2 [autosaved]
Cd2 [autosaved]Cd2 [autosaved]
Cd2 [autosaved]
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
 
cfl2.pdf
cfl2.pdfcfl2.pdf
cfl2.pdf
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsing
 
Parsing
ParsingParsing
Parsing
 
lec02-Syntax Analysis and LL(1).pdf
lec02-Syntax Analysis and LL(1).pdflec02-Syntax Analysis and LL(1).pdf
lec02-Syntax Analysis and LL(1).pdf
 
Control chap7
Control chap7Control chap7
Control chap7
 
Turing machine-TOC
Turing machine-TOCTuring machine-TOC
Turing machine-TOC
 
Mathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpMathematical Statistics Assignment Help
Mathematical Statistics Assignment Help
 
PARSING.ppt
PARSING.pptPARSING.ppt
PARSING.ppt
 

Recently uploaded

RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Servicejennyeacort
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Sapana Sha
 
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...shivangimorya083
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 
Spark3's new memory model/management
Spark3's new memory model/managementSpark3's new memory model/management
Spark3's new memory model/managementakshesh doshi
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 

Recently uploaded (20)

RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
 
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
Spark3's new memory model/management
Spark3's new memory model/managementSpark3's new memory model/management
Spark3's new memory model/management
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 

parsing in compiler design presentation .pptx

  • 2. Bottom-Up Parsing o Bottom-Up Parser : Constructs a parse tree for an input string beginning at the leaves(the bottom) and working up towards the root(the top) o We can think of this process as one of “reducing” a string w to the start symbol of a grammar o Bottom-up parsing is also known as shift-reduce parsing because its two main actions are shift and reduce.  At each shift action, the current symbol in the input string is pushed to a stack. At each reduction step, the symbols at the top of the stack (this symbol sequence is the right side of a production) will replaced by the non- terminal at the left side of that production.
  • 3. Shift-Reduce Parsing o A shift-reduce parser tries to reduce the given input string into the starting symbol. a string  the starting symbol reduced to o At each reduction step, a substring of the input matching to the right side of a production rule is replaced by the non-terminal at the left side of that production rule. o If the substring is chosen correctly, the right most derivation of that string is created in the reverse order. Rightmost Derivation: S   Shift-Reduce Parser finds:   ...  S rm rm rm *
  • 4. Shift–Reduce Parsing-Example o Consider the grammar Input string : abbcde S aABe aAbcde A Abc | b aAde  reduction B d aABe S We can scan abbcde looking for a substring that matches the right side of some production.The substrings b and d qualify.Let us choose left most b and replace it by A,the left side of the production Ab;we thus obtain the string aAbcde.Now the substrings Abc,b and d match the right side of some production.Although b is the leftmost substring that matches the right side of the some production,we choose to replace the substring Abc by A,the left side of the production AAbc.We obtain aAde.Then replacing d by B,and then replacing the entire string by S.Thus,by a sequence of four reductions we are able to reduce abbcde to S
  • 5. Shift–Reduce Parsing-Example o These reductions infact trace out the following right-most derivation in reverse S  aABe  aAde  aAbcde  abbcde o How do we know which substring to be replaced at each reduction step? rm rm rm rm Right Sentential Forms
  • 6. Handle rm rm * o Informally, a “handle” of a string is a substring that matches the right side of the production,and whose reduction to nonterminal on the left side of the production represents one step along the reverse of a rightmost derivation ▫ But not every substring matches the right side of a production rule is handle. o Formally , a “handle” of a right sentential form γ ( ) is a production rule A   and a position of  where the string  may be found and replaced by A to produce the previous right-sentential form in a rightmost derivation of . S  A   then Aβ in the position following α is a handle of αβω o The string  to the right of the handle contains only terminal symbols.
  • 7. Example o Consider the example discussed in the beginning,abbcde is a right sentential form whose handle is Ab at position 2.Likewise,aAbcde is a right sentential form whose handle is AAbc at position 2. o Sometimes we say “the substring β is a handle of αβω” if the position of β and the production Aβ we have in mind are clear.
  • 8. Handle Pruning o A rightmost derivation in reverse can be obtained by “handle pruning”.That is,we start with a string of terminals w that we wish to parse.If ω is a sentence of grammar at hand,then ω = γ,where γn is the nth right-sentential form of some as yet unknown rightmost derivation S = 0  1  2  ...  n-1  n=  Input string rm rm rm rm rm
  • 9. Handle Pruning S = 0  1  2  ...  n-1  n=  o Start from n, find a handle Ann in n, and replace n in by An to get n-1. o Then find a handle An-1n-1 in n-1, and replace n-1 in by An-1 to get n-2. o Repeat this, until we reach S. rm rm rm rm rm
  • 10. A Shift-Reduce Parser E  E+T | T Right-Most Derivation of id+id*id T  T*F | F E  E+T  E+T*F  E+T*id  E+F*id F  (E) | id  E+id*id  T+id*id  F+id*id  id+id*id Right-Most Sentential form HANDLE Reducing Production id+id*id F+id*id T+id*id E+id*id E+F*id E+T*id E+T*F E+T E id F T id F Id T*F E+T Fid TF ET Fid TF Fid TT*F EE+T
  • 11. A Stack Implementation of a Shift-Reduce Parser o There are four possible actions of a shift-parser action: 1.Shift : The next input symbol is shifted onto the top of the stack. 2.Reduce: Replace the handle on the top of the stack by the non-terminal. 3.Accept: Successful completion of parsing. 4.Error: Parser discovers a syntax error, and calls an error recovery routine. o Initial stack just contains only the end-marker $. o The end of the input string is marked by the end-marker $.
  • 12. A Stack Implementation of A Shift-Reduce Parser Stack Input Action $ $id $F $T $E $E+ $E+id $E+F $E+T $E+T* $E+T*id $E+T*F $E+T $E id+id*id$shift +id*id$ +id*id$ +id*id$ +id*id$ Id*id$ *id$ *id$ *id$ id$ $ $ $ $ Reduce by Fid Reduce by TF Reduce by ET Shift Shift Reduce by Fid Reduce by TF Shift Shift Reduce by Fid Reduce by TT*F Reduce by E E+T Accept Parse Tree E 8 E 3 T 7 + T 5 F 6 * F 4 F 1 T 2 id id id