mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 08:48:24 +08:00
41 lines
3.8 KiB
JavaScript
41 lines
3.8 KiB
JavaScript
/*! `c` grammar compiled for Highlight.js 11.6.0 */
|
|
var hljsGrammar=(()=>{"use strict";return e=>{
|
|
const n=e.regex,t=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]
|
|
}),a="[a-zA-Z_]\\w*::",s="(decltype\\(auto\\)|"+n.optional(a)+"[a-zA-Z_]\\w*"+n.optional("<[^<>]+>")+")",r={
|
|
className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{
|
|
match:/\batomic_[a-z]{3,6}\b/}]},i={className:"string",variants:[{
|
|
begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{
|
|
begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",
|
|
end:"'",illegal:"."},e.END_SAME_AS_BEGIN({
|
|
begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},l={
|
|
className:"number",variants:[{begin:"\\b(0b[01']+)"},{
|
|
begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)"
|
|
},{
|
|
begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"
|
|
}],relevance:0},o={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{
|
|
keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"
|
|
},contains:[{begin:/\\\n/,relevance:0},e.inherit(i,{className:"string"}),{
|
|
className:"string",begin:/<.*?>/},t,e.C_BLOCK_COMMENT_MODE]},c={
|
|
className:"title",begin:n.optional(a)+e.IDENT_RE,relevance:0
|
|
},d=n.optional(a)+e.IDENT_RE+"\\s*\\(",u={
|
|
keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],
|
|
type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal128","const","static","complex","bool","imaginary"],
|
|
literal:"true false NULL",
|
|
built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"
|
|
},m=[o,r,t,e.C_BLOCK_COMMENT_MODE,l,i],g={variants:[{begin:/=/,end:/;/},{
|
|
begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],
|
|
keywords:u,contains:m.concat([{begin:/\(/,end:/\)/,keywords:u,
|
|
contains:m.concat(["self"]),relevance:0}]),relevance:0},p={
|
|
begin:"("+s+"[\\*&\\s]+)+"+d,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,
|
|
keywords:u,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:"decltype\\(auto\\)",
|
|
keywords:u,relevance:0},{begin:d,returnBegin:!0,contains:[e.inherit(c,{
|
|
className:"title.function"})],relevance:0},{relevance:0,match:/,/},{
|
|
className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0,
|
|
contains:[t,e.C_BLOCK_COMMENT_MODE,i,l,r,{begin:/\(/,end:/\)/,keywords:u,
|
|
relevance:0,contains:["self",t,e.C_BLOCK_COMMENT_MODE,i,l,r]}]
|
|
},r,t,e.C_BLOCK_COMMENT_MODE,o]};return{name:"C",aliases:["h"],keywords:u,
|
|
disableAutodetect:!0,illegal:"</",contains:[].concat(g,p,m,[o,{
|
|
begin:e.IDENT_RE+"::",keywords:u},{className:"class",
|
|
beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{
|
|
beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:o,
|
|
strings:i,keywords:u}}}})();export default hljsGrammar; |