Skip to content

Commit

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

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion autogenerated/cpp.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,13 @@
"name": "punctuation.definition.comment.end.cpp"
}
},
"name": "comment.block.cpp"
"name": "comment.block.cpp",
"patterns": [
{
"match": "[^\\*]*\\n"
}
],
"applyEndPatternLast": 1
},
"builtin_storage_type_initilizer": {
"begin": "\\s*+(?<!\\w)(?:(?:(?:((?:(?:unsigned)|(?:wchar_t)|(?:double)|(?:signed)|(?:short)|(?:float)|(?:auto)|(?:void)|(?:long)|(?:char)|(?:bool)|(?:int)))|((?:(?:uint_least32_t)|(?:uint_least64_t)|(?:uint_least16_t)|(?:uint_fast64_t)|(?:uint_least8_t)|(?:int_least64_t)|(?:int_least32_t)|(?:int_least16_t)|(?:uint_fast16_t)|(?:uint_fast32_t)|(?:int_least8_t)|(?:int_fast16_t)|(?:int_fast32_t)|(?:int_fast64_t)|(?:uint_fast8_t)|(?:int_fast8_t)|(?:suseconds_t)|(?:useconds_t)|(?:uintmax_t)|(?:uintmax_t)|(?:in_port_t)|(?:uintmax_t)|(?:in_addr_t)|(?:blksize_t)|(?:uintptr_t)|(?:intmax_t)|(?:intptr_t)|(?:blkcnt_t)|(?:intmax_t)|(?:u_quad_t)|(?:uint16_t)|(?:uint32_t)|(?:uint64_t)|(?:ssize_t)|(?:fixpt_t)|(?:qaddr_t)|(?:u_short)|(?:int16_t)|(?:int32_t)|(?:int64_t)|(?:uint8_t)|(?:daddr_t)|(?:caddr_t)|(?:swblk_t)|(?:clock_t)|(?:segsz_t)|(?:nlink_t)|(?:time_t)|(?:u_long)|(?:ushort)|(?:quad_t)|(?:mode_t)|(?:size_t)|(?:u_char)|(?:int8_t)|(?:u_int)|(?:uid_t)|(?:off_t)|(?:pid_t)|(?:gid_t)|(?:dev_t)|(?:div_t)|(?:key_t)|(?:ino_t)|(?:id_t)|(?:id_t)|(?:uint))))|((?:(?:pthread_rwlockattr_t)|(?:pthread_mutexattr_t)|(?:pthread_condattr_t)|(?:pthread_rwlock_t)|(?:pthread_mutex_t)|(?:pthread_cond_t)|(?:pthread_attr_t)|(?:pthread_once_t)|(?:pthread_key_t)|(?:pthread_t))))|([a-zA-Z_]\\w*_t))(?!\\w)\\s*+(?<!\\w)(\\()",
Expand Down
7 changes: 7 additions & 0 deletions language_examples/feature_preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,10 @@ int other;
{


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

#if thing /*
this should be a comment
*/
49 changes: 49 additions & 0 deletions language_examples/feature_preprocessor.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -772,3 +772,52 @@
- source: '{'
scopes:
- punctuation.section.block.begin.bracket.curly.struct
scopesEnd:
- meta.block.struct
- meta.head.struct
- source: '#'
scopesBegin:
- keyword.control.directive.define
scopes:
- punctuation.definition.directive
- source: define
scopesEnd:
- keyword.control.directive.define
- source: thing
scopes:
- entity.name.function.preprocessor
- source: /*
scopes:
- comment.block
- punctuation.definition.comment.begin
scopesEnd:
- meta.preprocessor.macro
- source: this
scopes:
- variable.language.this
- source: ' should be a comment'
- source: '*/'
scopes:
- invalid.illegal.unexpected.punctuation.definition.comment.end
- source: '#'
scopesBegin:
- keyword.control.directive.conditional.if
scopes:
- punctuation.definition.directive
- source: if
scopesEnd:
- keyword.control.directive.conditional.if
- source: thing
scopesBegin:
- meta.preprocessor.conditional
scopes:
- entity.name.function.preprocessor
- source: /*
scopesBegin:
- comment.block
scopes:
- punctuation.definition.comment.begin
- source: ' this should be a comment'
- source: '*/'
scopes:
- punctuation.definition.comment.end
6 changes: 4 additions & 2 deletions language_examples/ranged_for.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25824,7 +25824,8 @@
- source: ' We don’t check the path right now, because we don’t want to'
- source: ' throw if the path isn’t allowed, but just return false (and we'
- source: ' can’t just catch the exception here because we still want to'
- source: ' throw if something in the evaluation of `*args[0]` tries to'
- source: ' throw if something in the evaluation of `*'
- source: 'args[0]` tries to'
- source: ' access an unauthorized path). '
- source: '*/'
scopes:
Expand Down Expand Up @@ -59193,7 +59194,8 @@
- comment.block
scopes:
- punctuation.definition.comment.begin
- source: ' Convert the argument to a string. Paths are *not* copied to the'
- source: ' Convert the argument to a string. Paths are *not*'
- source: ' copied to the'
- source: ' store, so `toString /foo/bar'' yields `"/foo/bar"'', not'
- source: ' `"/nix/store/whatever..."''. '
- source: '*/'
Expand Down
10 changes: 9 additions & 1 deletion main/patterns/comments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,15 @@
end_pattern: Pattern.new(
match: /\*\//,
tag_as: "punctuation.definition.comment.end"
)
),
apply_end_pattern_last: true,
includes: [
# seems useless, but prevents issues like https://github.com/jeff-hykin/better-cpp-syntax/issues/527
# note: this is more of a way to turn off the bailout for just this pattern when the macro_bailout is generated
# it should be the only pattern that needs this because its the only thing that is run in phase1 of the
# preprocessor (e.g. before macros are handled)
Pattern.new(/[^\*]*\n/),
],
)

# this is kind of a grandfathered-in pattern
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.

0 comments on commit 407d6fd

Please sign in to comment.