Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion runtime/syntax/arduino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,21 @@ rules:
- identifier: "\\b(setup|loop)\\b"

##
- statement: "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)"
- statement: "^[[:space:]]*#[[:space:]]*(define|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)"

## GCC builtins
- constant: "(__attribute__[[:space:]]*\\(\\([^)]*\\)\\)|__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__)"

# #include lines are a region so that the header name (e.g. <float.h>)
# is not matched by the type rules above
- statement:
start: "^[[:space:]]*#[[:space:]]*include(_next)?\\b"
end: "$"
rules:
- identifier: "\\b[A-Z_][0-9A-Z_]+\\b"
- constant.string: "<[^>]*>|\"[^\"]*\""
- comment: "//.*|/\\*.*?\\*/"

- constant.string:
start: "\""
end: "\""
Expand Down
12 changes: 11 additions & 1 deletion runtime/syntax/c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rules:
- statement: "\\b(for|if|while|do|else|case|default|switch|_Generic|_Static_assert|static_assert)\\b"
- statement: "\\b(goto|continue|break|return)\\b"
- statement: "\\b(asm|fortran)\\b"
- preproc: "^[[:space:]]*#[[:space:]]*(define|embed|pragma|include|(un|ifn?)def|endif|el(if|ifdef|ifndef|se)|if|line|warning|error|__has_include|__has_embed|__has_c_attribute)"
- preproc: "^[[:space:]]*#[[:space:]]*(define|embed|pragma|(un|ifn?)def|endif|el(if|ifdef|ifndef|se)|if|line|warning|error|__has_include|__has_embed|__has_c_attribute)"
- preproc: "^[[:space:]]*_Pragma\\b"
# GCC builtins
- statement: "__attribute__[[:space:]]*\\(\\([^)]*\\)\\)"
Expand All @@ -30,6 +30,16 @@ rules:
- constant.number: "(\\b0[Xx]([0-9A-Za-z]*[.][0-9A-Za-z]+|[0-9A-Za-z]+[.][0-9A-Za-z]*)[Pp][+-]?[0-9]+[FfLl]?\\b)"
- constant.bool: "(\\b(true|false|NULL|nullptr|TRUE|FALSE)\\b)"

# #include lines are a region so that the header name (e.g. <float.h>)
# is not matched by the type rules above
- preproc:
start: "^[[:space:]]*#[[:space:]]*include(_next)?\\b"
end: "$"
rules:
- identifier: "\\b[A-Z_][0-9A-Z_]+\\b"
- constant.string: "<[^>]*>|\"[^\"]*\""
- comment: "//.*|/\\*.*?\\*/"

- constant.string:
start: "\""
end: "\""
Expand Down
12 changes: 11 additions & 1 deletion runtime/syntax/cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rules:
- statement: "\\b(for|if|while|do|else|case|default|switch)\\b"
- statement: "\\b(try|throw|catch|operator|new|delete|static_assert)\\b"
- statement: "\\b(goto|continue|break|return)\\b"
- preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)|_Pragma"
- preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|(un|ifn?)def|endif|el(if|se)|if|warning|error)|_Pragma"

# Conditionally-supported/extension keywords
- statement: "\\b(asm|fortran)\\b"
Expand Down Expand Up @@ -61,6 +61,16 @@ rules:

- constant.bool: "(\\b(true|false|NULL|nullptr|TRUE|FALSE)\\b)"

# #include lines are a region so that the header name (e.g. <float.h>)
# is not matched by the type rules above
- preproc:
start: "^[[:space:]]*#[[:space:]]*include(_next)?\\b"
end: "$"
rules:
- identifier: "\\b[A-Z_][0-9A-Z_]*\\b"
- constant.string: "<[^>]*>|\"[^\"]*\""
- comment: "//.*|/\\*.*?\\*/"

- constant.string:
start: "\""
end: "\""
Expand Down
12 changes: 11 additions & 1 deletion runtime/syntax/cuda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rules:
- statement: "\\b(for|if|while|do|else|case|default|switch)\\b"
- statement: "\\b(try|throw|catch|operator|new|delete|static_assert)\\b"
- statement: "\\b(goto|continue|break|return)\\b"
- preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)|_Pragma"
- preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|(un|ifn?)def|endif|el(if|se)|if|warning|error)|_Pragma"

