For Inside {}'s, or []'s only identifier like keys or values. There isn't a good way to handle unquoted values inside of these, because of examples like 'a: 1, b: 2'
For maps, we have to pick and choose between nesting and error handling.
Scan the line for ':' followed by a space or a newline.
Error out if line/word starts with YAML controls `@%!"'`
if the line ends in a :, and does not contain "'s or spaces, then it is a bare key, and the next line must be indented further in, and be the start of an indented list, or new indented map)
If the line has one ': ', then split it into key, value. Key must not have spaces.
If value starts with a {, [, ',", or -+0123456789, parse as normal
Or take entire line, trimming whitespace at end and front, as value
For indented lists we can do the same, handling a value in the same way as a map,
search for a {, [, ',", or -+0123456789 and parse as normal.
Or take entire line, trimming whitespace at end and front, as value
Note: Because of negative numbers, nesting lists complicate nesting
Unquoted handling:
For Inside
{}
's, or[]
's only identifier like keys or values. There isn't a good way to handle unquoted values inside of these, because of examples like 'a: 1, b: 2'For maps, we have to pick and choose between nesting and error handling.
Scan the line for ':' followed by a space or a newline.
Error out if line/word starts with YAML controls
`@
%!"'`if the line ends in a
:
, and does not contain"'
s or spaces, then it is a bare key, and the next line must be indented further in, and be the start of an indented list, or new indented map)If the line has one ': ', then split it into key, value. Key must not have spaces.
If value starts with a
{
,[
,'
,"
, or-+0123456789
, parse as normalOr take entire line, trimming whitespace at end and front, as value
For indented lists we can do the same, handling a value in the same way as a map,
{
,[
,'
,"
, or-+0123456789
and parse as normal.Note: Because of negative numbers, nesting lists complicate nesting
However, a
- name: foo
can work.