Terminal and nonterminal symbols

In formal languages, terminal and nonterminal symbols are the lexical elements used in specifying the production rules constituting a formal grammar.

The terminals and nonterminals of a particular grammar are in two completely separate sets.

Applying the rules recursively to a source string of symbols will usually terminate in a final output string consisting only of terminal symbols.

A formal grammar includes a start symbol, a designated member of the set of nonterminals from which all the strings in the language may be derived by successive applications of the production rules.

In fact, the language defined by a grammar is precisely the set of terminal strings that can be so derived.

This restriction is non-trivial; not all languages can be generated by context-free grammars.

Each such rule has a head, or left-hand side, which consists of the string that may be replaced, and a body, or right-hand side, which consists of a string that may replace it.

The string "the dog ate the bone" was created using production rules that replaced non-terminal with terminal symbols. [ 1 ]
Diagram 1. The string Б Б Б Б was formed by the grammar defined by the given production rules. This grammar can create strings with any number of the symbol Б