package core.encoding.kdl
#allow_stale_code
+KDL_TAB_SIZE :: 4
+
use core {io}
write :: (d: &Document, w: &io.Writer) {
}
write_node :: (n: &Node, w: &io.Writer, indentation := 0) {
- for indentation * 4 do io.write(w, " ");
+ for indentation * KDL_TAB_SIZE do io.write(w, " ");
n.type_annotation->with([ta] {
io.write_format(w, "({}) ", ta);
write_node(it, w, indentation + 1);
}
- for indentation * 2 do io.write(w, " ");
+ for indentation * KDL_TAB_SIZE do io.write(w, " ");
io.write(w, "}");
}
case .Start_Children {
self.tokenizer->next_token();
+ self->skip_linespace();
+
while !self.tokenizer->peek_token().End_Children {
child := self->parse_node()?;
if child {
dependencies: Map(str, Dependency);
- _source_doc: kdl.Document;
+ _source_doc: ? kdl.Document;
}
Dependency :: struct {
doc := kdl.parse(contents).Ok?;
c: Config;
+ c._source_doc = doc;
c.dependency_source_path = "./lib";
c.dependency_binary_path = "./bin";
native_node.children << library_node;
build_node := doc->create_node("build");
- build_node->add_value(.{ String = config.native_library_build->unwrap() });
+ build_node->add_value(.{ String = config.native_library_build ?? "" });
native_node.children << build_node;
}
}
}
+ config._source_doc->with([source] {
+ for source->query_all("top() > []") {
+ if !array.contains(str.["package", "config", "native", "dependencies"], it.node) {
+ doc.nodes << it;
+ }
+ }
+ });
+
file := os.open(path, .Write)->or_return(false);
defer os.close(&file);