- 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
Find Canonical Parsing Table (CLR) or LR (1) Parsing Table for Grammar.nS ā CCnC ā c C | d
Solution
Step1 − Construct Augmented Grammar
(0) S′ → S
(1) S → CC
(2) C → cC
(3) C → d.
Step2 − Find closure & goto to construct LR (1) items
Applying goto on I7, I8, I9
In 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 DFA
First 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 will be an edge from I0 to I1 labeled S.
Similarly, other nodes are connected by seeing all goto statements in LR (1) items of grammar.
- Related Articles
- Consider the Grammar\nS ā CC\nC ā c C | d\nConstruct the parsing table for LALR (1) parser.
- Constructing LALR (1) Parsing table for a given grammar.\nProblem− Construct LALR (1) Parsing table for the grammar.\nS ā A a|b A c|dc|bda\nA ā d\nParse input string "bdc" using LALR Parsing Table.
- Consider the ambiguous grammar.\nE ā E + E\nE ā E * E\nE ā (E)\nE ā id\n(a) Construct LR (0) items for above grammar.\n(b) Construct SLR parsing table for grammar.\n(c) Parse the input string id + id * id.
- Construct a Predictive Parsing table for the following grammar & also check whether string \nid + id * id is accepted or not.
- What is Implementation of LR Parsing Tables?
- Construct SLR (1) parsing table for the following grammar\nS ā x A y |x B y |x A z\nA ā q s | q\nB ā q
- Construct the SLR Parsing table for the following grammar. Also, Parse the input string a * b + a.
- How to Fill the Entries in Parsing Table?
- Verifying whether the string id * id + id is accepted by a given grammar using SLR parsing\nConsider the SLR parsing table for the Grammar\nE ā E + T\nE ā T\nT ā T ā F\nT ā F\nF ā (E)\nF ā id\nCheck whether the string id * id + id is accepted or not by using the SLR parsing table constructed in the example.
- Parsing Command Line Parameters in C++ Program
- Program to Find Out the Minimum Parsing Tree in C++
- Show that the following grammar is LR (1)\nS ā A a |b A c |B c | b B a\nA ā d\nB ā d
- Construct SLR (1) parsing table for the grammar\n1. E ā E + T\n2. E ā T\n3. T ā T * F\n4. T ā F\n5.F ā (E)\n6.F ā id
- Parsing a comma-delimited std::string in C++
- Difference between Top-Down Parsing and Bottom-Up Parsing

Advertisements