javascwipt
v1.0.10
Published
JavaScwipt lang & transpiler
Downloads
29
Readme
Install JavaScwipt with npm:
npm install javascwiptInstall globally (enables access to jswc compile command):
npm install -g javascwiptCreate a .jscwipt file -
src/test.jscwipt
Note:
.jscwiptfiles must be insrcdirectory
nya x = 'Hello World!';
console.log(x);Compile/transpile .jscwipt files into .js or .mjs (.mjs is necessary if running with node):
jswc # creates .js
jswc mjs # creates .mjsProduces - src/test.js or src/test.mjs:
let x = 'Hello World!';
console.log(x);Use node to run the created .mjs file:
node src/test.mjsOutput:
Hello World!General Info
JavaScript keywords cannot be used as keywords or identifiers:
// .jscwipt file:
let x = 0; // unexpected token 'let'
nya let = 0; // 'let' is reservedVariable Declaration
var, let, and const are replaced by vawar, nya, and fowever:
vawar x = 0; // var
nya y = 0; // let
fowever z = 0; // constConditionals
true, false, and null are replaced by twue, fawse, and nuwull:
nya x = twue; // let x = true;
nya y = fawse; // let y = false;
nya z = nuwull; // let z = null;if and else are replaced by iwf and ewse:
iwf () { // if
// code
} ewse iwf () { // else if
// code
} ewse { // else
// code
}Loops
for is replaced with fwor:
fwor (nya i=0; i<1; i++) { // for
// code
}while is replaced with duwuring:
duwuring (/* cond */) { // while
// code
}do is also replaced with dowo:
dowo { // do
// code
} duwuring (/* cond */); // whilecontinue and break are replaced with continuwu and bweak
fwor (nya i=0; i<1; i++) {
continuwu; // continue
}
duwuring (twue) {
bweak; // break
}Switch & Case
switch, case, and default are replaced by mwatch, cwase, and nowormal:
mwatch (x) { // switch
cwase 0: // case
bweak;
cwase 1: // case
bweak;
nowormal: // default
bweak;
}Functions & Methods
function is replaced by fuwunction:
fuwunction myFunc() {} // function
fowever myOtherFunc = fuwunction() {} // also worksreturn is replaced by bacc:
fuwunction returnFunc() {
bacc 'this is a return statement'; // return
}Classes
class is replaced by cwass:
cwass myClass {} // classextends is replaced by extwends:
cwass myChildClass extwends myClass {} // extendsthis and super are replaced by kohai and senpai:
cwass myClass {
myMethod() {
kohai.x = 0; // this
}
}
cwass myChildClass extwends myClass {
myMethod() {
senpai.myMethod(); // super
}
}new is replaced by cweate:
nya instance = cweate myClass(); // newObjects
in is replaced by inswide:
nya anObj = { field: 0 };
nya x = 'field' inswide anObj; // in
// x = truedelete is replaced by boop:
nya anObj = { field: 0 };
boop anObj.field; // delete
// anObj = {}instanceof is replaced by wa ... desu:
nya anObj = cweate myClass();
nya x = anObj wa myClass desu; // instanceof
// x = trueNote:
waanddesuare both considered individual keywords, so neither can be used as identifiers
Error Handling
try, catch, and finally are replaced by twy, cwatch, and finawwy:
twy { // try
// code
} cwatch (err) { // catch
// code
} finawwy { // finally
// code
}throw is replaced by nuzzle:
twy {
// code
} cwatch (err) {
nuzzle cweate Error(err); // throw
}Modules (Import & Export)
import is replaced by gwab:
gwab "foo"; // importexport is replaced by gib:
gib fuwunction bar() { // export
// code
}Other Keywords
typeof is replaced by nani:
nya x = nani 0; // typeof
// x = 'number'void is replaced by vowoid:
nya x = vowoid 0; // void
// x = undefineddebugger is replaced by pweasefix:
pweasefix; // debuggerNew Keywords
JavaScwipt also has 2 new keywords that do not have JavaScript counterparts:
gimmeuwuify
(Because I'm garbage at programming, these keywords may be broken in some edge cases I didn't test.)
gimme:
Normally, in a .jscwipt file, it is not possible to use JavaScwipt keywords as identifiers:
vawar nya = 0; // error, 'nya' is a keyword
vawar cwass = { x: nya }; // error, 'cwass' and 'nya' are keywords
fuwunction vowoid() {} // error, 'vowoid' is a keyword
// etc.However, since JavaScwipt is ultimately transpiled into JavaScript, it is fine for the final .js file to use JavaScwipt keywords as identifiers.
Thus, the gimme keyword allows for JavaScwipt keywords to be used as identifiers during declaration and when accessing!
// No errors!
vawar gimme nya = 0; // var nya = 0;
vawar gimme cwass = { x: gimme nya }; // let cwass = { field: 0 };
fuwunction gimme vowoid() {} // function vowoid() {}
// etc.gimme gimme is also possible:
nya gimme gimme = 0; // let gimme = 0;uwuify:
The uwuify keyword can be used on strings to uwu-ify their contents:
nya x = uwuify 'test';
// x = 'twest'
nya y = 'I love programming in JavaScript.';
nya z = uwuify y;
// z = 'I wuv pwogwamming in JavaScwipt.'The uwu-ify algorithm can currently be found in src/javascwipt/scwipt.util.mjs.
