| FazBrowse Wikipedia Viewer | Main Page | | |
| Viewing: https://en.wikipedia.org/wiki/Wirth_syntax_notation |
| Contents |
|---|
| Another example |
| Syntax diagram |
| References |
Wirth syntax notation (WSN) is a metasyntax, that is, a formal way to describe formal languages. 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 <empty> or ε).
WSN has been used in several international standards, starting with ISO 10303-21. It was also used to define the syntax of EXPRESS, the data modelling language of STEP.
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" . upper-case = "A" | "B" | … | "Y" | "Z" . lower-case = "a" | "b" | … | "y" | "z" . letter = upper-case | lower-case .If character goes on to include digit and other printable ASCII characters, then it diverges even more from letter, which one can assume does not include the digit characters or any of the special (non-alphanumeric) characters.
The syntax of BNF can be represented with WSN as follows, based on translating the BNF example of itself:
This definition appears overcomplicated because the concept of "optional whitespace" must be explicitly defined in BNF, but it is implicit in WSN. Even in this example, text is left undefined, but it is assumed to mean "ASCII-character { ASCII-character }". (EOL is also left undefined.) Notice how the kludge "<" rule-name ">" has been used twice because text was not explicitly defined.
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 literal, 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 quoted-literal is defined.
| Programming languages | |
|---|---|
| Operating systems | Oberon System (1987) → Active Object System (AOS, 2002), Bluebottle (2005), A2 (2008) |
| Formalisms | |
| Books |
| View original on Wikipedia | Back | FazBrowse Home |