Skip to content

Annotation namespace is lexed as whitespace #11

@ShortDevelopment

Description

@ShortDevelopment

Thanks for the quick release!

Sadly I discovered one more bug with the annotation lexing 😅.
(Sry for all these weird ede-cases 🙈)

POC

Consider the following OpenQASM 3 snippet:

@annotation
@annotation value
@annotation.long.namespace
@annotation.long.namespace  value
 @annotation.long.namespace
 @annotation.long.namespace  value

Issue

Using the current regex, the last namespace segment get's captured in a separate capture-group that will currently be marked as whitespace instead of the actual whitespace (last capture-group) at the end.

r"^([ \t]*)(@\w+(\.\w+)*)([ \t]*)",
bygroups(token.Whitespace, token.Name.Decorator, token.Whitespace),

https://regex101.com/r/a6mCWI/1

Solution

Use a non-capturing group for the namespace part.

- r"^([ \t]*)(@\w+(\.\w+)*)([ \t]*)",
+ r"^([ \t]*)(@\w+(?:\.\w+)*)([ \t]*)",

https://regex101.com/r/DsSRKZ/1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions