Learn to Code via Tutorials on Repl.it!

← Back to all posts
How To Make A Programming Language In Javascript
h
Battledash2

Hey There!

I’d bet your here to learn how to make your own programming language using js! (im on mobile so I cant make code blocks :()

This Will NOT Tell You How To Do The HTML and CSS Only The Parser!

Step One:
Create a function called “parse” with argument one named ttp for text to parse, it should look like this:

Ok, great!

Step Two:
We now need to create something to convert the text givin into something computer readable. We're gonn replace every \n that doesnt have a ; before it with a ; then replace ;\n with just ; last we're gonna replace all \n with nothing, here's how:

Now our commands are splitted with ;'s so we can split with ; but type our commands with either ; or backspace!

Step Three:
Splitting The Commands So We Can Parse!
We now need to split our code in to an array so our script can understand what to do! We'll do it like this:

We Now Need To Loop Through It:

Nice!!

Step Four:
We need to check the command now. We can use if(cmd[0] == 'CommandName')

Here's an example:

That's all! We can now do this to run the code:

TextInput:

Voters
glitchish
EpicGamer007
Battledash2
Comments
hotnewtop
Vandesm14

You should put your code in code fences like this: