tree-sitter / tree-sitter-css

CSS grammar for Tree-sitter
MIT License
85 stars 34 forks source link

Non space separated attributes generates a huge parser error #40

Closed Andyson007 closed 9 months ago

Andyson007 commented 11 months ago
div {
  all:unset;
  display: flex;
  justify-content: center;
}

generates

rule_set [0, 0] - [4, 1]
  selectors [0, 0] - [0, 3]
    tag_name [0, 0] - [0, 3]
  block [0, 4] - [4, 1]
    ERROR [1, 2] - [3, 26]
      descendant_selector [1, 2] - [3, 25]
        descendant_selector [1, 2] - [3, 17]
          descendant_selector [1, 2] - [2, 15]
            descendant_selector [1, 2] - [2, 9]
              pseudo_class_selector [1, 2] - [1, 11]
                tag_name [1, 2] - [1, 5]
                class_name [1, 6] - [1, 11]
              ERROR [1, 11] - [1, 12]
              tag_name [2, 2] - [2, 9]
            ERROR [2, 9] - [2, 10]
            tag_name [2, 11] - [2, 15]
          ERROR [2, 15] - [2, 16]
          tag_name [3, 2] - [3, 17]
        ERROR [3, 17] - [3, 18]
        tag_name [3, 19] - [3, 25]

As oppesed to the case where there is a space following the all::

div {
  all: unset;
  display: flex;
  justify-content: center;
}
rule_set [0, 0] - [4, 1]
  selectors [0, 0] - [0, 3]
    tag_name [0, 0] - [0, 3]
  block [0, 4] - [4, 1]
    declaration [1, 2] - [1, 13]
      property_name [1, 2] - [1, 5]
      plain_value [1, 7] - [1, 12]
    declaration [2, 2] - [2, 16]
      property_name [2, 2] - [2, 9]
      plain_value [2, 11] - [2, 15]
    declaration [3, 2] - [3, 26]
      property_name [3, 2] - [3, 17]
      plain_value [3, 19] - [3, 25]
amaanq commented 9 months ago

fixed on master, and I created a release (0.20.0)