Skip to content

Commit

Permalink
fix #641
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-hykin committed Aug 9, 2023
1 parent affcf5a commit 401d7c2
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 5 deletions.
2 changes: 1 addition & 1 deletion autogenerated/cpp.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -11583,7 +11583,7 @@
]
},
"preprocessor_conditional_standalone": {
"match": "^((?:((?:\\s*+\\/\\*(?:[^\\*]++|\\*+(?!\\/))*+\\*\\/\\s*+)+)|(?:\\s++)|(?<=\\W)|(?=\\W)|^|(?:\\n?$)|\\A|\\Z))(#)(?:\\s+)?((?<!\\w)(?:endif|else|elif)(?!\\w))",
"match": "^((?:((?:\\s*+\\/\\*(?:[^\\*]++|\\*+(?!\\/))*+\\*\\/\\s*+)+)|(?:\\s++)|(?<=\\W)|(?=\\W)|^|(?:\\n?$)|\\A|\\Z))(#)(?:\\s+)?((?<!\\w)(?:endif|else|elif|elifdef|elifndef)(?!\\w))",
"captures": {
"1": {
"patterns": [
Expand Down
11 changes: 11 additions & 0 deletions language_examples/#641.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <iostream>

int main(int argc, const char ** argv)
{
#ifdef _WIN32
std::cout << "Hello World Windows" << std::endl;
#elifdef __linux__
std::cout << "Hello World Linux" << std::endl;
#endif
return 0;
}
190 changes: 190 additions & 0 deletions language_examples/#641.spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
- source: '#'
scopesBegin:
- meta.preprocessor.include
- keyword.control.directive.include
scopes:
- punctuation.definition.directive
- source: include
scopesEnd:
- keyword.control.directive.include
- source: <
scopesBegin:
- string.quoted.other.lt-gt.include
scopes:
- punctuation.definition.string.begin
- source: iostream
- source: '>'
scopes:
- punctuation.definition.string.end
scopesEnd:
- meta.preprocessor.include
- string.quoted.other.lt-gt.include
- source: int
scopesBegin:
- meta.function.definition
scopes:
- meta.qualified_type
- storage.type.primitive
- storage.type.built-in.primitive
- source: main
scopesBegin:
- meta.head.function.definition
scopes:
- entity.name.function.definition
- source: (
scopes:
- punctuation.section.parameters.begin.bracket.round
- source: int
scopesBegin:
- meta.function.definition.parameters
- meta.parameter
scopes:
- storage.type.primitive
- storage.type.built-in.primitive
- source: argc
scopes:
- variable.parameter
- source: ','
scopes:
- punctuation.separator.delimiter.comma
- source: const
scopes:
- storage.modifier.specifier.const
- source: char
scopes:
- storage.type.primitive
- storage.type.built-in.primitive
- source: '*'
scopesBegin:
- storage.modifier.pointer
- source: '*'
scopesEnd:
- storage.modifier.pointer
- source: argv
scopes:
- variable.parameter
scopesEnd:
- meta.function.definition.parameters
- meta.parameter
- source: )
scopes:
- punctuation.section.parameters.end.bracket.round
- source: '{'
scopes:
- punctuation.section.block.begin.bracket.curly.function.definition
scopesEnd:
- meta.head.function.definition
- source: '#'
scopesBegin:
- meta.body.function.definition
- keyword.control.directive.conditional.ifdef
scopes:
- punctuation.definition.directive
- source: ifdef
scopesEnd:
- keyword.control.directive.conditional.ifdef
- source: _WIN32
scopes:
- meta.preprocessor.conditional
- entity.name.other.preprocessor.macro.predefined._WIN32
- source: std
scopes:
- entity.name.scope-resolution
- source: '::'
scopes:
- punctuation.separator.namespace.access
- punctuation.separator.scope-resolution
- source: 'cout '
- source: '<<'
scopes:
- keyword.operator.bitwise.shift
- source: '"'
scopesBegin:
- string.quoted.double
scopes:
- punctuation.definition.string.begin
- source: Hello World Windows
- source: '"'
scopes:
- punctuation.definition.string.end
scopesEnd:
- string.quoted.double
- source: '<<'
scopes:
- keyword.operator.bitwise.shift
- source: std
scopes:
- entity.name.scope-resolution
- source: '::'
scopes:
- punctuation.separator.namespace.access
- punctuation.separator.scope-resolution
- source: endl
- source: ;
scopes:
- punctuation.terminator.statement
- source: '#'
scopesBegin:
- keyword.control.directive.elifdef
scopes:
- punctuation.definition.directive
- source: elifdef
scopesEnd:
- keyword.control.directive.elifdef
- source: ' __linux__'
- source: std
scopes:
- entity.name.scope-resolution
- source: '::'
scopes:
- punctuation.separator.namespace.access
- punctuation.separator.scope-resolution
- source: 'cout '
- source: '<<'
scopes:
- keyword.operator.bitwise.shift
- source: '"'
scopesBegin:
- string.quoted.double
scopes:
- punctuation.definition.string.begin
- source: Hello World Linux
- source: '"'
scopes:
- punctuation.definition.string.end
scopesEnd:
- string.quoted.double
- source: '<<'
scopes:
- keyword.operator.bitwise.shift
- source: std
scopes:
- entity.name.scope-resolution
- source: '::'
scopes:
- punctuation.separator.namespace.access
- punctuation.separator.scope-resolution
- source: endl
- source: ;
scopes:
- punctuation.terminator.statement
- source: '#'
scopesBegin:
- keyword.control.directive.endif
scopes:
- punctuation.definition.directive
- source: endif
scopesEnd:
- keyword.control.directive.endif
- source: return
scopes:
- keyword.control.return
- source: '0'
scopes:
- constant.numeric.decimal
- source: ;
scopes:
- punctuation.terminator.statement
- source: '}'
scopes:
- punctuation.section.block.end.bracket.curly.function.definition
2 changes: 1 addition & 1 deletion main/patterns/preprocessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def wordBounds(regex_pattern)
grammar[:preprocessor_conditional_standalone] = Pattern.new(
tag_as: "keyword.control.directive.$reference(conditional_name)",
match: directive_start.then(
match: wordBounds(/(?:endif|else|elif)/),
match: wordBounds(/(?:endif|else|elif|elifdef|elifndef)/),
reference: "conditional_name"
)
)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "better-cpp-syntax",
"displayName": "Better C++ Syntax",
"description": "The bleeding edge of the C++ syntax",
"version": "1.20.0",
"version": "1.20.1",
"icon": "icon.png",
"scripts": {},
"keywords": [
Expand Down

0 comments on commit 401d7c2

Please sign in to comment.