2022-08-02 21:07:10 +03:00
|
|
|
// Now the file with the extension .json5, but then it will be .onla
|
|
|
|
|
2022-08-02 17:58:00 +03:00
|
|
|
[
|
|
|
|
{
|
2022-08-03 16:28:00 +03:00
|
|
|
print: [
|
|
|
|
"Test calc and recursion\n",
|
|
|
|
"(2+2*4) + 2 = ",
|
|
|
|
{
|
|
|
|
calc: [{ calc: [2, "+", { calc: [2, "*", 4] }] }, "+", 2],
|
|
|
|
},
|
|
|
|
"\n",
|
|
|
|
],
|
2022-08-02 17:58:00 +03:00
|
|
|
},
|
2022-08-02 20:24:20 +03:00
|
|
|
{
|
2022-08-03 16:28:00 +03:00
|
|
|
print: [
|
|
|
|
"-----All operators-----\n\n\tNORMAL",
|
2022-08-03 19:03:29 +03:00
|
|
|
"\n 2 * 3 = ",
|
2022-08-03 16:28:00 +03:00
|
|
|
{ calc: [2, "*", 3] },
|
2022-08-03 19:03:29 +03:00
|
|
|
"\n 6 / 2 = ",
|
2022-08-03 16:28:00 +03:00
|
|
|
{ calc: [6, "/", 2.5] },
|
2022-08-03 19:03:29 +03:00
|
|
|
"\n 2 + 3 = ",
|
2022-08-03 16:28:00 +03:00
|
|
|
{ calc: [2, "+", 3] },
|
2022-08-03 19:03:29 +03:00
|
|
|
"\n 2 - 3 = ",
|
2022-08-03 16:28:00 +03:00
|
|
|
{ calc: [2, "-", 3] },
|
2022-08-02 20:24:20 +03:00
|
|
|
|
2022-08-03 19:03:29 +03:00
|
|
|
"\n 2 % 2 = ",
|
2022-08-03 16:28:00 +03:00
|
|
|
{ calc: [2, "%", 2] },
|
2022-08-03 19:03:29 +03:00
|
|
|
"\n 3 % 2 = ",
|
2022-08-03 16:28:00 +03:00
|
|
|
{ calc: [3, "%", 2] },
|
2022-08-02 20:24:20 +03:00
|
|
|
|
2022-08-03 16:28:00 +03:00
|
|
|
"\n\n\tBit operators",
|
2022-08-02 20:24:20 +03:00
|
|
|
|
2022-08-03 19:03:29 +03:00
|
|
|
"\n 4 & 4 = ",
|
2022-08-03 16:28:00 +03:00
|
|
|
{ calc: [4, "&", 4] },
|
2022-08-03 19:03:29 +03:00
|
|
|
"\n 4 & 3 = ",
|
2022-08-03 16:28:00 +03:00
|
|
|
{ calc: [4, "&", 3] },
|
2022-08-02 21:07:10 +03:00
|
|
|
|
2022-08-03 19:03:29 +03:00
|
|
|
"\n 4 | 4 = ",
|
2022-08-03 16:28:00 +03:00
|
|
|
{ calc: [4, "|", 4] },
|
2022-08-03 19:03:29 +03:00
|
|
|
"\n 4 | 3 = ",
|
2022-08-03 16:28:00 +03:00
|
|
|
{ calc: [4, "|", 3] },
|
2022-08-02 21:07:10 +03:00
|
|
|
|
2022-08-03 19:03:29 +03:00
|
|
|
"\n -8 >> 3 = ",
|
2022-08-03 16:28:00 +03:00
|
|
|
{ calc: [-8, ">>", 3] },
|
2022-08-03 19:03:29 +03:00
|
|
|
"\n 5 << 3 = ",
|
2022-08-03 16:28:00 +03:00
|
|
|
{ calc: [5, "<<", 3] },
|
2022-08-02 21:07:10 +03:00
|
|
|
|
2022-08-03 16:28:00 +03:00
|
|
|
"\n\n--End of All operators--",
|
|
|
|
],
|
2022-08-02 21:07:10 +03:00
|
|
|
},
|
2022-08-03 19:03:29 +03:00
|
|
|
|
|
|
|
{
|
|
|
|
print: [
|
|
|
|
"-----All comparisons-----\n\n\tBool",
|
|
|
|
"\n true != false: ",
|
|
|
|
{ comp: [true, "!=", false] },
|
|
|
|
"\n true == false: ",
|
|
|
|
{ comp: [true, "==", false] },
|
|
|
|
"\n true && false: ",
|
|
|
|
{ comp: [true, "&&", false] },
|
|
|
|
"\n true || false: ",
|
|
|
|
{ comp: [true, "||", false] },
|
|
|
|
"\n true > false: ",
|
|
|
|
{ comp: [true, ">", false] },
|
|
|
|
|
|
|
|
"\n true >= false: ",
|
|
|
|
{ comp: [true, ">=", false] },
|
|
|
|
"\n true <= false: ",
|
|
|
|
{ comp: [true, "<=", false] },
|
|
|
|
|
|
|
|
"\n\n\tNumbers",
|
|
|
|
|
|
|
|
"\n 1 != 2: ",
|
|
|
|
{ comp: [1, "!=", 2] },
|
|
|
|
"\n 4 == 2+2: ",
|
|
|
|
{ comp: [4, "==", { calc: [2, "+", 2] }] },
|
|
|
|
"\n 4 > 2+2: ",
|
|
|
|
{ comp: [4, ">", { calc: [2, "+", 2] }] },
|
|
|
|
"\n 4 < 2+2: ",
|
|
|
|
{ comp: [4, "<", { calc: [2, "+", 2] }] },
|
|
|
|
"\n 4 >= 2+2: ",
|
|
|
|
{ comp: [4, ">=", { calc: [2, "+", 2] }] },
|
|
|
|
|
|
|
|
"\n 8 <= 2+2: ",
|
|
|
|
{ comp: [8, "<=", { calc: [2, "+", 2] }] },
|
|
|
|
|
|
|
|
"\n 8 <= 4+4: ",
|
|
|
|
{ comp: [8, "<=", { calc: [4, "+", 4] }] },
|
|
|
|
|
|
|
|
"\n\n\tOther",
|
|
|
|
|
|
|
|
"\n [0,1] != [1,0]: ",
|
|
|
|
{ comp: [[0, 1], "!=", [1, 0]] },
|
|
|
|
"\n [0,1] == [0,1]: ",
|
|
|
|
{ comp: [[0, 1], "==", [0, 1]] },
|
|
|
|
|
|
|
|
'\n "What" != "Not What": ',
|
|
|
|
{ comp: ["What", "!=", "Not What"] },
|
|
|
|
'\n "What" == "Not What": ',
|
|
|
|
{ comp: ["What", "==", "Not What"] },
|
|
|
|
|
|
|
|
"\n\n\tMore complex",
|
|
|
|
|
|
|
|
"\n (1 + 1 > 3) == false: ",
|
|
|
|
{ comp: [{ comp: [{ calc: [1, "+", 1] }, ">", 3] }, "==", false] },
|
|
|
|
|
|
|
|
"\n (( 1 + 1 > 3 ) == false) && (( 1 + 1 > 3 ) == true): ",
|
|
|
|
{
|
|
|
|
comp: [
|
|
|
|
{ comp: [{ comp: [{ calc: [1, "+", 1] }, ">", 3] }, "==", false] },
|
|
|
|
"&&",
|
|
|
|
{ comp: [{ comp: [{ calc: [1, "+", 1] }, ">", 3] }, "==", true] },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
"\n (( 1 + 1 > 3 ) == false) || (( 1 + 1 > 3 ) == true): ",
|
|
|
|
{
|
|
|
|
comp: [
|
|
|
|
{ comp: [{ comp: [{ calc: [1, "+", 1] }, ">", 3] }, "==", false] },
|
|
|
|
"||",
|
|
|
|
{ comp: [{ comp: [{ calc: [1, "+", 1] }, ">", 3] }, "==", true] },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
"\n\n-End of All comparisons-",
|
|
|
|
],
|
|
|
|
},
|
2022-08-03 21:30:22 +03:00
|
|
|
|
|
|
|
"\nCreating variables",
|
|
|
|
{
|
|
|
|
let: {
|
|
|
|
str: "A",
|
|
|
|
num: 2,
|
|
|
|
arr: ["Array", "in", "variable"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
let: {
|
|
|
|
calculated: { calc: [{ var: "num" }, "*", 4] },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[
|
|
|
|
"Created 4 variables with values:\n",
|
|
|
|
"str = ",
|
|
|
|
{ var: "str" },
|
|
|
|
"\nnum = ",
|
|
|
|
{ var: "num" },
|
|
|
|
"\narr = ",
|
|
|
|
{ var: "arr" },
|
|
|
|
"\ncalculated (num * 4) = ",
|
|
|
|
{ var: "calculated" },
|
|
|
|
],
|
|
|
|
|
|
|
|
"Execute calculated = calculated + 1",
|
|
|
|
{
|
|
|
|
assign: {
|
|
|
|
calculated: { calc: [{ var: "calculated" }, "+", 1] },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
["After executing calculated = ", { var: "calculated" }],
|
2022-08-03 22:59:54 +03:00
|
|
|
|
|
|
|
"\nRun loop",
|
|
|
|
{
|
|
|
|
loop: [
|
|
|
|
{
|
|
|
|
assign: {
|
|
|
|
calculated: { calc: [{ var: "calculated" }, "+", 1] },
|
|
|
|
},
|
|
|
|
},
|
2022-08-04 11:21:39 +03:00
|
|
|
{
|
|
|
|
loop: [
|
|
|
|
{
|
|
|
|
if: {
|
|
|
|
condition: { comp: [{ var: "num" }, ">=", 200000] },
|
|
|
|
body: ["break"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
assign: {
|
|
|
|
num: { calc: [{ var: "num" }, "+", 1] },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
print: [
|
|
|
|
"\rcalculated = ",
|
|
|
|
{ var: "calculated" },
|
|
|
|
"; num = ",
|
|
|
|
{ var: "num" },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
print: [
|
|
|
|
"\rcalculated = ",
|
|
|
|
{ var: "calculated" },
|
|
|
|
"; num = ",
|
|
|
|
{ var: "num" },
|
|
|
|
],
|
|
|
|
},
|
2022-08-03 22:59:54 +03:00
|
|
|
{
|
|
|
|
if: {
|
|
|
|
condition: { comp: [{ var: "calculated" }, ">=", 200000] },
|
|
|
|
body: ["\n", "break"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
if: {
|
|
|
|
condition: { comp: [{ var: "calculated" }, ">=", 199999] },
|
|
|
|
body: [["Calculated is >= ", 199999]],
|
|
|
|
else: [["Calculated is < ", 199999]],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
if: {
|
|
|
|
condition: { comp: [{ var: "calculated" }, ">", 200000] },
|
|
|
|
body: [["Calculated is > ", 200000]],
|
|
|
|
else: [["Calculated is <= ", 200000]],
|
|
|
|
},
|
|
|
|
},
|
2022-08-03 19:03:29 +03:00
|
|
|
|
2022-08-04 12:59:08 +03:00
|
|
|
"clear",
|
2022-08-02 21:07:10 +03:00
|
|
|
|
2022-08-03 16:28:00 +03:00
|
|
|
// //TODO CONCEPTS ##########################################################################################################################################################################################################################
|
2022-08-02 21:07:10 +03:00
|
|
|
|
2022-08-03 16:28:00 +03:00
|
|
|
// {
|
|
|
|
// while: {
|
2022-08-04 12:59:08 +03:00
|
|
|
// cond: { comp: [1, ">=", {var: "variable"}] },
|
2022-08-03 16:28:00 +03:00
|
|
|
// body: [
|
|
|
|
// //commands
|
|
|
|
// ],
|
|
|
|
// },
|
|
|
|
// },
|
2022-08-02 17:58:00 +03:00
|
|
|
]
|