SlideShare a Scribd company logo
1 of 27
BOTTOM-UP PARSER
A compiler is a computer program (or set of
programs) that transforms source code
written in a programming
language(the source language) into another
computer language. The most common
reason for wanting to transform source code
is to create an executable program.
Source Program


                    Lexical Analysis




                    Syntax Analysis



                   Intermediate code
Trade Management                       Error Handing
                       generation



                   Code Optimization




                   Code generation


                    Target Program
Lexical Analysis Phase:
–  The Lexical Analyzer reads the characters in the source program and
groups them into a stream of tokens in which each token represents a logically
cohesive sequence of characters, such as, An identifier, A keyword, A
punctuation character.

Syntax Analysis Phase:
–  The Syntax Analyzer groups tokens together into syntactic structure.
Consider, for Ex: the three tokens representing A+B might be grouped into a
syntactic called an expression.

Intermediate Code Generator:
–  The Intermediate Code Generator uses the structure produce by the syntax
analyzer to create a stream of simple instructions. The primary difference
between the intermediate code and assembly code is that the intermediate
code need not specify the register to be used for each operation.
Code Optimization:
–   Code Optimization in an optional phase designed to improve the
intermediate code so that the ultimate program runs faster. Its output is
another intermediate code program that does the same job as the original
intermediate code.

Code Generation:
–    The final phase of the compiler is the generation of target code, consisting
normally of relocatable machine code or assembly code. Memory locations are
selected for each of the variables used by the program. Then, the each
intermediate instruction is translated into a sequence of machine instructions
that perform the same task.
–   A Parser for grammar G is a program that takes as input a string w and
produce as output either a parse tree for w, if w is a sentence of G, or an error
message indicating that w is not a sentence of G.
There are Two basic types of Parsers:
a) Bottom-up
b) Top-down


–    As name indicates Bottom-Up Parsers build parse trees from the Bottom
(leaves) to the Top (root), while top-down parsers starts with the root and work
down to the leaves. In both the cases the input to the parser is being scanned
from left to right, considering ONE symbol at a time.

      A Bottom-Up Parsers try to find the right-most derivation of the given input
in Reverse order.
 S  ...   (the right-most derivation of )
  (the bottom-up parser finds the right-most derivation in the reverse order)
Also Know as
                                             “Shift-reduce”
                                                 parsing




Bottom-Up Parsing
   The bottom-up parsing method is also know as Shift-reduce parsing

    because its consist of two main actions. i.e 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 will replaced by the
non-terminal at the left side of that production.
There are also two more actions: accept and error.
Shift-Reduce Parsing

There are four possible action of a shift-parse action are as follows:-
     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.
A shift-reduce parser tries to reduce the given input string
   into the starting symbol.

        A string reduced to () the starting symbol

          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.
          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
HANDLE
• Informally, a handle of a string is a substring that matches the right
  side of a production rule.
   – But not every substring matches the right side of a production
     rule is handle

• 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  
• If the grammar is unambiguous, then every right-sentential form of
  the grammar has exactly one handle.
• We will see that  is a string of terminals.
HANDLE PRUNING:

A right-most derivation in reverse can be obtained by handle-
pruning.

       S=0  1  2  ...  n-1  n= 
                                                   input string

Start from n, find a handle Ann in n,
and replace n in by An to get n-1.
Then find a handle An-1n-1 in n-1,
and replace n-1 in by An-1 to get n-2.
Repeat this, until we reach S.
Bottom –Up Parser:

 Consider for Example :-
     Grammar

                   S  aABe
                   A  Abc | b
                   B d


   parse


           The input string
             : abbcde.
Bottom-Up Parser Example

                           Shift a

                 INPUT:     a    b   b   c   d   e   $   OUTPUT:


  Production
  S  aABe
                                 Bottom-Up Parsing
   A  Abc
                                      Program
    A b
    Bd
Bottom-Up Parser Example
                           Shift b
                           Reduce from b to A
                 INPUT:    a   b   b   c   d    e   $   OUTPUT:


  Production
  S  aABe
                                Bottom-Up Parsing
   A  Abc                                               A
                                     Program
    A b
    Bd                                                  b
Bottom-Up Parser Example

                           Shift A

                 INPUT:    a    A    b   c   d   e   $   OUTPUT:


  Production
  S  aABe
                                Bottom-Up Parsing
   A  Abc                                                A
                                     Program
    A b
    Bd                                                   b
Bottom-Up Parser Example

                           Shift b

                 INPUT:    a    A    b   c   d   e   $   OUTPUT:


  Production
  S  aABe
                                 Bottom-Up Parsing
   A  Abc                                                A
                                      Program
    A b
    Bd                                                   b
Shift c
                       Reduce from Abc to A
             INPUT:   a   A   b   c   d       e   $   OUTPUT:


