Wednesday, March 29, 2017

Enki - my pet compiler project

So, for the last few years I've worked a bit at a time on a pet project - a compiler for a language of my own design, Enki, to Linux/MacOS/Windows/Android native code. Enki syntactically looks like Python with a dash of Pascal mixed in and is a statically-typed, statically-compiled language. I'm intending to explore things like cross-platform native-code binaries, extensible OO and just generally cool and fun programming language features.

Here's interview classic FizzBuzz:

Uint64 max = 100
Uint64 count = 0
Byte[20] number
while count < max
    if (count % 15) == 0
        write("Fizzbuzz\n")
    elif (count % 3) == 0
        write("Fizz\n")
    elif (count % 5) == 0
        write("Buzz\n")
    else
        num_to_str(count, @number)
        write(@number)
        write("\n")
    count = count + 1

Also supported are nested functions, Python-style generators and CLOS-style multimethods/OO.

GitHub link is here: https://github.com/jotheberlock/Enki

Links to HTML documentation (note the internal links won't work, unfortunately):

Overview
FAQ
What the compiler does when

No comments:

Post a Comment