TravonteD / tree-sitter-fennel

Treesitter grammar for the Fennel programming language
MIT License
42 stars 9 forks source link

Make `>` and `<` valid function/symbol names #22

Closed datwaft closed 3 years ago

datwaft commented 3 years ago

I am using the latest Neovim nightly version.

Symbols using those characters look like this: image

Here is the code I used for this test:

(fn str->tbl [str]
  (icollect [chr (string.gmatch str ".")] chr))

(str->tbl "Hello") ; Returns ["H" "e" "l" "l" "o"]

(fn ->str [obj]
  (tostring obj))

(->str 1) ; Returns "1"
sogaiu commented 3 years ago

For reference, the following is output I get for the tree-sitter cli's parse subcommand using https://github.com/TravonteD/tree-sitter-fennel/commit/bc689e2ef264e2cba499cfdcd16194e8f5fe87d2:

(program [0, 0] - [9, 0]
  (function_definition [0, 0] - [1, 47]
    name: (identifier [0, 4] - [0, 8])
    (ERROR [0, 8] - [0, 12]
      (identifier [0, 9] - [0, 12]))
    (parameters [0, 13] - [0, 18]
      (identifier [0, 14] - [0, 17]))
    body: (function_call [1, 2] - [1, 46]
      name: (identifier [1, 3] - [1, 11])
      (sequential_table [1, 12] - [1, 41]
        (identifier [1, 13] - [1, 16])
        (function_call [1, 17] - [1, 40]
          name: (field_expression [1, 18] - [1, 31]
            (identifier [1, 18] - [1, 24])
            (identifier [1, 25] - [1, 31]))
          (identifier [1, 32] - [1, 35])
          (string [1, 36] - [1, 39])))
      (identifier [1, 42] - [1, 45])))
  (function_call [3, 0] - [3, 18]
    name: (identifier [3, 1] - [3, 5])
    (ERROR [3, 5] - [3, 6])
    (identifier [3, 6] - [3, 9])
    (string [3, 10] - [3, 17]))
  (comment [3, 19] - [3, 50])
  (function_call [5, 0] - [6, 17]
    (ERROR [5, 1] - [5, 3])
    name: (identifier [5, 4] - [5, 6])
    (identifier [5, 6] - [5, 9])
    (sequential_table [5, 10] - [5, 15]
      (identifier [5, 11] - [5, 14]))
    (function_call [6, 2] - [6, 16]
      name: (identifier [6, 3] - [6, 11])
      (identifier [6, 12] - [6, 15])))
  (function_call [8, 0] - [8, 9]
    name: (identifier [8, 1] - [8, 3])
    (identifier [8, 3] - [8, 6])
    (number [8, 7] - [8, 8]))
  (comment [8, 10] - [8, 23]))
TravonteD commented 3 years ago

Updated in the latest master :+1:

Edit: Thank you for you contributions :)