CS3501 CD Qb-Unit 3
CS3501 CD Qb-Unit 3
PART – A
1. What is meant by backpatching? (Nov/Dec 2023)
Backpatching is a technique used in compiler design for managing the generation
of intermediate code, especially in the context of handling control flow statements
such as loops and conditional statements
2. What is meant by type checking? (Nov/Dec 2023)
Type checking is a process in programming language compilers and interpreters
that ensures that the operations in a program are performed on compatible data types.
This process can occur at various stages of program execution
3. Write three address code sequence for the assignment Statement.
(Nov/Dec 2021)
d := (a −b) + (a − c) + (a − c).
t1:=a−b
t2:=a−ct2 := a - ct2:=a−c
t3:=t1+t2t3 := t1 + t2t3:=t1+t2
Page 1 of 7
t4:=t3+t2t4 := t3 + t2t4:=t3+t2
d:=t4d := t4d:=t4
4. How do you identify predictive parser and non-recursive
predictive parser?
(Nov/Dec 2021)
A predictive parser is a type of top-down parser for a subset of context-free
grammars, typically LL(1) grammars. These parsers use a lookahead symbol to
make parsing decisions and do not involve backtracking.
A non-recursive predictive parser is a type of predictive parser that uses a stack and
parsing table instead of recursive procedures. This makes it iterative rather than
recursive.
1. Syntax Trees
2. Postfix notation
3. Three Address Code
7. Write the semantic action for the production rule of E ->E1 OR M
E2. E -> E1 OR M E2 { E.value = E1.value || E2.value;
(Nov/Dec 2020)
(0) + a b t1
(1) − t1 t2
(2) + c d t3
(3) ∗ t2 t3 t4
Page 2 of 7
Location Operator arg 1 arg 2 Result
(4) + t1 c t5
(5) − t4 t5 t6
9. Translate the arithmetic expression a * -(b+c) into syntax tree and postfix
notation. (Nov/Dec 2021)
10. Construct a decorated parse tree according to the syntax directed definition
for the following input statement: (4+7.5*3)/2. (Apr/ May 2015)
14. Mention the rules for type checking (April / May 2016)
A compiler must check that the source program should follow the syntactic and
semantic conventions of the source language and it should also check the type rules
of the language.
15. Write down syntax directed definition of a simple desk calculator.
(Nov / Dec 2016)
Page 4 of 7
18. Define Dependency Graph.
• Dependency Graphs are the most general technique used to evaluate syntax
directed definitions with both synthesized and inherited attributes.
• A Dependency Graph shows the interdependencies among the attributes of
the various nodes of a parse-tree.
– There is a node for each attribute;
– If attribute b depends on an attribute c there is a link from the node for c to
the node for b ( b ← c).
• Dependency Rule: If an attribute b depends from an attribute c, then we need
to fire the semantic rule for c first and then the semantic rule for b.
PART – B
1. Explain dangling-else problem with an example and give the unambiguous
grammar for the same (Nov/Dec 2020)
2. Below is a grammar for expressions involving operator + and integer or
Page 5 of 7
floating-point operands. Floating-point numbers are distinguished by having
a decimal point. (Nov/Dec 2020)
E -> E + T|T
T -> num.num | num
i) Give an Syntax Directed Definition (SDD) to determine the type of each
term T and expression E.
ii) Extend your SDD of (i) to translate expressions into postfix notation. Use
the binary operator intToFloat to turn an integer into an equivalent float.
3∗1+0∗x
Page 6 of 7
8. Explain in detail about Specification of a simple type checker. (Apr / May 2017)
9. Write the syntax directed translation scheme with backpatching to generate
three address code for the given grammar. (13)
S → while E do S | begin L end
L → L; S | S
E → E or E | E and E | not E | id
10. Create variants of Syntax tree. Explain in detail about it with suitable examples
Page 7 of 7