describing something, should i use Backus-Naur Form?
Asked Answered
F

5

5

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

Is there another form to describe a language then Backus-Naur Form? What alternatives should i consider?

Fanfaron answered 13/2, 2009 at 12:0 Comment(0)
A
8

The obvious alternative would be extended Backus-Naur form, however there are few others that can be used, and I found a couple of links with some quick searching:

Augmented BNF

Wirth syntax notation

Van Wijngaarden grammar

Personally I would stick with BNF / EBNF due to the prevalence of information and tools which use it in some form. Tools like bison or yacc can help with the generation of a parser from such a grammar and make it quite trivial to produce an interpreter.

Ambrogino answered 13/2, 2009 at 12:9 Comment(0)
E
5

It depends on how formal you wish to describe the language. Backus-Naur Form is meant to describe context-free grammars. So if you want to describe a context-free grammar Backus-Naur Form is probably the way to go as it is the most widespread known form of describing these.

However, if you wish to describe your semantics or more complex grammars you'll need to use other means. If you want to describe your semantics as well you need to choose between small-step or big-step semantics, based on language characteristics such as use of recursion.

Note that if your grammar cant be expressed using a context-free grammar then BNF wont be sufficient to express your language at all and you might have to consider describing your language in a context-sensitive grammar.

Edifice answered 13/2, 2009 at 12:6 Comment(0)
P
1

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

Pennipennie answered 13/2, 2009 at 12:6 Comment(0)
C
0

You may want to look at "M" from Microsoft. This is a language/syntax which allows you to describe another language (as does BNF). This is being used as the basis for developing your own domain driven language.

"M" from Microsoft

Cornerwise answered 13/2, 2009 at 12:13 Comment(0)
K
0

You could also consider using ANTLR, which uses a syntax/formal language close to BNF. It'll help you with the construction of a interpreter/compiler.

Katleen answered 13/2, 2009 at 13:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.