Thursday 28 April 2016

Difference between Terminal and Non-Terminal Symbols (Compiler Design)


Terminal Symbol

  • A terminal is a symbol which does not appear on the left-hand side of any production.
  • Terminal symbols cannot be changed using the rules of the grammar.
  • terminal symbols, which are the characters of the alphabet that appear in the strings generated by the grammar.
  • a terminal symbol is one that cannot be broken down further, e.g. a literal character or digit (but not necessarily as it depends on the grammar).
example : Contant etc

Non-Terminal Symbol

  • Nonterminal symbols are those symbols which can be replaced.
  • A non-terminal symbol is a symbol that can be reduced further by the production rules (the rules that define the grammar) until it's reduced to a terminal symbol, for example, in the following grammar integer is a non-terminal symbol, 0-9 are terminal symbols.
  •  A non-terminal called the left side of the production, an arrow, and a sequence of tokens and/or on- terminals.
  • The tokens that are recognized by the lexical analyzer and passed on to the parser are referred to as ``terminal symbols'', because they cannot be broken down into smaller units. The terms ``token'' and ``terminal symbol'' are essentially synonymous. By contrast, symbols that can be broken down into other symbols are called ``non-terminal symbols''. Symbols of each type are also called ``names''.
example : Variable Name expression etc

Next Topic

No comments:

Post a Comment