Lably
Skip to content

Terminal and nonterminal symbols

Categories of symbols in formal grammars

  • 3 min read
  • 4 chapters

Related on Lably

Through Context-free grammar

A formal grammar defines a formal language over the vocabulary of the grammar.

In the context of formal language, the term vocabulary is more commonly known as alphabet. Nonterminal symbols are also called syntactic variables.

Terminal symbols

Terminal symbols are those symbols that can appear in the formal language defined by a formal grammar. The process of applying the production rules successively to a start symbol might not terminate, but if it terminates when there is no more production rule can be applied, the output string will consist only of terminal symbols.

For example, consider a grammar defined by two rules. In this grammar, the symbol Б is a terminal symbol and Ψ is both a nonterminal symbol and the start symbol. The production rules for creating strings are as follows:

  1. The symbol Ψ can become БΨ
  2. The symbol Ψ can become Б

Here Б is a terminal symbol because no rule exists to replace it with other symbols. On the other hand, Ψ has two rules that can change it, thus it is nonterminal. The rules define a formal language that contains countably infinite many finite-length words by the fact that we can apply the first rule any countable times as we wish. Diagram 1 illustrates a string that can be produced with this grammar.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Computing and communication