Visual AKDL Editor
Published: 2022-12-16 12:59:18

It all begun with my intention to create a new programming langage called _CLApp_ (I’ve described in my first post). At the beginning (I’m from the old school), I started with the writing of my own lexer, my own parser and code generator (in C and, later in java), as a colleague of mine suggested to me to use _ANTLR_. This should have prevented me from writing that much. Another advantage: if I have to modify something in my language definition, I wouldn’t need to search in the different parts of my code where to adapt it to the new features; ANTLR would re-generate all the stuff for me.
So I tried that, but… my syntax didn’t fit to all ANTLR expectations; I was obliged to adapt my definitions to the tool. And at some time, it was too much and thus I decided to create my own tool that should do the same job as ANTLR but in a way I desire. And **AKDL** was born.
AKDL means _Another Keyword Definition Language_. Its’ main features are listed below:

1. It generates java code
2. The generated code, parser and runtime, appears in classes representing the defined keywords; it is stored within packages specified by the syntax designer. In other words, you can structure the whole code that AKDL generates for you.
3. Having 1 parsing class per keyword allows you to have as many entry points as keywords. That means you are able to parse snippets and are not obliged to have a complete source of your language to get its corresponding runtime. You can thus use those snippets to deploy them and let them run within an already existing application (as example of use).

Traditionally, to define a keyword, the **EBNF** (_Extended Bachus-Naur Form_) notation is used. In this notation, as you probably know, you have :

1. Brackets « **[]** » for the option ; for example, **[a b c]** means _group **(a b c)** is optional_
2. Braces « **{}** » for the quantification ; for example, **{a b c}** means _group **(a b c)** appears an undefined number n of times (n can be 0)_
3. The vertical bar symbol « **|** » is used for the alternative ; for example, **a | b | c** means _only one element out of the group **(a b c)** will be selected_

It appeared relatively soon that this good old notation won’t fullfill my expectations. The 1st stuff I’ve seen at glance was that point 3 was absolutely not consistent with the 2 others. Another thing I could not accept was that brackets as well as braces had 2 rules at the same time: they were used to group elements AND to apply an operation on them. Moreover, if a group is made of 1 element, you have something like **[a]** or **{a}**, which is not a big deal but also not really pretty.
In my case the problem was I needed to add some more operators beside the 3 mentioned above and this notation didn’t really allow me to do it. That’s why I decided to, first, simplify and, then, enhance the EBNF.
The simplification leads to this result:

1. _[a b c]_ is changed to **_^(a b c)_** as well as, _[a]_ is changed to **_^a_**
2. _{a b c}_ is changed to **_*(a b c)_** as well as, _{a}_ is changed to **_*a_**
3. _a | b | c_ is changed to **_+(a b c)_**

After having done that, I was able to simply add some new operators. The one I like very much is “_in any order you like_” and the used symbol for that is « **&** ».
Thus, **_&(a b c)_** means: _(a b c) | (a c b) | (b a c) | (b c a) | (c a b) | (c b a)_
You can also combine all that. For example:
**&(^a *b c)** to say _a is optional, b appears a certain number of times, c exactly once and the whole in any order you like_. (We have concrete cases in java with modifiers like synchronized, public, static …)
I called this new notation **seeBNF** (_simplified and enhanced EBNF_). It allows you to simply define a language in a tree form starting from a root which is the initial symbol. That’s exactly the way you can create your syntax using the **_Visual AKDL Editor_**.
Now you know enough about **AKDL**, I propose you discover how it concretely works through the following tutorials:

[1st tutorial](https://www.youtube.com/watch?v=2xLPWlhoGYM)
[2nd tutorial](https://www.youtube.com/watch?v=7KC9MtO9z7U)
[3rd tutorial](https://www.youtube.com/watch?v=baMcJUqGqIw)

You can also download the whole stuff and test by yourself (it’s a free open source):

[**AKDL**](https://github.com/dragan-clapp-creator/akdl)
[**Visual AKDL Editor**](https://github.com/dragan-clapp-creator/Visual-AKDL-Editor)

Feel free to give me your feedback. Thanks.