- 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 138 Articles for Compiler Design
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
5K+ Views
SolutionStep1 − Construct LR (1) Set of items. First of all, all the LR (1) set of items should be generated.In these states, states I3 and I6 can be merged because they have the same core or first component but a different second component of Look Ahead.Similarly, states I4 and I7 are the same.Similarly, states I8 and I9 are the same.So, I3 and I6 can be combined to make I36.I4 and I7 combined to make I47.I8 and I9 combined to make I89.So, the states will be∴ I3 = goto (I0, c)But I3 , I6 combined to make I36∴ I36 = ... Read More
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
4K+ Views
LALR Parser is Look Ahead LR Parser. It is intermediate in power between SLR and CLR parser. It is the compaction of CLR Parser, and hence tables obtained in this will be smaller than CLR Parsing Table.Here, first of all, we will construct LR (1) items. Next, we will look for the items having the same first component, and they are merged to form a single set of items. It means the states have the same first component, but the different second component can be integrated into a single state or item.For Example.Suppose ifI4: C → d ∙ , c ... Read More
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
5K+ Views
SolutionStep1 − Construct Augmented Grammar(0) S′ → S(1) S → CC(2) C → cC(3) C → d.Step2 − Find closure & goto to construct LR (1) itemsApplying goto on I7, I8, I9In I7, I8, I9 we have production C → d ∙, $, c → cC ∙, c | d and ∙ C → cC ∙, $ respectively, i.e., the dot cannot be shifted further.So, goto cannot be applied to I7, I8, I9.Drawing DFAFirst of all, 10 states, i.e., I0 to I9 will act as nodes for DFA.Edges are joined using goto statements. For example, goto(I0, S) = I1∴ There ... Read More
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
4K+ Views
CLR defines canonical lookahead. CLR parsing use the canonical collection of LR (1) items to construct the CLR (1) parsing table. CLR (1) parsing table makes the more number of states as compare to the SLR (1) parsing. In the CLR (1), it can locate the reduce node only in the lookahead symbols.Working of CLR ParserConstruction of LR (1) collection of items for GrammarIt requires three thingsAugmented GrammarClosure Functiongoto FunctionAugmented Grammar It is a new Grammar G′ which contains a new productionS′ → S with all other productions of given grammar G.Closureprocedure closure (I)begin Repeat for each item A → ... Read More
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
31K+ Views
Description − Consider the GrammarE → E + T|TT → TF|FF → F*|a|b.SolutionStep1 − Construct the augmented grammar and number the productions.(0) E′ → E(1) E → E + T(2) E → T(3) T → TF(4) T → F(5) F → F ∗(6) F → a(7) F → b.Step2 − Find closure & goto Functions to construct LR (0) items.Box represents the New states, and the circle represents the Repeating State.Computation of FOLLOWWe can find outFOLLOW(E) = {+, $}FOLLOW(T) = {+, a, b, $}FOLLOW(F) = {+, *, a, b, $}Parsing for Input String a * b + a −Stack ... Read More
![Ginni](https://www.tutorialspoint.com/assets/profiles/315708/profile/60_2311-1620134876.jpg)
3K+ Views
SolutionStep1 − Construct Augmented Grammar(0) S′ → S(1) S → x A y(2) S → x B y(3) A → q S(4) A → q(5) B → qStep2 − Find Closure & goto functions to construct LR (0) items. Here Boxes represent New States and Circles represent the repeating state.Step3 − Computation of FOLLOWS → x A yFOLLOW(S) = {$} (1)Applying Rules (2a) of FOLLOW.Comparing S → x a y with A → ... Read More
![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