0% found this document useful (0 votes)
63 views2 pages

Assignment # 2 (Clo2) Submission Date: 18-11-19 Compiler Construction BCS-7C By: Yasir Awan Q. 1

This document contains 3 questions regarding compiler construction and parsing. Question 1 involves constructing LR parsing tables for a grammar with production rules E →(L) | a and L → L, E| E. Question 2 involves constructing LR parsing tables for the grammar with production rule S → S(S) | ε. Question 3 asks to trace the behavior of a panic mode error recovery mechanism for the input string "*2." using a given parsing table.

Uploaded by

Yasir Awan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views2 pages

Assignment # 2 (Clo2) Submission Date: 18-11-19 Compiler Construction BCS-7C By: Yasir Awan Q. 1

This document contains 3 questions regarding compiler construction and parsing. Question 1 involves constructing LR parsing tables for a grammar with production rules E →(L) | a and L → L, E| E. Question 2 involves constructing LR parsing tables for the grammar with production rule S → S(S) | ε. Question 3 asks to trace the behavior of a panic mode error recovery mechanism for the input string "*2." using a given parsing table.

Uploaded by

Yasir Awan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

ASSIGNMENT # 2 (CLO2) Submission Date : 18-11-19

Compiler Construction BCS-7C By : Yasir Awan

Q. 1
Consider the following grammar:
E →(L) | a
L → L, E| E
Part-I
a) Construct the DFA of LR(0) items for this grammar.
b) Construct the SLR(1) parsing table for this grammar.
c) Show the parsing stack and the actions of an SLR(1) parser for the input string
( ( a ), a , (a , a ) ).
d) Is this grammar an LR (0) grammar? If not, describe the LR(0) conflict. If so,
construct the LR(0) parsing table, and describe how a parse might differ from an
SLR(1) parse.
Part-II
a) Construct the DFA of LR(1) items for this grammar.
b) Construct the general LR(1) parsing table.
c) Construct the DFA of LALR(1) items for this grammar.
d) Construct the LALR(1) parsing table.
e) Describe any difference that might occur between the actions of a general LR(1)
parser and an LALR(1) parser.

Q.2
Consider the following grammar:
S → S(S) | ∈
Part-I
a) Construct the DFA of LR(0) items for this grammar.
b) Construct the SLR(1) parsing table for this grammar.
c) Show the parsing stack and the actions of an SLR(1) parser for the input string
( ( ) ( ) ).
d) Is this grammar an LR (0) grammar? If not, describe the LR(0) conflict. If so,
construct the LR(0) parsing table, and describe how a parse might differ from an
SLR(1) parse.
Part-II
a) Construct the DFA of LR(1) items for this grammar.
b) Construct the general LR(1) parsing table.
c) Construct the DFA of LALR(1) items for this grammar.
Q. 3

Trace the behavior of a panic mode error recovery mechanism for the string (*2. using
the following parsing table. (As is discussed on page 246. Example 5.19) the DFA is given
on page 233.(Louden book)
State INPUT Goto

Number ( + - * ) $ command exp term Factor

0 s5 s6 1 2 3 4

1 accept

2 r1 r1 s7 s8 r1 r1 r1

3 r4 r4 r4 r4 s9 r4 r4

4 r6 r6 r6 r6 r6 r6 r6

5 r7 r7 r7 r7 r7 r7 r7

6 s5 s6 10 3 4

7 s5 s6 11 4

8 s5 s6 12 4

9 s5 s6 13

10 s7 s8 s14

11 r2 r2 r2 r2 s9 r2 r2

12 r3 r3 r3 r3 s9 r3 r3

13 r5 r5 r5 r5 r5 r5 r5

14 r8 r8 r8 r8 r8 r8 r8

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy