2. Module-1 Chapter 1
Introduction: Language Processors, The structure of Compiler, The evolution of
Programming Languages, The science of Building a Compiler, Applications of Compiler
Technology, Programming Language Basics
1. Define Compiler. Differentiate between Compiler and Interpreter and Lexical analyzer v/s
Paser.
2. With an neat diagram , explain Language Processing System.
3. Explain various phases of compiler. Show the translation for an Assignment statement:
Position = initial + rate * 60.
4. Write a note on the following
a. The evolution of Programming Language c. Science of building a compiler
b. Application of Compiler Technology
5. Explain Environment and state variables. Difference between Static and dynamic Scope with an
example.
Module-1 Chapter 2
A Simple Syntax Directed Translator: Introduction, Syntax Definition, Syntax Directed Translation, Parsing.
1. Explain the concept of syntax directed definition.
i) Give a SDD for a simple desk calculator / simple type declaration
2. Write a postfix SDT for desk calculator and show parser stack implementation.
3. What is annotated parse tree, Parse tree and syntax tree?
Construct Syntax tree, parse tree and annotated PT for the input string 3 * 5 + 4n.
4. Write annotated parse tree for expression 5 + 4 * 3n and (3+4)*(5+6)where grammar is
L -> En
E-> E+T|T
T ->T*F |F
F -> (E) digit
5. Define SDD. Explain synthesis attribute and inherited attribute with an example.
6. What is parser. Explain the role of parser with neat diagram. Explain its types.
7. What is Top down Parser. Briefly explain problem associated with top down parser.
3. Module-2 Chapter 1
Lexical Analysis: The Role of Lexical Analyzer, Input buffering, Specification of Tokens,
Recognition of Tokens, The lexical Analyzer Generator Lex.
1. Explain the role of lexical analysis.
2. What is meant by input buffering? Write an algorithm for look ahead code with sentinels.
3. List and explain reasons for separating analysis portion of a compiler into lexical analysis and
syntax analysis phases.
4. What are tokens, patterns, lexemes, attributes for tokens. Identify tokens, patterns , lexemes for
the following
a) printf(“Total=%d/n”,score);
b) Const pi=3.1416;
c) float limited square(x) float x {
/*returns x-squared, but never more than 100*/
return(x<=-10.0 || x>=10.0)?100:x*x;
}
Into appropriate lexemes. Which lexemes should get lexical values.
5. Write definition of operations on languages.
6. What are regular expression and regular set. Write algebraic laws for regular expressions.
7. Explain specification of tokens(Strings,language,alphabets,prefix/suffix strings etc).
8. Write regular definition for
a) Identifiers b) unsigned numbers. C) tokens
9. Construct the transition diagram for recognizing the following
a. Unsigned numbers c. relop e. reserved words and Identifers
b. Whitespace d. Delimiters
10. Construct the transition diagrams for a set of keywords like begin, end, if then and else and.
identifiers and constants along with a minimum set of relational operators.
11. Explain the structure of lex with its specification (Language for specifying lexical analyzers)
4. Module-2 Chapter 2
Syntax Analysis: Introduction, Context Free Grammars, Writing a Grammar
1. Explain the role of parser. Explain error recovery strategies.
2. Give a formal definition of a CFG. Design a CFG for a simple arithmetic expression.
3. What is left recursion? Explain with an algorithm for eliminating the same with an example.
4. What is left factoring? Rewrite the following grammar after "left factored
1) S->iEts | iEtSeS | a 2) S->bSSaaS| bSSaSb| bSb | a
E->b
5. What is ambiguous grammar? Show that following grammar is ambiguous:
S->S+S|S*S|id. Give an unambiguous grammar for the above grammar such that has highest
priority and has less priority and both are left associative.
6. Consider the context free grammar S → SS + ISS SSa
And the string aa + a*
i) Give a left most derivation for the string
ii) Give a right most derivation for the string
iii) Give a parse tree for the string
iv) Is the grammar ambiguous or unambiguous? Justify.
v). Describe the language generated by this grammar
vi) Remove the left recursion from the grammar?
vii) Left factor this grammar