Skip to content

bug: Line continuations for aliases from LuaCATS Annotations is not parsing #13

@ColinKennedy

Description

@ColinKennedy

Did you check existing issues?

  • I have read all the tree-sitter docs if it relates to using the parser
  • I have searched the existing issues

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

tree-sitter 0.22.5

Describe the bug

Possibly related to - #12

There's an example of line continuations in the LuaCATS Annotations page that this parser doesn't currently handle. It's under @alias's examples, here: https://luals.github.io/wiki/annotations/#alias

---@alias DeviceSide
---| '"left"' # The left side of the device
---| '"right"' # The right side of the device
---| '"top"' # The top side of the device
---| '"bottom"' # The bottom side of the device
---| '"front"' # The front side of the device
---| '"back"' # The back side of the device

This same tree parses as expected with llscheck, which further leads me to believe it's a bug.

Steps To Reproduce/Bad Parse Tree

Make a file with

@alias DeviceSide
| '"left"' # The left side of the device
| '"right"' # The right side of the device
| '"top"' # The top side of the device
| '"bottom"' # The bottom side of the device
| '"front"' # The front side of the device
| '"back"' # The back side of the device

Then run tree-sitter parse that_file.lua

Errors with

(documentation [0, 0] - [8, 0]
  (alias_annotation [0, 0] - [6, 40]
    (identifier [0, 7] - [0, 17])
    (ERROR [1, 0] - [6, 1]
      (literal_type [1, 2] - [1, 10])
      (comment [1, 10] - [1, 40])
      (literal_type [2, 2] - [2, 11])
      (comment [2, 11] - [2, 42])
      (literal_type [3, 2] - [3, 9])
      (comment [3, 9] - [3, 38])
      (literal_type [4, 2] - [4, 12])
      (comment [4, 12] - [4, 44])
      (literal_type [5, 2] - [5, 11])
      (comment [5, 11] - [5, 42]))
    (literal_type [6, 2] - [6, 10])
    (comment [6, 10] - [6, 40])))

Expected Behavior/Parse Tree

(documentation [0, 0] - [2, 0]
  (alias_annotation [0, 0] - [0, 84]
    (identifier [0, 7] - [0, 17])
    (union_type [0, 18] - [0, 84]
      (literal_type [0, 18] - [0, 26])
      (union_type [0, 29] - [0, 84]
        (literal_type [0, 29] - [0, 38])
        (union_type [0, 41] - [0, 84]
          (literal_type [0, 41] - [0, 48])
          (union_type [0, 51] - [0, 84]
            (literal_type [0, 51] - [0, 61])
            (union_type [0, 64] - [0, 84]
              (literal_type [0, 64] - [0, 73])
              (literal_type [0, 76] - [0, 84]))))))))

or something similar

Repro

tree-sitter parse that_file.lua

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions