Question 1 | MCQ
THIS IS QUESTION PAPER FOR THE SUBJECT "DEGREE LEVEL : COMPILER DESIGN (COMPUTER
BASED EXAM)"
ARE YOU SURE YOU HAVE TO WRITE EXAM FOR THIS SUBJECT?
CROSS CHECK YOUR HALL TICKET TO CONFIRM THE SUBJECTS TO BE WRITTEN.
(IF IT IS NOT THE CORRECT SUBJECT, PLS CHECK THE SECTION AT THE TOP FOR THE SUBJECTS REGISTERED BY YOU)
BASED EXAM)"
ARE YOU SURE YOU HAVE TO WRITE EXAM FOR THIS SUBJECT?
CROSS CHECK YOUR HALL TICKET TO CONFIRM THE SUBJECTS TO BE WRITTEN.
(IF IT IS NOT THE CORRECT SUBJECT, PLS CHECK THE SECTION AT THE TOP FOR THE SUBJECTS REGISTERED BY YOU)
Solution
Consider the regular language

over the alphabet

Which of the following strings belong to
? (Select all that apply.)
over the alphabet
Which of the following strings belong to
Solution
A lexical analyzer uses the following rules.

The keyword rule has higher priority than the identifier rule.
Input

Which of the following gives the correct number of Keyword, Identifier, and Number tokens?
The keyword rule has higher priority than the identifier rule.
Input
Which of the following gives the correct number of Keyword, Identifier, and Number tokens?
Solution
Convert the following infix expression to postfix notation:

Which one of the following is the correct postfix expression?
Which one of the following is the correct postfix expression?
Solution
A parser generator performs the following steps:
1. Construct the canonical LR(1) collection of item sets.
2. Merge all states having the same LR(0) core.
3. Construct the ACTION and GOTO tables from the merged automaton.
Which parsing technique is obtained after these steps?
1. Construct the canonical LR(1) collection of item sets.
2. Merge all states having the same LR(0) core.
3. Construct the ACTION and GOTO tables from the merged automaton.
Which parsing technique is obtained after these steps?
Solution
Consider the grammar

The initial state is

Which of the following is GOTO(I0, b) ?
The initial state is
Which of the following is GOTO(I0, b) ?
Solution
Consider the grammar:

A shift-reduce parser is parsing the input:

The parser has already performed the following actions:

What should be the next action?
A shift-reduce parser is parsing the input:
The parser has already performed the following actions:
What should be the next action?
Solution
Consider the production

The semantic rules are

Which of the following is the minimum valid attribute evaluation sequence?
The semantic rules are
Which of the following is the minimum valid attribute evaluation sequence?
Solution
Consider the following overloaded functions.

The compiler evaluates the following function calls.

Which one of the following function calls requires integer promotion before overload resolution selects the best match?
The compiler evaluates the following function calls.
Which one of the following function calls requires integer promotion before overload resolution selects the best match?
Solution
An embedded SDT contains the production

To convert it into an equivalent postfix SDT while preserving the execution point of the action
, which of the following transformations is correct?
To convert it into an equivalent postfix SDT while preserving the execution point of the action
Solution
Inscript
Consider the alphabet


Consider the alphabet
Solution
Inscript
Consider the following operator grammar:

An operator-precedence parser is used to parse the expression

using the following precedence and associativity rules:
-
has higher precedence than
.
- Both operators are left associative .
Ignoring the end marker
, how many reduce operations are performed by the parser while parsing the expression?
Consider the following operator grammar:
An operator-precedence parser is used to parse the expression
using the following precedence and associativity rules:
-
- Both operators are left associative .
Ignoring the end marker
Solution
Consider the grammar

and the following recursive descent parser.

Assume that:
- Parsing starts by calling
.
-
consumes the current input symbol only if it matches the expected symbol.
- Any call that reports an error (i.e., executes
) immediately causes the parse to fail, even if the final lookahead is
.
- After
returns, the input is accepted only if no error has been reported and the current lookahead is
.
Which of the following input strings is/are accepted?
and the following recursive descent parser.
Assume that:
- Parsing starts by calling
-
- Any call that reports an error (i.e., executes
- After
Which of the following input strings is/are accepted?
Solution
A context-free grammar contains the productions

Which language is generated?
Which language is generated?
Solution
Consider the following statements about SLR(1), Canonical LR(1), and LALR(1) parsers.
1. Every SLR(1) grammar is also an LALR(1) grammar.
2. Every LALR(1) grammar is also an LR(1) grammar.
3. Every LR(1) grammar is also an LALR(1) grammar.
Which of the following is correct?
1. Every SLR(1) grammar is also an LALR(1) grammar.
2. Every LALR(1) grammar is also an LR(1) grammar.
3. Every LR(1) grammar is also an LALR(1) grammar.
Which of the following is correct?
Solution
Consider the grammar.

Which of the following correctly gives FIRST(S) and FOLLOW(X)?
Which of the following correctly gives FIRST(S) and FOLLOW(X)?
Solution
A student wants the exponentiation operator (
) to have higher precedence than multiplication. They write the following Bison declarations.

For the expression

which of the following statements are correct? (Select all that apply.)
For the expression
which of the following statements are correct? (Select all that apply.)
Solution
Consider the SDD.

Which of the following statements are correct?
Which of the following statements are correct?
Solution
Shape
Thickness [ / ]
3
All colors