A metasyntax describes the allowable structure and composition of phrases and sentences of a metalanguage, which is used to describe either a natural language or a computer programming language. Some of the widely used formal metalanguages for computer languages are Backus–Naur Form (BNF), Extended Backus–Naur Form (EBNF), Wirth syntax notation (WSN), and Augmented Backus–Naur Form (ABNF). These metalanguages have their own metasyntax each composed of terminals, nonterminals, and metasymbols. A terminal symbol, such as a word or a token, is a stand-alone structure in a language being defined. A nonterminal symbol represents a syntactic category, which defines one or more valid phrasal or sentence structure consisted of an n-element subset. Metasymbols provide syntactic information for denotational purposes in a given metasyntax. Terminals, nonterminals, and metasymbols do not apply across all metalanguages. Typically, the metalanguage for token-level languages (formally called “regular languages”) does not have nonterminals because nesting is not an issue in these regular languages. English, as a metalanguage for describing certain languages, does not contain metasymbols since all explanation could be done using English expression. There are only certain formal metalanguages used for describing recursive languages (formally called context-free languages) have terminals, nonterminals, and metasymbols in their metasyntax.


Element of metasyntax

  • Terminals: a stand-alone syntactic structure. Terminals could be denoted by double quoting the name of the terminals.
eg. “else” , “if”, “then”, “while”
  • Nonterminals: a symbolic representation defining a set of allowable syntactic structures that is composed of a subset of elements. Nonterminals could be denoted by angle bracketing the name of the nonterminals.
eg. <int>, <char>, <boolean>
  • Metasymbol: a symbolic representation denoting syntactic information.
eg. := , |, {}, (), [], *

Methods of phrase termination

  • Juxtaposition: e.g. A B
  • Alternation: e.g. A|B
  • Repetition: e.g. {A B}
  • Optional phrase: e.g. [A B]
  • Grouping: e.g. (A|B)

Specific metasyntax conventions

The standard convention

  • 'Backus–Naur Form' denotes nonterminal symbols by angle bracketing the name of the syntactic category, while it denotes terminal symbols by double quoting the terminal words. Terminals can never appear on the left-hand side of the metasymbol "::=" in a derivation rule. The body of the definition on the right-hand side may be composed with several alternative forms with each alternative syntactic construct being separated by the metasymbol "|". Each of these alternative construct may be either terminal or nonterminal.
  • 'Extended Backus–Naur Form' uses all facilities in BNF and introduces two more metasymbols for additional features. One of these two new features is applied to denote an optional phrase in a statement by square bracketing the optional phrase. The second feature is applied to denote a phrase that is to be repeated zero or more times by curly bracketing the phrase.
  • 'Wirth syntax notation' uses all facilities in EBNF except that the nonterminals are not necessarily angle bracketed but is always defined on the right-hand side of "=" in its production rule. It also does not require every nonterminal to be explicitly defined. Nonterminals such as <text> and <opt-whitespace> are implicitly defined as ASCII-character and optional white space respectively.
  • 'Augmented Backus–Naur Form' denotes nonterminal symbols by starting a one-word-name with an alphabet as the name of the syntactic category. Angle brackets are not required. Terminal symbols are either denoted by double quoted words or denoted by the following numeric structure: a "%", followed by "b" or "x" or "d", followed by a numeric value or a concatenation of numeric values separated by ".". Metasymbol "-" is placed between two numeric values to denote value range. As that of BNF, the terminals of ABNF never occures on the left-hand-side of the metasymbol "=" in the derivation rule. Metasymbol "/" denotes alternations. White space is used to separate elements in the body of the definition. The metasyntax for repetition in ABNF has several forms. A "*" preceding an element denotes the element to be repeated zero or more times. Numeric value <n1> followed by "*" followed by numeric value <n2> followed by an element denotes the element to be repeated at least <n1> times and at most <n2> times. A single numeric value <n> preceding an element denotes the element to be repeated <n> times. Comments may be express after metasymbol ";". As in EBNF, square bracketing a phrase denotes the phrase to be optional.


