Skip to content

Commit

Permalink
Merge branch 'master' into Fix/vs-cpp-3703
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-hykin committed May 30, 2019
2 parents 715bf22 + 1c41cf4 commit 348c28b
Show file tree
Hide file tree
Showing 10 changed files with 1,161 additions and 109 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Better Syntax",
"description": "The bleeding edge of C-like syntaxes",
"icon": "icon.png",
"version": "1.11.0",
"version": "1.11.2",
"scripts": {
"build": "ruby scripts/generate.rb",
"prelint": "npm run build",
Expand Down
43 changes: 36 additions & 7 deletions source/languages/cpp/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3341,16 +3341,45 @@ def generateBlockFinder( name:"", tag_as:"", start_pattern:nil, needs_semicolon:
:preprocessor_rule_define_line_context
]
cpp_grammar[:function_call_context] = [
:attributes_context,
:struct_declare,
:string_context,
:functional_specifiers_pre_parameters,
:qualifiers_and_specifiers_post_parameters,
:storage_specifiers,
:access_control_keywords,
:exception_keywords,
:static_assert,
:other_keywords,
:memory_operators,
:the_this_keyword,
:language_constants,
:misc_storage_modifiers_1,
:lambdas,
:preprocessor_context,
:comments_context,
:misc_storage_modifiers_2,
:number_literal,
:string_context_c,
:meta_preprocessor_macro,
:meta_preprocessor_diagnostic,
:meta_preprocessor_include,
:pragma_mark,
:meta_preprocessor_line,
:meta_preprocessor_undef,
:meta_preprocessor_pragma,
:predefined_macros,
:operators,
:string_context,
:storage_types,
:method_access,
:member_access,
legacy_memory_new_call,
:attributes_context, # this is here because it needs to be lower than :operators. TODO: once all the contexts are cleaned up, this should be put in a better spot
:parentheses,
:type_casting_operators,
:function_call,
:block_context
:scope_resolution_inner_generated,
:storage_types,
:line_continuation_character,
:square_brackets,
:empty_square_brackets,
:semicolon,
:comma,
]

# Save
Expand Down
127 changes: 94 additions & 33 deletions syntaxes/cpp.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -6882,60 +6882,121 @@
"function_call_context": {
"patterns": [
{
"include": "#attributes_context"
"include": "#struct_declare"
},
{
"include": "#string_context"
},
{
"include": "#functional_specifiers_pre_parameters"
},
{
"include": "#qualifiers_and_specifiers_post_parameters"
},
{
"include": "#storage_specifiers"
},
{
"include": "#access_control_keywords"
},
{
"include": "#exception_keywords"
},
{
"include": "#static_assert"
},
{
"include": "#other_keywords"
},
{
"include": "#memory_operators"
},
{
"include": "#the_this_keyword"
},
{
"include": "#language_constants"
},
{
"include": "#misc_storage_modifiers_1"
},
{
"include": "#lambdas"
},
{
"include": "#preprocessor_context"
},
{
"include": "#comments_context"
},
{
"include": "#misc_storage_modifiers_2"
},
{
"include": "#number_literal"
},
{
"include": "#string_context_c"
},
{
"include": "#meta_preprocessor_macro"
},
{
"include": "#meta_preprocessor_diagnostic"
},
{
"include": "#meta_preprocessor_include"
},
{
"include": "#pragma_mark"
},
{
"include": "#meta_preprocessor_line"
},
{
"include": "#meta_preprocessor_undef"
},
{
"include": "#meta_preprocessor_pragma"
},
{
"include": "#predefined_macros"
},
{
"include": "#operators"
},
{
"include": "#string_context"
"include": "#attributes_context"
},
{
"include": "#parentheses"
},
{
"include": "#type_casting_operators"
},
{
"include": "#function_call"
},
{
"include": "#scope_resolution_inner_generated"
},
{
"include": "#storage_types"
},
{
"include": "#method_access"
"include": "#line_continuation_character"
},
{
"include": "#member_access"
"include": "#square_brackets"
},
{
"begin": "(?x)\n(?!(?:while|for|do|if|else|switch|catch|return|typeid|alignof|alignas|sizeof|and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq|alignof|alignas)\\s*\\()\n(\n(?:new)\\s*((?-mix:(?:(?-mix:(?:(?<!<)<(?!<)(?:[^<>]*|[^>]*+<[^>]*+>)++>\\s*)))?)) # actual name\n|\n(?:(?<=operator)(?:[-*&<>=+!]+|\\(\\)|\\[\\]))\n)\n\\s*(\\()",
"beginCaptures": {
"1": {
"name": "keyword.operator.wordlike.cpp memory.cpp keyword.operator.new.cpp"
},
"2": {
"patterns": [
{
"include": "#template_call_innards"
}
]
},
"3": {
"name": "punctuation.section.arguments.begin.bracket.round.cpp"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.section.arguments.end.bracket.round.cpp"
}
},
"patterns": [
{
"include": "#function_call_context"
}
]
"include": "#empty_square_brackets"
},
{
"include": "#function_call"
"include": "#semicolon"
},
{
"include": "#block_context"
"include": "#comma"
}
]
}
Expand Down
65 changes: 36 additions & 29 deletions syntaxes/cpp.tmLanguage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3647,35 +3647,42 @@
- include: "#preprocessor_rule_define_line_context"
function_call_context:
patterns:
- include: "#attributes_context"
- include: "#struct_declare"
- include: "#string_context"
- include: "#functional_specifiers_pre_parameters"
- include: "#qualifiers_and_specifiers_post_parameters"
- include: "#storage_specifiers"
- include: "#access_control_keywords"
- include: "#exception_keywords"
- include: "#static_assert"
- include: "#other_keywords"
- include: "#memory_operators"
- include: "#the_this_keyword"
- include: "#language_constants"
- include: "#misc_storage_modifiers_1"
- include: "#lambdas"
- include: "#preprocessor_context"
- include: "#comments_context"
- include: "#misc_storage_modifiers_2"
- include: "#number_literal"
- include: "#string_context_c"
- include: "#meta_preprocessor_macro"
- include: "#meta_preprocessor_diagnostic"
- include: "#meta_preprocessor_include"
- include: "#pragma_mark"
- include: "#meta_preprocessor_line"
- include: "#meta_preprocessor_undef"
- include: "#meta_preprocessor_pragma"
- include: "#predefined_macros"
- include: "#operators"
- include: "#string_context"
- include: "#storage_types"
- include: "#method_access"
- include: "#member_access"
- begin: |-
(?x)
(?!(?:while|for|do|if|else|switch|catch|return|typeid|alignof|alignas|sizeof|and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq|alignof|alignas)\s*\()
(
(?:new)\s*((?-mix:(?:(?-mix:(?:(?<!<)<(?!<)(?:[^<>]*|[^>]*+<[^>]*+>)++>\s*)))?)) # actual name
|
(?:(?<=operator)(?:[-*&<>=+!]+|\(\)|\[\]))
)
\s*(\()
beginCaptures:
'1':
name: keyword.operator.wordlike.cpp memory.cpp keyword.operator.new.cpp
'2':
patterns:
- include: "#template_call_innards"
'3':
name: punctuation.section.arguments.begin.bracket.round.cpp
end: "\\)"
endCaptures:
'0':
name: punctuation.section.arguments.end.bracket.round.cpp
patterns:
- include: "#function_call_context"
- include: "#attributes_context"
- include: "#parentheses"
- include: "#type_casting_operators"
- include: "#function_call"
- include: "#block_context"
- include: "#scope_resolution_inner_generated"
- include: "#storage_types"
- include: "#line_continuation_character"
- include: "#square_brackets"
- include: "#empty_square_brackets"
- include: "#semicolon"
- include: "#comma"
78 changes: 78 additions & 0 deletions test/fixtures/issues/218.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
static void a(
a a,
a a,
a a,
a a,
a a,
bool a,
bool a,
bool a,
bool a)

{
a a;


a(a, a,
a,
a,
a,
a,
a,
a,
a);
a->a(&a);
for (auto a : a) {
auto &a = a.a;
auto a = a.a;

if (a && a) {
switch (a) {
case a:
a->a(a->a());
break;
case a:
a->a(a->a());
break;
case a:
a->a(a->a());
break;
case a:
a->a(a->a());
break;
}
}
a(a, a,
a,
a,
a,
a,
a,
a,
a);
}
}

static void a(
a a,
a a,
a a,
a a)

{
a a;
a a =0;
a->a()->a();

a(a->a());
a->a(a);
a->a(a);
a(a, a, a,
a,
a);
a->a(&a);
for (auto a: a) {
a(a->a(), a, a,
a);
}
}
Loading

0 comments on commit 348c28b

Please sign in to comment.