- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 205 Articles for Computer Programming
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
3K+ Views
SolutionStep1 − First of all, convert it into augmented grammar G′ and number the productions(0) S′ → S(1) S → L = R(2) S → R(3) L →∗ R(4) L → id(5) R → LStep2 − Find closure and goto function to construct LR (0) items.In the following set of LR (0) items, Boxes represents the new states and circle represents Repeating statesStep3− Computation of FOLLOW− Applying Rule (1) of FOLLOW, we getFOLLOW(S) = $ (1)S ... Read More
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
48K+ Views
SLR ParserSLR represents "Simple LR Parser". It is very easy and cost-effective to execute. The SLR parsing action and goto function from the deterministic finite automata that recognizes viable prefixes. It will not make specificially defined parsing action tables for all grammars but does succeed on several grammars for programming languages. Given a grammar G. It augment G to make G’, and from G’ it can construct C, the canonical collection of a set of items for G’. It can construct ACTION the parsing action function, and GOTO, the goto function, from C using the following simple LR Parsing table ... Read More
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
305 Views
A parser is the second phase of compilation. The parser takes as its input tokens generated from the previous phase, i.e., the Lexical Analyzer phase, and groups them in such a way that their syntax can be recognized.For example, Consider I0I0 − E′ → ∙ E E → ∙ E + T E → ∙ T T → ∙ T ∗ F T → ∙ F F → ∙ (E) F → ∙ idFilling of Shifting EntriesApplying Rule (2a) of the algorithm of construction of SLR Parsing Table on a set of a ... Read More
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
746 Views
SolutionSteps to produce SLR Parsing TableGenerate Canonical set of LR (0) itemsCompute FOLLOW as required by Rule (2b) of Parsing Table Algorithm.Computation of FOLLOWBy Rule (1) of FOLLOWFOLLOW(E) = {$} (1)E → E + TApplying Rule (2) FOLLOWi.e., comparing E → E + T with A → α B βE →ΕE+ TA →ΑBΒ∴ A = E, α = ε, B = E, β = +T∵ Since FIRST(β) = FIRST(+T) = {+}which does not contain ε.∴ ... Read More
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
5K+ Views
SLR represents "Simple LR Parser". It is very simple and economical to execute. But it fails to make a parsing table for some class of grammars, i.e., why CLR and LALR are used which implements mainly all class or type of grammars. It constructs parsing tables which helps to perform parsing of input strings.SLR(1) − A grammar having an SLR parsing table is said to be SLR (1).Working of SLR ParserSLR Parsing can be done if context-free Grammar will be given. In LR (0), 0 means there is no Look Ahead symbol.The Canonical collection of LR (0) itemsThe LR (0) ... Read More
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
2K+ Views
SolutionStep1− Construct the Augmented Grammar and number the productions(0) E′ → E(1) E → E + T(2) E → T(3) T → T * F(4) T → F(5) F → (E)(6) F → idStep2− Apply closure to the set of items & find gotoSquare Boxes represent the new states or items, and Circle represents the repeating items.So, all rules of I0have been completed by applying goto on I0. Now, in the same manner apply goto on I1, I2 and then goes on.Drawing DFAEach set of the item can be taken as a state of DFA, i.e., I0, I1 … … ... Read More
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
5K+ Views
The LR (0) item for Grammar G consists of a production in which symbol dot (.) is inserted at some position in R.H.S of production.For Example − For the production S → ABC, the generated LR (0) items will be −S →∙ ABCS → A ∙ BCS → AB ∙ CS → ABC ∙Production S → ε generates only one item, i.e., S →∙Canonical LR (0) collection helps to construct LR parser called Simple LR (SLR) parser.To create Canonical LR (0) collection for Grammar, 3 things are required −Augmented GrammarClosure Functiongoto FunctionAugmented Grammar − If grammar G has start symbol ... Read More
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
2K+ Views
LR Parser is a class of Bottom-Up Parser that is used to parse Context-Free Grammars. LR Parsing is known as LR (K) parsing whereL represents Left to Right Scanning of InputR represents Rightmost DerivationK is the number of input symbols of Look ahead that are used in developing parsing decisions.LR parser is a shift-reduce parser that creates the use of deterministic finite automata, identifying the collection of all applicable prefixes by reading the stack from bottom to top.It decides what handle, if any, is feasible. An achievable prefix of a right sentential form is that prefix that includes a handle, ... Read More
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
2K+ Views
Top-Down Parsing with BacktrackingIn Top-Down Parsing with Backtracking, Parser will attempt multiple rules or production to discover the match for input string by backtracking at every step of derivation. So, if the used production does not give the input string as needed, or it does not match with the needed string, then it can undo that shift.Top-Down Parsing without BacktrackingAs backtracking looks more powerful by which we can select different alternatives. But backtracking cannot be applied or implemented so easily in parsing. There are two types of Top-Down Parsing without Backtracking, which are as follows −Recursive Descent ParserPredictive ParserRecursive Descent ... Read More