The metasyntax convention of these formal metalanguages are not yet formalized. Many metasyntactic variations or extensions exist in the reference manual of various computer programming languages. One variation to the standard convention for denoting nonterminals and terminals is to remove metasymbols such as angle brackets and quotations and apply font types to the intended words. In Ada, for example, syntactic categories are denoted by applying lower case sans-serif font on the intended words or symbols. All terminal words or symbols, in Ada, consist of characters of code position between 16#20# and 16#7E# (inclusive). The definition for each character set is referred to the International Standard described by ISO/IEC 10646:2003. In C and Java, syntactic categories are denoted using italic font while terminal symbols are denoted by gothic font. In J, its metasyntax does not apply metasymbols to describe J's syntax at all. Rather, all syntactic explanations are done in a metalanguage very similar to English called Dictionary, which is uniquely documented for J.

Advantage of the extensions

The purpose of the new extensions is to provide a simpler and unambiguous metasyntax. In terms of simplicity, BNF’s metanotation definitely does not help to make the metasyntax easier-to-read as the open-end and close-end metasymbols appear too abundantly. In terms of ambiguity, BNF’s metanotation generates unnecessary complexity when quotation marks, apostrophes, less-than signs or greater-than signs come to serve as terminal symbols, which they often do. The extended metasyntax utilizes properties such as case, font, and code position of characters to reduce unnecessary aforementioned complexity. Moreover, some metalanguages use fonted separator categories to incorporate metasyntactic features for layout conventions, which are not formally supported by BNF.

See also

  • Metavariable (logic)

Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • metasyntax — noun The syntax of a metalanguage …   Wiktionary

  • Extended Backus–Naur Form — In computer science, Extended Backus–Naur Form (EBNF) is a metasyntax notation used to express context free grammars: that is, a formal way to describe computer programming languages and other formal languages. It is an extension of the basic… …   Wikipedia

  • Yacc — The computer program yacc is a parser generator developed by Stephen C. Johnson at AT T for the Unix operating system. The name is an acronym for Yet Another Compiler Compiler. It generates a parser (the part of a compiler that tries to make… …   Wikipedia

  • Backus–Naur Form — In computer science, Backus–Naur Form (BNF) is a metasyntax used to express context free grammars: that is, a formal way to describe formal languages. John Backus and Peter Naur developed a context free grammar to define the syntax of a… …   Wikipedia

  • SDF — may refer to: * Scouts de France * Seattle Debate Foundation, a non profit urban debate league in Seattle, Washington * Seoul Digital Forum, a major international conference held annually in Seoul, Korea, addressing innovation in the digital… …   Wikipedia

  • Wireless sensor network — WSN redirects here. For the metasyntax, see Wirth syntax notation. Typical multi hop wireless sensor network architecture A wireless sensor network (WSN) consists of spatially distributed autonomous sensors to monitor physical or environmental… …   Wikipedia

  • Scannerless parsing — (also called lexerless parsing ) refers to the use of a single formalism to express both the lexical and context free syntax used to parse a language.This parsing strategy is suitable when a clear lexer parser distinction is not required.… …   Wikipedia

  • 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 can be defined using itself, it… …   Wikipedia

  • Syntax Definition Formalism — The Syntax Definition Formalism (SDF for short) is a metasyntax used to define context free grammars: that is, a formal way to describe formal languages. It can express the entire range of context free grammars. Its current version is SDF2. A… …   Wikipedia

  • BNF — steht als Abkürzung für: Backus Naur Form oder Backus Normalform, eine kompakte formale Metasyntax (Metasprache) Baranof Island (IATA Code der Basis für Wasserflugzeuge), eine zum US Bundesstaat Alaska gehörende Insel Bibliothèque nationale de… …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”