diff options
Diffstat (limited to 'dlang/src/read/report_unknown.d')
| -rw-r--r-- | dlang/src/read/report_unknown.d | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/dlang/src/read/report_unknown.d b/dlang/src/read/report_unknown.d new file mode 100644 index 0000000..2f81702 --- /dev/null +++ b/dlang/src/read/report_unknown.d @@ -0,0 +1,41 @@ +module read.report_unknown; + +import std.algorithm : sort; +import std.array : array; +import std.stdio : writeln, writefln; +import ocda.model; + +/+ ↓ say what was read and not understood. + This is what makes the reader usable as a check on the format + specification: a reader that ignores what it does not know is + conforming, but one that cannot say what it ignored cannot tell you + whether the specification it was written from was complete. Silence + and understanding look the same from outside. ++/ +void reportUnknown(ref OcdaDocument doc) { + if (!doc.unknown.any) { + writeln("\nread and understood: every property, block and line was known"); + return; + } + writeln("\nread and NOT understood:"); + if (doc.unknown.property.length > 0) { + writeln(" properties ignored (", doc.unknown.property.length, " distinct):"); + foreach (name; doc.unknown.property.keys.sort) { + writefln(" .%-26s %8d", name, doc.unknown.property[name]); + } + } + if (doc.unknown.block.length > 0) { + writeln(" blocks ignored (", doc.unknown.block.length, " distinct):"); + foreach (name; doc.unknown.block.keys.sort) { + writefln(" @%-26s %8d", name, doc.unknown.block[name]); + } + } + if (doc.unknown.line.length > 0) { + writeln(" lines of no known shape, by first character:"); + foreach (c; doc.unknown.line.keys.sort) { + writefln(" %-27s %8d", "\"" ~ c ~ "\"", doc.unknown.line[c]); + } + } + writeln(" (ignoring these is conforming within a major version;", + " the count is so that it is not silent)"); +} |
