Context-free languages: BNF and syntax diagrams
This worksheet marks itself
Set it as homework or classwork and every answer is marked as pupils go, with feedback on what they got wrong. The scores go straight into your mark book, so you can see who needs help before the next lesson.
- 12 questions
- 31 marks
- about 40 minutes
- marked instantly
Question types: short answer, multiple choice, matching, true or false.
Try one from this worksheet
The syntax diagram shown defines a <number>. Identify the string that is a valid <number>.
Pick an answer: it's marked straight away, just as your pupils would see it.
About this resource
AQA A-level Computer Science (7517) 4.4.3.1 Backus-Naur Form (BNF) / syntax diagrams. C# lesson 4 of 6 in 4.4 Theory of computation: a trace-the-recursion Do Now, a short key idea, an 11-challenge ladder in three sets with exact test data, two exam questions and a worksheet. Replaces aqa-7517-4-4…
18 slides.
Lesson outline
- Do Now: trace the recursion
- Do Now: answers
- Key idea: BNF: production rules
- Key idea: Syntax diagrams: the same rules, drawn
- Quick check: valid or not?
- Key idea: In C#: one method per rule
- Key idea: What BNF can do that a regular expression cannot
- Set 1: one method per rule
- Set 2: split the string
- Exam question E1: check the syntax
- Model answer E1
- Exam question E2: write the rule, then explain
More from 4.4 Theory of computation · full lessons
- Lesson pack · 4.4 L1Abstraction, decomposition and automationSubscription
- Lesson pack · 4.4 L2Finite state machines with and without outputSubscription
- Lesson pack · 4.4 L3Sets, regular expressions and regular languagesSubscription
- Lesson pack · 4.4 L5Classification of algorithms: Big-O, tractability and the Halting problemSubscription
- Lesson pack · 4.4 L6A model of computation: Turing machinesSubscription


