I am learning how BNF grammar works and I have been given the following example of some BNF grammar rules. I'm just trying to understand what this means and I'm having trouble:
<S> ::= ‘(‘ <A> ‘)’
<A> ::= ‘[‘ <A> ‘]’
| <S> ‘{‘ <A> ‘}’
| a | … | z
I don't understand what the brackets in quotations mean. And as far as I understood it this expression should be saying something like
S expanded = '(' <A> ')'.
A expanded = ‘[‘ <A> ‘]’
or <S> ‘{‘ <A> ‘}’
or a or … or z
but I do not understand why A's expansion would have A inside of it.
The brackets in quotes in the A
production here call for literal brackets in the input.
So a valid example of an A
construct could be [ z ]
.
As for your second point, the A
rule is recursive, meaning that angle brackets may be infinitely nested in an A
construct.