Eko: New Programming language write entirely in D (Feedback welcome)
pouya1dev
poyaxc545 at gmail.com
Fri Aug 21 17:46:29 UTC 2026
On Friday, 21 August 2026 at 15:31:25 UTC, Stefan Koch wrote:
> On Friday, 21 August 2026 at 08:26:59 UTC, pouya1dev wrote:
>> [...]
>
> I had a look and I really don't understand the structure of
> your project.
>
> Can you maybe post a comprehensive description of your grammar
> and desired semantics?
>
> Cheers
>
> - uplink
First of all, thank you very much, Stefan, for taking an interest
in this project. The Eko grammar is simple:
1. Before defining anything—such as variables or functions—the
`generate` keyword is used. Unlike in C, this keyword does not
indicate the function's return type; instead, its presence
prevents the interpreter from having to guess. By triggering a
specific condition, it signals the interpreter to look for
keywords related to creation or definition.
```
generate Printer() {
write("Hello");
}
generate main() {
Printer();
}
```
```
gen string -v:hello = "Hello world"
```
2. The variable names begin with `-v` or `--value` so that the
interpreter can more easily recognize—during the lexer phase—that
the token is a name.
And wherever you use the variable, you must place this prefix
before its name, because the strings are stored in the hash map
along with these `-v` markers. (By the way, I am removing this
requirement in newer versions to make things easier.)
```
gen string --value:hello = "Hello world"
gen main() {
write(--value:hello);
}
```
3. And in the new version that is adding AST (Abstract Syntax
Tree) to the language, you must use a `_` before calling
functions, that is, before their names, so that the interpreter
understands that you wrote a function.
When you use `_`, the parser first extracts the arguments and
then, by creating a FuncCall (a type in ast) in the tree,
abstracts the code into an array of ASTs and executes it inside
the executing function.
run with
```./eko -ast hello.eko```
```
_write("Hello world");
```
4. You should also define a main function. The main function is
mostly for C-likeness, of course, it will be important when you
compile, but in the interpreter it is only for C-likeness and
familiarity. You don't have to create a main function at all in
shorthand mode.
Meanwhile, looping means that keywords like "while" or "for" are
not available in eko. Instead, you have to use recursive
functions to create loops. Like Erlang.
```
generate int -v:count = 0
generate print() {
-v:count = -v:count++
write(-v:count + "\n");
test();
}
generate test() {
if (-v:count > 11):
write("Job is Done");
end;
else: print();
}
generate main() {
test();
}
```
5. For now, it supports the data types: String, Float, Int, Long,
Short, and Char.
6. Memory management in eko is manual; you have to free up
allocated memory using "free" to prevent memory leaks. That said,
I do plan to build a garbage collector for it—one that could be
disabled, for instance, using a `--nogc` flag.
And yes, that pretty much covers the eko syntax and its key
points. By the way, I realize the documentation is a bit
incomplete and sparse; I hope to finish it as soon as possible.
Once again, thank you for taking the time to check out this
project and read through this long text.
More information about the Digitalmars-d
mailing list