SlideShare a Scribd company logo
SLR PARSER
Steps:
1. create augment grammar
2. generate kernel items
3. find closure
4. compute goto()
5. construct parsing table
6. parse the string
Let us consider grammar:
S->a
S->(L)
L->S
L->L,S
• Step :1 Create augment grammar
S is start symbol in the given grammar
Augment grammar is S’-> S
• Step :2 Generate kernel items
Introduce dot in RHS of the production``
S’-> .S
• Step :3 Find closure
(Rule: A -> α.Xβ i.e if there is nonterminal next to dot then Include X production))
S’-> .S
S-> . a
S->.(L)
I0
Step :4 compute goto()
S’-> S .
I1
Goto (I0,a) S-> a .
I2
Goto (I0,( )
S’-> .S
S-> . a
S->.(L) I0
S-> (.L)
L->.S
L>.L,S
S->.a
S->.(L)
I3
Goto (I3,L )
S-> (L .)
L->L . ,S
I4
Goto (I3,S ) L->S . I5
Goto (I3,a ) S->a . I2
Goto (I3, ( )
S-> (. L )
L->.S
L>.L,S
S->.a
S->.(L)
I3
Goto (I0,S)
Goto (I4, ) ) S-> (L) . I6
Goto (I4, , ) L->L , . S
S-> . a
S->.(L)
I7
Goto (I7,S ) L->L , S . I8
Goto (I7,a ) S-> a . I2
Goto (I7,( )
S-> (.L)
L->.S
L>.L,S
S->.a
S->.(L)
I3
label Production Ending
iteration
R0 S’-> S . I1
R1 S->a . I2
R2 S->(L) . I6
R3 L->S . I5
R4 L->L,S . I8
Step :5 construct parsing table
Label the rows of table with no. of iterations
Divide the Column into two parts
• Action part: terminal symbols
• Goto part: Nonterminal symbols
Terminals Non terminals
a ( ) , $ S L
0
1
2
3
4
5
6
7
8
Step :5 construct parsing table from step 4:
Label the rows of table with no. of iterations
Divide the Column into two parts
• Action part: terminal symbols
• Goto part: Nonterminal symbols
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1
2
3 S2 S3 5 4
4 S6 S7
5
6
7 S2 S3 8
8
Goto (I0, S) 1 Goto (I3, ( ) 3
Goto (I0, a) 2 Goto (I4, ) ) 6
Goto (I0, ( ) 3
Goto (I4, ,)
7
Goto (I3, L) 4 Goto (I7, S) 8
Goto (I3, S) 5 Goto (I7, a) 2
Goto (I3, a) 2 Goto (I7, ( ) 3
Step :5 construct parsing table
Label the rows of table with no. of iterations
Divide the Column into two parts
• Action part: terminal symbols
• Goto part: Nonterminal symbols
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
label Production
Ending
iteration
Follow(LHS)
R0 S’-> S . I1 Follow(S’)={ $ }
R1 S-> a . I2
Follow(S)={ $ ) , }
R2 S-> ( L ) . I6
Follow(S)={ $ ) , }
R3 L-> S . I5
Follow(L)={ ) , }
R4 L-> L , S . I8
Follow(L)={ ) , }
Step :5 construct parsing table
Label the rows of table with no. of iterations
Divide the Column into two parts
• Action part: terminal symbols
• Goto part: Nonterminal symbols
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
label Production
Ending
iteration
Follow(LHS)
R0 S’-> S . I1 Follow(S’)={ $ }
R1 S-> a . I2
Follow(S)={ $ ) , }
R2 S-> ( L ) . I6
Follow(S)={ $ ) , }
R3 L-> S . I5
Follow(L)={ ) , }
R4 L-> L , S . I8
Follow(L)={ ) , }
Goto (I0, S) 1 Goto (I3, ( ) 3
Goto (I0, a) 2 Goto (I4, ) ) 6
Goto (I0, ( ) 3
Goto (I4, ,)
7
Goto (I3, L) 4 Goto (I7, S) 8
Goto (I3, S) 5 Goto (I7, a) 2
Goto (I3, a) 2 Goto (I7, ( ) 3
Step :6 String parsing
Let string w=(a,a) derived from the given grammar
S – Shift action
* shift input symbol to the stack
* shift number to the stack
R – Reduce action
* pop 2 times of RHS symbols
* shift LHS to the stack
* find the number in the parsing table for
the last two elements in the stack
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
Stack Input Action
$0 (a,a)$ S3
label Production
R0 S’-> S .
R1 S-> a .
R2 S-> ( L ) .
R3 L-> S .
R4 L-> L , S .
Step :6 String parsing
Let string w=(a,a) derived from the given grammar
S – Shift action
* shift input symbol to the stack
* shift number to the stack
R – Reduce action
* pop 2 times of RHS symbols
* shift LHS to the stack
* find the number in the parsing table for
the last two elements in the stack
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
Stack Input Action
$0 (a,a)$ S3
$0(3 a,a)$ S2
label Production
R0 S’-> S .
R1 S-> a .
R2 S-> ( L ) .
R3 L-> S .
R4 L-> L , S .
Step :6 String parsing
Let string w=(a,a) derived from the given grammar
S – Shift action
* shift input symbol to the stack
* shift number to the stack
R – Reduce action
* pop 2 times of RHS symbols
* shift LHS to the stack
* find the number in the parsing table for
the last two elements in the stack
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
Stack Input Action
$0 (a,a)$ S3
$0(3 a,a)$ S2
$0(3a2 ,a)$ R1
label Production
R0 S’-> S .
R1 S-> a .
R2 S-> ( L ) .
R3 L-> S .
R4 L-> L , S .
Step :6 String parsing
Let string w=(a,a) derived from the given grammar
S – Shift action
* shift input symbol to the stack
* shift number to the stack
R – Reduce action
* pop 2 times of RHS symbols
* shift LHS to the stack
* find the number in the parsing table for
the last two elements in the stack
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
Stack Input Action
$0 (a,a)$ S3
$0(3 a,a)$ S2
$0(3a2 ,a)$ R1
$0(3S5 ,a)$ R3
label Production
R0 S’-> S .
R1 S-> a .
R2 S-> ( L ) .
R3 L-> S .
R4 L-> L , S .
Step :6 String parsing
Let string w=(a,a) derived from the given grammar
S – Shift action
* shift input symbol to the stack
* shift number to the stack
R – Reduce action
* pop 2 times of RHS symbols
* shift LHS to the stack
* find the number in the parsing table for
the last two elements in the stack
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
Stack Input Action
$0 (a,a)$ S3
$0(3 a,a)$ S2
$0(3a2 ,a)$ R1
$0(3S5 ,a)$ R3
$0(3L4 ,a)$ S7
label Production
R0 S’-> S .
R1 S-> a .
R2 S-> ( L ) .
R3 L-> S .
R4 L-> L , S .
Step :6 String parsing
Let string w=(a,a) derived from the given grammar
S – Shift action
* shift input symbol to the stack
* shift number to the stack
R – Reduce action
* pop 2 times of RHS symbols
* shift LHS to the stack
* find the number in the parsing table for
the last two elements in the stack
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
Stack Input Action
$0 (a,a)$ S3
$0(3 a,a)$ S2
$0(3a2 ,a)$ R1
$0(3S5 ,a)$ R3
$0(3L4 ,a)$ S7
label Production
R0 S’-> S .
R1 S-> a .
R2 S-> ( L ) .
R3 L-> S .
R4 L-> L , S .
Step :6 String parsing
Let string w=(a,a) derived from the given grammar
S – Shift action
* shift input symbol to the stack
* shift number to the stack
R – Reduce action
* pop 2 times of RHS symbols
* shift LHS to the stack
* find the number in the parsing table for
the last two elements in the stack
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
Stack Input Action
$0 (a,a)$ S3
$0(3 a,a)$ S2
$0(3a2 ,a)$ R1
$0(3S5 ,a)$ R3
$0(3L4 ,a)$ S7
$0(3L4 , 7 a)$ S2
label Production
R0 S’-> S .
R1 S-> a .
R2 S-> ( L ) .
R3 L-> S .
R4 L-> L , S .
Step :6 String parsing
Let string w=(a,a) derived from the given grammar
S – Shift action
* shift input symbol to the stack
* shift number to the stack
R – Reduce action
* pop 2 times of RHS symbols
* shift LHS to the stack
* find the number in the parsing table for
the last two elements in the stack
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
Stack Input Action
$0 (a,a)$ S3
$0(3 a,a)$ S2
$0(3a2 ,a)$ R1
$0(3S5 ,a)$ R3
$0(3L4 ,a)$ S7
$0(3L4 , 7 a)$ S2
$0(3L4 , 7a2 )$ R1
label Production
R0 S’-> S .
R1 S-> a .
R2 S-> ( L ) .
R3 L-> S .
R4 L-> L , S .
Step :6 String parsing
Let string w=(a,a) derived from the given grammar
S – Shift action
* shift input symbol to the stack
* shift number to the stack
R – Reduce action
* pop 2 times of RHS symbols
* shift LHS to the stack
* find the number in the parsing table for
the last two elements in the stack
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
Stack Input Action
$0 (a,a)$ S3
$0(3 a,a)$ S2
$0(3a2 ,a)$ R1
$0(3S5 ,a)$ R3
$0(3L4 ,a)$ S7
$0(3L4 , 7 a)$ S2
$0(3L4 , 7a2 )$ R1
$0(3L4 , 7S8 )$ R4
label Production
R0 S’-> S .
R1 S-> a .
R2 S-> ( L ) .
R3 L-> S .
R4 L-> L , S .
Step :6 String parsing
Let string w=(a,a) derived from the given grammar
S – Shift action
* shift input symbol to the stack
* shift number to the stack
R – Reduce action
* pop 2 times of RHS symbols
* shift LHS to the stack
* find the number in the parsing table for
the last two elements in the stack
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
Stack Input Action
$0 (a,a)$ S3
$0(3 a,a)$ S2
$0(3a2 ,a)$ R1
$0(3S5 ,a)$ R3
$0(3L4 ,a)$ S7
$0(3L4 , 7 a)$ S2
$0(3L4 , 7a2 )$ R1
$0(3L4 , 7S8 )$ R4
$0(3L4 ) $ S6
label Production
R0 S’-> S .
R1 S-> a .
R2 S-> ( L ) .
R3 L-> S .
R4 L-> L , S .
Step :6 String parsing
Let string w=(a,a) derived from the given grammar
S – Shift action
* shift input symbol to the stack
* shift number to the stack
R – Reduce action
* pop 2 times of RHS symbols
* shift LHS to the stack
* find the number in the parsing table for
the last two elements in the stack
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
Stack Input Action
$0 (a,a)$ S3
$0(3 a,a)$ S2
$0(3a2 ,a)$ R1
$0(3S5 ,a)$ R3
$0(3L4 ,a)$ S7
$0(3L4 , 7 a)$ S2
$0(3L4 , 7a2 )$ R1
$0(3L4 , 7S8 )$ R4
$0(3L4 ) $ S6
$0(3L4)6 $ R2
label Production
R0 S’-> S .
R1 S-> a .
R2 S-> ( L ) .
R3 L-> S .
R4 L-> L , S .
Step :6 String parsing
Let string w=(a,a) derived from the given grammar
S – Shift action
* shift input symbol to the stack
* shift number to the stack
R – Reduce action
* pop 2 times of RHS symbols
* shift LHS to the stack
* find the number in the parsing table for
the last two elements in the stack
ACTION GOTO
a ( ) , $ S L
0 S2 S3 1
1 accept
2 R1 R1 R1
3 S2 S3 5 4
4 S6 S7
5 R3 R3
6 R2 R2 R2
7 S2 S3 8
8 R4 R4
Stack Input Action
$0 (a,a)$ S3
$0(3 a,a)$ S2
$0(3a2 ,a)$ R1
$0(3S5 ,a)$ R3
$0(3L4 ,a)$ S7
$0(3L4 , 7 a)$ S2
$0(3L4 , 7a2 )$ R1
$0(3L4 , 7S8 )$ R4
$0(3L4 ) $ S6
$0(3L4)6 $ R2
$0S1 $ accept
Hence the string parsed successfully !!!!!!
label Production
R0 S’-> S .
R1 S-> a .
R2 S-> ( L ) .
R3 L-> S .
R4 L-> L , S .

More Related Content

What's hot

Bottom up parser
Bottom up parserBottom up parser
Bottom up parser
Akshaya Arunan
 
A simple approach of lexical analyzers
A simple approach of lexical analyzersA simple approach of lexical analyzers
A simple approach of lexical analyzers
Archana Gopinath
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
Dattatray Gandhmal
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsing
kunj desai
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
Akshaya Arunan
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLR
Riazul Islam
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
Dattatray Gandhmal
 
Greedy algorithm
Greedy algorithmGreedy algorithm
CLR AND LALR PARSER
CLR AND LALR PARSERCLR AND LALR PARSER
CLR AND LALR PARSER
Akila Krishnamoorthy
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler Design
Kuppusamy P
 
Assemblers
AssemblersAssemblers
Assemblers
Dattatray Gandhmal
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
Akhil Kaushik
 
Dijkstra's Algorithm
Dijkstra's Algorithm Dijkstra's Algorithm
Dijkstra's Algorithm
Rashik Ishrak Nahian
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
Radhakrishnan Chinnusamy
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
DataminingTools Inc
 
Unit iv(simple code generator)
Unit iv(simple code generator)Unit iv(simple code generator)
Unit iv(simple code generator)
Kalaimathi Vijayakumar
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
ManishPrajapati78
 
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
venkatapranaykumarGa
 

What's hot (20)

Bottom up parser
Bottom up parserBottom up parser
Bottom up parser
 
A simple approach of lexical analyzers
A simple approach of lexical analyzersA simple approach of lexical analyzers
A simple approach of lexical analyzers
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsing
 
Knapsack Problem
Knapsack ProblemKnapsack Problem
Knapsack Problem
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLR
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
 
CLR AND LALR PARSER
CLR AND LALR PARSERCLR AND LALR PARSER
CLR AND LALR PARSER
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler Design
 
Assemblers
AssemblersAssemblers
Assemblers
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
 
Dijkstra's Algorithm
Dijkstra's Algorithm Dijkstra's Algorithm
Dijkstra's Algorithm
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
 
Unit iv(simple code generator)
Unit iv(simple code generator)Unit iv(simple code generator)
Unit iv(simple code generator)
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
 
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
 

Similar to Slr parser

UNIT 2 (1).pptx
UNIT 2 (1).pptxUNIT 2 (1).pptx
UNIT 2 (1).pptx
Abhishek Tirkey
 
LR-Parsing.ppt
LR-Parsing.pptLR-Parsing.ppt
LR-Parsing.ppt
BapanKar2
 
ch5-bottomupparser_jfdrhgfrfyyssf-gfrrt.PPT
ch5-bottomupparser_jfdrhgfrfyyssf-gfrrt.PPTch5-bottomupparser_jfdrhgfrfyyssf-gfrrt.PPT
ch5-bottomupparser_jfdrhgfrfyyssf-gfrrt.PPT
FutureTechnologies3
 
lr parsers bottom up parsers slr parser.pptx
lr parsers bottom up parsers slr parser.pptxlr parsers bottom up parsers slr parser.pptx
lr parsers bottom up parsers slr parser.pptx
srilakshmis17
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
Daniel Cukier
 
Lecture11 syntax analysis_7
Lecture11 syntax analysis_7Lecture11 syntax analysis_7
Lecture11 syntax analysis_7
Mahesh Kumar Chelimilla
 
11-SLR input string parsing, CLR introduction-06-06-2023.docx
11-SLR input string parsing, CLR introduction-06-06-2023.docx11-SLR input string parsing, CLR introduction-06-06-2023.docx
11-SLR input string parsing, CLR introduction-06-06-2023.docx
venkatapranaykumarGa
 
3.ASSEMBLERS.pptx
3.ASSEMBLERS.pptx3.ASSEMBLERS.pptx
3.ASSEMBLERS.pptx
GaganaP13
 
10-SLR parser practice problems-02-06-2023.pptx
10-SLR parser practice problems-02-06-2023.pptx10-SLR parser practice problems-02-06-2023.pptx
10-SLR parser practice problems-02-06-2023.pptx
venkatapranaykumarGa
 
BOTTOM UP PARSING GROUP 3.pptx
BOTTOM UP PARSING GROUP 3.pptxBOTTOM UP PARSING GROUP 3.pptx
BOTTOM UP PARSING GROUP 3.pptx
SnehaTiwari84
 
Compiler Design Unit 2
Compiler Design Unit 2Compiler Design Unit 2
Compiler Design Unit 2
Jena Catherine Bel D
 
chapter7.ppt
chapter7.pptchapter7.ppt
chapter7.ppt
Preetiverma538521
 
chapter7.pptfuifbsdiufbsiudfiudfiufeiufiuf
chapter7.pptfuifbsdiufbsiudfiudfiufeiufiufchapter7.pptfuifbsdiufbsiudfiudfiufeiufiuf
chapter7.pptfuifbsdiufbsiudfiudfiufeiufiuf
WrushabhShirsat3
 
chapter7 Sorting.ppt
chapter7 Sorting.pptchapter7 Sorting.ppt
chapter7 Sorting.ppt
Nielmagahod
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
Functional Thursday
 

Similar to Slr parser (20)

UNIT 2 (1).pptx
UNIT 2 (1).pptxUNIT 2 (1).pptx
UNIT 2 (1).pptx
 
LR-Parsing.ppt
LR-Parsing.pptLR-Parsing.ppt
LR-Parsing.ppt
 
ch5-bottomupparser_jfdrhgfrfyyssf-gfrrt.PPT
ch5-bottomupparser_jfdrhgfrfyyssf-gfrrt.PPTch5-bottomupparser_jfdrhgfrfyyssf-gfrrt.PPT
ch5-bottomupparser_jfdrhgfrfyyssf-gfrrt.PPT
 
lr parsers bottom up parsers slr parser.pptx
lr parsers bottom up parsers slr parser.pptxlr parsers bottom up parsers slr parser.pptx
lr parsers bottom up parsers slr parser.pptx
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
 
Lecture11 syntax analysis_7
Lecture11 syntax analysis_7Lecture11 syntax analysis_7
Lecture11 syntax analysis_7
 
11-SLR input string parsing, CLR introduction-06-06-2023.docx
11-SLR input string parsing, CLR introduction-06-06-2023.docx11-SLR input string parsing, CLR introduction-06-06-2023.docx
11-SLR input string parsing, CLR introduction-06-06-2023.docx
 
Ch4b
Ch4bCh4b
Ch4b
 
3.ASSEMBLERS.pptx
3.ASSEMBLERS.pptx3.ASSEMBLERS.pptx
3.ASSEMBLERS.pptx
 
Bottomupparser
BottomupparserBottomupparser
Bottomupparser
 
Bottomupparser
BottomupparserBottomupparser
Bottomupparser
 
Bottomupparser
BottomupparserBottomupparser
Bottomupparser
 
10-SLR parser practice problems-02-06-2023.pptx
10-SLR parser practice problems-02-06-2023.pptx10-SLR parser practice problems-02-06-2023.pptx
10-SLR parser practice problems-02-06-2023.pptx
 
BOTTOM UP PARSING GROUP 3.pptx
BOTTOM UP PARSING GROUP 3.pptxBOTTOM UP PARSING GROUP 3.pptx
BOTTOM UP PARSING GROUP 3.pptx
 
Hash map
Hash mapHash map
Hash map
 
Compiler Design Unit 2
Compiler Design Unit 2Compiler Design Unit 2
Compiler Design Unit 2
 
chapter7.ppt
chapter7.pptchapter7.ppt
chapter7.ppt
 
chapter7.pptfuifbsdiufbsiudfiudfiufeiufiuf
chapter7.pptfuifbsdiufbsiudfiudfiufeiufiufchapter7.pptfuifbsdiufbsiudfiudfiufeiufiuf
chapter7.pptfuifbsdiufbsiudfiudfiufeiufiuf
 
chapter7 Sorting.ppt
chapter7 Sorting.pptchapter7 Sorting.ppt
chapter7 Sorting.ppt
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
 

More from Akila Krishnamoorthy

Automata Theory - Turing machine
Automata Theory - Turing machineAutomata Theory - Turing machine
Automata Theory - Turing machine
Akila Krishnamoorthy
 
Automata theory - RE to DFA Conversion
Automata theory - RE to DFA ConversionAutomata theory - RE to DFA Conversion
Automata theory - RE to DFA Conversion
Akila Krishnamoorthy
 
Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)
Akila Krishnamoorthy
 
Automata theory -RE to NFA-ε
Automata theory -RE to  NFA-εAutomata theory -RE to  NFA-ε
Automata theory -RE to NFA-ε
Akila Krishnamoorthy
 
Automata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA ConversionAutomata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA Conversion
Akila Krishnamoorthy
 
Automata theory - NFA to DFA Conversion
Automata theory - NFA to DFA ConversionAutomata theory - NFA to DFA Conversion
Automata theory - NFA to DFA Conversion
Akila Krishnamoorthy
 
Automata theory -- NFA and DFA construction
Automata theory -- NFA and DFA  constructionAutomata theory -- NFA and DFA  construction
Automata theory -- NFA and DFA construction
Akila Krishnamoorthy
 
Intro to automata theory
Intro to automata theoryIntro to automata theory
Intro to automata theory
Akila Krishnamoorthy
 
Automata theory -Conversion of ε nfa to nfa
Automata theory -Conversion of ε nfa to nfaAutomata theory -Conversion of ε nfa to nfa
Automata theory -Conversion of ε nfa to nfa
Akila Krishnamoorthy
 
Automata theory - CFG and normal forms
Automata theory - CFG and normal formsAutomata theory - CFG and normal forms
Automata theory - CFG and normal forms
Akila Krishnamoorthy
 
Linear data structure concepts
Linear data structure conceptsLinear data structure concepts
Linear data structure concepts
Akila Krishnamoorthy
 
Keypoints c strings
Keypoints   c stringsKeypoints   c strings
Keypoints c strings
Akila Krishnamoorthy
 

More from Akila Krishnamoorthy (12)

Automata Theory - Turing machine
Automata Theory - Turing machineAutomata Theory - Turing machine
Automata Theory - Turing machine
 
Automata theory - RE to DFA Conversion
Automata theory - RE to DFA ConversionAutomata theory - RE to DFA Conversion
Automata theory - RE to DFA Conversion
 
Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)
 
