Skip to content

9618 · 16.2

Translation Software — practice questions

Practice and worked examples for 9618 Translation Software. Short previews only — attempt the full question in MarkScheme against the official scheme.

Worked example 1

For the following line of Pascal code, Score:=Score+10;Score := Score + 10;, describe the output of the Lexical Analysis stage and draw a simplified representation of the parse tree created during Syntax Analysis.

Show solution outline

Mark Scheme Breakdown:

1. Lexical Analysis (2 marks):

  • The lexical analyser removes whitespace and breaks the code into a sequence of tokens. (1 mark for process)
  • The token stream would be: IDENTIFIER('Score'), ASSIGNOP(:=)ASSIGN_OP(':='), IDENTIFIER('Score'), PLUSOP(+)PLUS_OP('+'), INTEGERLITERAL(10)INTEGER_LITERAL('10'), SEMICOLON(';'). (1 mark for correct token sequence)

2. Syntax Analysis (Parse Tree) (2 marks):

  • The syntax analyser uses the token stream to build a parse tree to check grammatical structure. (1 mark for purpose)
  • The tree would represent the assignment. A simplified text representation is:
    ASSIGN (:=)
     /       \
IDENTIFIER(Score)   EXPRESSION (+)
                     /         \
                IDENTIFIER(Score)  INTEGER(10)

(1 mark for a correctly structured tree showing the assignment and the addition as a sub-tree).

Worked example 2

A software company is developing a new video game for high-performance PCs. The game requires maximum graphical performance and fast processing to handle complex physics. The company also wants to protect its source code from being copied. Justify whether a compiler or an interpreter would be the more appropriate choice for distributing the final game.

Show solution outline

Mark Scheme Breakdown:

Choice: A compiler is the appropriate choice. (1 mark)

Justification (Maximum 3 marks from):

  • Performance/Execution Speed: A compiled program is translated into native machine code, which executes directly on the CPU. This results in the fastest possible execution speed, which is critical for a high-performance game's graphics and physics calculations. (1 mark)
  • Code Protection/Distribution: A compiler produces a standalone executable file. The company can distribute this file without including the original source code, thus protecting their intellectual property. An interpreter would require the source code to be present on the user's machine. (1 mark)
  • No Runtime Overhead: Unlike an interpreter, a compiled program does not have the overhead of translating code line-by-line while the game is running. This frees up CPU resources for the game itself. (1 mark)