Wirth syntax notation

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 ε).[1]

WSN has been used in several international standards, starting with ISO 10303-21.[2] It was also used to define the syntax of EXPRESS, the data modelling language of STEP.

WSN defined in itself

 SYNTAX     = { PRODUCTION } .
 PRODUCTION = IDENTIFIER "=" EXPRESSION "." .
 EXPRESSION = TERM { "|" TERM } .
 TERM       = FACTOR { FACTOR } .
 FACTOR     = IDENTIFIER
            | LITERAL
            | "[" EXPRESSION "]"
            | "(" EXPRESSION ")"
            | "{" EXPRESSION "}" .
 IDENTIFIER = letter { letter } .
 LITERAL    = """" character { character } """" .

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).

  • Repetition is denoted by curly brackets, e.g., {a} stands for ε | a | aa | aaa | ....
  • Optionality is expressed by square brackets, e.g., [a]b stands for ab | b.
  • Parentheses serve for groupings, e.g., (a|b)c stands for ac | bc.

We take these concepts for granted today, but they were novel and even controversial in 1977. Wirth later incorporated some of the concepts (with a different syntax and notation) into extended Backus–Naur form.

Notice that letter and character 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, e.g.:

 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.

Another example

The syntax of BNF can be represented with WSN as follows, based on translating the BNF example of itself:

 syntax         = rule [ syntax ] .
 rule           = opt-whitespace "<" rule-name ">" opt-whitespace "::=" 
                  opt-whitespace expression line-end .
 opt-whitespace = { " " } .
 expression     = list [ "|" expression ] .
 line-end       = opt-whitespace EOL | line-end line-end .
 list           = term [ opt-whitespace list ] .
 term           = literal | "<" rule-name ">" .
 literal        = """" text """" | "'" text "'" .

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.

Syntax diagram

Syntax diagram:

References

  1. ^ Wirth, Niklaus (November 1977). "What Can We Do about the Unnecessary Diversity of Notations for Syntax Definitions?". Communications of the ACM. 20 (11): 822–823. doi:10.1145/359863.359883. S2CID 35182224.
  2. ^ "ISO 10303-21, Industrial automation systems and integration — Product data representation and exchange — Part 21: Implementation methods: Clear text encoding of the exchange structure". International Organization for Standardization. 24 January 2002. {{cite journal}}: Cite journal requires |journal= (help)[dead link]

Read other articles:

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (أبريل 2019) جدعون هاولي معلومات شخصية تاريخ الميلاد سنة 1727[1][2][3]  تاريخ الوفاة سنة 1807 (79–80 سنة)[1][2][3]  مواطنة الولايات المتحدة  الحياة �...

Álvaro Negredo Negredo con el Valencia C. F. en 2015Datos personalesNombre completo Álvaro Negredo SánchezApodo(s) El Tiburón de Vallecas[1]​[2]​Nacimiento Madrid, España20 de agosto de 1985 (38 años)Nacionalidad(es) EspañolaAltura 1,86 m (6′ 1″)Peso 86 kg (189 lb)Carrera deportivaDeporte FútbolClub profesionalDebut deportivo 2004(Rayo Vallecano)Club Cádiz C. F.Liga Primera División de EspañaPosición DelanteroDorsal(es) 18Goles en clubes 261Sele...

Septo nasal Huesos y cartílagos del septo nasal. Lado derechoNombre y clasificaciónLatín [TA]: septum nasiTA A06.1.02.004Gray pág.993Información anatómicaRegión fosa nasalSistema OlfativoArteria Arteria etmoidal anteriorArteria etmoidal posteriorArteria esfenopalatinaArteria palatina mayorRama de la arteria labial superiorNervio Nervio etmoidal anteriorNervio nasopalatino [editar datos en Wikidata] El septo nasal[1]​ o tabique nasal[2]​ es una estructura impar sit...

Medical conditionPulmonary atresiaOther namesPulmonary atresia - intact ventricular septum[1]Pulmonary valve (center left)SpecialtyCardiology SymptomsCyanosis[1]CausesNo known cause for pulmonary atresia[1]Diagnostic methodChest x-ray, Echocardiogram[1]TreatmentProstaglandin E1, Heart catheterization[1] Pulmonary atresia is a congenital malformation of the pulmonary valve in which the valve orifice fails to develop. The valve is completely closed t...

Artykuł 51°17′08″N 17°54′08″E - błąd 38 m WD 51°17'N, 17°54'E - błąd 2310 m Odległość 308 m Bralin wieś Kościół Narodzenia Najświętszej Maryi Panny na Pólku pod Bralinem Państwo  Polska Województwo  wielkopolskie Powiat kępiński Gmina Bralin Liczba ludności  2500 Strefa numeracyjna 62 Kod pocztowy 63-640[1] Tablice rejestracyjne PKE SIMC 0194636 Położenie na mapie gminy BralinBralin Położenie na mapie PolskiBralin Położenie na mapie...

 凡例吉良義定時代 戦国時代 - 江戸時代初期生誕 永禄7年(1564年)[1]死没 寛永4年9月15日(1627年10月23日)別名 三郎(通称)、上野介戒名 興山墓所 実相寺、万昌院主君 徳川家康氏族 清和源氏足利氏流吉良氏父母 父:吉良義安、母:俊継尼(松平清康の娘)兄弟 義定、女(今川範以室)妻 正室:今川氏真の女子 義弥、荒川定安、一色定堅、女テンプレートを�...

Geographical features of Alaska Alaska occupies the northwestern portion of the North American continent and is bordered only by Canada on the east. It is one of two U.S. states not bordered by another state; Hawaii is the other. Alaska has more ocean coastline than all of the other U.S. states combined.[1] About 500 miles (800 km) of Canadian territory separate Alaska from Washington state. Alaska is thus an exclave of the United States that is part of the continental U.S. and t...