Automata theory -RE to NFA-ε
Automata theory -RE to  NFA-εAutomata theory -RE to  NFA-ε
Automata theory -RE to NFA-ε
 
Automata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA ConversionAutomata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA Conversion
 
Automata theory - NFA to DFA Conversion
Automata theory - NFA to DFA ConversionAutomata theory - NFA to DFA Conversion
Automata theory - NFA to DFA Conversion
 
Automata theory -- NFA and DFA construction
Automata theory -- NFA and DFA  constructionAutomata theory -- NFA and DFA  construction
Automata theory -- NFA and DFA construction
 
Intro to automata theory
Intro to automata theoryIntro to automata theory
Intro to automata theory
 
Automata theory -Conversion of ε nfa to nfa
Automata theory -Conversion of ε nfa to nfaAutomata theory -Conversion of ε nfa to nfa
Automata theory -Conversion of ε nfa to nfa
 
Automata theory - CFG and normal forms
Automata theory - CFG and normal formsAutomata theory - CFG and normal forms
Automata theory - CFG and normal forms
 
Linear data structure concepts
Linear data structure conceptsLinear data structure concepts
Linear data structure concepts
 
Keypoints c strings
Keypoints   c stringsKeypoints   c strings
Keypoints c strings
 

Recently uploaded

Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
Kamal Acharya
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
ssuser9bd3ba
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 

