Skip to content

C23/C++14 digit separators break syntax highlighting #3905

@neobrain

Description

@neobrain

Digit separators are a C/C++ feature to visually group digits in large hex numbers more clearly (reducing the risk of slipping in typos):

uint32_t Test1 = 0xffff'ffff;
uint32_t Test2 = 0xffff'ffff;
Image

In micro, ' is detected as the start of a character literal, so this ends up with incorrect syntax highlighting all the way up to the next ' (or possibly the end of the file). In practice, this effectively disables syntax highlighting in large parts of the projects I work with.

Some observations about the C++ grammar that may help to fix this problem:

  • A digit-separating ' may not be preceded or followed by a space
  • A digit-separating ' is always preceded or followed by a (hex) digit (0-9, a-f, A-F)
  • A single integer literal may contain multiple digit separators
  • A character literal may not contain line breaks (assuming utf-8 file encoding)

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