Left Recursion - Compiler Construction and Languages - Past Exam, Exams of Compiler Construction

Main points of this exam paper Compiler Construction and Languages are: Grammar, Language, Illustrates, Non-Deterministic, Finite State, State Automaton, Tabular Form, Deterministic Finite, Productions, Immediate Left Recursion

Typology: Exams

2012/2013

Uploaded on 03/24/2013

asita
asita 🇮🇳

1

(1)

75 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Cork Institute of Technology
Bachelor of Science (Honours) in Computer Applications – Award
(Bachelor of Science in Computer Applications – Award)
(NFQ – Level 8)
Autumn 2005
Compiler Construction and Languages
(Time: 3 Hours)
Instructions
Answer FOUR questions
All questions carry equal marks.
Examiners: Mr. E. A. Parslow
Mr. P. O Connor
Dr. D. Chambers
Mr. C.E. Manning
Q. 1
Part A. (5 marks)
L is a language where 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. (6 marks)
Write a Type 3 Grammar for the language described by ad*d+(ddcd)*fg
[No marks available for a Type 2]
pf3
pf4
pf5

Partial preview of the text

Download Left Recursion - Compiler Construction and Languages - Past Exam and more Exams Compiler Construction in PDF only on Docsity!

Cork Institute of Technology

Bachelor of Science (Honours) in Computer Applications – Award

(Bachelor of Science in Computer Applications – Award)

(NFQ – Level 8)

Autumn 2005

Compiler Construction and Languages

(Time: 3 Hours)

Instructions Answer FOUR questions All questions carry equal marks.

Examiners: Mr. E. A. Parslow Mr. P. O Connor Dr. D. Chambers Mr. C.E. Manning

Q. 1

Part A. (5 marks) L is a language where 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. (6 marks) Write a Type 3 Grammar for the language described by ad^ d+^ (ddcd)fg [No marks available for a Type 2]

Part C. (7 marks) Construct a deterministic finite state automaton (DFA) that is equivalent to ad^ d+^ (ddcd)fg [No marks available for a non deterministic machine]

Part D. (7 marks) Table 1

State ε a b c 0 - Start 3 1 2 1 3 2 3 2 - Accept 3 2 3 1

Table 1 illustrates a non-deterministic finite state automaton in tabular form. Construct an equivalent deterministic finite state automaton.

Q. 3

Part A (10 marks) Construct an LR parser for the language described by grammar G 4

G 4 :

  1. S -> dP
  2. S -> bR
  3. P -> d
  4. R -> ccR
  5. R -> d

Part B (15 marks) Construct a top down parser for the language described by G 5

G 5 : E -> E + T E -> E – T E -> T T -> T * F T -> T / F T -> F F -> ( E ) F -> I

Q. 4

Part A (10 marks) State the pumping lemma for regular languages.

Part B (15 marks) Use the pumping lemma to prove that the language

an^ bcn

is not regular

Q. 5

Part A (7 marks) Use Dijkstra’s shunting algorithm to rewrite a$bc$d@e@f@g#h@j in postfix form. The order of precedence for operators is @$# with # having the highest prececence.

Part B (6 marks) How might a shift register be used for a reduction in strength? Illustrate your answer with code.

Part C (6 marks) What is common sub-expression elimination? Illustrate your answer with code.

Part D (6 marks) What is code hoisting? Illustrate your answer with code

Q. 6

Part A (5 marks) What is register slaving?

Part B (5 marks) What is a register descriptor table?

Part C (7 marks) In what circumstances is spilling advisable?