American mathematician For other people named John Conway, see John Conway (disambiguation). John B. ConwayBorn (1939-09-22) September 22, 1939 (age 84)New Orleans, Louisiana, United StatesNationalityAmericanAlma mater Loyola University (BS) Louisiana State University (PhD) Websitehttp://home.gwu.edu/~conway/ Academic careerInstitutionsThe George Washington UniversityThesiswww.jstor.org/stable/1994310 (1966)Doctoral advisorHeron S. CollinsDoctoral studentsJim Agler (1980)&...

Vision G Vision G rear view Vision G interior The Hyundai Vision G Concept is a coupe concept car produced by the Hyundai Motor Company. It made its debut on 2015 Pebble Beach Concours d'Elegance after a showcase in The Los Angeles County Museum of Art on August 12.[1] Designed by Hyundai's multiple global design studios and overseen by Peter Schreyer, The Vision G prominently features Hyundai's signature hexagonal grille and restrained take on fluidic sculpture design language. Power...

Archipelago in the Pacific Ocean Sandwich Islands redirects here. For other uses, see Sandwich Islands (disambiguation). For the list of individual islands belonging to the state of Hawaii, see List of islands of Hawaii. This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Hawaiian Islands – news · newspapers · books ·...

Uprisings by Muslims in southern Iberia Rebellion of the Alpujarras (1499–1501)The Kingdom of Granada in CastileDateDecember 1499 – April 1501; 1 year and 4 monthsLocationThe city of Granada and the Alpujarra, Kingdom of Granada, Crown of CastileResult Rebellion defeated Mass forced conversions of all Muslims in Granada.Belligerents Castile-Aragon Union Muslims of GranadaCommanders and leaders Ferdinand II of Aragon Isabella I of Castile Francisco Jiménez de Cisneros Marquis de Tendilla ...

Election for the governorship of the U.S. state of Ohio 1938 Ohio gubernatorial election ← 1936 November 8, 1938 1940 →   Nominee John W. Bricker Charles W. Sawyer Party Republican Democratic Popular vote 1,265,548 1,147,323 Percentage 52.45% 47.55% County resultsBricker:      50-60%      60-70%      70-80%Sawyer:      50–60%      60–...

Civil police force of France This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: National Police France – news · newspapers · books · scholar · JSTOR (January 2008) (Learn how and when to remove this template message) National PolicePolice nationaleMottoPro patria vigilant[1]Agency overviewFormed23 ...

Vegetable oil This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Pongamia oil – news · newspapers · books · scholar · JSTOR (January 2019) (Learn how and when to remove this template message) Pongamia oil is derived from the seeds of the Millettia pinnata tree, which is native to tropical and temperate Asia. Mi...

Australian tennis player Patrick RafterRafter at the 2015 Australian OpenFull namePatrick Michael RafterCountry (sports) AustraliaResidenceLennox Head, New South Wales, AustraliaBorn (1972-12-28) 28 December 1972 (age 50)Mount Isa, Queensland, AustraliaHeight185 cm (6 ft 1 in)[1]Turned pro1991Retired2003 (last match November 2001)PlaysRight-handed (one-handed backhand)Prize moneyUS$11,133,128Int. Tennis HoF2006 (member page)SinglesCareer re...

Slag bij Turnhout kan verwijzen naar: Slag bij Turnhout (1597), veldslag tussen de Republiek der Zeven Verenigde Nederlanden en Spanje Slag bij Turnhout (1789), veldslag tussen de Turnhouters en Oostenrijkse troepen; het begin van de Brabantse Omwenteling Bekijk alle artikelen waarvan de titel begint met Slag bij Turnhout of met Slag bij Turnhout in de titel. Dit is een doorverwijspagina, bedoeld om de verschillen in betekenis of gebruik van Slag bij Turnhout inzichte...

American legislative district Map of Massachusetts House of Representatives' 11th Suffolk district, 2013. Based on 2010 United States Census Map of Massachusetts House of Representatives districts for Suffolk County, apportioned in 2011 Massachusetts House of Representatives' 11th Suffolk district in the United States is one of 160 legislative districts included in the lower house of the Massachusetts General Court. It covers part of the city of Boston in Suffolk County.[1][2]...

Fantasy role-playing game supplement published by Games Workshop This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Character Sheets – news · newspapers · books · scholar · JSTOR (December 2017) (Learn how and when to remove this template message) Character Sheets CoverGenreRole-playing gamePublisherGames Works...

Town and former municipality in North Brabant, NetherlandsBoxmeerTown and former municipalityFormer Boxmeer city hall (until 2010) FlagCoat of armsLocation of the former municipality of Boxmeer in North BrabantBoxmeerLocation in the province of North Brabant in the NetherlandsShow map of North BrabantBoxmeerBoxmeer (Netherlands)Show map of NetherlandsCoordinates: 51°39′N 5°57′E / 51.650°N 5.950°E / 51.650; 5.950CountryNetherlandsProvinceNorth BrabantMunicipalit...

In this Japanese name, the surname is Satake. Satake Yoshitaka佐竹義隆Satake Yoshitaka, portrait at Tentoku-ji, Akita2nd Daimyō of Kubota DomainIn office1633–1671MonarchsShōgun Tokugawa Iemitsu Tokugawa Ietsuna Preceded bySatake YoshinobuSucceeded bySatake Yoshizumi1st Daimyō of Kameda DomainIn office1623–1626Preceded by- none -Succeeded byIwaki Nobutaka1st Daimyō of Shinano-Nakamura DomainIn office1620–1623Preceded byIwaki SadatakaSucceeded by-none- Personal detailsBorn(1609-0...