DEV Community

JavaCode7
JavaCode7

Posted on • Updated on

Making an esolang

I have posted about esolangs a lot in the past. From good ones to mine to the esolist but never have I posted about making one.

In this article, I am going to go through a step by step procedure to make an esolang like loo. It is a simple language with only 4 commands. + to increment the value of the one variable it can hold, - to decrement, # to print out the value in ascii form (e.g. 97 would be the lowercase letter a) and finally ; stops the program. I will be making this in python but you can use any language you like.

Note

This is not the only way to create an esolang and it is not the only syntax for one. There are many types, each with their own peculiarities. I recommend looking at esolangs.org to see these.

Step 1: Accepting the code

This code takes in input from the user that should contain the loo code. It also sets up the variable for the value that loo holds.

value = 0
code = input("Enter your loo code here please > ")
Enter fullscreen mode Exit fullscreen mode

Step 2: String to List

This block of code basically splits the loo code string into a list that will be iterated through later.

lexed = []
for i in code:
    lexed.append(i)
Enter fullscreen mode Exit fullscreen mode

Step 3: Execution

Now we iterate through the lexed list and execute the code.

for j in lexed:
    if j == "+":
        value += 1
    elif j == "-":
        value -= 1
    elif j == "#":
        print(chr(value))
    elif j == ";":
        quit()
Enter fullscreen mode Exit fullscreen mode

It is as simple as that! I hope you enjoyed this and hopefully I will post again soon.

Top comments (4)

Collapse
 
olus2000 profile image
Alex Esoposting

That's as simple as it gets, but what about features that work differently depending on tokens surrounding them? The internet would really use some guides to using existing parsers and lexers (like rply for example) to make more powerful languages. It would be really cool if you shown how to do something more advanced.

Collapse
 
javacode7 profile image
JavaCode7

Ok... I'll be sure to write an article on that.

Collapse
 
moose profile image
moose

I've recently really got into regular expressions and I find this type of thing fascinating. Thanks for sharing, I never knew about esolangs before I read this!

Collapse
 
javacode7 profile image
JavaCode7

No problem, glad you enjoyed!