|
1 | 1 | Prism.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': /\-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|?\||[~^%?*\/]/, |
| 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 | 4 | 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i
|
5 | 5 | });
|
6 | 6 |
|
7 | 7 | Prism.languages.insertBefore('c', 'string', {
|
8 | 8 | 'macro': {
|
9 | 9 | // allow for multiline macro definitions
|
10 | 10 | // spaces after the # character compile fine with gcc
|
11 |
| - pattern: /(^\s*)#\s*[a-z]+([^\r\n\\]|\\.|\\(?:\r\n?|\n))*/im, |
| 11 | + pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im, |
12 | 12 | lookbehind: true,
|
13 | 13 | alias: 'property',
|
14 | 14 | inside: {
|
15 | 15 | // highlight the path of the include statement as a string
|
16 | 16 | 'string': {
|
17 |
| - pattern: /(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/, |
| 17 | + pattern: /(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/, |
18 | 18 | lookbehind: true
|
19 | 19 | },
|
20 | 20 | // highlight macro directives as keywords
|
21 | 21 | 'directive': {
|
22 |
| - pattern: /(#\s*)\b(define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/, |
| 22 | + pattern: /(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/, |
23 | 23 | lookbehind: true,
|
24 | 24 | alias: 'keyword'
|
25 | 25 | }
|
26 | 26 | }
|
27 | 27 | },
|
28 | 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/ |
| 29 | + 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/ |
30 | 30 | });
|
31 | 31 |
|
32 | 32 | delete Prism.languages.c['class-name'];
|
|
0 commit comments