I was asked:
> for the example of
> <greetings> ::= "hello" <statement> | "hi" <statement>
> <statement> ::= "you" | "world"
> Would I be correct in saying there are 4 terminal symbols (eg. hello, hi, you, world)?
Yes, there are four terminal symbols in that grammar - I've labelled them in this image:
> [and 4 productions?]
Yup. You can just think of "production" as meaning a "branch" or "alternative". As you say: <greetings> has two alternatives, and
<statement> has two alternatives. So 4 total.
I've labelled them in this image:
So, note that the definition of "production" we're using means there are three productions in the following grammar, let's call it
<outerthing> := <middlething>
<middlething> := <innerthing>
<innerthing> := "good morning"
But there is only one production in *this* grammar, let's call it grammar B:
<onlything> := "good morning"
So if we want production coverage, grammar A needs more tests than grammar B, even though they ultimately define exactly the same
language. But that's okay. If we had some reason for using Grammar A instead of Grammar B (maybe we're leaving room in our language
for future expansion, for instance), well, Grammar A definitely has more "parts" to it where failures might occur in an implementation
- so we intuitively should expect there to be more tests.