Closed hvr closed 6 years ago
looking at that, it seems you're right. thanks for listing the productions. see also the related #29 @ingydotnet @flyx makes sense? should we mark the test as an error?
Btw, what's valid however is something like
--- &foo !!seq
- x
- y
or also
--- &foo
a: b
but iirc we got tests for that...
I think I overlooked this detail until now. It's a pretty nasty gotcha that something named s-l-comments
can force a newline ;).
The test input is indeed illegal according to the productions and should be an error.
@flyx cool. I'll modify the test to be an error.
thanks @hvr!
test-case CXX2 considers
a valid yaml-stream; but in fact, the grammar doesn't allow for block collection nodes to appear on the
---
lineThis also excludes the simpler
or also sequences such as
The reason becomes obvious when we follow/trace the productions:
so the problem is that in order to match
s-l+block-collection(n,c)
(rule 200), we must matchs-l-comments
, but since we are not on column 1 (because we're 3 characters into the line due to---
), we must instead matchs-b-comment
; and that demands to match a line-break viab-break
(or an EOF).Hence, we cannot match a
s-l+block-collection
on the same line right after the directives-end marker---
.QED :-)
PS: One obvious workaround would be to make matching
s-l-comments
optional; but that would make other currently disallowed cases such as(for which iirc there's at least one tests which tests that YAML parser refuse it as a a parsing error). I don't know if there's an easy fix to make the grammar accept CXX2 without at the same being too liberal and allowing other syntax that isn't intended to be valid.