Exam-style question
Try this first
Write simple BNF production rules for a language containing one or more lowercase letters from the set {a, b, c}. Then use the rules to show how the string "cab" can be generated.
Answer and explanation
Concise answer
<letter> ::= "a" | "b" | "c" <word> ::= <letter> | <letter> <word>
Why this is correct
The <letter> rule restricts each character to a, b, or c. The recursive <word> rule allows another letter to be added, while the alternative containing only <letter> provides the stopping case. The derivation shows that "cab" is generated.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
