Professional Documents
Culture Documents
CD Long Answers
CD Long Answers
CD Long Answers
Unit 1
Unit 2
1. LR-I(CLR)
2. SLR
3. LALR
4. abstract syntax tree
5. Three address codes
Unit 3
Unit 4
1. Optimization techniques
local optimisation
Frequency reduction,folding
Global optimisation
Copy propagation
Optimisation Techniques
M/c dependent and M/c independent techniques
2. DAG construction and representation
3. Data Flow Graph
Block designing
Data flow graph
Data flow equation
Unit 5
Note : Just brief matter is provided for all answers for last minute revision (Some answers may be short and hence it
will not be sufficient if it is written as same in exam as long answer)
All answers mentioned below are just for reference.
CD Unit 1 Important
Unit 1
Note : Just brief matter is provided for all answers for last minute revision (Some answers may be short and hence it
will not be sufficient if it is written as same in exam as long answer)
All answers mentioned below are just for reference.
Answer :
2.Preprocessing directives(preprocessor,linker,loader etc)
Answer :
3.Regular Grammar
Answer :
4.Regular expressions
Answer :
6.Predictive parsing
Answer :
Predictive parsers are those recursive descent parsers needs no backtracking
Grammars for which we can create predictive parsers are called LL(1)
The first L means scanning input from left to right
The second L means leftmost derivation
And 1 stands for using one input symbol for lookahead
Example :
CD Unit 2 Important
Unit 2
1. LR-I(CLR)
2. SLR
3. LALR
4. abstract syntax tree
5. Three address codes
Note : Just brief matter is provided for all answers for last minute revision (Some answers may be short and hence it
will not be sufficient if it is written as same in exam as long answer)
All answers mentioned below are just for reference.
1.LR-I(CLR)
Answer :
Canonical LR Parsing(LR(1))
Example
2.SLR
Answer:
Example :
3.LALR
Answer :
4.abstract syntax tree
Answer :
Syntax trees are abstract or compact representation of parse trees. They are also called as Abstract Syntax Trees.
Syntax trees are called as Abstract Syntax Trees because-
They are abstract representation of the parse trees.
They do not provide every characteristic information from the real syntax.
For example- no rule nodes, no parenthesis etc.
5.Three address codes
Answer :
Example
CD Unit 3 Important
Unit 3
Note : Just brief matter is provided for all answers for last minute revision (Some answers may be short and hence it
will not be sufficient if it is written as same in exam as long answer)
All answers mentioned below are just for reference.
Answer:
We can associate information with a language construct by attaching attributes to the grammar symbols.
A syntax directed definition specifies the values of attributes by associating semantic rules with the grammar
productions.
2 types
S-attributed SDT
L-attributed SDT
S-attributed SDT
If an SDT uses only synthesized attributes, it is called as S-attributed SDT. These attributes are evaluated using
S-attributed SDTs that have their semantic actions written after the production (right hand side).
As depicted above, attributes in S-attributed SDTs are evaluated in bottom-up parsing, as the values of the
parent nodes depend upon the values of the child nodes.
L-attributed SDT
This form of SDT uses both synthesized and inherited attributes with restriction of not taking values from right
siblings.
In L-attributed SDTs, a non-terminal can get values from its parent, child, and sibling nodes. As in the following
production
S → ABC
S can take values from A, B, and C (synthesized). A can take values from S only. B can take values from S and A.
C can get values from S, A, and B. No nonterminal can get values from the sibling to its right.
Attributes in L-attributed SDTs are evaluated by depth-first and left-to-right parsing manner.
We may conclude that if a definition is S-attributed, then it is also L-attributed as L-attributed definition
encloses S-attributed definitions.
Answer :
Eg :
Attributes may be of many kinds: numbers, types, table references, strings, etc.
Annotated Parse Tree – The parse tree containing the values of attributes at each node for given input string is
called annotated or decorated parse tree.
Features
High level specification
Hides implementation details
Explicit order of evaluation is not specified
Based on the way the attributes get their values, they can be broadly divided into two categories : synthesized
attributes and inherited attributes.
1. Synthesized attributes
2. Inherited attributes
Synthesized attributes
These attributes get values from the attribute values of their child nodes. To illustrate, assume the following
production:
S → ABC
If S is taking values from its child nodes (A,B,C), then it is said to be a synthesized attribute, as the values of
ABC are synthesized to S.
Synthesized attributes never take values from their parent nodes or any sibling nodes.
Inherited attributes
In contrast to synthesized attributes, inherited attributes can take values from parent and/or siblings. As in the
following production,
S → ABC
A can get values from S, B and C. B can take values from S, A, and C. Likewise, C can take values from S, A, and
B.
3.Semantic rules
Answer :
Answer :
Answer :
Unit 4
1. Optimization techniques
2. DAG construction and representation
3. Data Flow Graph
Note : Just brief matter is provided for all answers for last minute revision (Some answers may be short and hence it
will not be sufficient if it is written as same in exam as long answer)
All answers mentioned below are just for reference.
1.Optimization techniques
Answer:
The code optimization in the synthesis phase is a program transformation technique, which tries to improve the
intermediate code by making it consume fewer resources (i.e. CPU, Memory) so that faster-running machine code will
result.
Types of Code Optimization
1. Machine Independent Optimization
This code optimization phase attempts to improve the intermediate code to get a better target code as
the output. The part of the intermediate code which is transformed here does not involve any CPU
registers or absolute memory locations.
2. Machine Dependent Optimization
Machine-dependent optimization is done after the target code has been generated and when the code
is transformed according to the target machine architecture. It involves CPU registers and may have
absolute memory references rather than relative references. It Divide the problem into basic blocks.
Machinedependent optimizers put efforts to take maximum advantage of the memory hierarchy.
after optimisation
Strength reduction (frequency reduction) and Induction variable
It is a process of replacing the expensive operation by equivalent cheaper operation without
changing the meaning of code. Induction variable is a variable which is used inside the loop and
whose values changes everytime.
Compiler takes more time to excute multiplication operator than addition and subtraction
Constant Folding
It is a process of replacing a constant value into the instructions directly
Reference -> https://www.youtube.com/watch?v=fAjIlKmCuUY
Answer :
DAG is a graphical representation that consist of nodes and leaves. Where nodes represent operators and leaves
represent identifiers(constants and variables)
DAG is generated by 3 address code or intermediate code
Examples
1. (a/b)+((a/b)*(c*d))
2. (a + a * (b - c)) + ((b - c) * d)
Answer :
Flow Graph:
Flow graph establishes flow of control between blocks.
Flow graph is generated to perform control flow analysis and also used for data flow analysis
Flow graph is a graphical representation that consists of nodes and edges where nodes represents blocks and
edges represents flow of control between blocks
Basic Block
A block is defined as a set of statements grouped together.
Generally a flowgraph is generated for 3-address code or intermediate code.
The first block in the flowgraph is known as header or starting point.
The last statement where flow of control ends is called a ending point.
Every block is having entry point and exit point.
Basic blocks also have leaders.
Steps for finding the Leaders and constructing the basic blocks
Unit 5
Note : Just brief matter is provided for all answers for last minute revision (Some answers may be short and hence it
will not be sufficient if it is written as same in exam as long answer)
All answers mentioned below are just for reference.
Answer :
2.Peephole optimisation
Answer :
3.Register allocation and assignments
Answer :
4.generic code generation algorithms
Answer :
5.Addressing modes
Answer :
7.Assembly language conversion