Skip to content

[C/C++] Add attributes#4523

Merged
deathaxe merged 3 commits intosublimehq:masterfrom
12Thanjo:master
Apr 24, 2026
Merged

[C/C++] Add attributes#4523
deathaxe merged 3 commits intosublimehq:masterfrom
12Thanjo:master

Conversation

@12Thanjo
Copy link
Copy Markdown
Contributor

I added support for syntax highlighting of C/C++ attributes based on the cppreference documentation for C and C++.

In addition, this fixes a bug where the syntax highlighting breaks when an attribute is in the same line as a function (it no longer considered it to be a function).

@michaelblyons
Copy link
Copy Markdown
Collaborator

  • It looks like the .c and .c++ got mixed up in some of the test assertions.
  • Most syntax files avoid deeply nested push or set
  • If you're interested in the C/C++ family, perhaps consider taking [C Family] Full rewrite of C family syntaxes #4147 across the finish line! (No pressure. This is not a trivial quest.)

Comment thread C++/syntax_test_c.c
@12Thanjo
Copy link
Copy Markdown
Contributor Author

If you're interested in the C/C++ family, perhaps consider taking [C Family] Full rewrite of C family syntaxes #4147 across the finish line! (No pressure. This is not a trivial quest.)

I'll definitely consider it, but not soon. I don't understand how it all works well enough yet to do what I'd consider a good enough job yet. However, I am working on a programming language, so I'll have practice writing the syntax highlighting for that - it's (in part) designed to be much easier to parse than C++, so it should be easier to do and good practice before I try full production-grade C++ syntax.

In addition, I have never touched Objective-C or Objective-C++, so I wouldn't be able to complete those rewrites.

@michaelblyons
Copy link
Copy Markdown
Collaborator

michaelblyons commented Apr 16, 2026

However, I am working on a programming language, so I'll have practice writing the syntax highlighting for that

Cool! If you have questions, feel free to visit the ST forum or Discord.

Edit: I should also mention that if you're the one designing the language, and you're using formal syntax to do so, there are projects to convert them to Sublime Syntax: SBNF original in Rust, SBNF re-implementation in Python, and Langspec.

But if you're writing a syntax the by-hand way, people are happy to help. (Maybe help with the formal things, too, just not me.)

@rwols
Copy link
Copy Markdown
Contributor

rwols commented Apr 22, 2026

From what I understand, “Objective-X is a strict superset of X”, so all you have to do is understand the Objective syntax extensions to bolt it on top. (Contrast with the fact that C++ is not a strict superset of C)

@deathaxe deathaxe merged commit 15a3f85 into sublimehq:master Apr 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants