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 strings
|
||||
- [ ] methods for objects
|
||||
- [ ] writing objects to a variable
|
||||
- [x] yaml support?
|
||||
- [x] writing objects to a variable
|
||||
- [x] yaml support
|
||||
- [ ] command execution function
|
||||
- [ ] function for random
|
||||
- [x] delete variable
|
||||
|
@ -16,6 +16,7 @@
|
|||
- [ ] checking variable type
|
||||
- [x] checking for the existence of a variable
|
||||
- [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
|
||||
|
|
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
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
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",
|
||||
num: 2,
|
||||
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 = ",
|
||||
{ var: "str" },
|
||||
"\nnum = ",
|
||||
{ var: "num" },
|
||||
"\narr = ",
|
||||
{ var: "arr" },
|
||||
"\nobj = ",
|
||||
{ toString: { var: "obj" } },
|
||||
"\ncalculated (num * 4) = ",
|
||||
{ var: "calculated" },
|
||||
'\ncalculated array ["Some str", num] = ',
|
||||
{ var: "calcArr" },
|
||||
],
|
||||
|
||||
"Execute calculated = calculated + 1",
|
||||
|
@ -175,7 +194,7 @@
|
|||
loop: [
|
||||
{
|
||||
if: {
|
||||
condition: { comp: [{ var: "num" }, ">=", 100000] },
|
||||
condition: { comp: [{ var: "num" }, ">=", 10000] },
|
||||
body: ["break"],
|
||||
},
|
||||
},
|
||||
|
@ -204,7 +223,7 @@
|
|||
},
|
||||
{
|
||||
if: {
|
||||
condition: { comp: [{ var: "calculated" }, ">=", 100000] },
|
||||
condition: { comp: [{ var: "calculated" }, ">=", 10000] },
|
||||
body: ["\n", "break"],
|
||||
},
|
||||
},
|
||||
|
@ -213,17 +232,17 @@
|
|||
|
||||
{
|
||||
if: {
|
||||
condition: { comp: [{ var: "calculated" }, ">=", 99999] },
|
||||
body: [["сalculated is >= ", 99999]],
|
||||
else: [["сalculated is < ", 99999]],
|
||||
condition: { comp: [{ var: "calculated" }, ">=", 9999] },
|
||||
body: [["сalculated is >= ", 9999]],
|
||||
else: [["сalculated is < ", 9999]],
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
if: {
|
||||
condition: { comp: [{ var: "calculated" }, ">", 100000] },
|
||||
body: [["сalculated is > ", 100000]],
|
||||
else: [["сalculated is <= ", 100000]],
|
||||
condition: { comp: [{ var: "calculated" }, ">", 10000] },
|
||||
body: [["сalculated is > ", 10000]],
|
||||
else: [["сalculated is <= ", 10000]],
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -262,5 +281,25 @@
|
|||
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