4.4.3.1 Backus-Naur Form (BNF)/syntax diagrams Flashcards
What is BNF?
notation for describing a set of rules of a regular language.
one method of defining syntax of a language
Why is BNF used over regular expressions?
Some languages cannot be defined by regular expressions, because it doesn’t allow recursion
BNF allows representations of a wider range of languages,
Describe one example of why a syntactically correct loop may still produce an error when a program is compiled.
Variable may not have been declared;
Variable may be of inappropriate type;
Position of statement within program may be invalid;
Rightmost integer may be a lower value than the leftmost one;
One of the numbers / limits may be outside of the range of valid integers
Explain why recursion has been used in this production rule.
Can contain any number of _
BNF does not support iteration / looping // BNF can only achieve iteration through recursion // would need infinite number of rules otherwise