Sie sind auf Seite 1von 12

MRK Institute of Technology

(Approved by AICTE & Affiliated to Anna University)


Kattumannarkoil - 608 301

CS 2352 PRINCIPLES OF COMPILER DESIGN


PART-B (16 MARKS QUESTIONS)
UNIT I
LEXICAL ANALYSIS
1. Explain in detail about phases of the compiler.
Lexical Analysis
Syntax Analysis
Semantic Analysis
Intermediate Code Generator
Code Optimization
Code Generation
Symbol Table Management
Error Handling
2. Explain in detail about cousins of the compiler
Preprocessor
Assemblers
Loaders & Linkers
3. Explain about the grouping of phases
Front and back ends
Passes
4. What are the tools used to construct the compiler? Explain.
Parser Generator
Scanner Generator
Syntax directed translation engines
Automatic code generators
Data flow engines
5. Explain in detail about the roles of lexical analyzer.
Issues in lexical analysis
Tokens, patterns, lexemes
Attributes for tokens
Lexical Errors
6. Explain in detail about input buffering.
Buffer pairs
Sentinels

7. How to specify the tokens? Explain


Strings and languages
Operations on languages
Regular Expression
Notational Shorthands
8. Explain in detail about recognition of tokens.
Grammar fragment
Regular expression pattern
Transition Diagram
9. Explain the language for specifying lexical analyzers.
Computer Language Representation
Grammars and parse Trees
Expression Grammar
Left Recursion
LEX
10. Explain the issues in lexical analyzer
Design Simple
Efficiency
Portability
11. Convert the DFA from NFA.
Find the states of QN

Construct the subsets


Find N for all subsets
12.
Write down the exclusive functions carried out by the analysis phase
of any compiler.
Linear Analysis
Hierarchical Analysis
Semantic Analysis
13. Convert the NFA into a DFA by eliminating transitions
Find the closure
Eliminate duplicate states
Construct the DFA
14. Write briefly on the issues in input buffering and how they are handled.
Buffer pairs
Sentinels

15. Give the rules for generating regular expression for describing
languages.
is a regular expression
Precedence and associativity of operators

The algebraic properties

UNIT II
SYNTAX ANALYSIS
1. Explain in detail about the role of parser.
Syntax Error Handling
Error Recovery Strategies
Panic Mode Recovery
Phrase level Recovery
Error Productions
2. Explain in detail about CFG.
Notational Conventions of CFG
Derivations
Parse tree
Ambiguity
3. Explain how to write the CFG.
Regular Expression vs. CFG
Eliminating Ambiguity
Elimination of left recursion
Left factoring
4. Explain in detail about top down parsing.
Backtracking Parser / Recursive Descent Parsing
Predictive Parser
Recursive Predictive Parser
Working of Predictive Parser
Error Recovery modes.
5. Explain in detail about the error recovery modes in Predictive Parser.
Panic Mode Error Recovery
Phrase level recovery
6. Explain about Non Recursive Predictive Parser.
Input buffer
Stack
Parsing Table
Output Stream
7. Write the steps for Non Recursive Predictive Parser.
Eliminate left recursion or left factoring
Computation of FIRST
Computation FOLLOW
Parsing Table

8. How can we find the LL(1) Grammar?


Eliminate left recursion or left factoring
Computation of FIRST
Computation FOLLOW
Parsing Table
More than one entries LL(1) Grammar.
9. Explain in detail about bottom up parsing
Shift reduce parser
Handle
Handle pruning
Stack implementation of SR parser
Viable prefixes
Conflicts during SR parsing.
10. Steps for Operator precedence grammar.
Computation of LEADING
Computation of TRAILING
Computation of precedence relations
Computation of precedence table
Precedence functions
Precedence graph
11. Explain in detail about LR parser.
Top down parser
Bottom up parser
Handle
Algorithm.
12. Steps for finding SLR Parser.
Find LR(0) Items
Computing the closure
Compute goto.
Compute Parser table

13. Steps for finding CLR Parser.


Find LR(1) Items
Computing the augmented grammar.
Compute goto.
Compute Parser table
14.Steps for finding LALR Parser.
Find LR(1) Items
Computing the augmented grammar.

Compute look ahead


Compute goto.
Compute Parser table
15. Explain in detail about YACC generator.
Structure
Definition Section
o Lex Yacc interaction
o Return values
Rules section
User code section
UNIT III
INTERMEDIATE CODE GENERATION
1. Explain in detail about intermediate code generator.
Introduction
Benefits
Syntax directed translation
Translation Scheme
2. Explain in detail about intermediate languages.
Syntax tree
Postfix Notation
Three address code.
3. Explain in detail about implementation of three address code.
Quadruple
Triple
Indirect triple
Comparison of representation
4. Explain in detail about Declarations.
Declaration in procedure
Field names in records
5. Explain in detail about Assignment Statements.
Names in the symbol table
Reusing temporary names
Addressing Array Elements
Type conversion within assignments
Accessing Records

6. Explain in detail about Boolean Expressions.


