In this question, you are shown pseudocode in place of a real high-level language. A compiler uses

Question:

In this question, you are shown pseudocode in place of a real high-level language.
A compiler uses a keyword table and a symbol table.
Part of the keyword table is shown below.
– Tokens for keywords are shown in hexadecimal.

– All the keyword tokens are in the range 00 to 5F.

Entries in the symbol table are allocated tokens. These values start from 60 (hexadecimal).
Study the following piece of code:

a) Copy and complete this symbol table to show its contents after the lexical analysis stage.

b) Each cell below represents one byte of the output from the lexical analysis stage. Using the keyword table and your answer to part a), copy and complete the output from the lexical analysis.

c) The compilation process has a number of stages. The output of the lexical analysis stage forms the input to the next stage.
i) Name this stage.
ii) State two tasks that occur at this stage.

d) The final stage of compilation is optimisation. There are a number of reasons for performing optimisation. One reason is to produce code that minimises the amount of memory used.
i) State another reason for the optimisation of code.
ii) What could a compiler do to optimise the following expression?

iii) These lines of code are to be compiled:

Following the syntax analysis stage, object code is generated. The equivalent code, in assembly language, is shown below.

iv) Rewrite the equivalent code, given above, following optimisation.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: