SlideShare a Scribd company logo
NADAR SARASWATHI COLLEGE OF
ARTS AND SCIENCE,
VADAPUTHUPATTI,THENI.
DEPARTEMENT OF COMPUTER SCIENCE
LR PARSERS
SUBMITTED BY:
S.AISHWARYA LAKSHMI I MSC(CS)
LR parser
 LR parser is a bottom-up parser for context-free grammar that is
very generally used by computer programming language compiler and
other associated tools.
 LR parser reads their input from left to right and produces a
right-most derivation.
 It is called a Bottom-up parser because it attempts to reduce the
top-level grammar productions by building up from the leaves.
 LR parsers are the most powerful parser of all deterministic
parsers in practice.
Description of LR parser :
 The term parser LR(k) parser, here the L refers to the left-to-
right scanning,
 R refers to the rightmost derivation in reverse and k refers to the
number of unconsumed “look ahead” input symbols that are used in
making parser decisions.
 Typically, k is 1 and is often omitted.
 A context-free grammar is called LR (k) if the LR (k) parser exists
for it.
 This first reduces the sequence of tokens to the left.
 But when we read from above, the derivation order first extends
to non-terminal.
Description of LR parser :
 The stack is empty, and we are looking to reduce the
rule by S’→S$.
 Using a “.” in the rule represents how many of the rules
are already on the stack.
 A dotted item, or simply, the item is a production rule
with a dot indicating how much RHS has so far been
recognized.
 Closing an item is used to see what production rules can
be used to expand the current structure.
Rules for LR parser :
 The rules of LR parser as follows.
 The first item from the given grammar rules adds itself
as the first closed set.
 If an object is present in the closure of the form A→ α.
β. γ,
 where the next symbol after the symbol is non-
terminal, add the symbol’s production rules where the
dot precedes the first item.
 Repeat steps (B) and (C) for new items added under (B).
LR parser algorithm :
 LR Parsing algorithm is the same for all the parser, but the parsing
table is different for each parser. It consists following components
as follows.
 Input Buffer –
It contains the given string, and it ends with a $ symbol.
 Stack –
The combination of state symbol and current input symbol is used
to refer to the parsing table in order to take the parsing decisions.
Parsing Table :
 Parsing table is divided into two parts- Action table and Go-To
table. The action table gives a grammar rule to implement the given
current state and current terminal in the input stream.
 There are four cases used in action table as follows.
 Shift Action- In shift action the present terminal is removed from
the input stream and the state n is pushed onto the stack, and it
becomes the new present state.
 Reduce Action- The number m is written to the output stream.
Parsing Table :
 The symbol m mentioned in the left-hand side of
rule m says that state is removed from the stack.
 The symbol m mentioned in the left-hand side of
rule m says that a new state is looked up in the goto
table and made the new current state by pushing it onto
the stack.
 R parsers are used to parse the large class of context
free grammars. This technique is called LR(k) parsing.
 L is left-to-right scanning of the input.
 R is for constructing a right most derivation in reverse.
Parsing Table :
 k is the number of input symbols of lookahead
that are used in making parsing decisions.
 There are three widely used algorithms
available for constructing an LR parser:
 SLR(l) – Simple LR
 Few number of states, hence very small table.
 Simple and fast construction.
 Works on smallest class of grammar.
Reasons for attractiveness of LR parser
 LR parsers can handle a large class of context-free
grammars.
 The LR parsing method is a most general non-back
tracking shift-reduce parsing method.
 An LR parser can detect the syntax errors as soon as
they can occur.
 LR grammars can describe more languages than LL
grammars.
Drawbacks of LR parsers
 It is too much work to construct LR parser by
hand. It needs an automated parser generator.
 If the grammar contains ambiguities or other
constructs then it is difficult to parse in a left-
to-right scan of the input.
Behavior of the LR parser
 1. If ACTION[sm, ai] = shift s. The parser executes the
shift move, it shifts the next state s onto the stack,
entering the configuration
a) Sm – the state on top of the stack.
b) ai– the current input symbol.
Behavior of the LR parser
 2. If ACTION[sm, ai] =reduce A—> β, then the parser
executes a reduce move, entering the configuration
(s0s1 … S(m-r)S, ai+l … an$)
a) where r is the length of β and s= GOTO[sm – r, A].
b) First popped r state symbols off the stack, exposing
state Sm-r·
THANK YOU!!!

