Search code examples
parsingsyntaxgrammar

Difference between terminal symbol and nonterminal symbol?


What's the difference between terminal & non-terminal symbols in system programming with examples?


Solution

  • A terminal symbol represents a single element of the language, and a non-terminal symbol represents several elements.

    terminal and nonterminal symbols are the lexical elements used in specifying the production rules constituting a formal grammar. Terminal symbols are the elementary symbols of the language defined by a formal grammar. Nonterminal symbols (or syntactic variables) are replaced by groups of terminal symbols according to the production rules.

    source: http://en.wikipedia.org/wiki/Terminal_and_nonterminal_symbols