yaml
| Kind | kit |
|---|---|
| Categories | parser data-format config |
| Keywords | yaml parser config serialization data-format |
YAML parsing and generation for Kit
Files
| File | Description |
|---|---|
kit.toml | Package manifest with metadata and dependencies |
src/yaml.kit | YAML generation and value conversion utilities |
tests/yaml.test.kit | Tests for generation and value-to-string conversion |
examples/basic.kit | Parse YAML and access typed values |
examples/debug.kit | Debug line splitting and filtering |
examples/yaml.kit | Full demo of parsing, nesting, and generation |
LICENSE | MIT license file |
Dependencies
No Kit package dependencies.
Installation
kit add gitlab.com/kit-lang/packages/kit-yaml.gitUsage
import Kit.YamlLicense
MIT License - see LICENSE for details.
Exported Functions & Types
YamlValue
YAML value types for typed access.
Variants
YamlString {String}Text value (quoted or unquoted)
YamlInt {Int}Integer value
YamlFloat {Float}Floating-point value
YamlBool {Bool}Boolean value (true/false, yes/no)
YamlNullNull/empty value (null, ~, or empty)
YamlList {_0}List of YAML values
YamlError
YAML parse error types.
Variants
SyntaxError {line, message}General syntax error
InvalidIndentation {line, message}Invalid indentation
InvalidValue {line, key, message}Invalid value for a key
UnclosedString {line}Unclosed string literal at line
UnclosedList {line}Unclosed list at line
DuplicateKey {line, key}Duplicate key definition
Yaml
Marker type for the YAML format. Used with StringEncode/StringDecode traits to distinguish YAML serialization.
Variants
Yamlgenerate
Generates YAML string from list of {key, value} records.
Creates a simple flat YAML document with key: value pairs.
Parameters:
Returns:
[{key: String, value: YamlValue}] -> String
pairs = [
{key: "name", value: YamlString "MyApp"},
{key: "port", value: YamlInt 8080},
{key: "enabled", value: YamlBool true}
]
yaml-str = YAML.generate pairs
# Output:
# name: "MyApp"
# port: 8080
# enabled: truevalue-to-string
Converts a YamlValue to its string representation.
Parameters:
Returns:
YamlValue -> String
str-val = YAML.value-to-string (YamlString "hello")
# Returns: "hello"
int-val = YAML.value-to-string (YamlInt 42)
# Returns: 42
bool-val = YAML.value-to-string (YamlBool true)
# Returns: true
list-val = YAML.value-to-string (YamlList [YamlInt 1, YamlInt 2])
# Returns: [1, 2]