ikatyang / tree-sitter-yaml

YAML grammar for tree-sitter
https://ikatyang.github.io/tree-sitter-yaml/
MIT License
94 stars 38 forks source link

Faulty parsing of arrays that look like they might be strings #29

Open dimbleby opened 3 years ago

dimbleby commented 3 years ago

Sorry for the clumsy title!

foo: [
]

is successfully parsed by all the other parsers that I have found, as being equivalent to foo: []

But this parser says:

(ERROR
  (flow_node
    (plain_scalar
      (string_scalar))))
char0n commented 3 years ago

Interestingly following is parsed correctly:

foo: [
 ]

One empty space makes difference here. There is actually a test case in corpus that demonstrate this empty space significance: https://github.com/ikatyang/tree-sitter-yaml/blob/master/corpus/spec.txt#L6869

@ikatyang any idea on this one? Thanks!

rliebz commented 2 years ago

Worth noting that we see the same thing with objects defined with a curly brace.

This parses correctly:

foo: {
 }

But this does not:

foo: {
}