| Lesson Plan |
| Grade: |
Date: 25/02/2026 |
| Subject: Computer Science |
| Lesson Topic: Show understanding of how the grammar of a language can be expressed using syntax diagrams or Backus-Naur Form (BNF) notation |
Learning Objective/s:
- Describe the role of grammar in translation software such as compilers and interpreters.
- Compare syntax diagrams and BNF notation in terms of readability and machine‑readability.
- Write BNF rules for simple language constructs (e.g., arithmetic expressions, while‑loops).
- Translate a BNF rule into a syntax diagram and vice‑versa.
- Apply a grammar definition using a parser‑generator tool (e.g., yacc or ANTLR).
|
Materials Needed:
- Projector and screen
- Whiteboard and markers
- Printed handouts with example BNF rules and blank syntax‑diagram templates
- Worksheets for conversion activities
- Computers with a text editor and access to a parser generator (yacc/ANTLR)
|
Introduction:
Begin with a quick poll: how many students have seen rules that define how code or markup must be written? Recall that a compiler must first recognise whether a sequence of symbols forms a valid program, which relies on a formal grammar. Today we will explore two ways to express that grammar—visual syntax diagrams and textual BNF—and decide when each is most useful. Success will be measured by your ability to write and translate between the two forms.
|
Lesson Structure:
- Do‑now (5 min): Students list examples of language rules they have encountered (e.g., HTML tags, programming syntax).
- Mini‑lecture (10 min): Explain why grammar matters in translation software and introduce syntax diagrams vs. BNF.
- Guided demonstration (12 min): Show BNF for simple arithmetic expressions and draw the corresponding syntax diagram on the board.
- Pair activity (15 min): Using worksheets, each pair converts a given BNF rule into a syntax diagram and a provided diagram back into BNF.
- Whole‑class check (8 min): Groups present their conversions; teacher highlights common errors and clarifies misconceptions.
- Tool showcase (10 min): Brief demo of yacc/ANTLR consuming BNF to generate a parser.
- Exit ticket (5 min): Students write one advantage of BNF and one advantage of syntax diagrams.
|
Conclusion:
Summarise that both syntax diagrams and BNF describe the same grammar, but BNF is concise and machine‑readable while diagrams provide visual intuition for humans. Collect the exit tickets, and assign the worksheet as homework: write BNF for a while‑loop and sketch its syntax diagram. This reinforces the translation between the two representations.
|