# Conditionally-supported/extension keywords
- statement: "\\b(asm|fortran)\\b"
Expand All @@ -39,6 +39,16 @@ rules:
- constant.number: "(\\b0[Xx]([0-9a-zA-Z']*[.][0-9a-zA-Z']+|[0-9a-zA-Z']+[.][0-9a-zA-Z']*)[Pp][+-]?[0-9']+[FfLl]?\\b)"
- constant.bool: "(\\b(true|false|NULL|nullptr)\\b)"

# #include lines are a region so that the header name (e.g. <float.h>)
# is not matched by the type rules above
- preproc:
start: "^[[:space:]]*#[[:space:]]*include(_next)?\\b"
end: "$"
rules:
- identifier: "\\b[A-Z_][0-9A-Z_]*\\b"
- constant.string: "<[^>]*>|\"[^\"]*\""
- comment: "//.*|/\\*.*?\\*/"

- constant.string:
start: "\""
end: "\""
Expand Down
12 changes: 11 additions & 1 deletion runtime/syntax/hc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rules:

- statement: "\\b(for|if|while|do|else|case|default|switch)\\b"
- statement: "\\b(try|catch|throw|goto|continue|break|return)\\b"
- preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|help_index|ifjit|ifaot|exe)"
- preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|(un|ifn?)def|endif|el(if|se)|if|help_index|ifjit|ifaot|exe)"

# Operator Color
- symbol.operator: "([.:;,+*|=!\\%]|<|>|/|-|&)"
Expand All @@ -24,6 +24,16 @@ rules:
- constant.number: "TRUE"
- constant.number: "FALSE"

# #include lines are a region so that the header name (e.g. <float.h>)
# is not matched by the type rules above
- preproc:
start: "^[[:space:]]*#[[:space:]]*include(_next)?\\b"
end: "$"
rules:
- identifier: "\\b[A-Z_][0-9A-Z_]+\\b"
- constant.string: "<[^>]*>|\"[^\"]*\""
- comment: "//.*|/\\*.*?\\*/"

- constant.string:
start: "\""
end: "\""
Expand Down
11 changes: 10 additions & 1 deletion runtime/syntax/objc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ rules:
- statement: "\\b(nonatomic|atomic|readonly|readwrite|strong|weak|assign)\\b"
- statement: "@(encode|end|interface|implementation|class|selector|protocol|synchronized|try|catch|finally|property|optional|required|import|autoreleasepool)"

- preproc: "^[[:space:]]*#[[:space:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma).*$"
- preproc: "^[[:space:]]*#[[:space:]]*(define|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma).*$"
- preproc: "__[A-Z0-9_]*__"

- special: "^[[:space:]]*[#|@][[:space:]]*(import|include)[[:space:]]*[\"|<].*\\/?[>|\"][[:space:]]*$"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You accidentally removed highlighting for @import here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored it verbatim in 555409f. @import Foundation; was never affected (the @(...) statement rule covers it), but @import <Foundation/Foundation.h> and @import "X.h" lost highlighting since the region only matches #. The region supersedes that rule for # lines, so it still does its job for @.

I also diffed every touched syntax file before/after over a corpus: the only lines that change now are #include/#import directives.

Expand All @@ -33,6 +33,15 @@ rules:
- constant: "\\bk[[:alnum]]*\\b"
- constant.string: "'.'"

# #include lines are a region so that the header name (e.g. <float.h>)
# is not matched by the type rules above
- special:
start: "^[[:space:]]*#[[:space:]]*(include(_next)?|import)\\b"
end: "$"
rules:
- constant.string: "<[^>]*>|\"[^\"]*\""
- comment: "//.*|/\\*.*?\\*/"
Comment on lines +36 to +43

@Neko-Box-Coder Neko-Box-Coder Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between this and line 25? Other than line 25 covering @Import .... Maybe we can merge/remove one?..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. With the region in place, line 25 no longer applies to any #import/#include line, since regions are matched before patterns. The only thing it still affects is @import followed by a header in angle brackets, like @import <Foundation/Foundation.h>, which isn't valid Objective-C: @import takes a module name (@import Foundation;, @import std.io;), and those are highlighted by the @(...) statement rule either way.

I diffed objc.yaml with and without line 25 over 22 valid and invalid lines. Only three change: @import <Foundation/Foundation.h>, @ import <UIKit/UIKit.h> and |import <x.h> (the [#|@] class also matches a literal |).

Merging it into the region would be worse: the region would then also take @import Foundation; and color the whole line as special.

So I think it can simply go. I restored it after the earlier review to keep the output identical for every input. @Andriamanitra, are you OK with removing it?


- constant.string:
start: "@\""
end: "\""
Expand Down
Loading