Terminal symbol

from Wikipedia, the free encyclopedia

A terminal symbol (also called terminal character or terminal for short ) in a formal grammar is a symbol that cannot be replaced individually by a production rule. Thus, no word that consists only of terminal symbols can occur as a premise (i.e. left side) of a production rule. The set of all terminal symbols in a grammar forms the alphabet of symbols that make up the words of the languages ​​generated by the grammar. All replaceable symbols are called nonterminal symbols .

When parsing , each token is ultimately compared with a terminal symbol of a grammar; the corresponding grammar rule can only be applied if the terminal symbol matches the token.

The terminal symbols of a grammar form the leaves of the syntax trees of all derivable words. Similarly, the tokens that match the terminal symbols form the leaves of the parse tree .

In theory, terminal symbols are often represented by lowercase letters, but in practice other symbols such as punctuation marks and programming language keywords , e.g. B. FOR , IF , PROGRAM etc.

Individual evidence

  1. Small reference work on computer science for Lower Saxony. Retrieved November 16, 2018 .