Worked solution from the System Software Paper 3 Advanced Theory booklet, Part 2 of 2.
Check each statement against the diagram: variable = variable operator variable, and a variable is one letter followed by an unsigned integer.
X1 = Y2 – 12: 12 is an unsigned integer, not a variable (it has no letter), so the last item is invalid [1]
Z = Y12 + Z1: Z is not a valid variable because there is no unsigned integer after the letter [1]
Write each rule using | for choices:
<variable> ::= <letter><unsigned_integer> <unsigned_integer> ::= <digit> | <digit><digit> <digit> ::= 1 | 2 | 3 <operator> ::= + | - | * <assignment_statement> ::= <variable> = <variable><operator><variable>
<variable> ::= <letter><unsigned_integer> [1]
<unsigned_integer> ::= <digit> | <digit><digit> [1]
<digit> ::= 1 | 2 | 3 and <operator> ::= + | - | * [1]
<assignment_statement> ::= <variable> = [1]
... <variable><operator><variable> to finish the rule [1]
Draw the same diagram as before: variable, then the = circle, then a branch, then operator, then a second branch. At each of the two places where a variable was, add a choice: one path through the variable box and another path through an unsigned integer box, joining again afterwards.
Both unsigned integer boxes added [1]
Correct positions and connectors (a bypass line around each variable box that joins back to the main line) [1]
The rest correct: variable, =, operator in order, with arrows in and out and the name assignment statement [1]
Write the BNF with an extra helper rule for the two choices:
<operand> ::= <variable> | <unsigned_integer> <assignment_statement> ::= <variable> = <operand><operator><operand>
<operand> ::= <variable> | <unsigned_integer> [1]
<assignment_statement> ::= <variable> = [1]
<operand><operator><operand> completes the rule [1]
Another accepted answer lists all four combinations after <variable> = : two or three correct options score 1, all four score 2.
▶ Whole paper
Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.