Six original Cambridge-style questions on Backus-Naur Form and syntax diagrams, with mark-scheme solutions.
State the meaning of each of these BNF symbols: (a) ::= (b) | (c) < >
A password is defined by:
<letter> ::= a | b | c | d | e <digit> ::= 0 | 1 | 2 | 3 <name> ::= <letter> | <letter><name> <password> ::= <name><digit><digit> | <name>#<digit><digit>
State whether each is a valid <password> and give a reason for each invalid one: (a) cab#23 (b) ace3 (c) #12 (d) dd#4
Using the grammar in the previous question, show how bad01 is derived from <password>.
A product code consists of one or two upper-case letters from P, Q and R, followed by a colon, followed by one or more digits from 0 to 9. Write BNF to define <product>.
Describe the syntax diagram for the rule <number> ::= <digit> | <digit><number>, and explain how it represents the recursion.
A student writes <word> ::= <letter><word> to define a word of one or more letters. Explain why this rule is incorrect and correct it.
Mark this once you have attempted all six and checked your working. It records a Practiced badge on the topic and adds a one-time bonus. Revealing the solutions alone does not count.