1 | Prism.languages.c = Prism.languages.extend('clike', {
|
2 | 'comment': {
|
3 | pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
|
4 | greedy: true
|
5 | },
|
6 | 'class-name': {
|
7 | pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+/,
|
8 | lookbehind: true
|
9 | },
|
10 | 'keyword': /\b(?:__attribute__|_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/,
|
11 | 'function': /[a-z_]\w*(?=\s*\()/i,
|
12 | 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/,
|
13 | 'number': /(?:\b0x(?:[\da-f]+\.?[\da-f]*|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i
|
14 | });
|
15 |
|
16 | Prism.languages.insertBefore('c', 'string', {
|
17 | 'macro': {
|
18 |
|
19 |
|
20 | pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
|
21 | lookbehind: true,
|
22 | greedy: true,
|
23 | alias: 'property',
|
24 | inside: {
|
25 | 'string': [
|
26 | {
|
27 |
|
28 | pattern: /^(#\s*include\s*)<[^>]+>/,
|
29 | lookbehind: true
|
30 | },
|
31 | Prism.languages.c['string']
|
32 | ],
|
33 | 'comment': Prism.languages.c['comment'],
|
34 |
|
35 | 'directive': {
|
36 | pattern: /^(#\s*)[a-z]+/,
|
37 | lookbehind: true,
|
38 | alias: 'keyword'
|
39 | },
|
40 | 'directive-hash': /^#/,
|
41 | 'punctuation': /##|\\(?=[\r\n])/,
|
42 | 'expression': {
|
43 | pattern: /\S[\s\S]*/,
|
44 | inside: Prism.languages.c
|
45 | }
|
46 | }
|
47 | },
|
48 |
|
49 | 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/
|
50 | });
|
51 |
|
52 | delete Prism.languages.c['boolean'];
|