nushell / tree-sitter-nu

A tree-sitter grammar for nu-lang, the language of nushell
MIT License
122 stars 27 forks source link

reduce interpolated string nodes #30

Closed 1Kinoti closed 1 year ago

1Kinoti commented 1 year ago

a fix for #29

fdncred commented 1 year ago

Thanks @1Kinoti! I'm wondering if there is a way to test for this?

1Kinoti commented 1 year ago

before this change,

this

$"my shell is ($shell)"

produces this tree

(nu_script [0, 0] - [1, 0]
  (pipeline [0, 0] - [1, 0]
    (pipe_element [0, 0] - [0, 23]
      (val_interpolated [0, 0] - [0, 23]
        (escaped_interpolated_content [0, 2] - [0, 3])
        (escaped_interpolated_content [0, 3] - [0, 4])
        (escaped_interpolated_content [0, 4] - [0, 5])
        (escaped_interpolated_content [0, 5] - [0, 6])
        (escaped_interpolated_content [0, 6] - [0, 7])
        (escaped_interpolated_content [0, 7] - [0, 8])
        (escaped_interpolated_content [0, 8] - [0, 9])
        (escaped_interpolated_content [0, 9] - [0, 10])
        (escaped_interpolated_content [0, 10] - [0, 11])
        (escaped_interpolated_content [0, 11] - [0, 12])
        (escaped_interpolated_content [0, 12] - [0, 13])
        (escaped_interpolated_content [0, 13] - [0, 14])
        expr: (expr_interpolated [0, 14] - [0, 22]
          (pipeline [0, 15] - [0, 21]
            (pipe_element [0, 15] - [0, 21]
              (val_variable [0, 15] - [0, 21]
                name: (identifier [0, 16] - [0, 21])))))))))

but after, this is the tree

(nu_script [0, 0] - [1, 0]
  (pipeline [0, 0] - [1, 0]
    (pipe_element [0, 0] - [0, 23]
      (val_interpolated [0, 0] - [0, 23]
        (escaped_interpolated_content [0, 2] - [0, 14])
        expr: (expr_interpolated [0, 14] - [0, 22]
          (pipeline [0, 15] - [0, 21]
            (pipe_element [0, 15] - [0, 21]
              (val_variable [0, 15] - [0, 21]
                name: (identifier [0, 16] - [0, 21])))))))))

i don't really have a way to test for this

fdncred commented 1 year ago

ok, thanks for the before and after, that's always a good thing to put in a PR. let's move forward with this.

1Kinoti commented 1 year ago

you should also probably close #29