Difference between revisions of "Backus-Naur form"

From PKC
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 5: Line 5:
   <symbol> ::= __expression__
   <symbol> ::= __expression__
</syntaxhighlight>
</syntaxhighlight>
In the example shown above, <code><symbol></code> denotes a [[key-value pair|key]], and <code>__expression__</code> denotes a [[key-value pair|value]].


* <[[symbol]]>is a ''[[nonterminal]]'' (variable) and the [[expression (mathematics)|__expression__]] consists of one or more sequences of either terminal or nonterminal symbols;
* <code><symbol></code>is a ''nonterminal'' (variable) and the <code>__expression__</code> consists of one or more sequences of either terminal or nonterminal symbols;
* <code>=::=</code> means that the symbol on the left must be replaced with the expression on the right.
* <code>=::=</code> means that the symbol on the left must be replaced with the expression on the right.
* more sequences [of symbols] are separated by the [[vertical bar]] "|", indicating a [[alternation (formal language theory)|choice]], the whole being a possible substitution for the symbol on the left.  
* more sequences of symbols are separated by the vertical bar "|", indicating an alternation choice, the whole being a possible substitution for the symbol on the left.  


Symbols that never appear on a left side are ''[[Terminal symbol|terminal]]s''. On the other hand, symbols that appear on a left side are ''[[nonterminal symbol|non-terminal]]s'' and are always enclosed between the pair <>.
Symbols that never appear on a left side are ''terminals''. On the other hand, symbols that appear on a left side are ''non-terminals'' and are always enclosed between the pair <code><></code>.


=Key-value Pair Interpretation=
 
In the example shown above, <code><symbol></code> denotes a key, and the <code>__expression__</code> denotes a value.
<noinclude>
 
=References=
<references/>
==Related Pages==
[[Category:Meta Language]]
[[Category:Universal Data Abstraction]]
</noinclude>

Latest revision as of 11:59, 13 May 2022

Backus-Naur Form(Q211577), often abbreviated as BNF, is one of the two main notation techniques for context-free grammars in computer science.

BNF is a formal language that can be denoted in a collection of key-value pairs. For instance:

  <symbol> ::= __expression__

In the example shown above, <symbol> denotes a key, and __expression__ denotes a value.

  • <symbol>is a nonterminal (variable) and the __expression__ consists of one or more sequences of either terminal or nonterminal symbols;
  • =::= means that the symbol on the left must be replaced with the expression on the right.
  • more sequences of symbols are separated by the vertical bar "|", indicating an alternation choice, the whole being a possible substitution for the symbol on the left.

Symbols that never appear on a left side are terminals. On the other hand, symbols that appear on a left side are non-terminals and are always enclosed between the pair <>.



References

Related Pages