Skip to content

Commit

Permalink
Update cpp grammar to handle macros (#80974)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexr00 committed Sep 16, 2019
1 parent 1c01ce8 commit 8601a47
Show file tree
Hide file tree
Showing 9 changed files with 17,620 additions and 160 deletions.
1 change: 1 addition & 0 deletions extensions/cpp/build/update-grammars.js
Expand Up @@ -8,6 +8,7 @@ var updateGrammar = require('../../../build/npm/update-grammar');

updateGrammar.update('jeff-hykin/cpp-textmate-grammar', '/syntaxes/c.tmLanguage.json', './syntaxes/c.tmLanguage.json', undefined, 'master', 'source/languages/cpp/');
updateGrammar.update('jeff-hykin/cpp-textmate-grammar', '/syntaxes/cpp.tmLanguage.json', './syntaxes/cpp.tmLanguage.json', undefined, 'master', 'source/languages/cpp/');
updateGrammar.update('jeff-hykin/cpp-textmate-grammar', '/syntaxes/cpp.embedded.macro.tmLanguage.json', './syntaxes/cpp.embedded.macro.tmLanguage.json', undefined, 'master', 'source/languages/cpp/');

// `source.c.platform` which is still included by other grammars
updateGrammar.update('textmate/c.tmbundle', 'Syntaxes/Platform.tmLanguage', './syntaxes/platform.tmLanguage.json');
Expand Down
4 changes: 2 additions & 2 deletions extensions/cpp/cgmanifest.json
Expand Up @@ -6,11 +6,11 @@
"git": {
"name": "jeff-hykin/cpp-textmate-grammar",
"repositoryUrl": "https://github.com/jeff-hykin/cpp-textmate-grammar",
"commitHash": "7e5b098736796056fa99d1ef50e1b95b6131d16c"
"commitHash": "dd94b6a93799f2bce7e29b2515d96553e34574b0"
}
},
"license": "MIT",
"version": "1.14.3",
"version": "1.14.5",
"description": "The files syntaxes/c.json and syntaxes/c++.json were derived from https://github.com/atom/language-c which was originally converted from the C TextMate bundle https://github.com/textmate/c.tmbundle."
},
{
Expand Down
108 changes: 73 additions & 35 deletions extensions/cpp/package.json
Expand Up @@ -5,44 +5,82 @@
"version": "1.0.0",
"publisher": "vscode",
"license": "MIT",
"engines": { "vscode": "*" },
"engines": {
"vscode": "*"
},
"scripts": {
"update-grammar": "node ./build/update-grammars.js"
},
"contributes": {
"languages": [{
"id": "c",
"extensions": [ ".c", ".i"],
"aliases": [ "C", "c" ],
"configuration": "./language-configuration.json"
},
{
"id": "cpp",
"extensions": [ ".cpp", ".cc", ".cxx", ".c++", ".hpp", ".hh", ".hxx", ".h", ".ii", ".ino", ".inl", ".ipp", ".hpp.in", ".h.in" ],
"aliases": [ "C++", "Cpp", "cpp"],
"configuration": "./language-configuration.json"
}],
"grammars": [{
"language": "c",
"scopeName": "source.c",
"path": "./syntaxes/c.tmLanguage.json"
},
{
"language": "cpp",
"scopeName": "source.cpp",
"path": "./syntaxes/cpp.tmLanguage.json"
},
{
"scopeName": "source.c.platform",
"path": "./syntaxes/platform.tmLanguage.json"
}],
"snippets": [{
"language": "c",
"path": "./snippets/c.json"
},
{
"language": "cpp",
"path": "./snippets/cpp.json"
}]
"languages": [
{
"id": "c",
"extensions": [
".c",
".i"
],
"aliases": [
"C",
"c"
],
"configuration": "./language-configuration.json"
},
{
"id": "cpp",
"extensions": [
".cpp",
".cc",
".cxx",
".c++",
".hpp",
".hh",
".hxx",
".h",
".ii",
".ino",
".inl",
".ipp",
".hpp.in",
".h.in"
],
"aliases": [
"C++",
"Cpp",
"cpp"
],
"configuration": "./language-configuration.json"
}
],
"grammars": [
{
"language": "c",
"scopeName": "source.c",
"path": "./syntaxes/c.tmLanguage.json"
},
{
"language": "cpp",
"scopeName": "source.cpp.embedded.macro",
"path": "./syntaxes/cpp.embedded.macro.tmLanguage.json"
},
{
"language": "cpp",
"scopeName": "source.cpp",
"path": "./syntaxes/cpp.tmLanguage.json"
},
{
"scopeName": "source.c.platform",
"path": "./syntaxes/platform.tmLanguage.json"
}
],
"snippets": [
{
"language": "c",
"path": "./snippets/c.json"
},
{
"language": "cpp",
"path": "./snippets/cpp.json"
}
]
}
}
145 changes: 29 additions & 116 deletions extensions/cpp/syntaxes/c.tmLanguage.json
Expand Up @@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/jeff-hykin/cpp-textmate-grammar/commit/7e5b098736796056fa99d1ef50e1b95b6131d16c",
"version": "https://github.com/jeff-hykin/cpp-textmate-grammar/commit/dd94b6a93799f2bce7e29b2515d96553e34574b0",
"name": "C",
"scopeName": "source.c",
"patterns": [
Expand Down Expand Up @@ -1150,99 +1150,10 @@
"comments": {
"patterns": [
{
"name": "comment.line.documentation.c",
"while": "(?-mix:(?:^)(?>\\s*)(\\/\\/[!\\/]+))",
"whileCaptures": {
"1": {
"name": "punctuation.definition.comment.continuation.documentation.c"
}
},
"begin": "(\\/\\/[!\\/]+)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.comment.documentation.c"
}
},
"patterns": [
{
"match": "(?<=[\\s*!\\/])[\\\\@](?:callergraph|callgraph|else|endif|f\\$|f\\[|f\\]|hidecallergraph|hidecallgraph|hiderefby|hiderefs|hideinitializer|htmlinclude|n|nosubgrouping|private|privatesection|protected|protectedsection|public|publicsection|pure|showinitializer|showrefby|showrefs|tableofcontents|\\$|\\#|<|>|%|\"|\\.|=|::|\\||\\-\\-|\\-\\-\\-)\\b(?:\\{[^}]*\\})?",
"name": "storage.type.class.doxygen.c"
},
{
"match": "((?<=[\\s*!\\/])[\\\\@](?:a|em|e))\\s+(\\S+)",
"captures": {
"1": {
"name": "storage.type.class.doxygen.c"
},
"2": {
"name": "markup.italic.doxygen.c"
}
}
},
{
"match": "((?<=[\\s*!\\/])[\\\\@]b)\\s+(\\S+)",
"captures": {
"1": {
"name": "storage.type.class.doxygen.c"
},
"2": {
"name": "markup.bold.doxygen.c"
}
}
},
{
"match": "((?<=[\\s*!\\/])[\\\\@](?:c|p))\\s+(\\S+)",
"captures": {
"1": {
"name": "storage.type.class.doxygen.c"
},
"2": {
"name": "markup.inline.raw.string.c"
}
}
},
{
"match": "(?<=[\\s*!\\/])[\\\\@](?:a|anchor|b|c|cite|copybrief|copydetail|copydoc|def|dir|dontinclude|e|em|emoji|enum|example|extends|file|idlexcept|implements|include|includedoc|includelineno|latexinclude|link|memberof|namespace|p|package|ref|refitem|related|relates|relatedalso|relatesalso|verbinclude)\\b(?:\\{[^}]*\\})?",
"name": "storage.type.class.doxygen.c"
},
{
"match": "(?<=[\\s*!\\/])[\\\\@](?:addindex|addtogroup|category|class|defgroup|diafile|dotfile|elseif|fn|headerfile|if|ifnot|image|ingroup|interface|line|mainpage|mscfile|name|overload|page|property|protocol|section|skip|skipline|snippet|snippetdoc|snippetlineno|struct|subpage|subsection|subsubsection|typedef|union|until|vhdlflow|weakgroup)\\b(?:\\{[^}]*\\})?",
"name": "storage.type.class.doxygen.c"
},
{
"match": "((?<=[\\s*!\\/])[\\\\@]param)\\s+(\\b\\w+\\b)",
"captures": {
"1": {
"name": "storage.type.class.doxygen.c"
},
"2": {
"name": "variable.parameter.c"
}
}
},
{
"match": "(?<=[\\s*!\\/])[\\\\@](?:arg|attention|author|authors|brief|bug|copyright|date|deprecated|details|exception|invariant|li|note|par|paragraph|param|post|pre|remark|remarks|result|return|returns|retval|sa|see|short|since|test|throw|todo|tparam|version|warning|xrefitem)\\b(?:\\{[^}]*\\})?",
"name": "storage.type.class.doxygen.c"
},
{
"match": "(?<=[\\s*!\\/])[\\\\@](?:code|cond|docbookonly|dot|htmlonly|internal|latexonly|link|manonly|msc|parblock|rtfonly|secreflist|uml|verbatim|xmlonly|endcode|endcond|enddocbookonly|enddot|endhtmlonly|endinternal|endlatexonly|endlink|endmanonly|endmsc|endparblock|endrtfonly|endsecreflist|enduml|endverbatim|endxmlonly)\\b(?:\\{[^}]*\\})?",
"name": "storage.type.class.doxygen.c"
},
{
"match": "(?:\\b[A-Z]+:|@[a-z_]+:)",
"name": "storage.type.class.gtkdoc"
},
{
"match": "[\\\\@]\\S++(?!(?:\\n|$))",
"name": "invalid.unknown.documentation.command.c"
}
]
},
{
"match": "(\\/\\*[!*]+(?=\\s))(.+)([!*]*\\*\\/)",
"match": "(?:^)(?>\\s*)(\\/\\/[!\\/]+)(.*)",
"captures": {
"1": {
"name": "punctuation.definition.comment.begin.documentation.c"
"name": "punctuation.definition.comment.documentation.c"
},
"2": {
"patterns": [
Expand Down Expand Up @@ -1319,36 +1230,17 @@
"name": "invalid.unknown.documentation.command.c"
}
]
},
"3": {
"name": "punctuation.definition.comment.end.documentation.c"
}
},
"name": "comment.block.documentation.c"
"name": "comment.line.double-slash.documentation.c"
},
{
"name": "comment.block.documentation.c",
"begin": "(\\/\\*[!*]+(?:(?:\\n|$)|(?=\\s)))",
"beginCaptures": {
"match": "(\\/\\*[!*]+(?=\\s))(.+)([!*]*\\*\\/)",
"captures": {
"1": {
"name": "punctuation.definition.comment.begin.documentation.c"
}
},
"end": "([!*]*\\*\\/)",
"endCaptures": {
"1": {
"name": "punctuation.definition.comment.end.documentation.c"
}
},
"patterns": [
{
"while": "(?-mix:(?:^)(?>\\s*)(?![!*]*\\*\\/)((?>\\**)))",
"whileCaptures": {
"1": {
"name": "punctuation.definition.comment.continuation.documentation.c"
}
},
"begin": "\\G",
},
"2": {
"patterns": [
{
"match": "(?<=[\\s*!\\/])[\\\\@](?:callergraph|callgraph|else|endif|f\\$|f\\[|f\\]|hidecallergraph|hidecallgraph|hiderefby|hiderefs|hideinitializer|htmlinclude|n|nosubgrouping|private|privatesection|protected|protectedsection|public|publicsection|pure|showinitializer|showrefby|showrefs|tableofcontents|\\$|\\#|<|>|%|\"|\\.|=|::|\\||\\-\\-|\\-\\-\\-)\\b(?:\\{[^}]*\\})?",
Expand Down Expand Up @@ -1424,6 +1316,27 @@
}
]
},
"3": {
"name": "punctuation.definition.comment.end.documentation.c"
}
},
"name": "comment.block.documentation.c"
},
{
"name": "comment.block.documentation.c",
"begin": "((?>\\s*)\\/\\*[!*]+(?:(?:\\n|$)|(?=\\s)))",
"beginCaptures": {
"1": {
"name": "punctuation.definition.comment.begin.documentation.c"
}
},
"end": "([!*]*\\*\\/)",
"endCaptures": {
"1": {
"name": "punctuation.definition.comment.end.documentation.c"
}
},
"patterns": [
{
"match": "(?<=[\\s*!\\/])[\\\\@](?:callergraph|callgraph|else|endif|f\\$|f\\[|f\\]|hidecallergraph|hidecallgraph|hiderefby|hiderefs|hideinitializer|htmlinclude|n|nosubgrouping|private|privatesection|protected|protectedsection|public|publicsection|pure|showinitializer|showrefby|showrefs|tableofcontents|\\$|\\#|<|>|%|\"|\\.|=|::|\\||\\-\\-|\\-\\-\\-)\\b(?:\\{[^}]*\\})?",
"name": "storage.type.class.doxygen.c"
Expand Down

0 comments on commit 8601a47

Please sign in to comment.