Closed ColinH closed 6 years ago
Does this refer to the ABNF? According to the written spec, comments are allowed anywhere in arrays, which is indeed the logical thing. If the ABNF says otherwise that's certainly a mistake.
Yes, I used the ABNF since it is more precise. After converting it to PEGTL I tested with various inputs.
Hmm yes this should be allowed. A mistake in the ABNF or in the PEGTL conversion?
It's the ABNF, the rule for array-values only allows a single comment after a value (and its comma, if present). And no comments before the first value.
array = array-open array-values array-close
array-open = %x5B ws-newline ; [
array-close = ws-newline %x5D ; ]
array-values = [ ( val array-sep [ ( ws-newline comment ws-newlines) / ws-newlines ] array-values ) /
( val [ array-sep ] [ ( ws-newline comment ws-newlines ) ] ) ]
array-sep = ws %x2C ws ; , Comma
ws-newline = *( wschar / newline )
ws-newlines = newline *( wschar / newline )
Why are the rules for comments so inconsistent and complicated? For example take all the places where empty lines are allowed. In some cases there can be arbitrary many comment lines among the empty lines, in some cases only a single comment is allowed, and in others again there can be no comments.