Methods for translating Boolean expression
Numerical representation
Short circuit code
Flow of control statements
7. Explain in detail about CASE statements.
Syntax
Translation of switch statements
8. Explain in detail about Back patching.
Boolean Expression
Floe of control Statements
Labels and gotos
9. Explain in detail about procedure calls.
Grammar function
Translation scheme
Syntax directed translation
10. Explain the various data structures used for implementing the symbol
table.
Symbol table entries
Storage allocation information
List data structure
Insertion
Lookup
Hash table.

UNIT-IV
CODE GENERATION
1. Explain in detail about the issues in the design of code generator.
Input to the code generator
Target program
Memory management
Instruction selection
Register allocation
Choice of evaluation order
2. Explain in detail about the target language
A simple target machine model

o Load operation
o Store operation
o Computation operation
o Unconditional jumps
o Conditional jumps
Program and instruction cost
3. Explain in detail about basic blocks and flow graphics.
Basic blocks
Algorithm for partitioning blocks
Structure preserving transformations
Algebraic transformation
Floe graph
Loops
4. Explain the steps for Structure preserving transformations.
Common sub expression elimination
Dead code elimination
Renaming of temporary variables
Interchange of two independent adjacent statements
5. Explain in detail about next use information
Consider the instruction sequence
Find the next use of variables
Take the statements with numbers

6. Explain in detail about peephole optimization.


Redundant information elimination
Unreachable code elimination
Flow of control optimization
Algebraic simplification
Use of machine idioms
7. Explain in detail about the simple code generator.
Register Descriptor
Address Descriptor
Code generation algorithm
The getreg() function
Code generation for other statements

8. Explain in detail about DAG representation of basic blocks.


DAG Construction
Algorithm
Applications of DAGs
9. Explain in detail about code generation from DAGs.
Rearranging the order
Heuristic ordering for DAGs
Node listing algorithm
10. Explain in detail about the register allocation.
Local Register Allocation
Global Register Allocation
Usage Counts
Register assignments for outer loops
Register allocation by graph coloring
11. Explain in detail about run time storage management.
Static allocation
Stack allocation
Code for initialization of stack
Code for procedure call
Code for return

12. What are the different addressing modes for a target machine?
Load operation
Store operation
Computation operation
Unconditional jumps
Conditional jumps
13. Explain how declarations are done in a procedure using syntax directed
Translation.
Grammar function
Translation scheme
Syntax directed translation
14. Explain code generation phase with simple code generation
algorithm.
Register Descriptor

Address Descriptor
Code generation algorithm
The getreg() function
Code generation for other statements

15. Discuss the run time storage management of a code generator.


Static allocation
Stack allocation
Code for initialization of stack
Code for procedure call
Code for return

UNIT V
CODE OPTIMIZATION
1. List the criteria for code improving transformations.
Factors for code transformations
Forms of the programs
Compiler improving methods
Machine resources
2. Explain in detail about code optimizer organizer
Front end
Code generator
Control flow analysis
Data flow analysis
Transformations
3. Explain in detail about principle sources of optimization.
Function preserving transformations
o Common sub expression elimination
o Copy propagation
o Dead code elimination
o Constant folding
Loop optimization
o Code motion
o Induction variable elimination
o Reduction in strength
4. Explain in detail about function preserving transformations.
Common sub expression elimination
Copy propagation

Dead code elimination


Constant folding
5. Explain in detail about loop optimization.
Code motion
Induction variable elimination
Reduction in strength
6. Explain in detail about optimization of basic blocks.
Create the tree
Remove the dead code
Use of algebraic identities
Use reduction in strength
Use constant folding
7. Explain in detail about global data flow analysis.
Points and paths
Reaching definitions
Data flow analysis of structured programs
8. Explain in detail about run time environments.
Source language issues
Diagrammatic representation
Example program
Result
9. Explain in detail about Source language issues.
Procedures
Activation trees
Control stacks
Scope of a declaration
Binding of names
10. Explain in detail about storage organization.
Categories
Activation records
Compile time layout of local data
Example
11. List the categories of storage organization
Code area to hold generated target code
Static data area to hold data objects

Stack area to hold control stack


Separate area called heap to hold all other information.
12. Explain in detail about storage allocation strategies.
Static allocation
Stack allocation
o Calling sequence
o Variable length data
o Dangling references
Heap allocation
13. How can access the non-local loops?
Lexical scope without nested procedures
Lexical scope with nested procedures
Nesting depth
Access to non local names
Access link
Displays
14. Explain the methods to access dynamic scope.
Deep access
Shallow access
Steps for access methods
Example
15. Explain in detail about parameter passing methods.
Call by value
Call by reference
Copy restores
Call by name
Macro expansion
16. Explain in detail about loops in flow graphics.
Dominators
Immediate dominators
Dominator tree
Dominators and Natural loops
Symbol table
17. Explain in detail about code improving transformations.
Common sub expression elimination
Copy propagation
Loop invariant computations

Induction variable elimination


18. Explain with an example how basic blocks are optimized?
Create the tree
Remove the dead code
Use of algebraic identities
Use reduction in strength
Use constant folding
19. Explain the three techniques for code optimization with example.
Code motion
Induction variable elimination
Reduction in strength
20. Explain the data flow analysis concept with example.
Points and paths
Reaching definitions
Data flow analysis of structured programs

Das könnte Ihnen auch gefallen