0% found this document useful (0 votes)
21 views12 pages

Unit - 1 University Questions

compiler design
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views12 pages

Unit - 1 University Questions

compiler design
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

UNIT I INTRODUCTION TO COMPILERS

Structure of a compiler — Lexical Analysis — Role of Lexical Analyzer — Input


Buffering — Specification of Tokens — Recognition of Tokens — Lex — Finite
Automata — Regular Expressions to Automata — Minimizing DFA.

PART-A
1. Define Token.APRIL/MAY20ll MAY/JUNE 2013
The token can be defined as a meaningful group or cha racters over the character set of the
programming language like identifiers, keywords, constants and others.
2. Define Symbol Table. NOV DEC 2 6 MAY/JUNE 2014
A Symbol table is a data structure containing a record for each identifier, w ith fields for the
attributes of the identifier. The data structure allows us to find the record for each identifier
quickly and to store or retrieve data from that record quickly.
3. What is a Complier? MAY/JUNE 2007
A Complier is a program that reads a program written in one language-the source language-
and translatcs it in to an cquivalcnt program in another language-the targct language. As an
iinponaot part of this translation process, the compiler reports to its user the presence of
errors in the source program.
4. What is an interpreter? NOV/DEC 2017
Intrprctcr is a prOgram Which convcrts source language to machinc languagc ine by line.
No intermediate object code is nerated, hence are memory efficient. Ex: Python, COBOL.
5. What do you mean by C ross-Compiler? NOV/DEC 2017
A cross compiler is a comfier capable of creating executable code for a latfgmor other than
the one on which the compiler is run. (ie). A compiler may run on one machine and produce
target code for another machine.
6. What are the cousins of compiler?
(APRIL/MAY2004 APRIL/MAY2005 APRIL/MAY 2012 MAYY/JUNE 2013 MAY/JUNE
2012. APRIL/MAY 2017)

● compilers

● Preprocessors

● Assemblers
● Loaders

● Link editors.

7. What are the main two parts of compilation?What are they performing?
MAY/JUNE 2016 , APRIL/MAY 2010, APRIL/MAY 2017a APRIL/MAY 2018
The two main parts are

● Analysis part breaks up the source program into constituent pieces and creates . An

intermediate representation of the source program.

● Synthesis part constructs the desired target program from the intermediate

representation.
8. What are an assembler and interpreter? APRIL/MAY 2011
Assembler is a program, which converts the assembly language in to machine language.
Interpreter is a program which converts source language into machine language line by line.
9. State any two reasons as to why phases of compiler should be grouped.
MAY/JUNE 2014
The reasons for grouping,
1.Implementation purpose
2.Compiler work is based on two things; one is based on language other one is based on
machine.
10.State some compiler construction tools?NOV/DEC 2016, APRIL/MAY2008
o Scanner generators
o Syntax-directed
o translation engines
o Automatic code generator
o Data flow engines.
o Parse generator
11. What is a preprocessor? Nov/Dec 2004
A preprocessor is one, which produces input to compilers. source program may be divided
into modules stored in separate files. The task of collecting the source program is sometimes
entrusted to a distinct program called a preprocessor. The preprocessor may also expand
macros into source language statements.
12. Depict diagrammatically how a language is processed. MAY/JUNE 2016

13. Write a grammar for branching statements. MAY/JUNE 2016


Stmt
| if expr then stmt else stmt

expr-> term relop term
| term term -> id
14.What is a lexeme? Define a regular set. APRIL/MAY2011,MAY/JUNE2013
MAY/JUNE2014, NOV/DEC 2017
A lexeme is a sequence of characters in the source program that is matched by the pattern
for a token. A language denoted by a regular expression is said to be a regular set.
15.What is a regular expression? State the rules, which define regular expression?
MAY/JUNE 2007,APRIL/MAY 2018
Regular expression is a method to describe regular language Rules:

● €-is a regular expression that denotes {€} that is the set containing the empty

string

● If a is a symbol in ,then a is a regular expression that denotes

{a}

● Suppose r and s are regular expressions denoting the languages L(r ) and L(s)

Then,
o (r )/(s) is a regular expression denoting L(r) U L(s).

o (r )(s) is a regular expression denoting L(r )L(s)


o (r )* is a regular expression denoting L(r)*.
o (r) is a regular expression denoting L(r ).
16.What are the Error-recovery actions in a lexical analyzer? APRIL/MAY 2012,
MAY/JUNE 2013,APRIL/MAY 2015,APRIL/MAY 2018

● Deleting an extraneous character Inserting a missing character

● Replacing an incorrect character by a correct character

● Transposing two adjacent characters

17.Draw a transition diagram to represent relational operators. NOV/DEC 2007


18.What are the issues to be considered in the design of lexical analyzer?
MAY/JUNE 2009

● How to Precisely match Strings to Tokens

● How to Implement a Lexical Analyzer

19.Write short notes on buffer pair. APRIL/MAY 2008


Lexical analyzer will detect the tokens from the source language with the help of input
buffering. The reason is, the lexical analyzer will scan the input character by character, it
will increase the cost file read operation. So buffering is used. The buffer is a pair in which
each half is equal to system read command.
20.How the token structure is is specified? Or Define Patterns. APRIL/MAY 2010,
MAY/JUNE 2013
Token structure is specified with the help of Pattern. The pattern can be described with the
help of Regular Expression
21.What is the role of lexical analyzer? NOV/DEC 2011, NOV/DEC 2014,
NOV/DEC 2017
Its main task is to read input characters and produce as output a sequence of tokens that
parser uses for syntax analysis. Additionally task is removing blank, new line and tab
characters
22.Give the transition diagram for an identifier. NOV/DEC 2011

