Reputation:
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?
Upvotes: 5
Views: 2866
Reputation: 3113
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:
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.
Upvotes: 8
Reputation: 9078
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.
Upvotes: 0
Reputation: 1023
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.
Upvotes: 0
Reputation: 876
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.
Upvotes: 5
Reputation: 75704
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++.
Upvotes: 1