0% found this document useful (0 votes)
6 views

Assignment 2

The document outlines various assignments related to parsing techniques and grammar analysis, including constructing predictive parsing tables, operator precedence relation tables, and LL(1) parsing tables. It also involves checking for ambiguity in grammars and generating three-address code for a function processing a 3D array. Each question requires specific tasks such as parsing strings, determining handles, and analyzing grammar properties.

Uploaded by

Vidushi Varshney
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Assignment 2

The document outlines various assignments related to parsing techniques and grammar analysis, including constructing predictive parsing tables, operator precedence relation tables, and LL(1) parsing tables. It also involves checking for ambiguity in grammars and generating three-address code for a function processing a 3D array. Each question requires specific tasks such as parsing strings, determining handles, and analyzing grammar properties.

Uploaded by

Vidushi Varshney
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment 2

Q1. a) Construct a predictive parsing table for the following grammar:

b) Parse the string using Predictive parsing table

Q.2 (a) Consider the following grammar . What is the total number of handles in the right
sentential form for the string

(b) Consider the following grammar G1 and G2. Find which grammar G1 and (or) G2 are
Ambiguous or not?
G1: G2:
(c) Consider the grammar a X +SY | Yb | What is the cardinality (Number of elements)
of FOLLOW(S) ?

Q3. Consider the following grammar for Boolean Expression as

a) Generate the operator precedence relation table (OPRT) for this grammar.
b) Parse the string using OPRT
c) Construct an operator function table (OFT) for OPRT
d) Discuss the advantages of OFT over OPRT.

4. a) Construct LL(1) parsing table for the following grammar:

b) Check whether belongs to the grammar or not using parsing table

Q.5 (a) Consider the following grammar . The total number of handles in the
right sentential form for the string is ………….
Consider the following grammar G1 and G2. Find which grammar G1 and (or) G2 are
Ambiguous or not?
G1: G2:
Consider the grammar: . What is the cardinality (Number of elements) of FOLLOW(S) ?

6. Consider the following grammar and check whether it is LL(1) or not:

7.Write the Three-Address Code (TAC) for the following function that processes a 3D array.

void process3DArray(int A[2][2][2]) {


for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
for (int k = 0; k < 2; k++) {
A[i][j][k] *= 2;
}
}
}
}

Three-Address Code (TAC)

You might also like