Find Canonical Parsing Table (CLR) or LR (1) Parsing Table for Grammar.
S ā†’ CC
C ā†’ 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.

Ginni
Ginni

e

Updated on: 02-Nov-2021

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements