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

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 CLRRiazul Islam
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generationAkshaya Arunan
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First SearchKevin Jadiya
 
Lock based protocols
Lock based protocolsLock based protocols
Lock based protocolsChethanMp7
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
16. Concurrency Control in DBMS
16. Concurrency Control in DBMS16. Concurrency Control in DBMS
16. Concurrency Control in DBMSkoolkampus
 
Control Strategies in AI
Control Strategies in AI Control Strategies in AI
Control Strategies in AI Bharat Bhushan
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javaMonika Mishra
 
Nonrecursive predictive parsing
Nonrecursive predictive parsingNonrecursive predictive parsing
Nonrecursive predictive parsingalldesign
 
Bubble sort | Data structure |
Bubble sort | Data structure |Bubble sort | Data structure |
Bubble sort | Data structure |MdSaiful14
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra pptGirdharRatne
 

What's hot (20)

Data structures using c
Data structures using cData structures using c
Data structures using c
 
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
 
Selection sorting
Selection sortingSelection sorting
Selection sorting
 
Stack
StackStack
Stack
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
 
Predictive parser
Predictive parserPredictive parser
Predictive parser
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
 
Lock based protocols
Lock based protocolsLock based protocols
Lock based protocols
 
Merge sort algorithm
Merge sort algorithmMerge sort algorithm
Merge sort algorithm
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
16. Concurrency Control in DBMS
16. Concurrency Control in DBMS16. Concurrency Control in DBMS
16. Concurrency Control in DBMS
 
Control Strategies in AI
Control Strategies in AI Control Strategies in AI
Control Strategies in AI
 
LR Parsing
LR ParsingLR Parsing
LR Parsing
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Nonrecursive predictive parsing
Nonrecursive predictive parsingNonrecursive predictive parsing
Nonrecursive predictive parsing
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Types of Parser
Types of ParserTypes of Parser
Types of Parser
 
Python dictionary
Python   dictionaryPython   dictionary
Python dictionary
 
Bubble sort | Data structure |
Bubble sort | Data structure |Bubble sort | Data structure |
Bubble sort | Data structure |
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra ppt
 

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
 
Bottom up parser
Bottom up parserBottom up parser
Bottom up parser
 
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
 

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
 
LR(0) PARSER
LR(0) PARSERLR(0) PARSER
LR(0) PARSER
 
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
 

Recently uploaded

9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000Sapana Sha
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bSérgio Sacani
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoSérgio Sacani
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bSérgio Sacani
 
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATINChromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATINsankalpkumarsahoo174
 
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
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsAArockiyaNisha
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfSumit Kumar yadav
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPirithiRaju
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencySheetal Arora
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsSumit Kumar yadav
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPirithiRaju
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...RohitNehra6
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticssakshisoni2385
 
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.Nitya salvi
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PPRINCE C P
 
Green chemistry and Sustainable development.pptx
Green chemistry  and Sustainable development.pptxGreen chemistry  and Sustainable development.pptx
Green chemistry and Sustainable development.pptxRajatChauhan518211
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Lokesh Kothari
 

Recently uploaded (20)

9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on Io
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
 
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATINChromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
 
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
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based Nanomaterials
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdf
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questions
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
 
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C P
 
Green chemistry and Sustainable development.pptx
Green chemistry  and Sustainable development.pptxGreen chemistry  and Sustainable development.pptx
Green chemistry and Sustainable development.pptx
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
 

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