I have a Linux system. I want to create a version of JavaScript with French keywords and stuff. I don’t want to modify JavaScript itself, but only have synonyms for keywords in French that when compiled to JS, replace into the English version. I don’t want to use a parser/lexer because that’s too complicated for what I’m doing.
I will show you an example of what my code could do:
var message = "Salut, StackExchange!"
fonction bonjourMonde() {
dire(message);
}
pour (var i = 0; i < 10; i++) {
si (i % 2 == 0) dire(`${i}: even`);
sinon dire(i + ': odd');
}
That code would compile to this:
var message = "Salut, StackExchange!"
function bonjourMonde() {
console.log(message);
}
for (var i = 0; i < 10; i++) {
if (i % 2 == 0) console.log(`${i}: even`);
else console.log(i + ': odd');
}
As you can see, fonction
leads to function
, pour
= for
, si
=if
, sinon
=else
, dire
=console.log
.
Any way I could do this? I’m thinking it would probably be a bash or a makefile compiling it to JS, then running the compiled JS with node. But I’m not sure how to do that.