Production
                                                           A
S  aABe
                           Bottom-Up Parsing
 A  Abc                                               A   b    c
                                Program
  A b
  Bd                                                  b
Bottom-Up Parser Example

                           Shift A

                 INPUT:    a    A    d   e   $      OUTPUT:


  Production
                                                         A
  S  aABe
                                Bottom-Up Parsing
   A  Abc                                           A   b    c
                                     Program
    A b
    Bd                                              b
Bottom-Up Parser Example
                           Shift d
                           Reduce from d to B
                 INPUT:    a   A   d   e    $       OUTPUT:


  Production
                                                         A      B
  S  aABe
                                Bottom-Up Parsing
   A  Abc                                           A   b    c d
                                     Program
    A b
    Bd                                              b
Bottom-Up Parser Example

                           Shift B

                 INPUT:    a    A    B   e   $       OUTPUT:


  Production
                                                          A      B
  S  aABe
                                 Bottom-Up Parsing
   A  Abc                                            A   b    c d
                                      Program
    A b
    Bd                                               b
Bottom-Up Parser Example
                           Shift e
                           Reduce from aABe to S
                 INPUT:    a   A   B   e   $        OUTPUT:
                                                              S
  Production                                                          e
                                                    a    A        B
  S  aABe
                                Bottom-Up Parsing
   A  Abc                                           A   b    c d
                                     Program
    A b
    Bd                                              b
Bottom-Up Parser Example
                           Shift S
                           Hit the target $
                 INPUT:    S    $                   OUTPUT:
                                                              S
  Production                                                          e
                                                    a    A        B
  S  aABe
                                Bottom-Up Parsing
   A  Abc                                           A   b    c d
                                     Program
    A b
    Bd                                              b
Complier designer

More Related Content

Viewers also liked

Viewers also liked (8)

LR Parsing
LR ParsingLR Parsing
LR Parsing
 
Lexing and parsing
Lexing and parsingLexing and parsing
Lexing and parsing
 
Source-to-Source Compiler
Source-to-Source CompilerSource-to-Source Compiler
Source-to-Source Compiler
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Module 11
Module 11Module 11
Module 11
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loaders
 
Lexical Approach
Lexical ApproachLexical Approach
Lexical Approach
 

Similar to Complier designer

Similar to Complier designer (10)

BOTTOM UP PARSING GROUP 3.pptx
BOTTOM UP PARSING GROUP 3.pptxBOTTOM UP PARSING GROUP 3.pptx
BOTTOM UP PARSING GROUP 3.pptx
 
Lecture 07 08 syntax analysis-4
Lecture 07 08 syntax analysis-4Lecture 07 08 syntax analysis-4
Lecture 07 08 syntax analysis-4
 
Bottom up parsing.pptx
Bottom up parsing.pptxBottom up parsing.pptx
Bottom up parsing.pptx
 
Topdown parsing
Topdown parsingTopdown parsing
Topdown parsing
 
Topdown parsing
Topdown parsingTopdown parsing
Topdown parsing
 
parsing in compiler design presentation .pptx
parsing in compiler design presentation .pptxparsing in compiler design presentation .pptx
parsing in compiler design presentation .pptx
 
Syntactic analysis in NLP
Syntactic analysis in NLPSyntactic analysis in NLP
Syntactic analysis in NLP
 
Adc.pptx ashvani 151503
Adc.pptx ashvani 151503Adc.pptx ashvani 151503
Adc.pptx ashvani 151503
 
Capacitor
CapacitorCapacitor
Capacitor
 
Capacitor
CapacitorCapacitor
Capacitor
 

More from Jagjit Wilku

More from Jagjit Wilku (7)

Health insurance
Health insuranceHealth insurance
Health insurance
 
Auto insurance
Auto insuranceAuto insurance
Auto insurance
 
Mobile communication
Mobile communicationMobile communication
Mobile communication
 
Regular expression (compiler)
Regular expression (compiler)Regular expression (compiler)
Regular expression (compiler)
 
Neural networks
Neural networksNeural networks
Neural networks
 
Decision trees
Decision treesDecision trees
Decision trees
 
Mc wireless lan
Mc wireless lanMc wireless lan
Mc wireless lan
 

Recently uploaded

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 

Recently uploaded (20)

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 

