<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Wirth_syntax_notation</id>
	<title>Wirth syntax notation - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Wirth_syntax_notation"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Wirth_syntax_notation&amp;action=history"/>
	<updated>2026-10-25T22:50:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Wirth_syntax_notation&amp;diff=3981891&amp;oldid=prev</id>
		<title>imported&gt;RandFreeman: Adding local short description: &quot;Formal way to describe formal languages&quot;, overriding Wikidata description &quot;metasyntax, or formal way to describe formal languages&quot;</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Wirth_syntax_notation&amp;diff=3981891&amp;oldid=prev"/>
		<updated>2025-06-23T19:05:23Z</updated>

		<summary type="html">&lt;p&gt;Adding local &lt;a href=&quot;https://en.wikipedia.org/wiki/Short_description&quot; class=&quot;extiw&quot; title=&quot;wikipedia:Short description&quot;&gt;short description&lt;/a&gt;: &amp;quot;Formal way to describe formal languages&amp;quot;, overriding Wikidata description &amp;quot;metasyntax, or formal way to describe formal languages&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Formal way to describe formal languages}}&lt;br /&gt;
{{Use dmy dates|date=March 2023}}&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Wirth syntax notation&amp;#039;&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;WSN&amp;#039;&amp;#039;&amp;#039;) is a [[metasyntax]], that is, a formal way to describe [[formal language]]s. Originally proposed by [[Niklaus Wirth]] in 1977 as an alternative to [[Backus–Naur form]] (BNF). It has several advantages over BNF in that it contains an explicit iteration construct, and it avoids the use of an explicit symbol for the empty string (such as &amp;lt;nowiki&amp;gt;&amp;lt;empty&amp;gt;&amp;lt;/nowiki&amp;gt; or ε).&amp;lt;ref&amp;gt;{{Cite journal |last=Wirth |first=Niklaus |date=November 1977 |title=What Can We Do about the Unnecessary Diversity of Notations for Syntax Definitions? |journal=[[Communications of the ACM]] |volume=20 |issue=11 |pages=822–823 |doi=10.1145/359863.359883 |s2cid=35182224 |doi-access=free |authorlink=Niklaus Wirth}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WSN has been used in several [[International Organization for Standardization|international standards]], starting with [[ISO 10303-21]].&amp;lt;ref&amp;gt;{{Cite journal |date=24 January 2002 |title=ISO 10303-21, Industrial automation systems and integration — Product data representation and exchange — Part 21: Implementation methods: Clear text encoding of the exchange structure |url=http://www.iso.org/iso/search/extendedsearchstandards.htm?from_js=true&amp;amp;type=adv&amp;amp;displayResult=true&amp;amp;published=on&amp;amp;formKeyword=&amp;amp;title=on&amp;amp;description=on&amp;amp;formISO_number=10303&amp;amp;formPart_number=21&amp;amp;formDocument_type=ALL&amp;amp;formSupp_type=&amp;amp;formICS=&amp;amp;formStage_code=&amp;amp;repost=1&amp;amp;formDate_stage=0&amp;amp;formOther_date=&amp;amp;formCommittee=&amp;amp;formSub_committee=&amp;amp;formSubmit=Search |publisher=International Organization for Standardization}}{{dead link|date=September 2021}}&amp;lt;/ref&amp;gt; It was also used to define the syntax of [[ISO 10303-11|EXPRESS]], the [[data modelling]] language of [[ISO 10303|STEP]].&lt;br /&gt;
&lt;br /&gt;
== WSN defined in itself ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ebnf&amp;quot;&amp;gt;&lt;br /&gt;
 SYNTAX     = { PRODUCTION } .&lt;br /&gt;
 PRODUCTION = IDENTIFIER &amp;quot;=&amp;quot; EXPRESSION &amp;quot;.&amp;quot; .&lt;br /&gt;
 EXPRESSION = TERM { &amp;quot;|&amp;quot; TERM } .&lt;br /&gt;
 TERM       = FACTOR { FACTOR } .&lt;br /&gt;
 FACTOR     = IDENTIFIER&lt;br /&gt;
            | LITERAL&lt;br /&gt;
            | &amp;quot;[&amp;quot; EXPRESSION &amp;quot;]&amp;quot;&lt;br /&gt;
            | &amp;quot;(&amp;quot; EXPRESSION &amp;quot;)&amp;quot;&lt;br /&gt;
            | &amp;quot;{&amp;quot; EXPRESSION &amp;quot;}&amp;quot; .&lt;br /&gt;
 IDENTIFIER = letter { letter } .&lt;br /&gt;
 LITERAL    = &amp;quot;&amp;quot;&amp;quot;&amp;quot; character { character } &amp;quot;&amp;quot;&amp;quot;&amp;quot; .&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The equals sign indicates a production. The element on the left is defined to be the combination of elements on the right. A production is terminated by a full stop (period). &lt;br /&gt;
