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+|\b[a-z]\w*_t\b/,
|
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': /\b[a-z_]\w*(?=\s*\()/i,
|
12 | 'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
13 | 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
|
14 | });
|
15 |
|
16 | Prism.languages.insertBefore('c', 'string', {
|
17 | 'macro': {
|
18 |
|
19 |
|
20 | pattern: /(^[\t ]*)#\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 | 'macro-name': [
|
35 | {
|
36 | pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
|
37 | lookbehind: true
|
38 | },
|
39 | {
|
40 | pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
|
41 | lookbehind: true,
|
42 | alias: 'function'
|
43 | }
|
44 | ],
|
45 |
|
46 | 'directive': {
|
47 | pattern: /^(#\s*)[a-z]+/,
|
48 | lookbehind: true,
|
49 | alias: 'keyword'
|
50 | },
|
51 | 'directive-hash': /^#/,
|
52 | 'punctuation': /##|\\(?=[\r\n])/,
|
53 | 'expression': {
|
54 | pattern: /\S[\s\S]*/,
|
55 | inside: Prism.languages.c
|
56 | }
|
57 | }
|
58 | },
|
59 |
|
60 | 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/
|
61 | });
|
62 |
|
63 | delete Prism.languages.c['boolean'];
|