23.Why is buffering used in lexical analysis? What are the commonly used
buffering methods?MAY/JUNE 2014
Lexical analyzer needs to get the source program statement from character by character,
without buffering it is difficult to synchronize the speed between the read write hardware
and the lexical program. Methods are two way buffering and sentinels.
24.Write regular expression to describe a languages consist of strings made of even
numbers a and b.NOV/DEC 2014
((a+b)(a+b))*
25.What are the various parts in LEX program? APRIL/MAY 2017
Lex specification has three parts declarations
%%
pattern specifications
%%
support routines
26.Write regular expression for identifier and number. NOV/DEC 2012,
APRIL/MAY 2017
For identifier (a-z)((a-z)|(0-9))*other symbols For numbers (0-9)(0-9)*
27.What is a sentinel? What is its usage? April/May 2004
A Sentinel is a special character that cannot be part of the source program. Normally we
use ‘eof’ as the sentinel. This is used for speeding-up the lexical analyzer.
28.Differentiate tokens, patterns, lexeme. NOV/DEC 2016

● Tokens- Sequence of characters that have a collective meaning.


● Patterns- There is a set of strings in the input for which the same token is produced as

output. This set of strings is described by a rule called a pattern associated with the
token

● Lexeme- A sequence of characters in the source program that is matched by the

pattern for a token.

29.List the operations on languages.MAY/JUNE 2016


Union – L U ε ={s | s is in L or s is in ε}
Concatenation – Lε ={st | s is in L and t is in ε}
Kleene Closure – L* (zero or more concatenations of L)
Positive Closure – L+ ( one or more concatenations of L)
30.Differentiate NFA and DFA. NOV/DEC 2017
31.What are the rules that define the regular expression over alphabet? (Or) List
the rules that form the BASIS.NOV/DEC 2016

● € is a regular expression denoting { € }, that is, the language containing only the

empty string.

● For each ‘a’ in Σ, is a regular expression denoting { a }, the language with only

one string consisting of the single symbol ‘a’ .

● If R and S are regular expressions, then

(R )| (S) means L(r) U L(s)


R.S means L(r).L(s) R* denotes L(r*)
Part-B

1. What are the various phases of a compiler? Explain each phase in detail
APRIL/MAY 2011, APRIL/MAY 2012, MAY/JUNE 2014, MAY/JUNE 2013,NOV/DEC 2016,
NOV/DEC 2017
2. Explain the various Cousins of Compiler. APRIL/MAY 2011, APRIL/MAY 2012
,NOV/DEC2014,MAY/JUNE 2015,NOV/DEC2017
3. What are the cousins of a Compiler? Explain them in detail. Explain the need for
grouping of phases of compiler. NOV/DEC 2014,APRIL/MAY 2017
4. Write about the Error handling in different phases. (OR) Explain various Error
encountered in different phases of compiler. MAY/JUNE 2016, NOV/DEC 2016
5. Draw the transition diagram for relational operators and unsigned numbers.
APRIL/MAY2017
6. For the following expression Position: =initial+ rate*60.Write down the output after
each phase.MAY/JUNE 2016, APRIL/MAY 2017
7. Explain language processing system with neat diagram. MAY/JUNE 2016
8. Explain Input Buffering with example. NOV/DEC 2011
9. Explain the specification of tokens, MAY/JUNE 2016,MAY/JUNE 2013,
APRIL/MAY 2008,NOV/DEC 2014
10. Elaborate in detail the recognition of tokens. APRIL/MAY 2012, NOV/DEC 2014
11.Write an algorithm to convert NFA to DFA and minimize DFA. Give an
example.NOV/DEC 2017
12.What are the issues in Lexical analysis? MA Y/JUNE 2016,APRIL/MAY 2012,
MAY/JUNE 2013
13.Minimize the regular expression (a+b)*abb. (NFA toDFA)MAY/JUNE
2016,NOV/DEC 2016, MAY/JUNE 2014, AP IL/MAY 2017, NOV/DEC 2017
14.What is input buffering? Explain technique of buffer pair.MAY/JUNE 2015
15.Differentiate tokens, patterns, lexeme. MAY/JUNE 2016, APRIL/MAY 2017
16.Conversion from Regular Expression to DFA without constructing NFA Example
a*( b*/ c* ) ( a / c ) *o.121) NOV/DEC 2017
17.
1. Explain Input Buffering with example. NOV/DEC 2011
2. Explain the specification oftokens, MAY/JUNE 2016,MAY/JUNE 2013,
APRIL/MAY 2008,NOV/DEC 2014
3. Elaborate in detail the recognition of tokens. APRIL/MAY 2012, NOV/DEC
2014
4. Write an algorithm to convert NFA to DFA and minimize DFA. Give an
example.NOV/DEC 2017
5. What are the issues in Lexical analysis? MA Y/JUNE 2016,APRIL/MAY 2012,
MAY/JUNE 2013
6. Minimize the regular expression (a+b)*abb. (NFA toDFA)MAY/JUNE
2016,NOV/DEC 2016, MAY/JUNE 2014, AP IL/MAY 2017, NOV/DEC 2017
7. What is input buffering? Explain technique of buffer pair.MAY/JUNE 2015
8. Differentiate tokens, patterns, lexeme. MAY/JUNE 2016, APRIL/MAY 2017
9. Conversion from Regular Expression to DFA without constructing NFA Example
a*( b*/ c* ) ( a / c ) *o.121) NOV/DEC 2017
10.
11.

You might also like