More Related Content

What's hot

Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler Design
Akhil Kaushik
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
Tanzeela_Hussain
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
Radhakrishnan Chinnusamy
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsing
R Islam
 
Shift reduce parser
Shift reduce parserShift reduce parser
Shift reduce parser
TEJVEER SINGH
 
LR Parsing
LR ParsingLR Parsing
LR Parsing
Eelco Visser
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
Aman Sharma
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
DataminingTools Inc
 
Flat unit 3
Flat unit 3Flat unit 3
Flat unit 3
VenkataRaoS1
 
Parsing
ParsingParsing
Parsing
khush_boo31
 
Ll(1) Parser in Compilers
Ll(1) Parser in CompilersLl(1) Parser in Compilers
Ll(1) Parser in Compilers
Mahbubur Rahman
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler Design
Akhil Kaushik
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compiler
Sudhaa Ravi
 
Top down parsering and bottom up parsering.pptx
Top down parsering and bottom up parsering.pptxTop down parsering and bottom up parsering.pptx
Top down parsering and bottom up parsering.pptx
LaibaFaisal3
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
Bipul Roy Bpl
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
Akshaya Arunan
 
Parsing
ParsingParsing
Compiler unit 2&3
Compiler unit 2&3Compiler unit 2&3
Compiler unit 2&3
BBDITM LUCKNOW
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
Radhakrishnan Chinnusamy
 
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dhrumil Panchal
 

What's hot (20)

Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler Design
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsing
 
Shift reduce parser
Shift reduce parserShift reduce parser
Shift reduce parser
 
LR Parsing
LR ParsingLR Parsing
LR Parsing
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
 
Flat unit 3
Flat unit 3Flat unit 3
Flat unit 3
 
Parsing
ParsingParsing
Parsing
 
Ll(1) Parser in Compilers
Ll(1) Parser in CompilersLl(1) Parser in Compilers
Ll(1) Parser in Compilers
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler Design
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compiler
 
Top down parsering and bottom up parsering.pptx
Top down parsering and bottom up parsering.pptxTop down parsering and bottom up parsering.pptx
Top down parsering and bottom up parsering.pptx
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
Parsing
ParsingParsing
Parsing
 
Compiler unit 2&3
Compiler unit 2&3Compiler unit 2&3
Compiler unit 2&3
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
 
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
 

Similar to LR PARSE.pptx

compiler design.pdf
compiler design.pdfcompiler design.pdf
compiler design.pdf
RijuMandal11
 
COMPILER DESIGN- Syntax Analysis
COMPILER DESIGN- Syntax AnalysisCOMPILER DESIGN- Syntax Analysis
Bottom up parser
Bottom up parserBottom up parser
Bottom up parser
Inocentshuja Ahmad
 
Syntactic analysis in NLP
Syntactic analysis in NLPSyntactic analysis in NLP
Syntactic analysis in NLP
kartikaVashisht
 
Parsing LL(1), SLR, LR(1)
Parsing LL(1), SLR, LR(1)Parsing LL(1), SLR, LR(1)
Parsing LL(1), SLR, LR(1)
Nitin Mohan Sharma
 
parsing.pptx
parsing.pptxparsing.pptx
parsing.pptx
Aman564573
 
07 top-down-parsing
07 top-down-parsing07 top-down-parsing
07 top-down-parsing
Harish Khodke
 
Lecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptxLecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptx
Yusra11491
 
Pcd question bank
Pcd question bank Pcd question bank
Pcd question bank
Sumathi Gnanasekaran
 
Compiler design important questions
Compiler design   important questionsCompiler design   important questions
Compiler design important questions
akila viji
 
Programming_Language_Syntax.ppt
Programming_Language_Syntax.pptProgramming_Language_Syntax.ppt
Programming_Language_Syntax.ppt
Amrita Sharma
 
Chapter-3 compiler.pptx course materials
Chapter-3 compiler.pptx course materialsChapter-3 compiler.pptx course materials
Chapter-3 compiler.pptx course materials
gadisaAdamu
 
Lecture 15 16
Lecture 15 16Lecture 15 16
Lecture 15 16
Najmul Hassan
 
