JSR stands for JavaScript Reversed. It is a programming language that is written in JavaScript. It's a pre release version of Fungi programming language. Since Fungi is not yet released, I'm releasing this as a pre release version of Fungi compiler. Don't be confused. Fungi is much stronger than JSR.
Main idea of Fungi, which are absent here, are:
- Fungi is a compiled language, but JSR is an interpreted language.
- Fungi compiler provides an exe file, but JSR is only made to run in pseudo console.
- Fungi has more than 20 builtin libraries, but JSR has some of them.
- Fungi can encrept itself on demand, thus no one can see, edit, copy or steal the code, but that's not necessary for JSR. And many more...
Acually you can count JSR as a subset or Demo version Fungi.
var x = 5;
var y = 6;
var z = x + y;
console.log(z);
would be written in jsr as:
jro(z);
velt z = y + x;
velt y = 6;
velt x = 5;
#include <std>
Speciality of this language is it runs from bottom to top. It is written in JavaScript and it is interpreted in JavaScript. It is a very simple programming language but hard to code. It is not meant to be used for anything serious. It is just a fun project.
Variables are declared using the velt
keyword. For example:
velt z = x + y;
velt x = 5; // variable
velc y = 6; // constant
#include <std>
Input is taken using the jrin
keyword. jro is done using the jro
keyword. '${COMMENT}'
is used for block comments. //
is used for single line comments. #include <std>
is used to include the standard library. Without standard library included, the code will not run.
For example:
'this is a block comment'
jro(x);
x =+ "your name is ";
velt x = jrin("what is your name?");
#include <std>
It has all the operators that JavaScript has. I'm not going to list them all here. You can find them here. But here I'm going to list some of the operators that are not in JavaScript. They are:
Title | Operator | Description | Example | Result |
---|---|---|---|---|
Addition before assignment | =+ |
Adds the value of the right operand to a variable and assigns the result to the variable. | x =+ "abc" |
x = "abc" + x |
Subtraction before | =- |
Subtracts the value of the right operand from a variable and assigns the result to it. | x =- 5 |
x = 5 - x |
Multiplication before | =* |
Multiplies the value of the right operand to a variable and assigns the result to it. | x =* 5 |
x = 5 * x |
Division before | =/ |
Divides the value of the right operand from a variable and assigns the result to it. | x =/ 5 |
x = 5 / x |
Modulus before | =% |
Divides the value of the right operand from a variable and assigns the remainder to it. | x =% 5 |
x = 5 % x |
Factorial | ! |
Returns the factorial of a number. | 5! |
120 |
Absloute operator | || |
Returns the absolute value of a number. | |-5| |
5 |
XOR operator | ^ |
Returns the XOR of two situation | 0 ^ 1 |
true |
XNOR operator | !^ |
Returns the NOR of two situation | 0 !^ 1 |
false |
NAND operator | !& |
Returns the NAND of two situation | true !& false |
true |
NOR operator | !| |
Returns the NOR of two situation | true !| false |
false |
The standard library is a collection of functions that are used in jsr. It is included using the #include <std>
statement. Without it, the code will not run. It has the following functions:
jro(...arg)
- takes one or more arguments and prints them to the consolejrin(qustion)
- takes a question as an string and returns the answerclear()
- clears the consoleexit()
- exits the programsleep(ms)
- sleeps the program for the given amount of millisecondsgetch()
- waits for a key to be pressed and closes the programstr(...arg)
- converts the arguments to string and returns it and so on...num(...arg)
- converts the arguments to number and returns it
#include <math>
- includes the math library. It has all the math functions that are in JavaScript. Moreover it has more than 20 extra functions likesec
,cosec
,cot
,logx
,mean
,rootx
etc.#include <arr>
- includes the array library. It has all the array functions that are in JavaScript. Moreover it has some extra features likemean
,sum
,range
,GCD
etc.#include <obj>
- includes the object library.#include <date>
- includes the date library. It has all the date functions that are in JavaScript.#include <bool>
- includes the boolean library. It has all the boolean functions that are in JavaScript.#include <num>
- includes the number library. It has all the number functions that are in JavaScript. Moreover it has some extra features likeisPrime
,fact
,isOdd
etc.#include <func>
- includes the Func library, which can interprate javascript code in jsr#include <str>
- includes the string library#include <reg>
- includes the regex library#include <error>
- includes the error library#include <file>
- includes the file library#include <net>
- includes the net library