Assignment 1 2015

2
C O M P I L E RD E S I G N ASSIGNMENT – I Floating date: 26 th Feb ! S"b#i$$ion date: 6 th Ma%&h ! E'e%&i$e : Describe the languages denoted by the following regular expressions: a( a ) ba ) ba ) ba ) * b( +a,b( , ab +a,b( ) E'e%&i$e 2: Write regular definitions for the following languages: a) All strings of a's and b's with an even number of a's and an odd number of b)All strings of a's and b's that do not contain the substring abb. c) All strings of a's and b's that do not contain the subsequence abb. E'e%&i$e -: Design finite automata deterministic or nondeterministic) for each of languages of E'e%&i$e 2* E'e%&i$e .: !onvert the following regular expressions to deterministic finite autom using algorithms : a ) ba ) ba ) ba , E'e%&i$e !: !onsider the context#free grammar: S SS, / SS) /a and the string aa$a%. a) &ive a leftmost derivation for the string. b)&ive a rightmost derivation for the string. c) &ive a parse tree for the string. d) s the grammar ambiguous or unambiguous( ustify your answer. e) Describe the language generated by this grammar. E'e%&i$e 6: *epeat E'e%&i$e ! for each of the following grammar and strings: a( S ,S S / ) S S / a +0ith $t%ing ,)aaa (* b( S S +S( S / 1 + 0ith $t%ing ++(+(( (* &( S aSbS / bSaS / 1 + 0ith $t%ing aabbab (* E'e%&i$e : !ompute + *,- and + // W for the grammar of E'e%&i$e ! and 6 .

description

yuytu

Transcript of Assignment 1 2015

C O M P I L E R D E S I G N

ASSIGNMENT I

Floating date: 26th Feb 15

Submission date: 16th March 15Exercise 1: Describe the languages denoted by the following regular expressions:

a) a* ba* ba* ba* .

b) (a+b) + ab (a+b) *Exercise 2: Write regular definitions for the following languages:

a) All strings of a's and b's with an even number of a's and an odd number of b's.

b) All strings of a's and b's that do not contain the substring abb.

c) All strings of a's and b's that do not contain the subsequence abb.

Exercise 3: Design finite automata (deterministic or nondeterministic) for each of the languages of Exercise 2.Exercise 4: Convert the following regular expressions to deterministic finite automata, using algorithms:

a* ba* ba* ba+Exercise 5: Consider the context-free grammar:

S( SS+ | SS* |a

and the string aa+a*.

a) Give a leftmost derivation for the string.

b) Give a rightmost derivation for the string.

c) Give a parse tree for the string.

d) Is the grammar ambiguous or unambiguous? Justify your answer.

e) Describe the language generated by this grammar.

Exercise 6: Repeat Exercise 5 for each of the following grammar and strings:

a) S ( +S S | * S S | a (with string +*aaa ).

b) S ( S (S) S | ( with string (()()) ).

c) S ( aSbS | bSaS | ( with string aabbab ).

Exercise 7: Compute FIRST and FOLLOW for the grammar of Exercise 5 and 6.