Describing something, should the Backus-Naur form be used?

I want to describe a complex script and possibly a programming language. I was thinking of describing it in the form of Baksu-Naur before doing anything (excluding the code of a dummy / sample script)

Is there another form for describing the language, and then the Backus-Naur form? What alternatives should I consider?

+4
source share
5 answers

An obvious alternative might be an extended Backus-Naur form , however there are several others that can be used, and I found a couple of links with some quick search:

Added by BNF

Virt syntax notation

Van Winghard grammar

Personally, I would adhere to BNF / EBNF because of the prevalence of information and tools that use it in one form or another. Tools such as bison or yacc can help with the generation of the parser from such a grammar and make it pretty trivial to create an interpreter.

+7
source

It depends on how formally you want to describe the language. The Backus-Naur form is intended to describe context-free grammars. Therefore, if you want to describe context-free grammar, the Backus-Naur form is probably the way to go, as this is the most common known form for describing these.

However, if you want to describe your semantics or more complex grammars, you will need other tools. If you also want to describe your semantics, you need to choose between a small degree or a large power semantics based on linguistic characteristics, such as using recursion.

Note that if your grammar cannot be expressed using a context-free grammar, then BNF will not be sufficient to express your language at all, and you may need to consider the description of your language in a context-sensitive grammar.

+5
source

BNF is a good start; there are several parser generators that can use it as input. Boost.Spirit is a good example if you plan to use C ++.

+1
source

You might want to take a look at Microsoft's “M”. This is a language / syntax that allows you to describe a different language (like BNF). This is used as the basis for developing your own domain-driven language.

"M" from Microsoft

0
source

You might also consider using ANTLR , which uses a syntax / formal language similar to BNF. This will help you build an interpreter / compiler.

0
source

All Articles