CD course file
CD course file
COMPILER DESIGN
COURSEFILE
1
S.NO CONTENTS
1 Vision&Missionof College
2 Vision&Missionof Department
3 CourseObjectives& Outcomes
4 Syllabus
5 RollList
6 ClassTimeTables
7 SubjectTimeTables
8 AcademicCalender
9 Lesson Plan
11 Lecture Notes(handwritten)
12 TutorialClasses
13 QuestionBank
14 AssignmentQuestions
15 MidQuestionPaperswithSchemaofEvaluationandKey
16 PreviousUniversityQuestion Papers
20 KeyforLatestPreviousQuestionPaper
21 TopicsBeyondSyllabus
19 InternalMarks
20 BestandWorstMidAnswerScripts
21 List ofe-resources
22 ResultSheetpublishedbyUniversity
23 PassPercentage
24 SampleAssignmentSheet
25 AttainmentSheet
2
Institute Vision
To evolve women as a center of excellence in emerging technology and to craft them as global
leaders.
Institute Mission
IM1. To achieve Academic excellence through innovative learning practices.
IM2. To install self confidence among rural students by supplementing with co-curricular and
extra-curricular activities.
IM4. To establish centres for Institute Industry partnership in order to enhance their technical
IM5. To facilitate world class arena to learn and to establish admirable living environment.
Principal
3
Department Vision
To become a global leader in providing academicand research excellence with empowerment skills
for women in the area of Computer Science & Engineering.
Department Mission
HOD
4
Course Name:Compiler Design Branch: CSE Year – Sem : III – II
Regulation: R20 Academic Year: 2024-25
ProgramOutcomes(POs):
5
Engineering Knowledge: Apply the knowledge of mathematics, science, engineering
PO1 fundamentals, and an engineering specialization to the solution of complex
engineering
problems.
Modern Tool Usage: Create, select, and apply appropriate techniques, resources, and
PO5 modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.
The Engineer and Society: Apply reasoning informed by the contextual knowledge
PO6 to assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
6
Project Management and Finance: Demonstrate knowledge and understanding of
PO11 the engineering and management principles and apply these to one’s own work, as a
member
Program Educational Objectives(PEOs):
Graduateswillhavetheexpertisein analyzingrealtimeproblemsandproviding
PEO#1
appropriate solutions related to Computer Science & Engineering.
Graduateswillhavetheknowledgeoffundamentalprinciplesandinnovative technologies
PEO#2
to succeed in higher studies, and research.
Graduateswillcontinuetolearnandtoadapttechnologydevelopmentscombined with
PEO#3 deep awareness of ethical responsibilities in profession.
Utilize the skills of Data Analytics, Cloud Computing, Artificial Intelligence and
PSO#2 MachineLearningtoaddresstechnologicalchallengesinmultidisciplinaryareasof
engineering.
7
HOD
8
Course Name:Compiler Design Branch: CSE Academic Year: 2023-24
Regulation: R20 Year – Sem : III – II
Course Objectives:
Understand the basic concept of compiler design, and its different phases which will be
helpful to construct new tools like LEX, YACC, etc.
Course Outcomes:
SUBJECT:COMPILER DESIGN
CO.NO
Course Outcomes BT Level
.
C322.2 CO2 : Organize Syntax Analysis, Top Down and LL(1) grammars Creating
9
Course Name:Compiler Design Branch: CSE Year – Sem: III – II
Regulation:R20 Academic Year: 2023-24
CO – PO MAPPING
Course Program
Outcome Specific
s (CO) Program Outcomes (PO’S) Outcomes
(PSO’s)
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO 10 PO 11 PO 12 PSO1 PSO2
3 3 1 - - - - 2 1
C322.1
3 3 3 2 - - - - 2 1
C322.2
3 3 2 2 - - - - 2 1
C322.3
3 3 2 2 - - - - 2 1
C322.4
3 3 3 2 - - - - 2 1
C322.5
3 3 2 2 0 0 0 0 2 1
Avg
10
Course Name:Compiler Design Branch: CSE
Regulation:R20 Year – Sem: III – II
Academic Year: 2024-25
CO-PO Mapping Justification
PO5: Modern Tool Usage: Create, select, and apply appropriate techniques,
resources, and modern engineering and IT tools including prediction and
modeling to complex
C322.1
C322.1-P01 3 Students will be able to apply engineering Knowledge moderately for
different phases of compilation.
C322.1-P02 3 Students will be able to identify mathematical algorithmic knowledge
that helps moderately to analyze given problem for removing ambiguities
in the Syntax Analyzer.
C322.1-P03 3 Students will develop computer programs for Syntax analysis phase of a
compiler.
C322.1-P04 2 Students will recognize the knowledge of constructing finite automata
from regular expression.
C322.1-P05 2 Students will understand selection of LEX tool to design a lexical
analyzer phase of a compiler
C322.1-P10 2 Students will be able to optimize storage organization and effectively
generate machine codes.
C322.1-P012 2 Information acquired from the design of assembler is moderately
applicable for lifelong learning in the context of system software
development.
C322.1-PS01 2 Students will Gain knowledge on design of compiler.
C322.1-PS02 1 Students will Have the knowledge about the compiler construction tools
helps strongly in the study and design of compiler.
12
C322.2
C322.2-P01 3 Students will be able to recognize the knowledge of constructing syntax
Analyzer(parser).
C322.2-P02 3 Students will apply the knowledge of compiler design and after reducing
it into a system of Grammers in many areas of the engineering .
C322.2-P03 3 Syntax Analysis, Top Down parsing techniques.
C322.2-P04 2 Students will be able to choose appropriate software tools to conduct the
experiments using lex and yacc.
C322.2-P05 2 Students will be able to figure out top down parsing techniques and
effectively generate machine codes.
C322.2-P10 2 Students will communicate effectively on complex algorithmic
knowledge that helps moderately to analyze given problem for
removing ambiguities in the context free Grammar. C322.3:
Design 2 Students can understand and implement different types Intermediate Bottom
C322.2-P012
Up Representation of code used for generating target code. Parsing
C322.2-PS01 2 Students will apply various information acquir from the fundamentals of
and parsing leads moderately to implement the intermediate code.
C322.2-PS02 1 Information acquired from the fundamentals of intermediate
representation leads moderately for implementation of target code
Construction of LR parsers
C322.3
C322.3-P01 3 Apply engineering Knowledge moderately to design assemblers for
different architectures
C322.3-P02 3 Students can able to solve problems in Bottom Up Parsing.
13
C322.4: Analyze synthesized, inherited attributes and syntax directed translation schemes
C322.4
C322.4-P01 3 Knowledge of Ambiguities in the context free Grammar helps students
moderately for analyzing the problems in SDT(syntax directed translation).
C322.4-P02 3 Students will be able identify knowledge that helps moderately to analyze
given problem for removing ambiguities in the SDT.
C322.4-P03 2 Students will select Prefered tool to design a Syntax Directed Translation for
any grammer.
C322.4-P04 2 Students identifies L-Attributed SDD’s to analyze given problem in syntax
directed translation.
C322.4-P05 1 Students will be able design the Applications of Syntax Directed Translation .
C322.4-P012 1 Students will be able to recognize the need for synthesized and inherited
attributes.
C322.4-PS01 2 Ability to implement computer programs for Ability to implement computer
programs for evaluation orders for SDD’s.
C322.4-PS02 1 Students will be able to develop compiler product.
C322.5:
Determine algorithms to generate code for a target machine.
C322.5
C322.5-P01 3 Students will analyze the storage organization for Code Generation Algorithm.
C322.5-P02 3 Students will identify the differences between Register Allocation and
Register Assignment.
C322.5-P03 2 Students will design a method to find a solution for Object Code Forms in
code generation.
C322.5-P04 2 Students will analyze machine code generation effectively and generate target
code using target machine.
C322.5-P05 1 Students will gain knowledge on Heap Management and Dynamic
Programming Code-Generation.
C322.5-P10 2 Students will be able to communicate effectively on programming language
basics for project management using target code.
C322.1-P012 1 Students will learn the methods to apply in real life problems like profit gaining
in Industries.
C322.1-PS01 2 Students will be able to optimize storage organization and effectively generate
machine codes 14
C322.1-PS02 1 Information acquired from the fundamentals of intermediate representation
leads moderately for implementation of target code
Course Name:Compiler Design Branch: CSE Regulation:R20
Year – Sem: III – II Academic Year: 2024-25
SYLLABUS
COMPILER DESIGN
UNIT I: Lexical Analysis: Language Processors, Structure of a Compiler, Lexical Analysis, The
Role of the Lexical Analyzer, Bootstrapping, Input Buffering, Specification of Tokens,
RecognitionofTokens,Lexical AnalyzerGenerator-LEX, FiniteAutomata,RegularExpressions and
Finite Automata, Design of a Lexical Analyzer Generator.
Syntax Analysis: The Role of the Parser, Context-Free Grammars, Derivations, Parse
Trees,Ambiguity,LeftRecursion,LeftFactoring.
BottomUpParsing:Introduction,DifferencebetweenLRandLLParsers,TypesofLR Parsers,Shift
Reduce Parsing,SLRParsers,ConstructionofSLRParsingTables,More Powerful LR Parses,
Construction of CLR (1) and LALR Parsing Tables, Dangling Else Ambiguity, Error Recovery
in LR Parsing.
UNIT III: Syntax Directed Translation: Syntax-Directed Definitions, Evaluation Orders for
SDD’s, Applications of Syntax Directed Translation, Syntax-Directed Translation Schemes,
Implementing L-Attributed SDD’s. Intermediate Code Generation: Variants of Syntax Trees,
ThreeAddressCode,TypesandDeclarations,TranslationofExpressions,TypeChecking,Control
Flow, Backpatching, Intermediate Code for Procedures.
UNITIV:CodeOptimization:ThePrincipleSourcesofOptimization,BasicBlocks,Optimization of
BasicBlocks,Structure Preserving Transformations, Flow Graphs, Loop Optimization, Data-Flow
Analysis, Peephole Optimization.
UNIT V: CodeGeneration: Issues in the Design of a Code Generator, Object Code Forms, Code
15
Generation Algorithm, Register Allocation and Assignment. Run Time Environments: Storage
Organization, Run Time Storage Allocation, Activation Records, Procedure Calls, Displays.
Text Books: 1. Compilers: Principles, Techniques and Tools, Second Edition, Alfred V. Aho,
Monica S. Lam, Ravi Sethi, Jeffry D. Ullman, Pearson Publishers, 2007.
RReferenceBooks:1.CompilerConstruction,PrinciplesandPractice,KennethCLouden,Cengage
Learning, 2006
2. ModerncompilerimplementationinC,AndrewWAppel,Revisededition,CambridgeUniversity
Press.
3. OptimizingCompilersforModernArchitectures,RandyAllen,KenKennedy,Morgan Kauffmann,
2001.
4. Levine,J.R.,T.MasonandD.Brown,LexandYacc,edition,O'Reilly&Associates,1990
16
Course Name:Compiler Design Branch: CSE
Regulation:R20 Year – Sem: III – II
Academic Year: 2024-25
19
20
Course Name:Compiler Design Branch: CSE
Regulation:R20 Year – Sem: III – II
Academic Year: 2024-25
ClassTime Tables
TIME TABLE FOR III B.Tech CSE (A) Section
1 2 3 4 5 6 7
DAY/ 1:00-
TIME 9:30- 10:20 - 11:20- 12:10- 2:00 2:00- 2.50-
10:20 11:10 12:10 1:00 2:50 3:40 3:40-4:30
SEMINAR
MON OOAD CD POC ML CNS SPORTS
ON OOAD
SEMINA
LUNCHBREAK
TUE
CNS OOAD CD POC ML R ON LIBRARY
POC
SEMINAR
WED ML OOAD CNS POC CD SPORTS
ON ML
SEMINA
THU POC CNS CD OOAD ML LIBRARY
R ON CD
SEMINAR
FRI ML CD OOAD CNS POC SPORTS
ON CNS
SEMINAR
SAT CD OOAD CNS POC ML LIBRARY
ON ML
HOD
21
Course Name:Compiler Design Branch: CSE
1 2 3 4 5 6 7
DAY/ 1:00-
TIME 9:30- 10:20 - 11:20- 12:10- 2:00 2:00- 2.50-
10:20 11:10 12:10 1:00 2:50 3:40 3:40-4:30
SEMINAR
MON POC OOAD ML CNS CD LIBRARY
ON CD
SEMINA
TUE CD ML OOAD CNS POC SPORTS
LUNCHBREAK
R ON ML
SEMINAR
WED CNS POC OOAD CD ML LIBRARY
ON POC
SEMINAR
THU CD ML OOAD CNS POC SPORTS
ON CNS
SEMINAR
FRI CNS OOAD POC ML CD LIBRARY
ON OOAD
SEMINAR
SAT OOAD ML POC CD CNS SPORTS
ON ML
HOD
22
Course Name:Compiler Design Branch: CSE
Regulation:R20 Year – Sem: III – II
Academic Year: 2024-25
Subject Time Tables
1 2 3 4 5 6 7
DAY/ 1:00-
TIME 9:30- 10:20- 11:20- 12:10- 2:00 2:00- 2.50-
3:40-4:30
10:20 11:10 12:10 1:00 2:50 3:40
LUNCH
TUE III CSE-B III CSE-A
BREAK
THU III CSE-B III CSE-A
HOD
23
Course Name:Compiler Design Branch: CSE
Regulation:R20 Year – Sem: III – II
Academic Year: 2024-25
Academic Calendar
Preparation and
07-04-2025 12-04-2025 1 Week
Practical’s
Principal
24
Course Name:Compiler Design Branch: CSE
Regulation:R20 Year – Sem: III – II
Academic Year: 2024-25
LESSON PLAN
UNIT-I : Lexical Analysis
25
UNIT-II : Top Down Parsing
26
UNIT-III: Syntax Directed Translation
27
No. of Tentative Actual Teachin TB and
S.No. Topics to be covered Classes Date of Date of g Page
Required Completion Completion Learni Number
ng
Metho
ds
24/01/2025- 24/01/2025 White RB1, 48
1. 2
26/01/2025 - board
and
26/01/202
marker
Storage Organization 5
24/01/2025- 24/01/2025 White RB1, 50
2. 2
25/01/2025 - board
25/01/2025 and
Run Time Storage Allocation marker
27/01/2025- 27/01/2025- White RB1, 52
3. 2
28/01/2025 board
28/01/2025
and
Activation Records, Procedure Calls marker
29/01/2025- 29/01/2025- White RB1, 55
4. 2
30/01/2025 30/01/2025 board
Code Optimization: The Principle and
Sources of Optimization marker
31/01/2025- 31/01/2025- White RB1, 57
5. 2
01/02/2025 01/02/2025 board
Basic Blocks, Optimization of Basic and
Blocks marker
02/02/2025- 02/02/2025- White RB1, 60
6. 3
03/02/2025 03/02/2025 board
and
Structure Preserving Transformations marker
04/02/2025- 04/02/2025- White RB1, 63 Unit
7 2
V: 05/02/2025 05/02/2025 board Code
and
Flow Graphs marker
06/02/2025- 06/02/2025- White RB1, 65
8 2
07/02/2025 07/02/2025 board
and
Loop Optimization marker
10/02/2025- 10/02/2025- White RB1, 67
9 2
11/02/2025 11/02/2025 board
and
Data-Flow Analysis marker
12/02/2025- 12/02/2025- White RB1, 69
10 3 13/02/2025 13/02/2025 board
and
Peephole Optimization marker
No. of classes required to complete UNIT-IV
13
Generation
28
No. of Tentative Actual Teaching TB and
S.No Topics to be covered Classes Date of Date of Learning Page
Required Completion Completion Methods Number
.
14/02/2025- 14/02/2025- White RB1, 72
1. 2
15/02/2025 board and
15/02/2025
Storage Organization marker
17/02/2025- 17/02/2025- White RB1, 75
2. 2
18/02/2025 18/02/2025 board and
Run Time Storage Allocation marker
19/02/2025- 19/02/2025- White RB1, 77
3. 2
20/02/2025 board and
Activation Records, Procedure Calls 20/02/2025
marker
21/02/2025- 21/02/2025- White RB1, 79
4. Code Optimization: The Principle 2
22/02/2025 board and
Sources of Optimization 22/02/2025
marker
24/02/2025- 24/02/2025- White RB1, 80
5. Basic Blocks, Optimization of Basic 2 24/02/2025 board and
Blocks 24/02/2025
marker
25/02/2025- 25/02/2025- White RB1, 84
6. 3
27/02/2025 board and
Structure Preserving Transformations 27/02/2025
marker
28/02/2025- 28/02/2025- White RB1, 89
7 2
01/03/2025 01/03/2025 board and
Flow Graphs marker C&T:
03/03/2025- 03/03/2025- White RB1, 91
8 2
04/03/2025 04/03/2025 board and
Loop Optimization marker
05/03/2025- 05/03/2025- White RB1, 93
9 2 06/03/2025 06/03/2025 board and
Data-Flow Analysis marker
07/03/2025- 07/03/2025- White RB1, 96
10 3
08/03/2025 08/03/2025 board and
Peephole Optimization marker
No. of classes required to complete UNIT-V
13
Chalk& Talk
Text Book: T1:
Compilers:Principles, Techniques and Tools, Second Edition, Alfred V. Aho, Monica S
Pearson Publishers, 2007.
Text Book:T2: Optimizing Compilers for Modern Architectures, Randy Allen, Ken Kennedy, Morgan Kauffmann,
Reference Books: RB1: Levine, J.R., T. Mason and D. Brown, Lex and Yacc, edition, O'Reilly & Associates, 1990.
Web References:
29
W1 202.113.80.118:8080/sjjg/upLoad/down/.../20120704005.doc
W2 baggins.nottingham.edu.my/~hsooihock/G52CMP/semantic.ppt
W3 books.google.co.in/books?isbn=8131707881
Question Bank
Unit1:
9. Define interpreter.
10. What are the differences between the NFA and DFA?
Unit 2:
1. Explain the role of parser. Explain types of grammars used for parsing.
30
2. Write an algorithm for constructing a predictive parsing table. Give an Example.
4. Write about various types of top down parsing. Discuss about the error recover
in predictive parsing.
E->E+T | T
T->T* F | F
F-> (E) | id
Unit 3:
1. How to handle ambiguity through LR parsers? Discuss about the Dangling – Else ambiguity
2. Write the rules used to construct SLR Parser. Give example
3. Write and explain the LR Parsing algorithm.
4. What are different intermediate code forms? Discuss different Three Address code types and
implementations of Three Address statements.
5. What are the various types of intermediate code representation?
6. Write a note on the specification of a simple type checker.
7. State general activation record?
8. Explain type expression and type systems.
9. Define Type Equivalence.
10. Define left most derivation and right most derivation with example.
31
Unit 4:
1. Explain various storage allocation strategies with its merits and demerits.
3. What is runtime stack? Explain the storage allocation strategies used for recursive procedure
calls. What is a flow graph?
4. What is the role of code Optimizer in compiler? Is it a mandatory phase? Explain the various
sources of optimization.
5. Describe Loop unrolling? Describe its advantage with your own examples.
Unit-5:
10. Explain in brief about different Principal sources of optimization techniques with
suitable examples.
33
ASSIGNMENT QUESTIONS
Assignment-1:
Assignment-1:
1.
Phases of a compiler: A compiler operates in phases. A phase is a logically interrelated operation that takes
source program in one representation and produces output in another representation. The phases of a
compiler are shown in below
There are two phases of compilation.
a. Analysis (Machine Independent/Language Dependent)
b. Synthesis(Machine Dependent/Language independent) Compilation process is partitioned
into no-of-sub processes called ‘phases’.
34
Lexical Analysis:-
LA or Scanners reads the source program one character at a time, carving the source program into a
sequence of automic units called tokens.
Syntax Analysis:-
The second stage of translation is called Syntax analysis or parsing. In this phase expressions, statements,
declarations etc… are identified by using the results of lexical analysis. Syntax analysis is aided by using
techniques based on formal grammar of the programming language.
Intermediate Code Generations:-
An intermediate representation of the final machine language code is produced.
This phase bridges the analysis and synthesis phases of translation.
Code Optimization :-
This is optional phase described to improve the intermediate code so that the output runs faster and takes
less space.
Code Generation:-
The last phase of translation is code generation. A number of optimizations to reduce the length of
machine language program are carried out during this phase. The output of the code generator is the
machine language program of the specified computer.
2.
ROLE OF LEXICAL ANALYZER
The LA is the first phase of a compiler. It main task is to read the input character and produce as output a
sequence of tokens that the parser uses for syntax analysis.
35
Upon receiving a ‘get next token’ command form the parser, the lexical analyzer reads the input character
until it can identify the next token. The LA return to the parser representation for the token it has found.
The representation will be an integer code, if the token is a simple construct such as parenthesis, comma or
colon.
LA may also perform certain secondary tasks as the user interface. One such task is striping out from the
source program the commands and white spaces in the form of blank, tab and new line characters. Another
is correlating error message from the compiler with the source program.
3.
The LA scans the characters of the source pgm one at a time to discover tokens. Because of large amount of time can
be consumed scanning characters, specialized buffering techniques have been developed to reduce the amount of
overhead required to process an input character.
Buffering techniques:
1. Buffer pairs
2. Sentinels
lexical analyzer scans the characters of the source program one a t a time to discover tokens. Often,
however, many characters beyond the next token many have to be examined before the next token itself
can be determined. For this and other reasons, it is desirable for the lexical analyzer to read its input
from an input buffer. Figure shows a buffer divided into two haves of, say 100 characters each. One
pointer marks the beginning of the token being discovered. A look ahead pointer scans ahead of the
beginning point, until the token is discovered. we view the position of each pointer as being between the
character last read and the character next to be read. In practice each buffering scheme adopts one
convention either appointer is at the symbol last read or the symbol it is ready to read.
36
Token beginnings look ahead pointer The distance which the lookahead pointer may have to travel past
the actual token may be large. For example, in a PL/I program we may see: DECALRE (ARG1,
ARG2… ARG n) Without knowing whether DECLARE is a keyword or an array name until we see the
character that follows the right parenthesis. In either case, the token itself ends at the second E. If the
look ahead pointer travels beyond the buffer half in which it began, the other half must be loaded with
the next characters from the source file. Since the buffer shown in above figure is of limited size there is
an implied constraint on how much look ahead can be used before the next token is discovered. In the
above example, if the look ahead traveled to the left half and all the way through the left half to the
middle, we could not reload the right half, because we would lose characters that had not yet been
grouped into tokens. While we can make the buffer larger if we chose or use another buffering scheme,
we cannot ignore the fact that overhead is limited.
4.
Regular expression is a formula that describes a possible set of string.
Component of regular expression..
Xthe character x
. any character, usually accept a new line [x y z] any of the characters x, y, z, …..
R?a R or nothing (=optionally as R)
R*zero or more occurrences…..
R+one or more occurrences …… R1R2 an R1 followed by an R2 R2R1 either an R1 or an
R2.
A token is either a single string or one of a collection of strings of a certain type. If we view the set of
strings in each token class as an language, we can use the regular-expression notation to describe tokens.
Consider an identifier, which is defined to be a letter followed by zero or more letters or digits. In regular
expression notation we would write.
o is a regular expression denoting { € }, that is, the language containing only the empty string.
o For each ‘a’ in ∑, is a regular expression denoting { a }, the language with only one string
consisting of the single symbol ‘a’ .
o If R and S are regular expressions, then
37
(R) | (S) means LrULs
R.S means Lr.Ls R* denotes Lr*
REGULAR DEFINITIONS:
For notational convenience, we may wish to give names to regular expressions and to define
regular expressions using these names as if they were symbols.
Identifiers are the set or string of letters and digits beginning with a letter. The following regular
definition provides a precise specification for this class of string.
Example-1,
Ab*|cd? Is equivalent to (a(b*)) | (c(d?)) Pascal identifier
Letter - A | B | ……| Z | a | b |……| z| Digits - 0 | 1 | 2 | …. | 9
Id - letter (letter / digit)*
parser for any grammar is program that takes as input string w (obtain set of strings tokens from the
lexical analyzer) and produces as output either a parse tree for w, if w is a valid sentences of
grammar or error message indicating that w is not a valid sentences of given grammar. The goal of
the parser is to determine the syntactic validity of a source string is valid, a tree is built for use by the
subsequent phases of the computer. The tree reflects the sequence of derivations or reduction used
during the parser. Hence, it is called parse tree. If string is invalid, the parse has to issue diagnostic
message identifying the nature and cause of the errors in string. Every elementary subtree in the
parse tree corresponds to a production of the grammar.
There are two ways of identifying an elementary subtree:
38
2.
Predictive parsing is a special case of recursive descent parsing where no backtracking is
required.
The key problem of predictive parsing is to determine the production to be applied for a
non-terminal in case of alternatives.
Non-recursive predictive parser
The table-driven predictive parser has an input buffer, stack, a parsing table and
an output stream.
Input buffer:
It consists of strings to be parsed, followed by $ to indicate the end of the input
string.
Stack:
It contains a sequence of grammar symbols preceded by $ to indicate the bottom
of the stack. Initially, the stack contains the start symbol on top of $.
Parsing table:
It is a two-dimensional array M[A, a], where ‘A’ is a non-terminal and ‘a’ is a
terminal.
Predictive parsing program:
The parser is controlled by a program that considers X, the symbol on top of stack, and
a, the current input symbol. These two symbols determine the parser action. There are
three possibilities:
1. If X = a = $, the parser halts and announces successful completion of
parsing.
2. If X = a ≠ $, the parser pops X off the stack and advances the input pointer
39
to the next input symbol.
3. If X is a non-terminal , the program consults entry M[X, a] of the parsing
table
M. This entry will either be an X-production of the grammar or an error entry
3.
A grammar that produces more than one parse for some sentence is said to be ambiguous
grammar
The sentence id+id*id has the following two distinct leftmost derivations: E → E+ E
E → E* E
E → id + E E → E + E * E
E → id + E * E E → id + E * E
E → id + id * E E → id + id * E
E → id + id * id E → id + id * id
Example:
To disambiguate the grammar E → E+E | E*E | E^E | id | (E), we can use
precedence of operators as follows:
^ (right to left)
/,* (left to right)
-,+ (left to right) We get the following unambiguous grammar:
40
E → E+T | T
T → T*F | F F → G^F | G G → id | (E)
Consider this example, G: stmt→ if expr then stmt|if expr then stmtelsestmt| other This
grammar is ambiguous since the string if E1 then if E2 then S1 else S2 has the following.
Course: B.Tech
Branch: CSE Year/Semester: III/II
Reg: R20
Subject: Compiler Design
SET-I
Set-1 key:
1)
Phases of a compiler: A compiler operates in phases. A phase is a logically interrelated operation
that takes source program in one representation and produces output in another representation. The
phases of a compiler are shown in below
There are two phases of compilation.
a. Analysis (Machine Independent/Language Dependent)
b. Synthesis(Machine Dependent/Language independent) Compilation process is
partitioned into no-of-sub processes called ‘phases’.
43
LexicalAnalysis:-
LA or Scanners reads the source program one character at a time, carving the
sourceprogram into a sequence of automic units called tokens.
Syntax Analysis:-
The second stage of translation is called Syntax analysis or parsing. In this
phase expressions, statements, declarations etc… are identified by using the
results of lexical analysis. Syntax analysis is aided by using techniques based
on formal grammar of the programming language.
IntermediateCodeGenerations:-
Anintermediaterepresentationofthefinalmachinelanguage codeis produced.
thisphasebridgestheanalysis andsynthesisphasesof translation.
CodeOptimization:-
This is optional phase described to improve the intermediate code so that the
output runs faster and takes less space.
Code Generation:-
The last phase of translation is code generation. A number of optimizations
to reduce the length of machine language program are carried out during
this phase. The output of the code generator is the machine language program
of the specified computer.
44
Parserobtainsastringoftokensfromthelexicalanalyzerandverifiesthatitcanbegenerat
ed by the language for the source program. The parser should report any syntax
errors in an intelligible fashion. The two types of parsers employed are:
1. Topdownparser:
2. Bottomupparser:
Therefore therea retwo types of parsing methods– top-down parsing and bottom-up parsing
Lex is a tool or a computer program that generates Lexical Analyzers (converts the stream of
characters into tokens). The Lex tool itself is a compiler. The Lex compiler takes the input and
transforms that input into input patterns. It is commonly used with YACC(Yet Another Compiler
Compiler). It was written by Mike Lesk and Eric Schmidt .
Function of Lex
1. In the first step the source code which is in the Lex language having the file name ‘File.l’ gives as
input to the Lex Compiler commonly known as Lex to get the output as lex.yy.c.
Set-2 key:
1)
Compiler
Compiler is a translator program that translates a program written in (HLL) the source
program and translate it into an equivalent program in (MLL) the target program. As an
45
important part of a compiler is error showing to the programmer.
SourcepgmCompiler targetpgm
Error msg
executing a program written n HLL programming language is basically of two parts. The source
program must first be compiled and translated into a object program. Then the resulting object
program is loaded into a memory executed.
Languages such as BASIC, SNOBOL, LISP can be translated using interpreters. JAVA
also uses interpreter. The process of interpretation can be carried out in following
phases.
1. Lexicalanalysis
2. Synatxanalysis
3. Semanticanalysis
4. DirectExecution
Advantages:
Modificationofuserprogramcanbeeasilymadeandimplementedasexecution proceeds.
5. Typeofobject thatdenotesavariousmay changedynamically.
Debuggingaprogramandfindingerrorsissimplifiedtaskforaprogramused for
interpretation.
Theinterpreterfor thelanguagemakes itmachineindependent.
Disadvantages:
Theexecutionoftheprogramisslower. Memory
consumption is more.
2) Bootstrapping is an important technique in compiler design, where a basic compiler is used to create a
more advanced version of itself. This process helps in building compilers for new programming languages
and improving the ones already in use. By starting with a simple compiler, bootstrapping allows gradual
improvements and makes the compiler more efficient over time.
46
Bootstrapping relies on the idea of a self-compiling compiler, where each iteration improves the compiler’s
ability to handle more complex code.
it simplifies the development cycle, allowing incremental improvements and faster deployment of more
robust compilers.
Many successful programming languages, including C and Java, have used bootstrapping techniques during
their development.
SET-3 KEY:
1)
Compiler
Compiler is a translator program that translates a program written in (HLL) the source
program and translate it into an equivalent program in (MLL) the target program. As an
important part of a compiler is error showing to the programmer.
Error msg
47
executing a program written n HLL programming language is basically of two parts. The source program
must first be compiled and translated into a object program. Then the resulting object program is loaded into
a memory executed.
2) Two Buffer Scheme: To overcome the problem of one buffer scheme, in this method two buffers are
used to store the input string. the first buffer and second buffer are scanned alternately. when end of
current buffer is reached the other buffer is filled. the only problem with this method is that if length of
the lexeme is longer than length of the buffer then scanning input cannot be scanned completely.
Initially both the bp and fp are pointing to the first character of first buffer. Then the fp moves towards
right in search of end of lexeme. as soon as blank character is recognized, the string between bp and fp
is identified as corresponding token. to identify, the boundary of first buffer end of buffer character
should be placed at the end first buffer. Similarly end of second buffer is also recognized by the end of
buffer mark present at the end of second buffer. when fp encounters first eof, then one can recognize end
of first buffer and hence filling up second buffer is started. in the same way when second eof is obtained
then it indicates of second buffer. alternatively both the buffers can be filled up until end of the input
program and stream of tokens is identified. This eof character introduced at the end is
calling Sentinel which is used to identify the end of buffer.
Advantages:
Input buffering can reduce the number of system calls required to read input from the source code,
which can improve performance.
Input buffering can simplify the design of the compiler by reducing the amount of code required to
manage input.
Disadvantages:
If the size of the buffer is too large, it may consume too much memory, leading to slower
performance or even crashes.
If the buffer is not properly managed, it can lead to errors in the output .
3) ContextfreeGrammars(CFG)
CFGisusedtospecifythesyntaxofalanguage.Agrammarnaturallydescribesthe hierarchical
structure of most program-ming language constructs.
48
FormalDefinitionofGrammars
Acontext-freegrammarhasfour components:
1. Asetofterminalsymbols,sometimesreferredtoas"tokens."Theterminalsaretheelementary
symbols of the language defined by the grammar.
2. Asetofnonterminals,sometimescalled"syntacticvariables."Eachnon-
terminalrepresentsasetof strings of terminals, in a manner we shall describe.
3. A set of productions, where each production consists of a nonterminal, called the head
or left sideoftheproduction,anarrow,andasequenceofterminalsand1ornonterminals,called
thebodyorright sideof the production. The intuitive intent of a production is to specify one of
the written forms of a construct; if the head nonterminal represents a construct, then the
bodyrepresents a written form of the construct.
4. A designation ofone of the nonterminalsas thestartsymbol.
Production is for a nonterminal if the nonterminal is the head of the production. A string of
terminalsisasequenceofzeroormoreterminals.Thestringofzeroterminals,writtenas E,iscalled the empty
string.
Derivations
A grammar derives strings by beginning with the start symbol and repeatedly replacing a nonterminal
bythebodyofaproductionforthatnonterminal.Theterminalstringsthatcanbederivedfromthestart symbol
form the language defined by the grammar.
LeftmostandRightmostDerivationofa String
Leftmostderivation−Aleftmostderivationisobtainedbyapplyingproductiontotheleftmost
variableineachstep.
Rightmostderivation −Arightmostderivationisobtainedbyapplyingproductiontothe rightmost
variable in each step.
Example
Letanysetofproduction rulesinaCFG be
X→ X+X |X*X |X|a
overanalphabet{a}.
Theleftmost derivation for thestring"a+a*a"is
X→ X+X→ a+X → a+X*X→a+a*X→a+a*a
Therightmost derivation for theabovestring"a+a*a"is
X→ X*X→X*a→X+X*a→ X+a*a→ a+a*a
DerivationorYield ofaTree
The derivation or the yield of a parse tree is the final string obtained by concatenating the labels of the
49
leaves ofthetree from leftto right, ignoring theNulls. However,if all theleaves areNull, derivation is
Null.
parse tree pictorially shows how the start symbol of a grammar derives a string in the language. If
nonterminal A has a production AXYZ , then a parse tree may have an interior node labeled Awith
three children labeled X, Y, and Z, from left to right:
Givenacontext-freegrammar,aparsetreeaccordingtothegrammarisatreewiththefollowing properties:
1. Theroot islabeled bythestart symbol.
2. Eachleafislabeledby a terminalorbye.
3. Eachinteriornodeislabeled by a nonterminal
SET-4 KEY :
The lexical analyzer scans the input from left to right one character at a time. It uses two pointers begin
ptr(bp) and forward to keep track of the pointer of the input scanned.
50
Initially both the pointers point to the first character of the input string as shown below
The forward ptr moves ahead to search for end of lexeme. As soon as the blank space is encountered, it
indicates end of lexeme. In above example as soon as ptr (fp) encounters a blank space the lexeme “int” is
identified. The fp will be moved ahead at white space, when fp encounters white space, it ignore and
moves ahead.
then both the begin ptr(bp) and forward ptr(fp) are set at next token. The input character is thus read from
secondary storage, but reading in this way from secondary storage is costly. hence buffering technique is
used.A block of data is first read into a buffer, and then second by lexical analyzer.
there are two methods used in this context: One Buffer Scheme, and Two Buffer Scheme.
51
Weak and advanced learners Identification
Process:
Got the results of 3-1 semester.
Identified the students who got failed in 3-1 sem results–Weak learners.
Faculty signature
52
Course Name:Compiler Design Regulation:R20
Year – Sem: III – II Academic Year:2024-25
Branch: CSE
Weak learners identified before commencement of class work from result analysis III-I.
Students who got failed in the 3-1 semester exams.
Facultysignature
53
Result Analysis to Identify advanced learners
Note: These students are instructed and guided to solve previous GATE EXAM
questions from Compiler Design.
Advanced learners identified after III-I sem results-who got more than 70%
percentage.
FacultySignature
54
Date:08-02-2025
Circular
RemedialclassesforIIIB.TechISemCSE-1studentsforCompilerDesigncourse is scheduled
from 4:00 P.M – 5.00 P.M as follows .The students whoarein thelistshould attend
theclasses without failotherwiseaction will be taken.
Remedial ClassNo.
1 2 3 4
55
PLAN FOR REMEDIAL CLASS FOR WEAK STUDENTS
CSE
Doubts clarification
2 17-02-2025 RegardingUnit-2
CSE
Doubts clarification
3 21-02-2025 RegardingUnit-3
CSE
Doubts clarification
4 25-02-2025 RegardingUnit -4,5
FacultySignature
56
Course Name:Compiler Design Branch: CSE
Regulation:R20 Year – Sem: III – II
Academic Year: 2024-25
RollNo
S.No 10-02--2025 17-02-2025 21-02-2025 25-02-2025
CSE
226W1A0504
1 P P P A
226W1A0510
2 P P P P
226W1A0522
3 A P A P
226W1A0526
4 P A P A
226W1A0532
5 A P P P
226W1A0532
6 P A A P
226W1A0536
7 A P A P
226W1A0544
8 P P P A
9 226W1A0548
P P P A
10 226W1A0550
P P P P
11 226W1A0559
A P A P
12 226W1A0572
P A P A
13 226W1A0592
A P P P
14 226W1A0596
P A A P
15 226W1A0598
A P A P
16 226W1A05A1
P P P A
17 226W1A05A1
A P A P
18 226W1A05A2
P P P A
19 226W1A05A2
P P P A
20 226W1A05A6
P P P P
FacultySignature
57
58
COMPILER DESIGN PREVIOUS QUESTION PAPERS
59
60
61
62
63
64
Web References
W1 202.113.80.118:8080/sjjg/upLoad/down/.../20120704005.doc
W2 baggins.nottingham.edu.my/~hsooihock/G52CMP/semantic.ppt
W3 books.google.co.in/books?isbn=8131707881
W5 digitallibrary.srmuniv.ac.in/dspace/bitstream/.../l/3259.pdf ...
65
COMPILER DESIGN MCQs
BRANCH:CSE SEM:3-2
Question:1
Acompilerwhichallowsonlythemodifiedsectionofthesourcecodetoberecompiledis called
(A) Subjectivecompiler
(B) Dynamiccompiler
(C) Re-configurablecompiler
(D) Incremental compiler
Ans:D
Question: 2
Acompilerispreferabletoaninterpreterbecause
(A) Debuggingcanbefasterandeasier
(B) Ifonechangesastatement,onlythatstatementneedsre-compilation
(C) Itismuchhelpfulintheinitialstagesofprogramdevelopment
(D) Itcangeneratestandaloneprogramsthatoftentakelesstimeforexec
utionAns: D
Question:3
Whichofthefollowingsymboltableimplementationhastheminimumaccesstime?
(A) Self-organizinglist
(B) Linear
(C) Searchtree
(D) Hash
table
Ans: D
Question:4
66
Atop-downparsergenerates
(A) Left-mostderivationinreverse
(B) Left-mostderivation
(C) Right-mostderivationinreverse
(A) SLR
(B) LALR
(C) CanonicalLR
(D) Operator-
precedence Ans: C
Question:6
Which table is a permanent database that has an entry for each terminal symbol?
(A) Reductions
(B) Identifiertable
(C) Literaltable
(D) Terminal
table Ans: D
Question:7
Theactionofparsingthesourceprogramintopropersyntacticclassesiscalled
67
(A) Generalsyntaxanalysis
(B) Interpretationanalysis
(C) Syntaxanalysis
(D) Lexical
analysis Ans: D
Q8.Abottom-upparsergenerates
(A) Left-mostderivationinreverse
(B) Left-mostderivation
(C) Right-mostderivationinreverse
Question:9
Thebottom-upparsingmethodisalsocalled
(A) Shiftreduceparsing
(B) Predictiveparsing
(C) Recursivedescentparsing
(D) None of
these Ans: A
Question:10
Themethodwhichmergesthebodiesoftwoloopsis
(A) Constantfolding
68
(B) Loopjamming
(C) Loopunrolling
(D) None of
these Ans: B
Question:11
Synthesizedattributecanbeeasilysimulatedbya
(A) LRgrammar
(B) LLgrammar
(C) Ambiguousgrammar
(D) None of
these Ans: A
Question:12
Thetop-downparsingmethodisalsocalled
(A) Operatorprecedenceparsing
(B) Recursivedescentparsing
(C) Shiftreduceparsing
Ans: B
Question:13
Which ofthe following techniques isusedto replace run-time computations by compile time
computations?
(A) Constantfolding
69
(B) Codehoisting
(C) Peepholeoptimization
(D) Invariant
computation Ans: A
Question:14
The most general phase structured grammar
(A) Contextsensitive
(B) Contextfree
(C) Regular
(D) None of these
Ans: A
Question:15
(A) Assignmentstatement
(B) Structuralstatements
(C) Inputandoutputstatements
(D) Declaratio
n Ans: B
Question:16
Thelexicalanalyzertakes asinputandproducesalistof
ofoutput.
(A) Machinecode,mnemonic
70
(B) Tokens,sourcecode
(C) Sourcecode,tokens
Ans: C
Question:17
Linearanalysisiscalled inacompiler.
(A) Lexicalanalysis
(B) Scanning
(C) Testing
Ans: D
Question:18
Lexicalanalysisisaboutbreakingasequenceofcharactersinto
Tokens
(A) Lines
(B) Groups
(C) Packets
Ans: A
Question:19
ThephaseSyntaxAnalysisismodeledonthebasisof
(A) Highlevellanguage
(B) Lowlevellanguage
(C) Contextfreegrammar
71
(D) Regular grammar
Ans: C
Question:20
Compilerisaprogramthat
(A) Acceptsaprogramwritteninahighlevellanguageandproducesanobjectprogram
(B) Appearstoexecuteasourceprogramasifitweremachinelanguage
(C) Automatesthetranslationofassemblylanguageintomachinelanguage
executionAns: A
Question:21
Anoptimizingcompiler
(A) Isoptimizedtooccupylessspace
(B) Optimizedthecode
(C) Isoptimizedtotakelesstimeforexecution
Ans: B
Question:22
A compiler forahighlevel language thatrunsonone machine
andproducecodefordifferentmachineiscalled
(A) Onepasscompiler
(B) multipasscompiler
(C) crooscompiler
(D) optimizing
72
compiler Ans: C
Question:23
The graph that shows the basic blocks and their successorrelationship is called
(A) Hamiltoniangraph
(B) Controlgraph
(C) Flowgraph
(D) DAG
Ans:C
Question:24
constructs the desired target program from the intermediate
representation of the source program.
(A) Analysispart
(B) Lexicalpart
(C) Synthesispart
Ans: C
Question:25
Whatisthe name ofthe process that determining whether of tokens canbe
generated bya grammar?
(A) Analysing
(B) Parsing
(C) Translating
73
(D) Recognizing
Ans: B
Question:26
grammarsarenotphasestructuredgrammar.
(A) Regular
(B) Contextfree
(C) Contextsensitive
Ans: D
Question:27
Theparsingtechniquethatavoidsbacktrackingis
(A) Top-downparsing
(B) Recursive-descentparsing
(C) Predictiveparsing
Ans: D
Question:28
CSG(COntextSensitiveGrammar)canberecognizedby
(A) Pushdownautomata
(B) Finitestateautomata
(C) 2-waylinearboundedautomata
Ans: C
Question:29
74
Which of the following symbol table implementation is based onthe property
of locality of reference?
(A) Linearlist
(B) Self-organizinglist
(C) Searchtree
Ans: B
Question:30
The process of searching for matched tokens is typically
described using
(A) Finiteautomata
(B) Regularexpressions
(C) Contextfreegrammar
Ans: D
Question:31
Loaderisaprogramthat
(A) Placesprogramsintomemoryandpreparesthemforexecution
(B) Automatesthetranslationofassemblylanguageintomachinelanguage
(C) Acceptsaprogramwritteninahighlevellanguageandproducesanobjectprogram
Ans: A
75
Question:32
Interpreterispreferredoveracompileris
(A) Duringprogramdevelopmentphase
(B) Whenstoragespaceistobeminimized
(C) Whenefficientuseofcomputerresourcesistheconsideration
Ans: A
Question:33
Which ofthe following isusedfor grouping of characters into tokens?
(A) Scanner
(B) Codegenerator
(C) Codeoptimizer
(D) Parser
Ans: A
Question:34
Typecheckingisnormallydoneduring
(A) Codeoptimization
(B) Syntaxdirectedtranslation
(C) Lexicalanalysis
Ans: B
Question:35
Back-patchingisusefulforhandling
76
(A) Forwardreferences
(B) Backwardreferences
(C) Conditionaljumps
(D) Unconditional
jumps Ans: A
Question:36
isconsideredasasequenceofcharactersinatoken.
(A) Pattern
(B) Texeme
(C) Lexeme
(D) Mexeme
Question:37
or scanning is the process, where the stream of
charactersmakingupthesourceprogramisreadfromlefttorightand grouped into
tokens.
(A) Modeling
(B) Diversion
(C) Lexicalanalysis
Ans: C
Question:38
LRstands for
(D) Lefttorightandrightmostderivationinreverse
Ans: D
Question:39
Recursivedescentparsingbelongstotheclassof
(A) Top-downparsing
(B) Bottom-upparsing
(C) Predictiveparsing
Ans: A
Question:40
The graph depicting the inter-dependencies of the attribute ofdifferent nodes in a parse
is called
(A) Dependencygraph
(B) Karnaugh’sgraph
(C) Steffigraph
Ans: C
Question:41
Compiler should report the presence of in the source
program, in translation process.
(A) Text
78
(B) Errors
(C) Classes
(D) Objects
Ans: B
Question:42
A basic block can be analyzed by
(A) Graphwithcycles
(B) DAG
(C) Flowgraph
(D) Noneofthese
Ans: B
Question:43
Minimum hamming distance method isused for connection of
Ans: D
Question:44
Theoutputoflexicalanalyzeris
(A) Stringsofcharacters
(B) Asetoftokens
(C) Syntaxtree
79
(D) A set of regular expressions
Ans: B
Question:45
Symboltablecanbeusedfor
(A) Storageallocation
(B) Checkingtypecompatibility
(C) Suppressingduplicationoferrormessages
Ans: D
Question:46
compilercancheck error.
(A) syntax
(B) logical
(C) content
Ans: A
Question:47
Whichofthefollowingislanguageprocessor?
(A) Interpreters
(B) Assembler
(C) Compilers
80
(D) All of these
Ans: D
Question:48
CFG(ContextFreeGrammar)canberecognizedbya
(A) Pushdownautomata
(B) Finitestateautomata
(C) 2waylinearboundedautomata
Ans: D
Question:49
Handlepruningisthetechniqueusedtoobtain
(A) Canonicalreductionsequence
(B) Canonicalderivationsequence
(C) Both(a)and(b)
Ans: A
Question:50
Semanticerrorscanbedetectedat
(A) Compiletimeonly
(B) Run-timeonly
(C) Both(a)and(b)
81
(D) None of these
Ans: C
Question:51
Apermanentdatabaseinthegeneralmodelofcompileris
(A) Sourcecode
(B) Terminaltable
(C) Identifiertable
(D) Literal
table Ans: B
Question:52
Which of the following actions an operator-precedence parser
maytaketorecoverfromanerror?
(A) Insertsymbolsontothestack
(B) Deletesymbolsfromthestack
(C) Insertordeletesymbolsfromtheinput
Ans: D
Question:53
Which of the following system software resides in main memoryalways?
(A) Texteditor
(B) Assembler
(C) Linker
Question:54
Leftfactoring is the process of factoring out the common
(A) Prefixesofalternates
(B) Suffixesofalternates
(C) Both(a)and(b)
Ans: A
Question:55
is/arepartsofthecompiler.
(A) Executionpart
(B) Analysispart
(C) Synthesispart
Ans: D
Question:56
How many parts of compiler are there?
(A) 2
(B) 4
(C) 6
(D) 8
Ans:A
83
Question:57
Which of the following is/arethephasesofcompiler?
(A) Codegeneration
(B) Syntaxanalyser
(C) Lexicalanalyser
Ans: D
Question:58
Compilertranslatesthesourcecodeto
(A) Machinecode
(B) Executablecode
(C) Binarycode
(D) BothAandC
Ans:D
Question:59
Grammar of the programming is checked at phaseof
compiler.
(A) Syntaxanalysis
(B) Semanticanalysis
(C) Codegeneration
Ans: A
84
Question:60
Whichofthefollowinggroupsis/aretokentogetherintosyntactic structures?
(A) Syntaxanalyzer
(B) Semanticanalyzer
(C) Lexicalanalyzer
(D) Intermediatecodegeneration
Ans:C
Question:61
What is a compiler?
(A) Acompileriscalculatingdevicewhichisprovidingveryefficientexecution
(B) Acompilerisageneralpurposelanguageprovidingveryefficientexecution
Question:62
Only OS independent compiler is
(A) Javacompiler
(B) Visualbasiccompiler
(C) Pascalcompiler
(D) Turbo C
compiler Ans: A
Question:63
The phase ‘Semantic Analysis’ is responsible for in
Compiler.
85
(A) Checksemantics
(B) Staticchecking
(C) Typechecking
Ans: D
Question:64
Theerrorsthatcanbepointedoutbythecompilerareknownas
(A) Internalerrors
(B) Logicalerrors
(C) Semanticerrors
Ans: D
Question:65
What do you call the translator which takes assembly language program as input & produce
machine languagecodeasoutput?
(A) Assembler
(B) Compiler
(C) Debugger
(D) Interpreter
Ans: A
Question:66
Which ofthe following cannot beusedasan intermediate code form?
(A) Quadruples
(B) Syntaxtrees
(C) Threeaddresscodes
(D) Post fix notation
Ans: A
86
Question:67
Whichofthefollowingcanbeusedtoidentifyloops?
(A) Dominators
(B) Reduciblegraphs
(C) Depthfirstordering
(D) All of these
Ans: D
Question:68
Thecostofdevelopingacompilerisproportionalto
(A) Flexibilityoftheavailableinstructionset
(B) Complexityofthearchitectureofthetargetmachine
(C) Complexityofthesourcelanguage
Ans: D
Question:69
Replacement of an expensive operation by a cheaper one iscalled
(A) Reductioninstrength
(B) Loop-invariantcomputation
(C) Codemotion
Ans: A
87
Question:70
(A) Faultydesignspecification
(B) Faultyalgorithm
(C) Compilersthemselves
Ans: D
Question:71
Programminglanguagescanbecategoriesas
(A) Assemblylanguage
(B) Highlevellanguage
(C) Machinelanguage
Ans: D
Question:72
WhatisthemeaningofaCompiler?
(A) Namegiventothecomputeroperator
(B) Partofthedigitalmachinetostoreinformation
(C) OperatorofBooleanalgebra
codeAns: D
88
Question:73
Language used ina computer that is similar tothe languages of
humanandiseasytounderstand,isreferredas
(A) Sourcecode
(B) Machinelanguage
Ans: D
Question:74
Whichamongthefollowingis/areinterpretedlanguage?
(A) C++
(B) Java
(C) Visualbasic
Ans: D
Question:75
What is a notation for writing programs, which are specificationsof a
computation or algorithm?
(A) Aprogramminglanguage
(B) Anoperatingsystem
(C) Hardware
Question:7
6
Whatisthe action of parsing the source program into proper syntatic
classes?
(A) Syntaxanalysis
(B) Lexicalanalyis
(C) Interpretationanalysis
(D) Generalsyntaxanalysis
Ans:B
Question:77
isaprocessoffindingaparsetreeforastringoftokens.
(A) Analysing
(B) Recognizing
(C) Parsing
(D) Tokenizing
Ans: C
Question:78
Representing the syntax by a grammar is advantageous. Whatis the cause?
(A) Itisconcise
(B) Itisaccurate
(C) Automationbecomeseasy
Ans: D
90
Question:79
A grammar thatproducesmorethanoneparsetreeforsome sentence is called as
(A) Ambiguous
(B) Regular
(C) Unambiguous
Ans: A
Question:80
A isasoftwareutilitythattranslatescodewritteninhigher language into a
low level language.
(A) Converter
(B) Texteditor
Question:81
Which programming languages are classified as low level languages?
(A) BASIC,COBOL,FORTRAN
(B) Assemblylanguages
(C) KnowledgebasedSystems
Ans: B
91
Question:82
A compiler translate high level programs into low
levelprograms, which is called as
(A) Betacode
(B) Compiledcode
(C) Sourcecode
Ans: D
Question:83
Whatisaninterpreter?
(A) Aninterpreterisadecoderwhichprovidesveryefficientexecution
(B) Aninterpreterisageneralpurposelanguageprovidingveryefficientexecution
(C) Aninterpreterdoestheconversionlinebylineastheprogramisrun
(D) Aninterpreteristherepresentationofthesystembeingdesigned
Ans:D
Question:84
The translator program used in assembly language is called
(A) Assembler
(B) Interpreter
(C) Compiler
(D) Translator
Ans: A
92
Question: 85
A(n) languagereflectsthewaypeoplethinkmathematically.
(A) Functionalprogramming
(B) Crossplatformprogramming
(C) 3GLbusinessprogramming
93