redfloyd

redfloyd

Writing an interpreter in Elixir

Greetings fellow alchemists !

I have started to write an open-source interpreter in Elixir (GitHub - nicolasdilley/dwarf-interpreter: The compiler for the dwarf's language · GitHub) one week ago and I decided to write some tutorials on each stage of the development of my new language. I have finished the first one on the lexer. If you are interested in interpreters or even compilers these tutorials would give you a good practical approach to write your own !

You can find these tutorials on my website : http://nicolasdilley.com/?p=1 I would love to have your opinion !

The language is called “Dwarf” and has already lots of functionalities. The next steps are implementing loops, a type system and a good stdlib. If you want to contribute on it feel free to pm me

Most Liked

OvermindDL1

OvermindDL1

Yay another person making interpreters on the beam! We are getting quite a collection, from a couple of lisps to a multitude of typed languages to a beam native Lua to others. I love seeing blogs about the actually design though, looking forward to updates! :grinning_face_with_smiling_eyes:

OvermindDL1

OvermindDL1

Yep, recursive decent split lexical parsing steps is very classical, PEGs became more popular about 15 years ago, but they are not taught in schools or anything yet so few know about them, even though they are significantly better designs in my opinion, they can act as a lexer, a parser, both, an AST builder, an AST runner, any mix thereof, all with near the same code, while if implemented properly will run circles around the classical methods in speed while being far easier to read. :slightly_smiling_face:

redfloyd

redfloyd

Thanks @Qqwy !
I am actually writing this language just to be a very simple and small language ( hence the name :smiley: ). The aim is not to make anything new or fancy but to show a practical way of writing an interpreter. I found that when I wanted to learn how to build one, I could not find many practical advice and examples. In addition, I wanted to put in practice the theory that I am learning :slight_smile: My area of interest is concurrency so I might use it to test some ideas in the future. For the syntax rules, you can see a definition in BNF form of the language in the README. There are also examples of source program in the benchmarks folder.

Where Next?

Popular in Guides/Tuts Top

benwilson512
Correct if me I’m wrong, as best I can tell there aren’t any reasons to use mix run --no-halt in production vs releases. The marginal val...
New
tomciopp
TLS 1.3 has been out for a little over a year now, but it has been unavailable in Phoenix due to erlang’s handling of ssl. With the most ...
New
anuragg
Hi everyone! I’m the founder of Render, a new cloud provider with native support for Elixir. When we launched Elixir support the most po...
New
zenw0lf
Hello all! For those wanting to try your hands at Elixir / Phoenix, I wrote a comprehensive tutorial on doing a simple JSON API with sai...
New
tobleron
Ok, so I am so excited to share with you the most interesting setup I have made for Elixir/Phoenix today. Why? Because if you trust me, i...
New
hauleth
Some time ago someone suggested me to write article about how I have configured my Vim to work with Elixir, now there it is: https://med...
New
hauks96
Hello everyone, I created a deployment tutorial for Phoenix applications with Kubernetes (microk8s) a few months back with the goal of s...
New
water
I’ll post this here, It might help someone in the future. Feedback is greatly appreciated. I use it with direnv on NixOS, It should wor...
New
krasenyp
I don’t know if anyone is running Elixir releases as system services on FreeBSD but below is the simplest working solution I’ve found and...
New
nelsonic
When we were figuring out how to use Phoenix LiveView we got stuck a few times. So in order to save other people time, we created a comp...
New

Other popular topics Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43806 214
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

We're in Beta

About us Mission Statement