Values can be lists. Today you parse an inline array, a comma-separated sequence in square brackets, by reusing the value parser recursively for each element.
Parse a bracketed, comma-separated array of values.
An array is an ordered list of values written in square brackets, comma
separated: [1, 2, 3]. This is the first compound value, and it is where the
recursive nature of the parser shows: each element is itself a value, so parsing an
array means calling the same parseValue you already have, once per element, and
collecting the results into a KindArray.
The loop is straightforward: after the [, read a value, then expect either a comma
(more elements follow) or the closing ] (the array ends). An empty array []
is valid and has no elements, so check for the closing bracket before trying to read
a value. The elements can be any value type - ["a", "b"] is an array of strings -
because parseValue handles all of them. Today keep the array on one line; the next
lesson relaxes that and pins the finer rules.
// parseValue: a leading '[' starts an array// loop: skip whitespace; if ']' then stop// parse one value (recurse into parseValue)// append it; expect ',' or ']'// build a KindArray value holding the element Values