Sie sind auf Seite 1von 2

Compiler Design Mid Exam for 4th year department of

Computer Science and Engineering (30%)


1) Differentiate the terms Tokens, Lexemes and Patterns in compiler design? (2pt)

2) Describe the language denoted by the following regular expressions: (3pt)


a) a(a|b)*a (1pt)
b) (a|b)*a(a|b)(a|b) (1pt)
c) a*ba*ba*ba* (1pt)
3) Write regular expression for the following languages. (5pt)
a) All strings of a’s and b’s that contain at least two b's. (1.5pt)
b) All strings of a’s and b’s that contain just two or three b`s (1.5pt)
c) All strings of digits that represent even numbers (2pt)
4) Make a DFA equivalent to the following NFA: (5pt)

5) for all strings of a’s and b’s that contain an odd number of a’s find: (10pt)
a) Regular expression of the above language (2pt)
b) NFA (2.5pt)
c) DFA (3pt)
d) Minimized DFA if possible (2.5pt)
6) Construct a Deterministic Finite Automata (DFA) to accept a string which has neither aa nor
bb as a substring formulated from the alphabets ‘a’ and ‘b’. (5pt )
Bonus: 2pt for exact answer only
Find the total number of tokens from the following C programming code after it has scanned by
the lexical analyzer

int max(int x,int y)


{
return x>y?x:y; /*Find Maximum of X and Y*/
}
Int main ()
{
int x,y,maxOfXy;
x=10, y=20;
maxOfXy =max(x,y);
printf(“Maximum of X and Y =%d”, maxOfXy);
return 0;
}

Das könnte Ihnen auch gefallen