// 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.
State the difference between a compiler and an interpreter.
No verified answer or solution is available for this question.
Define the interaction between lexical analyzers and parsers.
No verified answer or solution is available for this question.
What are the common programming errors that can occur at different levels?
No verified answer or solution is available for this question.
What is the purpose of LR parsers?
No verified answer or solution is available for this question.
Define inherited attribute.
No verified answer or solution is available for this question.
State the rules of type checking.
No verified answer or solution is available for this question.
What are two strategies for dynamic storage allocation?
No verified answer or solution is available for this question.
Write the role of activation record.
No verified answer or solution is available for this question.
What are the causes of redundancy?
No verified answer or solution is available for this question.
What is copy propagation?
No verified answer or solution is available for this question.
(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.
(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.
(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.
(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.
(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.
(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.