Cosc 327
Cosc 327
CHUKA UNIVERSITY
UNIVERSITY EXAMINATIONS
SECTION A
ANSWER ALL THE QUESTIONS IN THIS SECTION
QUESTION ONE [30 MARKS]
a) Highlight the role of the symbol table in the compilation process. [4 Marks]
b) Giving one example for each, differentiate between a low level and a high-level
programming language. [4 Marks]
c) Compilers and Interpreters are both used in the language translation process.
Page 1 of 3
COSC 327
e) List and explain any four outputs of the preprocessor phase of compilation. [4 Marks]
f) Name any five popular compilers and identify the language popularly associated with.
[5 Marks]
SECTION B
ANSWER ANY TWO QUESTIONS FROM THIS SECTION
QUESTION TWO [20 MARKS]
a) In some language processing systems, the compiler compiles to assembly language rather
than to machine language. Discuss the pros and cons of this approach [6 Marks]
ii. Identify any three type of passes in compiler design and describe each briefly
[6 Marks]
c) Describe how a typical Java program is compiled and highlight the benefit of such an
approach of compilation. [4 Marks]
QUESTION THREE [20 MARKS]
a) Draw a diagram of a typical language processing system and explain in detail what happens
at each stage of the processing through the system. [8 Marks]
ii. By referencing the language processing system in a) above, explain how this C++
program moves from source language to target language. [6 Marks]
Page 2 of 3
COSC 327
a) Explain how lexemes becomes tokens and consequently highlight the importance of tokens in
the compilation process. [4 Marks]
b) Formally define a Context Free Grammar and explore the role a Context Free Grammar plays
in the compiler design. [6 Marks]
c) For any context-free grammar there is a parser that takes at most 0(n3) time to parse a string
of n terminals.
ii. Demonstrate how a CFG can be parsed in a typical compile process. [4 Marks]
iii. Cubic time 0(n3) is generally considered too expensive for a parser. Explain what
can be done to reduce this time. [2 Marks]
cubi
e.
a) With the aid of examples, differentiate between syntax and semantic analysis as regards
compilers. [4 Marks]
b) Diagrammatically present the structure of a compiler and explain how each part works and
how they work together. [16 Marks]
----------------------------------------------------------------------------------------------------------------
Page 3 of 3