From 09b0279de05f3f2bae0c1639449c2a88f03be35d Mon Sep 17 00:00:00 2001 From: pwbh <127856937+pwbh@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:58:30 +0200 Subject: [PATCH] Ignore new document symbol --- (#21) --- resources/yaml-test-suite/98YD-mixed.yml | 3 ++- resources/yaml-test-suite/98YD.yml | 3 ++- resources/yaml-test-suite/CC74.yml | 1 + src/root.zig | 3 ++- src/tests.zig | 1 + 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/resources/yaml-test-suite/98YD-mixed.yml b/resources/yaml-test-suite/98YD-mixed.yml index 7986aa0..73cb287 100644 --- a/resources/yaml-test-suite/98YD-mixed.yml +++ b/resources/yaml-test-suite/98YD-mixed.yml @@ -1,3 +1,4 @@ +--- elemennts: - name: Spec Example 5.5. Comment Indicator from: http://www.yaml.org/spec/1.2/spec.html#id2773032 @@ -11,4 +12,4 @@ elemennts: dump: "" bool_val: true bool_val_b2: false - bool_val_with_spaces: true \ No newline at end of file + bool_val_with_spaces: true diff --git a/resources/yaml-test-suite/98YD.yml b/resources/yaml-test-suite/98YD.yml index 9d5fed6..e2ac213 100644 --- a/resources/yaml-test-suite/98YD.yml +++ b/resources/yaml-test-suite/98YD.yml @@ -1,3 +1,4 @@ +--- elemennts: - name: Spec Example 5.5. Comment Indicator from: http://www.yaml.org/spec/1.2/spec.html#id2773032 @@ -8,4 +9,4 @@ elemennts: +STR -STR json: "" - dump: "" \ No newline at end of file + dump: "" diff --git a/resources/yaml-test-suite/CC74.yml b/resources/yaml-test-suite/CC74.yml index 1211cb7..2411397 100644 --- a/resources/yaml-test-suite/CC74.yml +++ b/resources/yaml-test-suite/CC74.yml @@ -1,3 +1,4 @@ +--- elements: - name: Spec Example 6.20. Tag Handles from: http://www.yaml.org/spec/1.2/spec.html#id2783195 diff --git a/src/root.zig b/src/root.zig index 0fca944..5f9ba2a 100644 --- a/src/root.zig +++ b/src/root.zig @@ -294,7 +294,8 @@ pub fn Ymlz(comptime Destination: type) type { try self.allocations.append(line); // TODO: Need to fix this comments can start not only from index 0. - if (line.len == 0 or line[0] == '#') { + // TODO: What shoud really happen if a file has '---' which means a new document in the same file. + if (line.len == 0 or line[0] == '#' or std.mem.eql(u8, "---", line)) { // Skipping comments return self.readLine(); } diff --git a/src/tests.zig b/src/tests.zig index a62ecce..e56a77f 100644 --- a/src/tests.zig +++ b/src/tests.zig @@ -119,6 +119,7 @@ test "98YD" { } test "CC74" { + // test const Element = struct { name: []const u8, from: []const u8,