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.
This commit is contained in:
parent
0f4a9fcaa7
commit
dbf2762982
@ -50,7 +50,7 @@ pub const Options = struct {
|
|||||||
// If an empty document is parsed, this defines what value type should be the
|
// 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
|
// resulting document root object. The default behavior is to emit an error if the
|
||||||
// document is empty.
|
// 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.
|
// Only used by the parseTo family of functions.
|
||||||
// If false, and a mapping contains additional keys that do not map to the fields of
|
// If false, and a mapping contains additional keys that do not map to the fields of
|
||||||
|
@ -59,7 +59,7 @@ pub const State = struct {
|
|||||||
|
|
||||||
switch (state.mode) {
|
switch (state.mode) {
|
||||||
.initial => switch (options.default_object) {
|
.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),
|
.list => state.document.root = Value.newList(arena_alloc),
|
||||||
.map => state.document.root = Value.newMap(arena_alloc),
|
.map => state.document.root = Value.newMap(arena_alloc),
|
||||||
.fail => {
|
.fail => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user