SlideShare uma empresa Scribd logo
1 de 14
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!!!

Mais conteúdo relacionado

Mais procurados

Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignAkhil Kaushik
 
4_5802928814682016556.pptx
4_5802928814682016556.pptx4_5802928814682016556.pptx
4_5802928814682016556.pptxAshenafiGirma5
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignKuppusamy P
 
RECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGRECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGJothi Lakshmi
 
A Role of Lexical Analyzer
A Role of Lexical AnalyzerA Role of Lexical Analyzer
A Role of Lexical AnalyzerArchana Gopinath
 
Lecture2 general structure of a compiler
Lecture2 general structure of a compilerLecture2 general structure of a compiler
Lecture2 general structure of a compilerMahesh Kumar Chelimilla
 
Lecture 04 syntax analysis
Lecture 04 syntax analysisLecture 04 syntax analysis
Lecture 04 syntax analysisIffat Anjum
 
Syntax Directed Definition and its applications
Syntax Directed Definition and its applicationsSyntax Directed Definition and its applications
Syntax Directed Definition and its applicationsShivanandManjaragi2
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translationAkshaya Arunan
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generationAkshaya Arunan
 
LALR Parser Presentation ppt
LALR Parser Presentation pptLALR Parser Presentation ppt
LALR Parser Presentation pptWPVKP.COM
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design) Tasif Tanzim
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Aman Sharma
 

Mais procurados (20)

Back patching
Back patchingBack patching
Back patching
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler Design
 
4_5802928814682016556.pptx
4_5802928814682016556.pptx4_5802928814682016556.pptx
4_5802928814682016556.pptx
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler Design
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
Compiler: Syntax Analysis
Compiler: Syntax AnalysisCompiler: Syntax Analysis
Compiler: Syntax Analysis
 
RECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGRECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSING
 
A Role of Lexical Analyzer
A Role of Lexical AnalyzerA Role of Lexical Analyzer
A Role of Lexical Analyzer
 
COMPILER DESIGN- Syntax Directed Translation
COMPILER DESIGN- Syntax Directed TranslationCOMPILER DESIGN- Syntax Directed Translation
COMPILER DESIGN- Syntax Directed Translation
 
Lecture2 general structure of a compiler
Lecture2 general structure of a compilerLecture2 general structure of a compiler
Lecture2 general structure of a compiler
 
Lecture 04 syntax analysis
Lecture 04 syntax analysisLecture 04 syntax analysis
Lecture 04 syntax analysis
 
Syntax Directed Definition and its applications
Syntax Directed Definition and its applicationsSyntax Directed Definition and its applications
Syntax Directed Definition and its applications
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
LL(1) parsing
LL(1) parsingLL(1) parsing
LL(1) parsing
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
 
Parsing LL(1), SLR, LR(1)
Parsing LL(1), SLR, LR(1)Parsing LL(1), SLR, LR(1)
Parsing LL(1), SLR, LR(1)
 
LALR Parser Presentation ppt
LALR Parser Presentation pptLALR Parser Presentation ppt
LALR Parser Presentation ppt
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
 

Semelhante a LR PARSE.pptx

Semelhante a 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.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
 
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
 
Compiler unit 2&3
Compiler unit 2&3Compiler unit 2&3
Compiler unit 2&3
 

Mais de 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
 

Último

Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberCall Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberMs Riya
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...nagunakhan
 
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls KolkataCall Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一ga6c6bdl
 
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)kojalkojal131
 
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...Pooja Nehwal
 
Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...
Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...
Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...nagunakhan
 
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Pooja Nehwal
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样qaffana
 
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service GayaGaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service Gayasrsj9000
 
Top Rated Pune Call Girls Katraj ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Katraj ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Katraj ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Katraj ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Call Girls in Nagpur High Profile
 
Book Sex Workers Available Pune Call Girls Yerwada 6297143586 Call Hot India...
Book Sex Workers Available Pune Call Girls Yerwada  6297143586 Call Hot India...Book Sex Workers Available Pune Call Girls Yerwada  6297143586 Call Hot India...
Book Sex Workers Available Pune Call Girls Yerwada 6297143586 Call Hot India...Call Girls in Nagpur High Profile
 
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...nagunakhan
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一zul5vf0pq
 
Dubai Call Girls O528786472 Call Girls In Dubai Wisteria
Dubai Call Girls O528786472 Call Girls In Dubai WisteriaDubai Call Girls O528786472 Call Girls In Dubai Wisteria
Dubai Call Girls O528786472 Call Girls In Dubai WisteriaUnited Arab Emirates
 
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...ur8mqw8e
 
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...Pooja Nehwal
 
Top Rated Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Call Girls in Nagpur High Profile
 
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 

Último (20)

Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberCall Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
 
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls KolkataCall Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
 
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
 
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
 
Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...
Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...
Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...
 
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
 
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service GayaGaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
 
Top Rated Pune Call Girls Katraj ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Katraj ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Katraj ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Katraj ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
 
Book Sex Workers Available Pune Call Girls Yerwada 6297143586 Call Hot India...
Book Sex Workers Available Pune Call Girls Yerwada  6297143586 Call Hot India...Book Sex Workers Available Pune Call Girls Yerwada  6297143586 Call Hot India...
Book Sex Workers Available Pune Call Girls Yerwada 6297143586 Call Hot India...
 
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
 
Dubai Call Girls O528786472 Call Girls In Dubai Wisteria
Dubai Call Girls O528786472 Call Girls In Dubai WisteriaDubai Call Girls O528786472 Call Girls In Dubai Wisteria
Dubai Call Girls O528786472 Call Girls In Dubai Wisteria
 
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
 
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
 
Top Rated Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
 
🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate
🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate
🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate
 
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 

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·