Introduction to R for beginners
Introduction to R for beginnersIntroduction to R for beginners
Introduction to R for beginners
Abishek Purushothaman
 
Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...
Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...
Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...
Bhavin Darji
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
LISP Content
 
Ch 2.pptx
Ch 2.pptxCh 2.pptx
Ch 2.pptx
woldu2
 
Handout#02
Handout#02Handout#02
Handout#02
Sunita Milind Dol
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Anujashejwal
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
kiran acharya
 

Similar to LR PARSE.pptx (20)

compiler design.pdf
compiler design.pdfcompiler design.pdf
compiler design.pdf
 
COMPILER DESIGN- Syntax Analysis
COMPILER DESIGN- Syntax AnalysisCOMPILER DESIGN- Syntax Analysis
COMPILER DESIGN- Syntax Analysis
 
Bottom up parser
Bottom up parserBottom up parser
Bottom up parser
 
Syntactic analysis in NLP
Syntactic analysis in NLPSyntactic analysis in NLP
Syntactic analysis in NLP
 
Parsing LL(1), SLR, LR(1)
Parsing LL(1), SLR, LR(1)Parsing LL(1), SLR, LR(1)
Parsing LL(1), SLR, LR(1)
 
parsing.pptx
parsing.pptxparsing.pptx
parsing.pptx
 
07 top-down-parsing
07 top-down-parsing07 top-down-parsing
07 top-down-parsing
 
Lecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptxLecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptx
 
Pcd question bank
Pcd question bank Pcd question bank
Pcd question bank
 
Compiler design important questions
Compiler design   important questionsCompiler design   important questions
Compiler design important questions
 
Programming_Language_Syntax.ppt
Programming_Language_Syntax.pptProgramming_Language_Syntax.ppt
Programming_Language_Syntax.ppt
 
Chapter-3 compiler.pptx course materials
Chapter-3 compiler.pptx course materialsChapter-3 compiler.pptx course materials
Chapter-3 compiler.pptx course materials
 
Lecture 15 16
Lecture 15 16Lecture 15 16
Lecture 15 16
 
Introduction to R for beginners
Introduction to R for beginnersIntroduction to R for beginners
Introduction to R for beginners
 
Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...
Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...
Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
 
Ch 2.pptx
Ch 2.pptxCh 2.pptx
Ch 2.pptx
 
Handout#02
Handout#02Handout#02
Handout#02
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 

More from Aishwarya SenthilNathan

cloud computing.pptx
cloud computing.pptxcloud computing.pptx
cloud computing.pptx
Aishwarya SenthilNathan
 
IOT.pptx
IOT.pptxIOT.pptx
women empowerment.pptx
women empowerment.pptxwomen empowerment.pptx
women empowerment.pptx
Aishwarya SenthilNathan
 
Digital Image Processing.pptx
Digital Image Processing.pptxDigital Image Processing.pptx
Digital Image Processing.pptx
Aishwarya SenthilNathan
 
Artifical Intelligence And Machine Learning Algorithum.pptx
Artifical Intelligence And Machine Learning Algorithum.pptxArtifical Intelligence And Machine Learning Algorithum.pptx
Artifical Intelligence And Machine Learning Algorithum.pptx
Aishwarya SenthilNathan
 
Cloud Computing.pptx
Cloud Computing.pptxCloud Computing.pptx
Cloud Computing.pptx
Aishwarya SenthilNathan
 
SENTIMENT ANALYSIS OF FEEDBACK DATA USING MACHINE LEARNING TECHNIQUE.pptx
SENTIMENT ANALYSIS OF FEEDBACK DATA USING MACHINE LEARNING TECHNIQUE.pptxSENTIMENT ANALYSIS OF FEEDBACK DATA USING MACHINE LEARNING TECHNIQUE.pptx
SENTIMENT ANALYSIS OF FEEDBACK DATA USING MACHINE LEARNING TECHNIQUE.pptx
Aishwarya SenthilNathan
 
2D Graphics animation - Bouncing ball(Python).pptx
2D Graphics animation - Bouncing ball(Python).pptx2D Graphics animation - Bouncing ball(Python).pptx
2D Graphics animation - Bouncing ball(Python).pptx
Aishwarya SenthilNathan
 
Growth Of IOT NETWORK.pptx
Growth Of IOT NETWORK.pptxGrowth Of IOT NETWORK.pptx
Growth Of IOT NETWORK.pptx
Aishwarya SenthilNathan
 
