Skip to content

bug: Line continuations not parsing as expected #12

Open
@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

LuaCATS annotations support line continuations but the parser errors.

For examples, see https://luals.github.io/wiki/annotations/#param under "Custom Type Parameter" or "Literal Custom Type Parameter"

Steps To Reproduce/Bad Parse Tree

file.lua

@param mode string
|"'immediate'"  # comment 1
|"'async'" # comment 2

Run tree-sitter parse file.lua

(documentation [0, 0] - [3, 0]
  (param_annotation [0, 0] - [2, 22]
    (identifier [0, 7] - [0, 11])
    (union_type [0, 12] - [2, 10]
      (union_type [0, 12] - [1, 14]
        (builtin_type [0, 12] - [0, 18])
        (literal_type [1, 1] - [1, 14]))
      (ERROR [1, 14] - [1, 27]
        (comment [1, 14] - [1, 27]))
      (literal_type [2, 1] - [2, 10]))
    (comment [2, 10] - [2, 22])))

Also worth noting that wrapping with () also does not work. e.g.

@param mode (
|string
|"'immediate'"  # comment 1
|"'async'" # comment 2)?

also does not work

Expected Behavior/Parse Tree

(documentation
  (param_annotation
    (identifier)
    (builtin_type)
    (comment))

(or something similar)

Repro

tree-sitter parse 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