mirror of
https://github.com/aNNiMON/Own-Programming-Language-Tutorial.git
synced 2024-09-20 08:44:20 +03:00
51 lines
1.3 KiB
Scala
51 lines
1.3 KiB
Scala
use yaml
|
|
|
|
data = {
|
|
"name": "Yaml Example",
|
|
"version": 1,
|
|
"arrayData": [
|
|
1, 2, 3, 4
|
|
],
|
|
"objectData": {
|
|
"key": "value",
|
|
10: "1000"
|
|
}
|
|
}
|
|
println "Yaml encode"
|
|
println yamlencode(data)
|
|
println "Yaml encode with options"
|
|
println yamlencode(data, {
|
|
"indent": 6,
|
|
"prettyFlow": true,
|
|
"defaultFlowStyle": "BLOCK"
|
|
})
|
|
|
|
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
|
|
} |