SlideShare a Scribd company logo
1 of 13
Presentationon
LALR PARSER
( Look Ahead Parser )
Submitted To
Dharemendra Sir
Submitted By
Vivek Kr Poddar
Table Of Content
o Introduction To LALR Parser
o LALR Table Construction Method
o Examples – Related To Grammer, First, CLR, etc.
o Computed LR( 0 ) Items
o GOTO Graph
o Canonical Parsing Table
o LALR Parsing Table
2
What is LALR Parser
o LALR stands for (look ahead LR) parser.
o LALR parser starts with the idea of building an LR parsing table
o Tables generated by LALR parser are smaller in size as compared to
that of Canonical LR ( CLR ) and Simple LR ( SLR ) techniques.
o LALR parsers are slightly less powerful than LR parsers, but still more
powerful than SLR parsers.
o LALR is used by YACC and other parser generators because of its
effectiveness.
3
LALR TableConstruction Idea
o Construct the set of LR (1) items.
o Merge the sets with common core together in CLR table.
o If any problem arises then grammar is not LALR.
4
Example
Grammar:
1. S’ -> S
2. S -> CC
3. C -> cC
4. C -> d
5
First : Where F Means First
F( S’ ) -> F( S ) -> F( C ) -> { c,d }
F ( C ) -> { c, d }
-> c/d Look Ahead Symbol
Note :: CC are two different items.
Note :: Non-terminals denoted by upper-case letters, terminals denoted by
lower-case letters
S’ -> .S,$ :: This (a rule with a dot in it) is called an item, it indicates what is in
the stack [ left side of . ] and what is to be expected on input [ right side of . ]
Anything after ( , ) comma is termed as look ahead.
Computed LR( 0 )& LR( 1 )Items6
I5: S -> CC., $
I6: C -> c.C, $
C -> .cC, $
C -> .d, $
I7: C -> d., $
I8: C -> cC., c /d
I9: C -> cC., $
I0 : S’ -> .S, $
S -> .CC, $
C -> .c C, c /d
C -> .d, c /d
I1: S’ -> S., $
I2: S -> C.C, $
C -> .c C, $
C -> .d, $
I3: C -> c. C, c /d
C -> .Cc, c /d
C -> .d, c /d
14: C -> d., c / d
Grammar:
1. S’ -> S
2. S -> CC
3. C -> cC
4. C -> d
Grammar:
1. S’ -> S
2. S -> CC
3. C -> cC/d
First ( c/d )
Note : I0 consist of LR ( 0 ).
Items while rest are LR ( 1 )
items.
Its always suggested not
to work beyond State 2 by
hand as they are
compicated and should be
calculated using standard
tools.
7
8 Canonical ParsingTable
States
c d $ S C
0 S3 S4 1 2
1 acc
2 S6 S7 5
3 S3 S4 8
4 R4 R4
5 R2
6 S6 S7 9
7 R4
8 R3 R3
9 R3
Actions GOTO
9 LALR Parser
Actions GOTO
Merge the Cores:
What is core ?
A core is a set of LR (0) (SLR) items for the grammar.
o 3 & 6
o 4 & 7
o 8 & 9
10 LALR Parsing Table
Actions
Start
c d $ S C
0 S36 S47 1 2
1 acc
2 S36 S47 5
36 S36 S47 89
47 R47 R47 R47
5 R2
89 R36 R36 R36
GOTOAction
Conflicts In LALR Parser
o LALR Parser cannot introduce shift/reduce conflicts.
o Such conflicts arises when the look ahead is same as the token on which
we can shift.
o They depend on the core of the item but we merge only those rows
which have common cores.
o The only way by which this conflict can arise in LALR is when the
conflict is already their in the LR(1).
11
11 Refrence
Actions
GOTOActionUsed to generate First of Given Grammer
http://hackingoff.com/compilers/predict-first-follow-set
IITKGP notes for making presentation
http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/
Compilers Principles Techniques and Tools (2nd Edition) - BOOK
Thank You
For Listening
12

More Related Content

What's hot

What's hot (20)

LR Parsing
LR ParsingLR Parsing
LR Parsing
 
Top down and botttom up Parsing
Top down     and botttom up ParsingTop down     and botttom up Parsing
Top down and botttom up Parsing
 
Time complexity
Time complexityTime complexity
Time complexity
 
5 csp
5 csp5 csp
5 csp
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
 
Code generation
Code generationCode generation
Code generation
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
 
Unit iv(simple code generator)
Unit iv(simple code generator)Unit iv(simple code generator)
Unit iv(simple code generator)
 
LL(1) parsing
LL(1) parsingLL(1) parsing
LL(1) parsing
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
 
Greedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptGreedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.ppt
 
Parsing
ParsingParsing
Parsing
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
RECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGRECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSING
 
Parse Tree
Parse TreeParse Tree
Parse Tree
 
Directed Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksDirected Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocks
 
Parsing
ParsingParsing
Parsing
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
 
