UNPKG

1.49 kBJavaScriptView Raw
1Prism.languages.c = Prism.languages.extend('clike', {
2 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,
3 'operator': /-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/]/,
4 'number': /(?:\b0x[\da-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i
5});
6
7Prism.languages.insertBefore('c', 'string', {
8 'macro': {
9 // allow for multiline macro definitions
10 // spaces after the # character compile fine with gcc
11 pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im,
12 lookbehind: true,
13 alias: 'property',
14 inside: {
15 // highlight the path of the include statement as a string
16 'string': {
17 pattern: /(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/,
18 lookbehind: true
19 },
20 // highlight macro directives as keywords
21 'directive': {
22 pattern: /(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,
23 lookbehind: true,
24 alias: 'keyword'
25 }
26 }
27 },
28 // highlight predefined macros as constants
29 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/
30});
31
32delete Prism.languages.c['class-name'];
33delete Prism.languages.c['boolean'];