Complier designer

  • 2.
  • 3. A compiler is a computer program (or set of programs) that transforms source code written in a programming language(the source language) into another computer language. The most common reason for wanting to transform source code is to create an executable program.
  • 4.
  • 5.
  • 6. Source Program Lexical Analysis Syntax Analysis Intermediate code Trade Management Error Handing generation Code Optimization Code generation Target Program
  • 7. Lexical Analysis Phase: – The Lexical Analyzer reads the characters in the source program and groups them into a stream of tokens in which each token represents a logically cohesive sequence of characters, such as, An identifier, A keyword, A punctuation character. Syntax Analysis Phase: – The Syntax Analyzer groups tokens together into syntactic structure. Consider, for Ex: the three tokens representing A+B might be grouped into a syntactic called an expression. Intermediate Code Generator: – The Intermediate Code Generator uses the structure produce by the syntax analyzer to create a stream of simple instructions. The primary difference between the intermediate code and assembly code is that the intermediate code need not specify the register to be used for each operation.
  • 8. Code Optimization: – Code Optimization in an optional phase designed to improve the intermediate code so that the ultimate program runs faster. Its output is another intermediate code program that does the same job as the original intermediate code. Code Generation: – The final phase of the compiler is the generation of target code, consisting normally of relocatable machine code or assembly code. Memory locations are selected for each of the variables used by the program. Then, the each intermediate instruction is translated into a sequence of machine instructions that perform the same task.
  • 9. A Parser for grammar G is a program that takes as input a string w and produce as output either a parse tree for w, if w is a sentence of G, or an error message indicating that w is not a sentence of G.
  • 10. There are Two basic types of Parsers: a) Bottom-up b) Top-down – As name indicates Bottom-Up Parsers build parse trees from the Bottom (leaves) to the Top (root), while top-down parsers starts with the root and work down to the leaves. In both the cases the input to the parser is being scanned from left to right, considering ONE symbol at a time. A Bottom-Up Parsers try to find the right-most derivation of the given input in Reverse order. S  ...   (the right-most derivation of )  (the bottom-up parser finds the right-most derivation in the reverse order)
  • 11. Also Know as “Shift-reduce” parsing Bottom-Up Parsing The bottom-up parsing method is also know as Shift-reduce parsing because its consist of two main actions. i.e 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 will replaced by the non-terminal at the left side of that production. There are also two more actions: accept and error.
  • 12. Shift-Reduce Parsing There are four possible action of a shift-parse action are as follows:- 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.
  • 13. A shift-reduce parser tries to reduce the given input string into the starting symbol. A string reduced to () the starting symbol 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. 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
  • 14. HANDLE • Informally, a handle of a string is a substring that matches the right side of a production rule. – But not every substring matches the right side of a production rule is handle • 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   • If the grammar is unambiguous, then every right-sentential form of the grammar has exactly one handle. • We will see that  is a string of terminals.
  • 15. HANDLE PRUNING: A right-most derivation in reverse can be obtained by handle- pruning. S=0  1  2  ...  n-1  n=  input string Start from n, find a handle Ann in n, and replace n in by An to get n-1. Then find a handle An-1n-1 in n-1, and replace n-1 in by An-1 to get n-2. Repeat this, until we reach S.
  • 16. Bottom –Up Parser: Consider for Example :- Grammar S  aABe A  Abc | b B d parse The input string : abbcde.
  • 17. Bottom-Up Parser Example Shift a INPUT: a b b c d e $ OUTPUT: Production S  aABe Bottom-Up Parsing A  Abc Program A b Bd
  • 18. Bottom-Up Parser Example Shift b Reduce from b to A INPUT: a b b c d e $ OUTPUT: Production S  aABe Bottom-Up Parsing A  Abc A Program A b Bd b
  • 19. Bottom-Up Parser Example Shift A INPUT: a A b c d e $ OUTPUT: Production S  aABe Bottom-Up Parsing A  Abc A Program A b Bd b
  • 20. Bottom-Up Parser Example Shift b INPUT: a A b c d e $ OUTPUT: Production S  aABe Bottom-Up Parsing A  Abc A Program A b Bd b
  • 21. Shift c Reduce from Abc to A INPUT: a A b c d e $ OUTPUT: Production A S  aABe Bottom-Up Parsing A  Abc A b c Program A b Bd b
  • 22. Bottom-Up Parser Example Shift A INPUT: a A d e $ OUTPUT: Production A S  aABe Bottom-Up Parsing A  Abc A b c Program A b Bd b
  • 23. Bottom-Up Parser Example Shift d Reduce from d to B INPUT: a A d e $ OUTPUT: Production A B S  aABe Bottom-Up Parsing A  Abc A b c d Program A b Bd b
  • 24. Bottom-Up Parser Example Shift B INPUT: a A B e $ OUTPUT: Production A B S  aABe Bottom-Up Parsing A  Abc A b c d Program A b Bd b
  • 25. Bottom-Up Parser Example Shift e Reduce from aABe to S INPUT: a A B e $ OUTPUT: S Production e a A B S  aABe Bottom-Up Parsing A  Abc A b c d Program A b Bd b
  • 26. Bottom-Up Parser Example Shift S Hit the target $ INPUT: S $ OUTPUT: S Production e a A B S  aABe Bottom-Up Parsing A  Abc A b c d Program A b Bd b