Greedy Algorithms
Greedy AlgorithmsGreedy Algorithms
Greedy Algorithms
 

Viewers also liked (20)

Compiler Components and their Generators - LR Parsing
Compiler Components and their Generators - LR ParsingCompiler Components and their Generators - LR Parsing
Compiler Components and their Generators - LR Parsing
 
Parsing example
Parsing exampleParsing example
Parsing example
 
Module 11
Module 11Module 11
Module 11
 
Compilers section 4.7
Compilers section 4.7Compilers section 4.7
Compilers section 4.7
 
Parsing using graphs
Parsing using graphsParsing using graphs
Parsing using graphs
 
Static Analysis
Static AnalysisStatic Analysis
Static Analysis
 
L Rparser Edos
L Rparser EdosL Rparser Edos
L Rparser Edos
 
ASSIGNMENT STATEMENTS AND
ASSIGNMENT STATEMENTS ANDASSIGNMENT STATEMENTS AND
ASSIGNMENT STATEMENTS AND
 
Ch4b
Ch4bCh4b
Ch4b
 
Vivek kumar resume
Vivek kumar resumeVivek kumar resume
Vivek kumar resume
 
linkedin profile
linkedin profilelinkedin profile
linkedin profile
 
Multimedia
Multimedia Multimedia
Multimedia
 
Cloud computing notes rgpv unit 5
Cloud computing notes rgpv unit 5Cloud computing notes rgpv unit 5
Cloud computing notes rgpv unit 5
 
Certi
CertiCerti
Certi
 
Cs419 lec11 bottom-up parsing
Cs419 lec11   bottom-up parsingCs419 lec11   bottom-up parsing
Cs419 lec11 bottom-up parsing
 
Chapter Five(2)
Chapter Five(2)Chapter Five(2)
Chapter Five(2)
 
Unit 4 Multimedia CSE Vth sem
Unit 4 Multimedia CSE Vth semUnit 4 Multimedia CSE Vth sem
Unit 4 Multimedia CSE Vth sem
 
Unit 5 animation notes
Unit 5 animation notesUnit 5 animation notes
Unit 5 animation notes
 
Web Engineering UNIT II Notes as per RGPV Syllabus
Web Engineering UNIT II Notes as per RGPV SyllabusWeb Engineering UNIT II Notes as per RGPV Syllabus
Web Engineering UNIT II Notes as per RGPV Syllabus
 
Distributed system unit II according to syllabus of RGPV, Bhopal
Distributed system unit II according to syllabus of  RGPV, BhopalDistributed system unit II according to syllabus of  RGPV, Bhopal
Distributed system unit II according to syllabus of RGPV, Bhopal
 

Similar to LALR Parser Presentation ppt

Similar to LALR Parser Presentation ppt (20)

Lecture 09 syntax analysis 05
Lecture 09 syntax analysis 05Lecture 09 syntax analysis 05
Lecture 09 syntax analysis 05
 
CD
CDCD
CD
 
CD-1.pptx
CD-1.pptxCD-1.pptx
CD-1.pptx
 
cd-1-221103004637-f7b43300.pdf
cd-1-221103004637-f7b43300.pdfcd-1-221103004637-f7b43300.pdf
cd-1-221103004637-f7b43300.pdf
 
Presentation mam saima kanwal
Presentation mam saima kanwalPresentation mam saima kanwal
Presentation mam saima kanwal
 
COMPILER DESIGN- Syntax Analysis
COMPILER DESIGN- Syntax AnalysisCOMPILER DESIGN- Syntax Analysis
COMPILER DESIGN- Syntax Analysis
 
sameermlr0parser-200701133032.pptx
sameermlr0parser-200701133032.pptxsameermlr0parser-200701133032.pptx
sameermlr0parser-200701133032.pptx
 
COMPILER_DESIGN_CLASS 2.ppt
COMPILER_DESIGN_CLASS 2.pptCOMPILER_DESIGN_CLASS 2.ppt
COMPILER_DESIGN_CLASS 2.ppt
 
COMPILER_DESIGN_CLASS 1.pptx
COMPILER_DESIGN_CLASS 1.pptxCOMPILER_DESIGN_CLASS 1.pptx
COMPILER_DESIGN_CLASS 1.pptx
 
LR PARSE.pptx
LR PARSE.pptxLR PARSE.pptx
LR PARSE.pptx
 
Lecture 15 16
Lecture 15 16Lecture 15 16
Lecture 15 16
 
compiler design.pdf
compiler design.pdfcompiler design.pdf
compiler design.pdf
 
Attachment_ VHDL datasheet
Attachment_ VHDL datasheetAttachment_ VHDL datasheet
Attachment_ VHDL datasheet
 
Relational Algebra
Relational AlgebraRelational Algebra
Relational Algebra
 
ARM instruction set
ARM instruction  setARM instruction  set
ARM instruction set
 
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
 
