4.4.3.1 Backus-Naur Form (BNF)/syntax diagrams Flashcards

1
Q

What is BNF?

A

notation for describing a set of rules of a regular language.
one method of defining syntax of a language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why is BNF used over regular expressions?

A

Some languages cannot be defined by regular expressions, because it doesn’t allow recursion
BNF allows representations of a wider range of languages,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe one example of why a syntactically correct loop may still produce an error when a program is compiled.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain why recursion has been used in this production rule.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly