CD Unit-I questions_MSWEC
CD Unit-I questions_MSWEC
July -2023
1. a) Discuss the phases of a compiler indicating the inputs and outputs of each
phase in translating the statement “a=p+r*36.0”.
b) Discuss about the role of lexical analyzer. Explain with program.
2. a) Explain various data structures used in lexical analysis.
b) Write a Regular Expression for identifier, reserved words & relation operators.
Design a transition diagram for each of them.
3. a) Explain the boot strapping process with suitable examples and diagrams.
b) Construct an FA equivalent to the regular expression (0+1)*(00+11)(0+1)*
4. a) Write about tokens generated by lexical analyzers. Describe the lexical errors
and various error recovery strategies with suitable examples.
b) Define Regular Expression. Explain the properties of Regular Expressions.
Discuss with suitable examples.
5. a) Explain various building blocks used to design a language translator.
b) Differentiate between
i) Phase and a pass ii) single-pass and multi-pass compiler.
6 a) What is LEX? Discuss the usage of LEX in Lexical Analyzer generation.
b) Construct a Finite Automata and Scanning algorithm for recognizing
identifiers, numerical constants in C language.
7. a) Write about Phases of a compiler. Explain each with an example.
b) Explain about Input Buffering in lexical Analyzer with an example.
8. a) Describe the need and functionality of linkers, assemblers and loaders.
b) State the steps to convert a regular expression to NFA. Explain with an
example.
December 2023
9. a) How to specify the tokens? Differentiate token, lexeme and pattern with
suitable examples.
b) Write the steps to convert Non-Deterministic Finite Automata (NDFA) into
Deterministic Finite Automata (DFA).
10. a) Write about Phases of a compiler. Explain each with an Example.
b) Give the general format of a LEX program.
June-2024
11. a)What are the different phases of compilation and explain the phases of the
compilation with the following C language statement as an input.
position = initial + rate * 60;
where position, initial, and rate are variables of type double
b) The programming language may be case sensitive or case in sensitive. Case
sensitive languages treat uppercase and lowercase letters as distinct characters in
programming whereas case insensitive languages treat both as same. Most of the
programming languages are case sensitive, However some languages like SQL are
case insensitive so the keyword can be written either in lower case, upper case, or
in any mixture case. The SQL keyword SELECT can also be written select,
Select, or SeLeCT. Show how to write a regular expression for a keyword in a
case insensitive language, explain with “select” in SQL
12. a) What is sentinel character in input buffering and explain its significance
b)Write a regular expression for recognizing the following patterns where input
alphabet {a,b,c}
i) Which begins with „a‟ and ends with „c‟
ii) Which begins and ends with same symbol
13. a) What is boot strapping in the context of compiler and explain how it helps in
language independence and reducing development time.
b) Write a regular expression for recognizing the following tokens in C
i) Identifier ii) integer constant iii) string constant.
14. a) What is input buffering in the context of lexical analysis and explain why we
take pair of input buffers instead of single buffer in lexical analysis.
b) Explain the output of the following Lex specification on input abbbabaa
%%
a*b {printf(“1”); }
ab* {printf(“2”); }
b*a {printf(“3”); }
ba* {printf(“4”); }
%%
15. a) Compare and contrast compiler and interpreter.
b) Define token, pattern, and lexeme. And mark the token, lexeme and pattern
required for the following C language statement.
printf(“ sum of %d and %d is %d”,a,b,a+b)
16. a) What are the different ways of designing a lexical analyzer and explain each
method with an example.
b) Write a regular expression for recognizing the following patterns where input
alphabet {a,b,c}
i) Which contains at least one a and at most one b
ii) Which contains at lease two a‟s and at most two b‟s
17. a) Define compiler and explain which phases of the compilation are machine dependent
and which are machine-independent.
b) Languages like Fortran ignores spaces and spaces having no significance,
Consider the following the statements A and B in Fortan
A: DO 5 I = 1.50
B: DO 5 I = 1,50
In statement A DO5I is an identifier and In statement B DO is a keyword. How
a lexical analyzer differentiates DO in statement A and B explain.
18. a) Explain the purpose of lexeme beginning and forward pointers in buffer pairs
with an example.
b) Explain the output of the following Lex specification on input bbaabaab
%%
a*b {printf(“1”); }
ab* {printf(“2”); }
b*a {printf(“3”); }
ba* {printf(“4”); }
%%
November -2024
19. a) What is the role of a Lexical Analyzer? Discuss about the issues and error
recovery strategies in Lexical analyzer.
b) Differentiate between i) phase and a pass ii) single-pass and multi-pass compiler.
20. a) Explain about Input Buffering in lexical Analyzer with a example.
b) Describe the lexical errors and various error recovery strategies with suitable
examples.