What is a meta language?

I found in SO En this question: Creating meta language with Java, in which the user has an interest in creating a meta language using Java.

I did a brief search and found on the Microsoft website a topic talking about: grammars, languages and compilers: a return to basics , where it says that:

[...].In computing, a well-known meta-language is BNF or " Backus-NAUR Form "

What is a meta language?

Author: viana, 2017-06-27

2 answers

Meta language is the language to create languages. Or at least it is a language for creating codes that generate codes.

Meta is something about that same thing. Just as we have meta SOpt which is a Q&A site for, and about, the SOpt Q&A site.

The most interesting here is the meta programming paradigm that can be applied to one language dedicated to it or can be added to the other language.

This meta language does not need to be programming, i.e. no it needs to be Turing Complete .

In the found example shows a defining language called BNF that is used to facilitate the creation and understanding of a language's grammar. But it is limited since it cannot express semantics.

This is often confused with DSLs.

Meta programming is something very interesting because it can avoid repetition, improve the DRY, simplify code by eliminating the boiler plate and create sugar syntax.

But it is also something quite complicated to do right unless in more trivial cases like the use of generic (used as normal as is common*), which is already a bit complicated. It gets worse with templates and macros.

Lisp is a language considered meta programming and that is why it is so fascinating. It provides the basic mechanisms and a strong macro and the rest the programmer will "create the language". Many inspired by her too. It seems that meta programming is the new frontier of programming and" everyone " is pursuing this on a higher or lower level.

There are also meta programming tools, such as scaffold.


*see Victor Stafusa's comment below shown that generics can become a drama too when used to their full potential. But me general he is used for a simple replacement of a generic type with a specific "flat" shape and has little to go wrong.

 21
Author: Maniero, 2020-05-28 13:24:30

In short? A language used to describe other languages.

BNF describes derivation rules for context-free grammars, so you can write any context-free language (such as the Java language, or even the email definition language) with BNF.

In this answer about context-free languages, I used a notation to describe productions of a subset of the Portuguese language, and also some productions of a sensitive grammar context.

As curious as it may be, it is impossible to describe a regular expression with a regular grammar, and it is also possible to describe any derivative grammar using a context-free grammar.

P : L ":" R
L : N           #para gramáticas regulares e livres de contexto 
R : N
R : N t         #produção regular, se L for para N
R : S
S : (t | N)*    #forma sentencial, qualquer string de terminais e não terminais
L : S           #produção generalizada, para gramáticas irrestritas
L : S N S       #produção para o lado esquerdo de uma gramática sensível ao contexto

Note that these rules even define the meta language to define languages, with the right to some comments of mine about some features of some productions.

 14
Author: Jefferson Quesado, 2017-12-23 17:15:14