Recently uploaded (20)

Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 

Slr parser

  • 1. SLR PARSER Steps: 1. create augment grammar 2. generate kernel items 3. find closure 4. compute goto() 5. construct parsing table 6. parse the string Let us consider grammar: S->a S->(L) L->S L->L,S
  • 2. • Step :1 Create augment grammar S is start symbol in the given grammar Augment grammar is S’-> S • Step :2 Generate kernel items Introduce dot in RHS of the production`` S’-> .S • Step :3 Find closure (Rule: A -> α.Xβ i.e if there is nonterminal next to dot then Include X production)) S’-> .S S-> . a S->.(L) I0
  • 3. Step :4 compute goto() S’-> S . I1 Goto (I0,a) S-> a . I2 Goto (I0,( ) S’-> .S S-> . a S->.(L) I0 S-> (.L) L->.S L>.L,S S->.a S->.(L) I3 Goto (I3,L ) S-> (L .) L->L . ,S I4 Goto (I3,S ) L->S . I5 Goto (I3,a ) S->a . I2 Goto (I3, ( ) S-> (. L ) L->.S L>.L,S S->.a S->.(L) I3 Goto (I0,S)
  • 4. Goto (I4, ) ) S-> (L) . I6 Goto (I4, , ) L->L , . S S-> . a S->.(L) I7 Goto (I7,S ) L->L , S . I8 Goto (I7,a ) S-> a . I2 Goto (I7,( ) S-> (.L) L->.S L>.L,S S->.a S->.(L) I3 label Production Ending iteration R0 S’-> S . I1 R1 S->a . I2 R2 S->(L) . I6 R3 L->S . I5 R4 L->L,S . I8
  • 5. Step :5 construct parsing table Label the rows of table with no. of iterations Divide the Column into two parts • Action part: terminal symbols • Goto part: Nonterminal symbols Terminals Non terminals a ( ) , $ S L 0 1 2 3 4 5 6 7 8
  • 6. Step :5 construct parsing table from step 4: Label the rows of table with no. of iterations Divide the Column into two parts • Action part: terminal symbols • Goto part: Nonterminal symbols ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 2 3 S2 S3 5 4 4 S6 S7 5 6 7 S2 S3 8 8 Goto (I0, S) 1 Goto (I3, ( ) 3 Goto (I0, a) 2 Goto (I4, ) ) 6 Goto (I0, ( ) 3 Goto (I4, ,) 7 Goto (I3, L) 4 Goto (I7, S) 8 Goto (I3, S) 5 Goto (I7, a) 2 Goto (I3, a) 2 Goto (I7, ( ) 3
  • 7. Step :5 construct parsing table Label the rows of table with no. of iterations Divide the Column into two parts • Action part: terminal symbols • Goto part: Nonterminal symbols ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 label Production Ending iteration Follow(LHS) R0 S’-> S . I1 Follow(S’)={ $ } R1 S-> a . I2 Follow(S)={ $ ) , } R2 S-> ( L ) . I6 Follow(S)={ $ ) , } R3 L-> S . I5 Follow(L)={ ) , } R4 L-> L , S . I8 Follow(L)={ ) , }
  • 8. Step :5 construct parsing table Label the rows of table with no. of iterations Divide the Column into two parts • Action part: terminal symbols • Goto part: Nonterminal symbols ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 label Production Ending iteration Follow(LHS) R0 S’-> S . I1 Follow(S’)={ $ } R1 S-> a . I2 Follow(S)={ $ ) , } R2 S-> ( L ) . I6 Follow(S)={ $ ) , } R3 L-> S . I5 Follow(L)={ ) , } R4 L-> L , S . I8 Follow(L)={ ) , } Goto (I0, S) 1 Goto (I3, ( ) 3 Goto (I0, a) 2 Goto (I4, ) ) 6 Goto (I0, ( ) 3 Goto (I4, ,) 7 Goto (I3, L) 4 Goto (I7, S) 8 Goto (I3, S) 5 Goto (I7, a) 2 Goto (I3, a) 2 Goto (I7, ( ) 3
  • 9. Step :6 String parsing Let string w=(a,a) derived from the given grammar S – Shift action * shift input symbol to the stack * shift number to the stack R – Reduce action * pop 2 times of RHS symbols * shift LHS to the stack * find the number in the parsing table for the last two elements in the stack ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 Stack Input Action $0 (a,a)$ S3 label Production R0 S’-> S . R1 S-> a . R2 S-> ( L ) . R3 L-> S . R4 L-> L , S .
  • 10. Step :6 String parsing Let string w=(a,a) derived from the given grammar S – Shift action * shift input symbol to the stack * shift number to the stack R – Reduce action * pop 2 times of RHS symbols * shift LHS to the stack * find the number in the parsing table for the last two elements in the stack ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 Stack Input Action $0 (a,a)$ S3 $0(3 a,a)$ S2 label Production R0 S’-> S . R1 S-> a . R2 S-> ( L ) . R3 L-> S . R4 L-> L , S .
  • 11. Step :6 String parsing Let string w=(a,a) derived from the given grammar S – Shift action * shift input symbol to the stack * shift number to the stack R – Reduce action * pop 2 times of RHS symbols * shift LHS to the stack * find the number in the parsing table for the last two elements in the stack ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 Stack Input Action $0 (a,a)$ S3 $0(3 a,a)$ S2 $0(3a2 ,a)$ R1 label Production R0 S’-> S . R1 S-> a . R2 S-> ( L ) . R3 L-> S . R4 L-> L , S .
  • 12. Step :6 String parsing Let string w=(a,a) derived from the given grammar S – Shift action * shift input symbol to the stack * shift number to the stack R – Reduce action * pop 2 times of RHS symbols * shift LHS to the stack * find the number in the parsing table for the last two elements in the stack ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 Stack Input Action $0 (a,a)$ S3 $0(3 a,a)$ S2 $0(3a2 ,a)$ R1 $0(3S5 ,a)$ R3 label Production R0 S’-> S . R1 S-> a . R2 S-> ( L ) . R3 L-> S . R4 L-> L , S .
  • 13. Step :6 String parsing Let string w=(a,a) derived from the given grammar S – Shift action * shift input symbol to the stack * shift number to the stack R – Reduce action * pop 2 times of RHS symbols * shift LHS to the stack * find the number in the parsing table for the last two elements in the stack ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 Stack Input Action $0 (a,a)$ S3 $0(3 a,a)$ S2 $0(3a2 ,a)$ R1 $0(3S5 ,a)$ R3 $0(3L4 ,a)$ S7 label Production R0 S’-> S . R1 S-> a . R2 S-> ( L ) . R3 L-> S . R4 L-> L , S .
  • 14. Step :6 String parsing Let string w=(a,a) derived from the given grammar S – Shift action * shift input symbol to the stack * shift number to the stack R – Reduce action * pop 2 times of RHS symbols * shift LHS to the stack * find the number in the parsing table for the last two elements in the stack ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 Stack Input Action $0 (a,a)$ S3 $0(3 a,a)$ S2 $0(3a2 ,a)$ R1 $0(3S5 ,a)$ R3 $0(3L4 ,a)$ S7 label Production R0 S’-> S . R1 S-> a . R2 S-> ( L ) . R3 L-> S . R4 L-> L , S .
  • 15. Step :6 String parsing Let string w=(a,a) derived from the given grammar S – Shift action * shift input symbol to the stack * shift number to the stack R – Reduce action * pop 2 times of RHS symbols * shift LHS to the stack * find the number in the parsing table for the last two elements in the stack ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 Stack Input Action $0 (a,a)$ S3 $0(3 a,a)$ S2 $0(3a2 ,a)$ R1 $0(3S5 ,a)$ R3 $0(3L4 ,a)$ S7 $0(3L4 , 7 a)$ S2 label Production R0 S’-> S . R1 S-> a . R2 S-> ( L ) . R3 L-> S . R4 L-> L , S .
  • 16. Step :6 String parsing Let string w=(a,a) derived from the given grammar S – Shift action * shift input symbol to the stack * shift number to the stack R – Reduce action * pop 2 times of RHS symbols * shift LHS to the stack * find the number in the parsing table for the last two elements in the stack ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 Stack Input Action $0 (a,a)$ S3 $0(3 a,a)$ S2 $0(3a2 ,a)$ R1 $0(3S5 ,a)$ R3 $0(3L4 ,a)$ S7 $0(3L4 , 7 a)$ S2 $0(3L4 , 7a2 )$ R1 label Production R0 S’-> S . R1 S-> a . R2 S-> ( L ) . R3 L-> S . R4 L-> L , S .
  • 17. Step :6 String parsing Let string w=(a,a) derived from the given grammar S – Shift action * shift input symbol to the stack * shift number to the stack R – Reduce action * pop 2 times of RHS symbols * shift LHS to the stack * find the number in the parsing table for the last two elements in the stack ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 Stack Input Action $0 (a,a)$ S3 $0(3 a,a)$ S2 $0(3a2 ,a)$ R1 $0(3S5 ,a)$ R3 $0(3L4 ,a)$ S7 $0(3L4 , 7 a)$ S2 $0(3L4 , 7a2 )$ R1 $0(3L4 , 7S8 )$ R4 label Production R0 S’-> S . R1 S-> a . R2 S-> ( L ) . R3 L-> S . R4 L-> L , S .
  • 18. Step :6 String parsing Let string w=(a,a) derived from the given grammar S – Shift action * shift input symbol to the stack * shift number to the stack R – Reduce action * pop 2 times of RHS symbols * shift LHS to the stack * find the number in the parsing table for the last two elements in the stack ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 Stack Input Action $0 (a,a)$ S3 $0(3 a,a)$ S2 $0(3a2 ,a)$ R1 $0(3S5 ,a)$ R3 $0(3L4 ,a)$ S7 $0(3L4 , 7 a)$ S2 $0(3L4 , 7a2 )$ R1 $0(3L4 , 7S8 )$ R4 $0(3L4 ) $ S6 label Production R0 S’-> S . R1 S-> a . R2 S-> ( L ) . R3 L-> S . R4 L-> L , S .
  • 19. Step :6 String parsing Let string w=(a,a) derived from the given grammar S – Shift action * shift input symbol to the stack * shift number to the stack R – Reduce action * pop 2 times of RHS symbols * shift LHS to the stack * find the number in the parsing table for the last two elements in the stack ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 Stack Input Action $0 (a,a)$ S3 $0(3 a,a)$ S2 $0(3a2 ,a)$ R1 $0(3S5 ,a)$ R3 $0(3L4 ,a)$ S7 $0(3L4 , 7 a)$ S2 $0(3L4 , 7a2 )$ R1 $0(3L4 , 7S8 )$ R4 $0(3L4 ) $ S6 $0(3L4)6 $ R2 label Production R0 S’-> S . R1 S-> a . R2 S-> ( L ) . R3 L-> S . R4 L-> L , S .
  • 20. Step :6 String parsing Let string w=(a,a) derived from the given grammar S – Shift action * shift input symbol to the stack * shift number to the stack R – Reduce action * pop 2 times of RHS symbols * shift LHS to the stack * find the number in the parsing table for the last two elements in the stack ACTION GOTO a ( ) , $ S L 0 S2 S3 1 1 accept 2 R1 R1 R1 3 S2 S3 5 4 4 S6 S7 5 R3 R3 6 R2 R2 R2 7 S2 S3 8 8 R4 R4 Stack Input Action $0 (a,a)$ S3 $0(3 a,a)$ S2 $0(3a2 ,a)$ R1 $0(3S5 ,a)$ R3 $0(3L4 ,a)$ S7 $0(3L4 , 7 a)$ S2 $0(3L4 , 7a2 )$ R1 $0(3L4 , 7S8 )$ R4 $0(3L4 ) $ S6 $0(3L4)6 $ R2 $0S1 $ accept Hence the string parsed successfully !!!!!! label Production R0 S’-> S . R1 S-> a . R2 S-> ( L ) . R3 L-> S . R4 L-> L , S .