I Created a JavaScript Simulator in Python SLY!
ELDER054

After finding someone’s project that used SLY (Sly Lex Yacc), I decided this would help me be able to create a programming language. So I picked my strongest language: JavaScript, and tried to recreate it in Python.

Link to SLY project I saw is https://repl.it/@sugarfi/Parser-Template

You can create integer or string variables, use comments, and print things so far in my JavaScript.
WARNING: this JS simulator requires you to put a semicolon (;) at the end of statements
You can easily extend and replace these syntax rules to create your own language! I will also try to use this as a reference for a future programming language I’m trying to create!

You are viewing a single comment. View All
elipie

uhm, javascript has ; at end of lines btw

BrutalBucket

@elipie Javascript does not need ; in it only when you are using it like console.log("Sdasdadas");console.log("Jsjiidhsiakd"); in one line

ELDER054

I made it require “;”s because it’s good practice to do it in JS, @BrutalBucket

elipie

@BrutalBucket Yes you do need ; at the end of the line, if you don't it will generate an error, that won't be shown, then it will kinda auto-correct your own line. So take this for example:

After running it it would turn into:

But your code would stay the same

ELDER054

Yeh, it is also preferred to use a semicolon, @elipie

ELDER054

If you don’t, it will take care of it for you though, @Elderosa

elipie
ELDER054

Can you test the alert function I just created. It doesn’t look too promising tho :( @elipie

CSharpIsGud

@elipie In JS and other languages that don't mandate ; newlines essentially function the same way as semicolons, so the only situation you need a semicolon is if you for some reason need multiple statements on one line. Otherwise they just keep going like normal.