DATA MINING.pptx
DATA MINING.pptxDATA MINING.pptx
DATA MINING.pptx
Aishwarya SenthilNathan
 
Software Engineering.pptx
Software Engineering.pptxSoftware Engineering.pptx
Software Engineering.pptx
Aishwarya SenthilNathan
 
HUMANOID ROBOTS.pptx
HUMANOID ROBOTS.pptxHUMANOID ROBOTS.pptx
HUMANOID ROBOTS.pptx
Aishwarya SenthilNathan
 
APPLET.pptx
APPLET.pptxAPPLET.pptx

More from Aishwarya SenthilNathan (13)

cloud computing.pptx
cloud computing.pptxcloud computing.pptx
cloud computing.pptx
 
IOT.pptx
IOT.pptxIOT.pptx
IOT.pptx
 
women empowerment.pptx
women empowerment.pptxwomen empowerment.pptx
women empowerment.pptx
 
Digital Image Processing.pptx
Digital Image Processing.pptxDigital Image Processing.pptx
Digital Image Processing.pptx
 
Artifical Intelligence And Machine Learning Algorithum.pptx
Artifical Intelligence And Machine Learning Algorithum.pptxArtifical Intelligence And Machine Learning Algorithum.pptx
Artifical Intelligence And Machine Learning Algorithum.pptx
 
Cloud Computing.pptx
Cloud Computing.pptxCloud Computing.pptx
Cloud Computing.pptx
 
SENTIMENT ANALYSIS OF FEEDBACK DATA USING MACHINE LEARNING TECHNIQUE.pptx
SENTIMENT ANALYSIS OF FEEDBACK DATA USING MACHINE LEARNING TECHNIQUE.pptxSENTIMENT ANALYSIS OF FEEDBACK DATA USING MACHINE LEARNING TECHNIQUE.pptx
SENTIMENT ANALYSIS OF FEEDBACK DATA USING MACHINE LEARNING TECHNIQUE.pptx
 
2D Graphics animation - Bouncing ball(Python).pptx
2D Graphics animation - Bouncing ball(Python).pptx2D Graphics animation - Bouncing ball(Python).pptx
2D Graphics animation - Bouncing ball(Python).pptx
 
Growth Of IOT NETWORK.pptx
Growth Of IOT NETWORK.pptxGrowth Of IOT NETWORK.pptx
Growth Of IOT NETWORK.pptx
 
DATA MINING.pptx
DATA MINING.pptxDATA MINING.pptx
DATA MINING.pptx
 
Software Engineering.pptx
Software Engineering.pptxSoftware Engineering.pptx
Software Engineering.pptx
 
HUMANOID ROBOTS.pptx
HUMANOID ROBOTS.pptxHUMANOID ROBOTS.pptx
HUMANOID ROBOTS.pptx
 
APPLET.pptx
APPLET.pptxAPPLET.pptx
APPLET.pptx
 

Recently uploaded

一比一原版(UOL文凭证书)利物浦大学毕业证如何办理
一比一原版(UOL文凭证书)利物浦大学毕业证如何办理一比一原版(UOL文凭证书)利物浦大学毕业证如何办理
一比一原版(UOL文凭证书)利物浦大学毕业证如何办理
eydeofo
 
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
xuqdabu
 
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
zpc0z12
 
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
xuqdabu
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
peuce
 
Production.pptxd dddddddddddddddddddddddddddddddddd
Production.pptxd ddddddddddddddddddddddddddddddddddProduction.pptxd dddddddddddddddddddddddddddddddddd
Production.pptxd dddddddddddddddddddddddddddddddddd
DanielOliver74
 
按照学校原版(QU文凭证书)皇后大学毕业证快速办理
按照学校原版(QU文凭证书)皇后大学毕业证快速办理按照学校原版(QU文凭证书)皇后大学毕业证快速办理
按照学校原版(QU文凭证书)皇后大学毕业证快速办理
8db3cz8x
 
一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理
一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理
一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理
byfazef
 
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理
xuqdabu
 
一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理
一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理
一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理
xuqdabu
 
一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理
一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理
一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理
kuehcub
 
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDARLORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
lorraineandreiamcidl
 
