YAML 1.2 parser in MoonBit
moon add bobzhang/yamlimport {
"bobzhang/yaml",
}fn main {
let document = try! @yaml.parse_yaml("name: MoonBit\nenabled: true\n")
match document {
Map(entries) => {
for entry in entries {
let (key, value) = entry
println("\{key}: \{value}")
}
}
_ => println("Expected a mapping")
}
}moon check --target all
moon test --target all
moon fmt --checkgit clone https://github.com/yaml/yaml-test-suite.git yaml-test-suite-data
git -C yaml-test-suite-data checkout 6ad3d2c62885d82fc349026c136ef560838fdf3d
moon build --target native
python3 scripts/run_yaml_suite.pypub(all) suberror ParseError {
UnexpectedChar(pos~ : Position, found~ : Char)
UnexpectedEof(pos~ : Position)
InvalidIndent(pos~ : Position)
InvalidNumber(pos~ : Position, value~ : String)
InvalidEscape(pos~ : Position, value~ : String)
UnknownAnchor(name~ : String)
InvalidMerge(detail~ : String)
InvalidDirective(detail~ : String)
InvalidTagValue(tag~ : String, value~ : String)
MultipleDocuments(count~ : Int)
NotImplemented(feature~ : String)
} derive(Eq, Show, ToJson, Debug)