Compiler Design GTU CH-2
Compiler Design GTU CH-2
CH-2 IMP
1. Define lexeme, token and pattern. Identify the tokens
from the following program segment (4M)
void change (int c, int d)
{ int m; m = c; c= d; d = m; }
2. Find the Regular Expression corresponding to given
statement subset of {0,1}* (3M)
1) The Language of all strings containing exactly three1’s
2) The Language of all strings begins or ends with 00
3) The Language of all strings that contain at least three
1’s
3. Draw DFA for the following regular expression without
construction of NFA. ( a | b) * a (a | b)# (7M)
4. Write short note on LEX. (4M)
5. Explain input buffering techniques in brief (4M)
6. Explain construction of DFA from regular expression
without making NFA with suitable example. (7M)
7. Explain role of lexical analyzer with example in compiler
design process. (7M)
8. Define lexemes, patterns and tokens (3M)
9. Write a regular definition for:
1. The language of all strings containing at least one 0
and at least one 1.
2. The language of all strings that do not end with 01.
3. The language of all strings containing 0’s and 1’s both
are even.
4. The language of all strings which are starting with 1
and ending with 0
Compiler Design (3170701)
10. Construct the NFA for following regular expression using
Thompson’s construction. Apply subset construction method
to convert into DFA. (a+b)*abb# (7M)
11. Define token, lexeme and pattern. Identify the lexemes
that makes up the tokens for the following code (7M)
const p = 10;
if( a < p)
{ a++ ;
If(a== 5)
continue ;
}
12. Construct deterministic finite automata without
constructing NFA for following regular expression.
(a/b)*abb* (7M)
13. What is lexical analysis? Which are the tasks performed
by lexical analyzer. (3M)
14. Write RE the following language. (3M)
1. All string of 0’s and 1’s that do not contain 11.
2. All string of 0’s and 1’s that every 1 is followed by 00
15. Write the regular expression R over {0,1} or {a,b}: (4M)
1) The set of all strings with even number of a’s followed
by an odd number of b’s.
2) The set of all strings that consist of alternating 0’s and
1’s
Compiler Design (3170701)
16. Draw the DFA for the regular expression (a|b)*abb using
set construction method only (7M)
17. Draw NFA from regular expression using Thomson’s
construction and convert it into DFA. (a | b)* a b* a