mirror of
https://github.com/artegoser/ONLang
synced 2024-12-23 01:23:46 +03:00
doc: for 0.3.0
This commit is contained in:
parent
d5d2e81ebb
commit
2eb1f773b0
3 changed files with 81 additions and 13 deletions
|
@ -7,8 +7,8 @@
|
||||||
- [ ] methods for arrays
|
- [ ] methods for arrays
|
||||||
- [ ] methods for strings
|
- [ ] methods for strings
|
||||||
- [ ] methods for objects
|
- [ ] methods for objects
|
||||||
- [ ] writing objects to a variable
|
- [x] writing objects to a variable
|
||||||
- [x] yaml support?
|
- [x] yaml support
|
||||||
- [ ] command execution function
|
- [ ] command execution function
|
||||||
- [ ] function for random
|
- [ ] function for random
|
||||||
- [x] delete variable
|
- [x] delete variable
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
- [ ] checking variable type
|
- [ ] checking variable type
|
||||||
- [x] checking for the existence of a variable
|
- [x] checking for the existence of a variable
|
||||||
- [x] create scopes without if, else, loop
|
- [x] create scopes without if, else, loop
|
||||||
- [ ] calculate values in arrays
|
- [x] calculate values in arrays
|
||||||
|
- [x] References for variables in variables
|
||||||
|
|
||||||
and something else
|
and something else
|
||||||
|
|
28
doc/main.md
28
doc/main.md
|
@ -90,6 +90,34 @@ works only with numbers (and variables with number type)
|
||||||
calculated: { calc: [{ var: "num" }, "*", 4] }, //result 8
|
calculated: { calc: [{ var: "num" }, "*", 4] }, //result 8
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
let: {
|
||||||
|
referenceVar: { ref: "calculated" },
|
||||||
|
},
|
||||||
|
//creates a reference variable, when the "calculated"
|
||||||
|
// is changed, "referenceVar" will also be changed, in the
|
||||||
|
// future it will be possible to change "referenceVar"
|
||||||
|
// and the "calculated" will be changed
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
let: {
|
||||||
|
array: { arr: [{ var: "num" }, 4] }, //create calculated array result [2, 4]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
let: {
|
||||||
|
objVar: { obj: { var: "num" } }, //create object (hashmap) variable result {var: "num"}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
let: {
|
||||||
|
wrongObjVar: { var: "num" }, //result 2
|
||||||
|
},
|
||||||
|
},
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,21 @@
|
||||||
str: "A",
|
str: "A",
|
||||||
num: 2,
|
num: 2,
|
||||||
arr: ["Array", "in", "variable"],
|
arr: ["Array", "in", "variable"],
|
||||||
|
obj: {
|
||||||
|
obj: {
|
||||||
|
arr: ["i'm array", "!"],
|
||||||
|
string: "I'm string!",
|
||||||
|
calculated: { calc: [2, "*", 2] },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
let: {
|
||||||
|
calcArr: {
|
||||||
|
arr: ["Some str", { var: "num" }],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -142,15 +157,19 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
[
|
[
|
||||||
"Created 4 variables with values:\n",
|
"Created 6 variables with values:\n",
|
||||||
"str = ",
|
"str = ",
|
||||||
{ var: "str" },
|
{ var: "str" },
|
||||||
"\nnum = ",
|
"\nnum = ",
|
||||||
{ var: "num" },
|
{ var: "num" },
|
||||||
"\narr = ",
|
"\narr = ",
|
||||||
{ var: "arr" },
|
{ var: "arr" },
|
||||||
|
"\nobj = ",
|
||||||
|
{ toString: { var: "obj" } },
|
||||||
"\ncalculated (num * 4) = ",
|
"\ncalculated (num * 4) = ",
|
||||||
{ var: "calculated" },
|
{ var: "calculated" },
|
||||||
|
'\ncalculated array ["Some str", num] = ',
|
||||||
|
{ var: "calcArr" },
|
||||||
],
|
],
|
||||||
|
|
||||||
"Execute calculated = calculated + 1",
|
"Execute calculated = calculated + 1",
|
||||||
|
@ -175,7 +194,7 @@
|
||||||
loop: [
|
loop: [
|
||||||
{
|
{
|
||||||
if: {
|
if: {
|
||||||
condition: { comp: [{ var: "num" }, ">=", 100000] },
|
condition: { comp: [{ var: "num" }, ">=", 10000] },
|
||||||
body: ["break"],
|
body: ["break"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -204,7 +223,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
if: {
|
if: {
|
||||||
condition: { comp: [{ var: "calculated" }, ">=", 100000] },
|
condition: { comp: [{ var: "calculated" }, ">=", 10000] },
|
||||||
body: ["\n", "break"],
|
body: ["\n", "break"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -213,17 +232,17 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
if: {
|
if: {
|
||||||
condition: { comp: [{ var: "calculated" }, ">=", 99999] },
|
condition: { comp: [{ var: "calculated" }, ">=", 9999] },
|
||||||
body: [["сalculated is >= ", 99999]],
|
body: [["сalculated is >= ", 9999]],
|
||||||
else: [["сalculated is < ", 99999]],
|
else: [["сalculated is < ", 9999]],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
if: {
|
if: {
|
||||||
condition: { comp: [{ var: "calculated" }, ">", 100000] },
|
condition: { comp: [{ var: "calculated" }, ">", 10000] },
|
||||||
body: [["сalculated is > ", 100000]],
|
body: [["сalculated is > ", 10000]],
|
||||||
else: [["сalculated is <= ", 100000]],
|
else: [["сalculated is <= ", 10000]],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -262,5 +281,25 @@
|
||||||
name: { input: "Your name: " },
|
name: { input: "Your name: " },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ print: ["Bye, ", { var: "name" }, "!"] },
|
["Hey, ", { var: "name" }, "!"],
|
||||||
|
|
||||||
|
"Check a var references",
|
||||||
|
'\nCreate variable refToName with reference variable "name"',
|
||||||
|
{
|
||||||
|
let: {
|
||||||
|
refToName: { ref: "name" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
["refToName = ", { var: "refToName" }],
|
||||||
|
|
||||||
|
"Try assign name with new value",
|
||||||
|
{
|
||||||
|
assign: {
|
||||||
|
name: { input: "Any name: " },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"",
|
||||||
|
["name = ", { var: "name" }],
|
||||||
|
["refToName = ", { var: "refToName" }],
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Reference in a new issue