Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Assignment 3 – Compiler Design

Q1. Which of the following strings is not matched by the regular expression (B(AB|A)*D)*
a) BD
b) BABD
c) BAADBAABDBAD
d) BAADBAABBDBAD
Ans: D: BAADBAABBDBAD

Q2. At a time, a DFA can be in


a) Many states
b) No state
c) Only a single state
d) None of the other options
Ans: C

Q3. Between NFA and DFA which an has the potential to have more states in it?
a) NFA
b) DFA
c) Cannot be said deterministically
d) Both have same number of states
Ans: B
DFA can have much greater number of states in it as compared to NFA.

Q4. At a time, an NFA can be in


a) Many states
b) No state
c) Only a single state
d) None of the other options
Ans: A

Q5. -closure of a state includes


a) All states reachable from it by  transitions only
b) All states reachable from it by single  transitions only
c) All states from which this state can be reached using  transitions
d) All states from which this state can be reached using  transitions and all states reachable
from it by  transitions only

Ans: A
-closure of a state includes all states reachable from it by exactly  transitions.

Q6. Output of lex program is available in a file named


a) lex.l
b) lex.yy.c
c) lex.yy.l
d) lex.c
Ans: B
Q7. Lex specification file sections are demarcated by
a) %
b) {%
c) %}
d) %%

Ans: D
Lex specification file sections are demarcated by %%.

Q8. Which of the following is a lexical analysis tool?


a) Jflex
b) Flex
c) Lex
d) All of the other options

Ans: D
jflex, flex and lex all are lexical analysis tools.

Q9. Number of components in formal definition of a grammar is


a) 2
b) 3
c) 4
d) None of the other options

Ans: C
There are 4 components in the formal definition of a grammar, which are, set of nonterminal
symbols used to write the grammar, set of words in the language, set of production rules and a
special symbol signifying the start of the grammar.

Q10. In a lex specification file "?" stands for


a) Exactly one occurrence of preceding regular expression
b) One or more occurrence of preceding regular expression
c) 0 or more occurrences of preceding regular expression
d) None of the other options

Ans: D

Q11. Number of sections in a lex program is


a) 4
b) 3
c) 2
d) 1
Ans: B

You might also like