B instruction set
B instruction setB instruction set
B instruction set
 
Follower
FollowerFollower
Follower
 
Follower
FollowerFollower
Follower
 
Lecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptxLecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptx
 

Recently uploaded

Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.aasikanpl
 
Work, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE PhysicsWork, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE Physicsvishikhakeshava1
 
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsSérgio Sacani
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Sérgio Sacani
 
Analytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdfAnalytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdfSwapnil Therkar
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real timeSatoshi NAKAHIRA
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |aasikanpl
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptMAESTRELLAMesa2
 
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCESTERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCEPRINCE C P
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Patrick Diehl
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRDelhi Call girls
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfSELF-EXPLANATORY
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSarthak Sekhar Mondal
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfmuntazimhurra
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)PraveenaKalaiselvan1
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...anilsa9823
 

Recently uploaded (20)

Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
 
Work, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE PhysicsWork, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE Physics
 
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
 
Analytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdfAnalytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdf
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real time
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.ppt
 
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCESTERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
 

LALR Parser Presentation ppt

  • 1. Presentationon LALR PARSER ( Look Ahead Parser ) Submitted To Dharemendra Sir Submitted By Vivek Kr Poddar
  • 2. Table Of Content o Introduction To LALR Parser o LALR Table Construction Method o Examples – Related To Grammer, First, CLR, etc. o Computed LR( 0 ) Items o GOTO Graph o Canonical Parsing Table o LALR Parsing Table 2
  • 3. What is LALR Parser o LALR stands for (look ahead LR) parser. o LALR parser starts with the idea of building an LR parsing table o Tables generated by LALR parser are smaller in size as compared to that of Canonical LR ( CLR ) and Simple LR ( SLR ) techniques. o LALR parsers are slightly less powerful than LR parsers, but still more powerful than SLR parsers. o LALR is used by YACC and other parser generators because of its effectiveness. 3
  • 4. LALR TableConstruction Idea o Construct the set of LR (1) items. o Merge the sets with common core together in CLR table. o If any problem arises then grammar is not LALR. 4
  • 5. Example Grammar: 1. S’ -> S 2. S -> CC 3. C -> cC 4. C -> d 5 First : Where F Means First F( S’ ) -> F( S ) -> F( C ) -> { c,d } F ( C ) -> { c, d } -> c/d Look Ahead Symbol Note :: CC are two different items. Note :: Non-terminals denoted by upper-case letters, terminals denoted by lower-case letters S’ -> .S,$ :: This (a rule with a dot in it) is called an item, it indicates what is in the stack [ left side of . ] and what is to be expected on input [ right side of . ] Anything after ( , ) comma is termed as look ahead.
  • 6. Computed LR( 0 )& LR( 1 )Items6 I5: S -> CC., $ I6: C -> c.C, $ C -> .cC, $ C -> .d, $ I7: C -> d., $ I8: C -> cC., c /d I9: C -> cC., $ I0 : S’ -> .S, $ S -> .CC, $ C -> .c C, c /d C -> .d, c /d I1: S’ -> S., $ I2: S -> C.C, $ C -> .c C, $ C -> .d, $ I3: C -> c. C, c /d C -> .Cc, c /d C -> .d, c /d 14: C -> d., c / d Grammar: 1. S’ -> S 2. S -> CC 3. C -> cC 4. C -> d Grammar: 1. S’ -> S 2. S -> CC 3. C -> cC/d First ( c/d ) Note : I0 consist of LR ( 0 ). Items while rest are LR ( 1 ) items. Its always suggested not to work beyond State 2 by hand as they are compicated and should be calculated using standard tools.
  • 7. 7
  • 8. 8 Canonical ParsingTable States c d $ S C 0 S3 S4 1 2 1 acc 2 S6 S7 5 3 S3 S4 8 4 R4 R4 5 R2 6 S6 S7 9 7 R4 8 R3 R3 9 R3 Actions GOTO
  • 9. 9 LALR Parser Actions GOTO Merge the Cores: What is core ? A core is a set of LR (0) (SLR) items for the grammar. o 3 & 6 o 4 & 7 o 8 & 9
  • 10. 10 LALR Parsing Table Actions Start c d $ S C 0 S36 S47 1 2 1 acc 2 S36 S47 5 36 S36 S47 89 47 R47 R47 R47 5 R2 89 R36 R36 R36 GOTOAction
  • 11. Conflicts In LALR Parser o LALR Parser cannot introduce shift/reduce conflicts. o Such conflicts arises when the look ahead is same as the token on which we can shift. o They depend on the core of the item but we merge only those rows which have common cores. o The only way by which this conflict can arise in LALR is when the conflict is already their in the LR(1). 11
  • 12. 11 Refrence Actions GOTOActionUsed to generate First of Given Grammer http://hackingoff.com/compilers/predict-first-follow-set IITKGP notes for making presentation http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/ Compilers Principles Techniques and Tools (2nd Edition) - BOOK