Worked solution from the System Software Paper 3 Advanced Theory booklet, Part 2 of 2.
BNF lists the allowed items with | meaning 'or'. The diagram for character allows $, %, &, * or #.
Write: <character> ::= $ | % | & | * | #
Starts with <character> ::= [1]
The five symbols separated by | [1]
A password starts with one character, then one or more digits or capital letters.
Write an example such as $A9E3 [1]
The loop after the first character means one or more digits or capital letters, so a helper rule that repeats itself (recursion) is needed. Write:
<password> ::= <character><code> <code> ::= <digit> | <capital_letter> | <digit><code> | <capital_letter><code>
<password> ::= <character><code> (a character followed by the helper rule) [1]
<code> ::= starts a rule for one or more digits or capital letters [1]
The single options <digit> | <capital_letter> [1]
The recursive options <digit><code> | <capital_letter><code> [1]
▶ 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.