Compiler Design - B.Tech. 6th Semester Examination, 2022
Compiler Design
Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
-
Which of the following derivations does a top-down parser use while parsing an input string? The input is assumed to be scanned in left to right order.
-
What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon- and unit-production (i.e., of type \( A \rightarrow \epsilon \) and \( A \rightarrow a \)) to parse a string with n tokens?
-
In a bottom-up evaluation of a syntax directed definition, inherited attributes can
-
Consider the grammar shown below : \( S \rightarrow CC \), \( C \rightarrow cC | d \). The grammar is
-
The lexical analyzer takes _____ as input and produces a stream of _____ as output.
-
In a compiler, when is the keywords of a language are recognized?
-
How many tokens are there in the following C statement?
printf("j=%d, & j=%x", j, & j) -
How is the parsing precedence relation defined?
-
Given the following expression grammar : \( E \rightarrow E*F | F+E | F \), \( F \rightarrow F-F | id \). Which of the following is true?
-
Shift reduce parsers are
-
Write a lexical analyzer program to identify strings, sequences, comments, reserved words and identifiers.
-
Explain about the sources and criterions of code optimization as machine dependent and independent types.
-
Construct the non-recursive predictive parse table for the given grammar and check the acceptance of input string "abfcg":
\( S \rightarrow A \)
\( A \rightarrow aB | Ad \)
\( B \rightarrow bBC | f \)
\( C \rightarrow cg \) -
What is the relationship with lexical analyzer, regular expressions and transition diagram? Give an example.
-
Explain the type system in type checker. Write the syntax directed definition for type checker.
-
What is activation record? Explain its usage in stack allocation strategy. How is it different from heap allocation?
-
Draw and explain the runtime memory organization static storage allocation strategy with pros and cons.
-
Differentiate inherited and synthesized attributes with an example.
-
Define dataflow analysis. List out the procedures to analyze the data flow of structured programs.
-
Draw a block diagram of phases of a compiler and indicate the main functions of each phase.
-
What is intermediate code? Translate the expression \( (a+b)/(c+d)*(a+b/c)-d \) into quadruples, triples and indirect triples.
-
Explain reducible and non-reducible flow graphs with an example each.
-
What is machine-dependent optimization? Explain how peephole techniques function in this.
-
Explain how type checking and error reporting are performed in compiler. Draw syntax tree and DAG for the statement: \( a=(a*b+c)\wedge(b+c)*b+c \)