ArticleslgStudy

science

Metasyntax

Metasyntax is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Metasyntax rather than just read about it. In short: A metasyntax is a syntax used to define the syntax of a programming language or formal language. It 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.

Key takeaways

  • Metasyntax belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Metasyntax to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Metasyntax from memory before moving on to harder problems.

Reference excerpt

A metasyntax is a syntax used to define the syntax of a programming language or formal language. It 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). Metalanguages have their own metasyntax each composed of terminal symbols, nonterminal symbols, 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) that 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. e.g. "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. e.g. <int>, <char>, <boolean> Metasymbol: a symbolic representation denoting syntactic information. e.g. := , |, {}, (), [], *

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 are 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 occurs 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.

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

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Metasyntax

Start with the simplest possible case. Write down what Metasyntax claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Metasyntax before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Metasyntax ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Metasyntax

In research
Metasyntax appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Metasyntax in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Metasyntax is common in secondary-school and first-year university syllabi. It links to neighbouring topics Metalanguages, so understanding it makes those chapters shorter.
In everyday life
Look for Metasyntax outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Metasyntax in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Metasyntax means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Metasyntax out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Metasyntax in simple terms?

A metasyntax is a syntax used to define the syntax of a programming language or formal language. It 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.

Why does Metasyntax matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Metasyntax?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Metasyntax.

Tags

  • Metalanguages

Keep exploring