I’ve always wanted to make a programming language, Even when I didn’t know how they worked and they felt like absolute magic that just runs my code using the power of the Pleides or something… After I learnt about how compilers and interpreters work and the steps they require to convert my code into executables or to actually execute it I had to also deal with the problem of time, each time I want to start making a programming language something pops out of nowhere (usually school) and says “fuck you, you aren’t doing that shit HAHAHA” Now that my first semester is nearly done and I can finally do my projects in peace I’m continueing on making a programming language so that I can learn more practically about how they work fundementally.

My language’s design choices.

For the language I’m going to work, it’ll be no more than a learning project so I tried to make my choices simplify the whole development process so I can focus more on learning. I have decided to make the language interpreted and statically typed, why? because compilation is quite hard at this point for me (I’ve already struggled with lexing, so yeah…) and I want to figure out how type systems work. I haven’t decided much on the syntax though I’m sure I won’t be much “creative” with it As I was working on the lexer I actually decided some elements of the syntax.

Starting the development.

I choose to use Rust for my language’s interpreter just to be able to learn the language further and improve my ability to think the Rust way, because I think that I still do things wrong in Rust most of the time. I started with the easiest part (to me at lest) which is the lexer, This is what turns your code into tokens that could be then parsed to make a meaning of the code. I used a crate called Logos in order to make the lexer, it is a popular choice for that purpose, making the lexer was kinda non-easy but fun, I learned a lot about lexing and some of it’s quirks. For example, When lexing integers I thought I’d get away with just doing a simple \d+ regex to get the numbers, But it turns out that I had to support some other formats or representations of numbers, Specifically supporting prefixes like 0x (hexidecimal) 0b (binary) and 0o (octal) and adding support for these was tricky as they couldn’t just be captured with regex, they had to have their own parsing logic.