dyaml/examples/resolver/main.d

39 lines
745 B
D
Raw Normal View History

import std.regex;
2011-08-16 12:53:13 +00:00
import std.stdio;
import dyaml;
2011-08-16 12:53:13 +00:00
int main(string[] args)
2011-08-16 12:53:13 +00:00
{
string path = "input.yaml";
if (args.length > 1)
{
path = args[1];
}
try
{
auto resolver = new Resolver;
resolver.addImplicitResolver("!color", regex("[0-9a-fA-F]{6}"),
"0123456789abcdefABCDEF");
auto loader = Loader.fromFile("input.yaml");
loader.resolver = resolver;
auto root = loader.load();
if(root["scalar-red"].tag == "!color" &&
root["scalar-orange"].tag == "!color")
{
writeln("SUCCESS");
return 0;
}
}
catch(YAMLException e)
{
writeln(e.msg);
}
writeln("FAILURE");
return 1;
2011-08-16 12:53:13 +00:00
}