diff --git a/runtime/syntax/arduino.yaml b/runtime/syntax/arduino.yaml index 35a0480f5f..47c97efb16 100644 --- a/runtime/syntax/arduino.yaml +++ b/runtime/syntax/arduino.yaml @@ -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. ) + # 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: "\"" diff --git a/runtime/syntax/c.yaml b/runtime/syntax/c.yaml index c6a46741ea..b816eac8a7 100644 --- a/runtime/syntax/c.yaml +++ b/runtime/syntax/c.yaml @@ -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:]]*\\(\\([^)]*\\)\\)" @@ -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. ) + # 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: "\"" diff --git a/runtime/syntax/cpp.yaml b/runtime/syntax/cpp.yaml index edd09c6087..d11de21f05 100644 --- a/runtime/syntax/cpp.yaml +++ b/runtime/syntax/cpp.yaml @@ -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" @@ -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. ) + # 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: "\"" diff --git a/runtime/syntax/cuda.yaml b/runtime/syntax/cuda.yaml index 6875b1ef5a..b86e6e6de0 100644 --- a/runtime/syntax/cuda.yaml +++ b/runtime/syntax/cuda.yaml @@ -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" @@ -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. ) + # 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: "\"" diff --git a/runtime/syntax/hc.yaml b/runtime/syntax/hc.yaml index 9b94b0cd25..6a91b3b17c 100644 --- a/runtime/syntax/hc.yaml +++ b/runtime/syntax/hc.yaml @@ -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: "([.:;,+*|=!\\%]|<|>|/|-|&)" @@ -24,6 +24,16 @@ rules: - constant.number: "TRUE" - constant.number: "FALSE" + # #include lines are a region so that the header name (e.g. ) + # 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: "\"" diff --git a/runtime/syntax/objc.yaml b/runtime/syntax/objc.yaml index d4cccac317..111553595d 100644 --- a/runtime/syntax/objc.yaml +++ b/runtime/syntax/objc.yaml @@ -19,11 +19,9 @@ 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:]]*$" - - statement: "([.:;,+*|=!\\%\\[\\]]|<|>|/|-|&)" - constant.number: "(\\b(-?)?[0-9]+\\b|\\b\\[0-9]+\\.[0-9]+\\b|\\b0x[0-9a-fA-F]+\\b)" @@ -33,6 +31,15 @@ rules: - constant: "\\bk[[:alnum]]*\\b" - constant.string: "'.'" + # #include lines are a region so that the header name (e.g. ) + # is not matched by the type rules above + - special: + start: "^[[:space:]]*#[[:space:]]*(include(_next)?|import)\\b" + end: "$" + rules: + - constant.string: "<[^>]*>|\"[^\"]*\"" + - comment: "//.*|/\\*.*?\\*/" + - constant.string: start: "@\"" end: "\""