加急办理美国南加州大学毕业证文凭毕业证原版一模一样
加急办理美国南加州大学毕业证文凭毕业证原版一模一样加急办理美国南加州大学毕业证文凭毕业证原版一模一样
加急办理美国南加州大学毕业证文凭毕业证原版一模一样
u0g33km
 
按照学校原版(Birmingham文凭证书)伯明翰大学|学院毕业证快速办理
按照学校原版(Birmingham文凭证书)伯明翰大学|学院毕业证快速办理按照学校原版(Birmingham文凭证书)伯明翰大学|学院毕业证快速办理
按照学校原版(Birmingham文凭证书)伯明翰大学|学院毕业证快速办理
6oo02s6l
 
按照学校原版(Adelaide文凭证书)阿德莱德大学毕业证快速办理
按照学校原版(Adelaide文凭证书)阿德莱德大学毕业证快速办理按照学校原版(Adelaide文凭证书)阿德莱德大学毕业证快速办理
按照学校原版(Adelaide文凭证书)阿德莱德大学毕业证快速办理
terpt4iu
 
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
yizxn4sx
 
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
aozcue
 
按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理
按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理
按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理
uyesp1a
 
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Peter Gallagher
 
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
terpt4iu
 

Recently uploaded (20)

一比一原版(UOL文凭证书)利物浦大学毕业证如何办理
一比一原版(UOL文凭证书)利物浦大学毕业证如何办理一比一原版(UOL文凭证书)利物浦大学毕业证如何办理
一比一原版(UOL文凭证书)利物浦大学毕业证如何办理
 
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
一比一原版(Monash文凭证书)莫纳什大学毕业证如何办理
 
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
按照学校原版(UST文凭证书)圣托马斯大学毕业证快速办理
 
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide文凭证书)阿德莱德大学毕业证如何办理
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
 
Production.pptxd dddddddddddddddddddddddddddddddddd
Production.pptxd ddddddddddddddddddddddddddddddddddProduction.pptxd dddddddddddddddddddddddddddddddddd
Production.pptxd dddddddddddddddddddddddddddddddddd
 
按照学校原版(QU文凭证书)皇后大学毕业证快速办理
按照学校原版(QU文凭证书)皇后大学毕业证快速办理按照学校原版(QU文凭证书)皇后大学毕业证快速办理
按照学校原版(QU文凭证书)皇后大学毕业证快速办理
 
一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理
一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理
一比一原版(Greenwich文凭证书)格林威治大学毕业证如何办理
 
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理
一比一原版(TheAuckland毕业证书)新西兰奥克兰大学毕业证如何办理
 
一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理
一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理
一比一原版(UQ文凭证书)昆士兰大学毕业证如何办理
 
一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理
一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理
一比一原版(KCL文凭证书)伦敦国王学院毕业证如何办理
 
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDARLORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
LORRAINE ANDREI_LEQUIGAN_GOOGLE CALENDAR
 
加急办理美国南加州大学毕业证文凭毕业证原版一模一样
加急办理美国南加州大学毕业证文凭毕业证原版一模一样加急办理美国南加州大学毕业证文凭毕业证原版一模一样
加急办理美国南加州大学毕业证文凭毕业证原版一模一样
 
按照学校原版(Birmingham文凭证书)伯明翰大学|学院毕业证快速办理
按照学校原版(Birmingham文凭证书)伯明翰大学|学院毕业证快速办理按照学校原版(Birmingham文凭证书)伯明翰大学|学院毕业证快速办理
按照学校原版(Birmingham文凭证书)伯明翰大学|学院毕业证快速办理
 
按照学校原版(Adelaide文凭证书)阿德莱德大学毕业证快速办理
按照学校原版(Adelaide文凭证书)阿德莱德大学毕业证快速办理按照学校原版(Adelaide文凭证书)阿德莱德大学毕业证快速办理
按照学校原版(Adelaide文凭证书)阿德莱德大学毕业证快速办理
 
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
按照学校原版(Westminster文凭证书)威斯敏斯特大学毕业证快速办理
 
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
一比一原版(UCSB毕业证)圣塔芭芭拉社区大学毕业证如何办理
 
按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理
按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理
按照学校原版(Columbia文凭证书)哥伦比亚大学毕业证快速办理
 
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
Building a Raspberry Pi Robot with Dot NET 8, Blazor and SignalR - Slides Onl...
 
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
按照学校原版(UOL文凭证书)利物浦大学毕业证快速办理
 

