I made a programming language without any knowledge.

aiocat

aiocat

Posted on February 16, 2022

I made a programming language without any knowledge.

Hello folks! I decided to make a minimal programming language... without any knowledge...

Starting

For this challenge, I chosed C++ because its fast. I would chose rust but i will rewrite with rust later.

And i started to searching about making a programming language, and i got some basics about lexers, compilers etc... and I started with reverse polish notation and stack based language. Because they are easy to implement.

Writing a Lexer

Lexer is the simplest part of writing a language, just tokenizing the keywords.

Lexer

I didn't use any lexer generator (like lex) because its better to make it from zero for me. But the worst part of it, I DON'T KNOW C++. And thats why it was a bit torture to me. I still think the lexer i wrote sucks because i made it without any C++ knowledge. But, atleast it works :D

50 100 + put
Enter fullscreen mode Exit fullscreen mode

=> (pseudo)

[
    {token: NUMBER, value: "50"},
    {token: NUMBER, value: "100"},
    {token: ADD, value: ""},
    {token: PUT, value: ""}
]
Enter fullscreen mode Exit fullscreen mode

Compiler? Transpiler?

After writing a lexer, i need to make a compiler/transpiler for my project. (i skipped AST since it doesn't need.) I checked LLVM but its really deep project to dive in so i tried with assembly. And another problem, i don't know assembly too! and i decided to make a C++ transpiler for my language.

It transpiles the code into C++ and runs g++ to compile the C++ source.

Trying the Language

I wanted to test the limits of the language, So i made a brainfuck compiler in my language. I think its best project to test your language too.

Features

After some days, i added tons of things to my language. It was really fun!

Features

Documentation

And the most boring thing in programming scenario... Writing a documentation! Well, i think nobody likes that but everyone needs that too. So i wrote a simple language reference for my programming language.

Finishing

So, that was my adventure about creating a minimal programming language. If you liked the project, you can star on GitHub page!

💖 💪 🙅 🚩
aiocat
aiocat

Posted on February 16, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related