Own-Programming-Language-Tu.../examples/formats/yaml.own

51 lines
1.3 KiB
Scala
Raw Normal View History

2023-09-09 15:52:32 +03:00
use yaml
2016-09-16 17:32:35 +03:00
2019-10-17 14:39:53 +03:00
data = {
2016-09-16 17:32:35 +03:00
"name": "Yaml Example",
"version": 1,
"arrayData": [
1, 2, 3, 4
],
"objectData": {
"key": "value",
10: "1000"
}
2019-10-17 14:39:53 +03:00
}
println "Yaml encode"
println yamlencode(data)
println "Yaml encode with options"
println yamlencode(data, {
"indent": 6,
"prettyFlow": true,
"defaultFlowStyle": "BLOCK"
2016-09-16 17:32:35 +03:00
})
println "\nYaml decode"
x = yamldecode("
name: \"std\"
scope: \"both\"
desc: \"Contains common functions\"
desc_ru: \"Содержит вспомогательные функции общего назначения\"
constants: []
functions:
-
name: \"arrayCombine\"
args: \"keys, values\"
desc: \"creates map by combining two arrays\"
desc_ru: \"создаёт объект на основе двух массивов\"
-
name: \"typeof\"
args: \"value\"
desc: \"returns the type of value\"
desc_ru: \"возвращает тип переданного значения\"
example: |-
print typeof(1) // 1 (NUMBER)
print typeof(\"text\") // 2 (STRING)
print typeof([]) // 3 (ARRAY)
")
println x.name + ", scope: " + x.scope
println x.desc
for func : x.functions {
println " - " + func.name + "(" + func.args + ")"
println " " + func.desc
}