Skip to content

// Anna University, Chennai / 2024

Anna University — Compiler Design (CS3501), April/May 2024

Compiler Design · CS3501 · R2021 · B.E. Computer Science and Engineering · Semester 5

Files open in a new tab. Use your browser's download or save option to keep a copy.

Work through the questions

16 questions

No verified answers are available for this paper.

  1. Question 1

    Part ADescriptive2 marks

    Compilers

    State the difference between a compiler and an interpreter.

    No verified answer or solution is available for this question.

  2. Question 2

    Part ADescriptive2 marks

    Compilers

    Define the interaction between lexical analyzers and parsers.

    No verified answer or solution is available for this question.

  3. Question 3

    Part ADescriptive2 marks

    Compilers

    What are the common programming errors that can occur at different levels?

    No verified answer or solution is available for this question.

  4. Question 4

    Part ADescriptive2 marks

    Compilers

    What is the purpose of LR parsers?

    No verified answer or solution is available for this question.

  5. Question 5

    Part ADescriptive2 marks

    Compilers

    Define inherited attribute.

    No verified answer or solution is available for this question.

  6. Question 6

    Part ADescriptive2 marks

    Compilers

    State the rules of type checking.

    No verified answer or solution is available for this question.

  7. Question 7

    Part ADescriptive2 marks

    Compilers

    What are two strategies for dynamic storage allocation?

    No verified answer or solution is available for this question.

  8. Question 8

    Part ADescriptive2 marks

    Compilers

    Write the role of activation record.

    No verified answer or solution is available for this question.

  9. Question 9

    Part ADescriptive2 marks

    Compilers

    What are the causes of redundancy?

    No verified answer or solution is available for this question.

  10. Question 10

    Part ADescriptive2 marks

    Compilers

    What is copy propagation?

    No verified answer or solution is available for this question.

  11. Question 11

    Part BDescriptive13 marks

    Compilers

    (a) (i) Divide the following C++ program. (5) float limitedSquare(x) { /* returns x-squared, but never float x; more than 100*/ return (x<=-10.0||x>=10.0)? 100:x*x; } Into appropriate lexemes. Which lexemes should get associated lexical values? What should those values be? (ii) Explain the role of lexical analyzer. (8) (OR) (b) (i) Describe the languages denoted by the following regular expressions : (5) (1) a(a|b)*a (2) ((ε|a)b*)* (3) (a|b)*a(a|b)(a|b) (4) a*ba*ba*ba* (5) !!(aa|bb)*((ab|ba)(aa|bb)* (ab|ba)(aa|bb)*)*. (ii) Explain the construction of a DFA from a regular expression. (8)

    No verified answer or solution is available for this question.

  12. Question 12

    Part BDescriptive13 marks

    Compilers

    (a) (i) Consider the context-free grammar. S -> SS+ | SS* | a and the string aa + a* (1) Give a leftmost derivation for the string. (1) (2) Give a rightmost derivation for the string. (1) (3) Give a parse tree for the string. (1) (4) Is the grammar ambiguous or unambiguous? Justify your answer. (2) (ii) Explain the error handling and error recovery mechanism of syntax analyser. (8) (OR) (b) (i) Show that the following grammar. (5) S -> SA | A A -> a is SLR(1) but not LL(1). (ii) State and explain the algorithm to eliminate left recursion from a grammar. (8)

    No verified answer or solution is available for this question.

  13. Question 13

    Part BDescriptive13 marks

    Compilers

    (a) (i) The expressions involving operator + and integer or floating-point operands. Floating-point numbers are distinguished by having a decimal point. (5) E -> E+T | T T -> num.num | num Give an SDD to determine the type of each term T and expression E. (ii) Explain the S-Attribute Definitions with example. (8) (OR) (b) (i) Translate the arithmetic expression a + (b + c) into (5) (1) Syntax tree (2) Quadruples. (ii) State and explain the translation of expressions and the addressing array elements with example. (8)

    No verified answer or solution is available for this question.

  14. Question 14

    Part BDescriptive13 marks

    Compilers

    (a) What are the issues in the design of a code generator? Explain with example. (OR) (b) Explain the stack allocation of space with example? What principles are helpful when designing calling sequences?

    No verified answer or solution is available for this question.

  15. Question 15

    Part BDescriptive13 marks

    Compilers

    (a) What are induction variable and how to find the induction variable in loops and optimize their computation. Explain with example. (OR) (b) Explain the optimization of basic blocks? How does the Directed Acyclic Graph (DAG) representation of a basic block facilitate code-improving transformations within the represented code?

    No verified answer or solution is available for this question.

  16. Question 16

    Part CDescriptive15 marks

    Compilers

    (a) Construct the DAG and identify the value numbers for the subexpressions of the following expressions, assuming + associates from the left. (i) a + b + (a + b) (ii) a + b + a + b (iii) a + a + (a + a + a + (a + a + a + a)). (OR) (b) Explain the steps involved in the construction of predictive parser with suitable example.

    No verified answer or solution is available for this question.

Keep preparing

Revisit another year or explore a different paper in the library.

More from this exam