*Repetition is denoted by curly brackets, &amp;#039;&amp;#039;e.g.,&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;&amp;lt;nowiki&amp;gt;{a}&amp;lt;/nowiki&amp;gt;&amp;#039;&amp;#039;&amp;#039; stands for &amp;#039;&amp;#039;&amp;#039;ε | a | aa | aaa | ...&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
*Optionality is expressed by square brackets, &amp;#039;&amp;#039;e.g.,&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;&amp;lt;nowiki&amp;gt;[a]b&amp;lt;/nowiki&amp;gt;&amp;#039;&amp;#039;&amp;#039; stands for &amp;#039;&amp;#039;&amp;#039;ab | b&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
*Parentheses serve for groupings, &amp;#039;&amp;#039;e.g.,&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;(a|b)c&amp;#039;&amp;#039;&amp;#039; stands for &amp;#039;&amp;#039;&amp;#039;ac | bc&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
We take these concepts for granted today, but they&lt;br /&gt;
were novel and even controversial in 1977. Wirth later incorporated some&lt;br /&gt;
of the concepts (with a different syntax and notation) into [[extended Backus–Naur form]].&lt;br /&gt;
&lt;br /&gt;
Notice that &amp;lt;code&amp;gt;letter&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;character&amp;lt;/code&amp;gt; are left undefined. This is because numeric characters (digits 0 to 9) may be included in both definitions or excluded from one, depending on the language being defined, &amp;#039;&amp;#039;e.g.&amp;#039;&amp;#039;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ebnf&amp;quot;&amp;gt;&lt;br /&gt;
 digit = &amp;quot;0&amp;quot; | &amp;quot;1&amp;quot; | &amp;quot;2&amp;quot; | &amp;quot;3&amp;quot; | &amp;quot;4&amp;quot; | &amp;quot;5&amp;quot; | &amp;quot;6&amp;quot; | &amp;quot;7&amp;quot; | &amp;quot;8&amp;quot; | &amp;quot;9&amp;quot; .&lt;br /&gt;
 upper-case = &amp;quot;A&amp;quot; | &amp;quot;B&amp;quot; | … | &amp;quot;Y&amp;quot; | &amp;quot;Z&amp;quot; .&lt;br /&gt;
 lower-case = &amp;quot;a&amp;quot; | &amp;quot;b&amp;quot; | … | &amp;quot;y&amp;quot; | &amp;quot;z&amp;quot; .&lt;br /&gt;
 letter = upper-case | lower-case .&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If &amp;lt;code&amp;gt;character&amp;lt;/code&amp;gt; goes on to include &amp;lt;code&amp;gt;digit&amp;lt;/code&amp;gt; and other printable [[ASCII]] characters, then it diverges even more from &amp;lt;code&amp;gt;letter&amp;lt;/code&amp;gt;, which one can assume does not include the digit characters or any of the special (non-[[alphanumeric]]) characters.&lt;br /&gt;
&lt;br /&gt;
== Another example ==&lt;br /&gt;
The syntax of BNF can be represented with WSN as follows, based on translating [[Backus–Naur form#Further examples|the BNF example of itself]]:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ebnf&amp;quot;&amp;gt;&lt;br /&gt;
 syntax         = rule [ syntax ] .&lt;br /&gt;
 rule           = opt-whitespace &amp;quot;&amp;lt;&amp;quot; rule-name &amp;quot;&amp;gt;&amp;quot; opt-whitespace &amp;quot;::=&amp;quot; &lt;br /&gt;
                  opt-whitespace expression line-end .&lt;br /&gt;
 opt-whitespace = { &amp;quot; &amp;quot; } .&lt;br /&gt;
 expression     = list [ &amp;quot;|&amp;quot; expression ] .&lt;br /&gt;
 line-end       = opt-whitespace EOL | line-end line-end .&lt;br /&gt;
 list           = term [ opt-whitespace list ] .&lt;br /&gt;
 term           = literal | &amp;quot;&amp;lt;&amp;quot; rule-name &amp;quot;&amp;gt;&amp;quot; .&lt;br /&gt;
 literal        = &amp;quot;&amp;quot;&amp;quot;&amp;quot; text &amp;quot;&amp;quot;&amp;quot;&amp;quot; | &amp;quot;&amp;#039;&amp;quot; text &amp;quot;&amp;#039;&amp;quot; .&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This definition appears overcomplicated because the concept of &amp;quot;optional [[Whitespace (computer science)|whitespace]]&amp;quot; must be explicitly defined in BNF, but it is implicit in WSN. Even in this example, &amp;lt;code&amp;gt;text&amp;lt;/code&amp;gt; is left undefined, but it is assumed to mean &amp;quot;&amp;lt;code&amp;gt;[[ASCII|ASCII-character]] { ASCII-character }&amp;lt;/code&amp;gt;&amp;quot;. (&amp;lt;code&amp;gt;EOL&amp;lt;/code&amp;gt; is also left undefined.) Notice how the [[kludge#Computer science|kludge]] &amp;lt;code&amp;gt;&amp;quot;&amp;lt;&amp;quot; rule-name &amp;quot;&amp;gt;&amp;quot;&amp;lt;/code&amp;gt; has been used twice because &amp;lt;code&amp;gt;text&amp;lt;/code&amp;gt; was not explicitly defined.&lt;br /&gt;
&lt;br /&gt;
One of the problems with BNF which this example illustrates is that by allowing both single-quote and double-quote characters to be used for a &amp;lt;code&amp;gt;literal&amp;lt;/code&amp;gt;, there is an added potential for human error in attempting to create a machine-readable syntax. One of the concepts that migrated to later meta syntaxes was the idea that giving the user multiple choices made it harder to write parsers for grammars defined by the syntax, so computer languages in general have become more restrictive in how a &amp;#039;&amp;#039;quoted-literal&amp;#039;&amp;#039; is defined.&lt;br /&gt;
&lt;br /&gt;
==Syntax diagram==&lt;br /&gt;
[[Syntax diagram]]:&lt;br /&gt;
[[File:Wirth-syntax-notation.png]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
{{Metasyntax}}&lt;br /&gt;
{{Wirth}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Metalanguages]]&lt;/div&gt;</summary>
		<author><name>imported&gt;RandFreeman</name></author>
	</entry>
</feed>