Terminals and Nonterminals in a Grammar

Terminal symbols form the final words. Nonterminals represent categories that a production may replace during derivation.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace one substitution
  2. Check the result of recursive expansion
  3. Locate the symbols still eligible for rewriting
  4. Let the grammar declaration assign the roles

Trace one substitution

For \(S\to aB\) and \(B\to b\), replacing B yields terminal word ab. The intermediate aB is a sentential form. See grammar alternatives.

Check the result of recursive expansion

A sequence still containing B is not a finished word. A generator needs a rule deciding when expansion ends. Recursive base cases explain the corresponding algorithmic condition.[1]

Locate the symbols still eligible for rewriting

In grammar \(S\to xS\) or \(S\to y\), the sentential form xxS still contains nonterminal S. Choosing the second production yields xxy, consisting entirely of terminals. That word is now in the language. See formal languages.

S → xS → xxS → xxy
x and y remain in the produced word
S is a grammar category and disappears from completed words

Let the grammar declaration assign the roles

A symbol's typography is only a convention. Token types in an implementation can serve as terminals even if their printed names are uppercase. Check actual production definitions when interpreting a grammar.

References

  1. Michael Sipser, Introduction to the Theory of Computation ↩