Skip to content

[Bug]: Lexing indented annotation #7

@ShortDevelopment

Description

@ShortDevelopment

Issue

   @annotation

is parsed as Token.Text.Whitespace( ) + Token.Operator(@) + Token.Text(annotation)

Expected behavior

Token.Text.Whitespace( ) + Token.Name.Decorator(@annotation)

Potential solution

Remove the check for newline / whitespace (^[ \t]*)

(r"^[ \t]*#?pragma", token.Comment.Preproc, "pragma"),
(r"^[ \t]*@\w+(\.\w+)*", token.Name.Decorator, "annotation"),

Note: Lexing of indented pragmas works but includes the whitespace in the Token.Comment.Preproc token

Pros

  • Match official grammar
  • Don't include whitespace in parsed token

Cons

  • Annotations might be highlighted within a line (Breaking change)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions