


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Instructions Answer FOUR questions All questions carry equal marks.
Examiners: Dr. M. O’Cinneide Mr. M. Donnelly Mr. C.E. Manning
Q. 1 (25 marks)
Part A. (5 marks) L is a language were all the words have exactly the same number of as, bs, and cs. E.g. aabccb, cbbbaacac. Write a grammar for language L
Part B. (10 marks) Write a Type 3 Grammar for the language described by ab+f+^ (ffc)*fg [No marks available for a Type 2]
Part C. (10 marks) Construct a deterministic finite state automaton (DFA) that is equivalent to ab+^ f+^ (ffc)*fg [No marks available or an incomplete or non-deterministic machine]
Q. 2 (25 marks)
Part A (10 marks)
Find the FIRST and FOLLOW sets for each of the non-terminals in the grammar G (^1)
G 1 : S -> ABC A -> q | Cr B -> t | zA | ε C -> x | y | ε
Part B (5 marks) G 2 : S -> xS | SB | v B -> By | z
Demonstrate (using xvz or any other word) that grammar G 2 is ambiguous.
Part C (10 marks)
G 3 : Q -> Qz | Qx | z | Ry R -> Qz | y | yT T -> z
Remove all the left recursion from G 3
Part A (10 marks) Construct a Top Down Parse Table for the following grammar
S -> ayB | ayC | aD | z B -> a C -> z D -> z
Part B (15 marks)
ε x^ y^ z
Use the subset construction technique to produce a deterministic finite state automaton equivalent to the one specified in the table above.