Skip to content

Commit

Permalink
fix #646
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-hykin committed Jul 5, 2024
1 parent 422729a commit 683e822
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 68 deletions.
2 changes: 1 addition & 1 deletion autogenerated/cpp.embedded.macro.tmLanguage.json

Large diffs are not rendered by default.

46 changes: 0 additions & 46 deletions autogenerated/cpp.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -3576,9 +3576,6 @@
{
"include": "#preprocessor_conditional_range"
},
{
"include": "#single_line_macro"
},
{
"include": "#macro"
},
Expand Down Expand Up @@ -11165,9 +11162,6 @@
{
"include": "#preprocessor_conditional_range"
},
{
"include": "#single_line_macro"
},
{
"include": "#macro"
},
Expand Down Expand Up @@ -13190,46 +13184,6 @@
}
}
},
"single_line_macro": {
"match": "^((?:((?:\\s*+\\/\\*(?:[^\\*]++|\\*+(?!\\/))*+\\*\\/\\s*+)+)|(?:\\s++)|(?<=\\W)|(?=\\W)|^|(?:\\n?$)|\\A|\\Z))#define.*(?<![\\\\])(?:\\n|$)",
"captures": {
"0": {
"patterns": [
{
"include": "#macro"
},
{
"include": "#comments"
}
]
},
"1": {
"patterns": [
{
"include": "#inline_comment"
}
]
},
"2": {
"patterns": [
{
"match": "\\s*+(\\/\\*)((?:[^\\*]++|\\*+(?!\\/))*+(\\*\\/))\\s*+",
"captures": {
"1": {
"name": "comment.block.cpp punctuation.definition.comment.begin.cpp"
},
"2": {
"name": "comment.block.cpp"
},
"3": {
"name": "comment.block.cpp punctuation.definition.comment.end.cpp"
}
}
}
]
}
}
},
"sizeof_operator": {
"begin": "((?<!\\w)sizeof(?!\\w))((?:(?:(?:\\s*+(\\/\\*)((?:[^\\*]++|\\*+(?!\\/))*+(\\*\\/))\\s*+)+)|(?:\\s++)|(?<=\\W)|(?=\\W)|^|(?:\\n?$)|\\A|\\Z))(\\()",
"end": "\\)",
Expand Down
11 changes: 10 additions & 1 deletion language_examples/feature_preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,13 @@ int other;

#if thing /*
this should be a comment
*/
*/

#define test test2 /* line 1
The timeout is set to 5x to ensure we don't timeout too early. */

/* test comment */
typedef enum{
A= 0,
B= 1
} BB;
22 changes: 12 additions & 10 deletions language_examples/feature_preprocessor.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,10 @@
- source: Stuff
scopes:
- entity.name.type.struct
scopesEnd:
- meta.block.struct
- source: '#'
scopesBegin:
- meta.head.struct
- meta.preprocessor.macro
- keyword.control.directive.define
scopes:
- punctuation.definition.directive
Expand Down Expand Up @@ -429,6 +429,9 @@
scopesEnd:
- meta.block.struct
- meta.head.struct
- meta.preprocessor.macro
- meta.block.struct
- meta.head.struct
- source: '#'
scopesBegin:
- keyword.control.directive.define
Expand Down Expand Up @@ -787,18 +790,17 @@
scopes:
- entity.name.function.preprocessor
- source: /*
scopes:
scopesBegin:
- comment.block
- punctuation.definition.comment.begin
scopesEnd:
- meta.preprocessor.macro
- source: this
scopes:
- variable.language.this
- source: ' should be a comment'
- punctuation.definition.comment.begin
- source: ' this should be a comment'
- source: '*/'
scopes:
- invalid.illegal.unexpected.punctuation.definition.comment.end
- punctuation.definition.comment.end
scopesEnd:
- meta.preprocessor.macro
- comment.block
- source: '#'
scopesBegin:
- keyword.control.directive.conditional.if
Expand Down
20 changes: 10 additions & 10 deletions main/patterns/preprocessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def wordBounds(regex_pattern)
:line,
:diagnostic,
:undef,
:single_line_macro,
# :single_line_macro,
:macro,
:macro_argument,
:preprocessor_conditional_range,
Expand Down Expand Up @@ -268,14 +268,14 @@ def wordBounds(regex_pattern)
#
# #define
#
grammar[:single_line_macro] = Pattern.new(
should_fully_match: ['#define EXTERN_C extern "C"'],
match: Pattern.new(/^/).then(std_space).then(/#define/).then(/.*/).lookBehindToAvoid(/[\\]/).then(@end_of_line),
includes: [
:macro,
:comments,
]
)
# grammar[:single_line_macro] = Pattern.new(
# should_fully_match: ['#define EXTERN_C extern "C"'],
# match: Pattern.new(/^/).then(std_space).then(/#define/).then(/.*/).lookBehindToAvoid(/[\\]/).then(@end_of_line),
# includes: [
# :macro,
# :comments,
# ]
# )
grammar[:macro] = PatternRange.new(
tag_as: "meta.preprocessor.macro",
start_pattern: Pattern.new(
Expand Down Expand Up @@ -425,7 +425,7 @@ def wordBounds(regex_pattern)
:diagnostic,
:undef,
:preprocessor_conditional_range,
:single_line_macro,
# :single_line_macro,
:macro,
:preprocessor_conditional_standalone,
:macro_argument,
Expand Down

0 comments on commit 683e822

Please sign in to comment.