From dbf27629826fb0afd4aff6293732652856633c95 Mon Sep 17 00:00:00 2001 From: torque Date: Fri, 1 Dec 2023 22:31:30 -0800 Subject: [PATCH] parser: empty document should be scalar, not string I think I originally set this up before I had fully decided on the semantics of scalars vs strings. This option makes much more sense to me because it mirrors the empty value behavior map keys. Without an introducer sequence, it's can't be a string. --- src/parser.zig | 2 +- src/parser/state.zig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parser.zig b/src/parser.zig index 8a337f5..bbf0a62 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -50,7 +50,7 @@ pub const Options = struct { // If an empty document is parsed, this defines what value type should be the // resulting document root object. The default behavior is to emit an error if the // document is empty. - default_object: enum { string, list, map, fail } = .fail, + default_object: enum { scalar, list, map, fail } = .fail, // Only used by the parseTo family of functions. // If false, and a mapping contains additional keys that do not map to the fields of diff --git a/src/parser/state.zig b/src/parser/state.zig index 044d6e8..69cfd2f 100644 --- a/src/parser/state.zig +++ b/src/parser/state.zig @@ -59,7 +59,7 @@ pub const State = struct { switch (state.mode) { .initial => switch (options.default_object) { - .string => state.document.root = Value.emptyString(), + .scalar => state.document.root = Value.emptyScalar(), .list => state.document.root = Value.newList(arena_alloc), .map => state.document.root = Value.newMap(arena_alloc), .fail => {