You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Backus-Naur Form (BNF) is a notation for defining the syntax (grammar) of formal languages, including programming languages. Syntax diagrams (also called railroad diagrams) are the visual equivalent. Both are essential for OCR H446 section 1.4.
| Reason | Explanation |
|---|---|
| Compiler design | A compiler needs precise rules to parse source code correctly |
| Language specification | Defines exactly what constitutes valid code in a programming language |
| Error detection | Helps compilers produce meaningful error messages |
| Unambiguity | Formal syntax leaves no room for interpretation — every string is either valid or invalid |
| Documentation | Provides a reference for programmers learning a language |
| Type | Definition | Convention |
|---|---|---|
| Terminal | An actual symbol/token that appears in the language (cannot be broken down further) | Written in quotes or bold: "if", "while", "+", "0", "1" |
| Non-terminal | A symbol that can be replaced by a sequence of terminals and/or non-terminals (a rule) | Written in angle brackets: , , |
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.