LR PARSE.pptx

  • 1. NADAR SARASWATHI COLLEGE OF ARTS AND SCIENCE, VADAPUTHUPATTI,THENI. DEPARTEMENT OF COMPUTER SCIENCE LR PARSERS SUBMITTED BY: S.AISHWARYA LAKSHMI I MSC(CS)
  • 2. LR parser  LR parser is a bottom-up parser for context-free grammar that is very generally used by computer programming language compiler and other associated tools.  LR parser reads their input from left to right and produces a right-most derivation.  It is called a Bottom-up parser because it attempts to reduce the top-level grammar productions by building up from the leaves.  LR parsers are the most powerful parser of all deterministic parsers in practice.
  • 3. Description of LR parser :  The term parser LR(k) parser, here the L refers to the left-to- right scanning,  R refers to the rightmost derivation in reverse and k refers to the number of unconsumed “look ahead” input symbols that are used in making parser decisions.  Typically, k is 1 and is often omitted.  A context-free grammar is called LR (k) if the LR (k) parser exists for it.  This first reduces the sequence of tokens to the left.  But when we read from above, the derivation order first extends to non-terminal.
  • 4. Description of LR parser :  The stack is empty, and we are looking to reduce the rule by S’→S$.  Using a “.” in the rule represents how many of the rules are already on the stack.  A dotted item, or simply, the item is a production rule with a dot indicating how much RHS has so far been recognized.  Closing an item is used to see what production rules can be used to expand the current structure.
  • 5. Rules for LR parser :  The rules of LR parser as follows.  The first item from the given grammar rules adds itself as the first closed set.  If an object is present in the closure of the form A→ α. β. γ,  where the next symbol after the symbol is non- terminal, add the symbol’s production rules where the dot precedes the first item.  Repeat steps (B) and (C) for new items added under (B).
  • 6. LR parser algorithm :  LR Parsing algorithm is the same for all the parser, but the parsing table is different for each parser. It consists following components as follows.  Input Buffer – It contains the given string, and it ends with a $ symbol.  Stack – The combination of state symbol and current input symbol is used to refer to the parsing table in order to take the parsing decisions.
  • 7. Parsing Table :  Parsing table is divided into two parts- Action table and Go-To table. The action table gives a grammar rule to implement the given current state and current terminal in the input stream.  There are four cases used in action table as follows.  Shift Action- In shift action the present terminal is removed from the input stream and the state n is pushed onto the stack, and it becomes the new present state.  Reduce Action- The number m is written to the output stream.
  • 8. Parsing Table :  The symbol m mentioned in the left-hand side of rule m says that state is removed from the stack.  The symbol m mentioned in the left-hand side of rule m says that a new state is looked up in the goto table and made the new current state by pushing it onto the stack.  R parsers are used to parse the large class of context free grammars. This technique is called LR(k) parsing.  L is left-to-right scanning of the input.  R is for constructing a right most derivation in reverse.
  • 9. Parsing Table :  k is the number of input symbols of lookahead that are used in making parsing decisions.  There are three widely used algorithms available for constructing an LR parser:  SLR(l) – Simple LR  Few number of states, hence very small table.  Simple and fast construction.  Works on smallest class of grammar.
  • 10. Reasons for attractiveness of LR parser  LR parsers can handle a large class of context-free grammars.  The LR parsing method is a most general non-back tracking shift-reduce parsing method.  An LR parser can detect the syntax errors as soon as they can occur.  LR grammars can describe more languages than LL grammars.
  • 11. Drawbacks of LR parsers  It is too much work to construct LR parser by hand. It needs an automated parser generator.  If the grammar contains ambiguities or other constructs then it is difficult to parse in a left- to-right scan of the input.
  • 12. Behavior of the LR parser  1. If ACTION[sm, ai] = shift s. The parser executes the shift move, it shifts the next state s onto the stack, entering the configuration a) Sm – the state on top of the stack. b) ai– the current input symbol.
  • 13. Behavior of the LR parser  2. If ACTION[sm, ai] =reduce A—> β, then the parser executes a reduce move, entering the configuration (s0s1 … S(m-r)S, ai+l … an$) a) where r is the length of β and s= GOTO[sm – r, A]. b) First popped r state symbols off the stack, exposing state Sm-r·