1 | 'use strict'
|
---|
2 |
|
---|
3 | module.exports = vala
|
---|
4 | vala.displayName = 'vala'
|
---|
5 | vala.aliases = []
|
---|
6 | function vala(Prism) {
|
---|
7 | Prism.languages.vala = Prism.languages.extend('clike', {
|
---|
8 | // Classes copied from prism-csharp
|
---|
9 | 'class-name': [
|
---|
10 | {
|
---|
11 | // (Foo bar, Bar baz)
|
---|
12 | pattern: /\b[A-Z]\w*(?:\.\w+)*\b(?=(?:\?\s+|\*?\s+\*?)\w)/,
|
---|
13 | inside: {
|
---|
14 | punctuation: /\./
|
---|
15 | }
|
---|
16 | },
|
---|
17 | {
|
---|
18 | // [Foo]
|
---|
19 | pattern: /(\[)[A-Z]\w*(?:\.\w+)*\b/,
|
---|
20 | lookbehind: true,
|
---|
21 | inside: {
|
---|
22 | punctuation: /\./
|
---|
23 | }
|
---|
24 | },
|
---|
25 | {
|
---|
26 | // class Foo : Bar
|
---|
27 | pattern:
|
---|
28 | /(\b(?:class|interface)\s+[A-Z]\w*(?:\.\w+)*\s*:\s*)[A-Z]\w*(?:\.\w+)*\b/,
|
---|
29 | lookbehind: true,
|
---|
30 | inside: {
|
---|
31 | punctuation: /\./
|
---|
32 | }
|
---|
33 | },
|
---|
34 | {
|
---|
35 | // class Foo
|
---|
36 | pattern:
|
---|
37 | /((?:\b(?:class|enum|interface|new|struct)\s+)|(?:catch\s+\())[A-Z]\w*(?:\.\w+)*\b/,
|
---|
38 | lookbehind: true,
|
---|
39 | inside: {
|
---|
40 | punctuation: /\./
|
---|
41 | }
|
---|
42 | }
|
---|
43 | ],
|
---|
44 | keyword:
|
---|
45 | /\b(?:abstract|as|assert|async|base|bool|break|case|catch|char|class|const|construct|continue|default|delegate|delete|do|double|dynamic|else|ensures|enum|errordomain|extern|finally|float|for|foreach|get|if|in|inline|int|int16|int32|int64|int8|interface|internal|is|lock|long|namespace|new|null|out|override|owned|params|private|protected|public|ref|requires|return|set|short|signal|sizeof|size_t|ssize_t|static|string|struct|switch|this|throw|throws|try|typeof|uchar|uint|uint16|uint32|uint64|uint8|ulong|unichar|unowned|ushort|using|value|var|virtual|void|volatile|weak|while|yield)\b/i,
|
---|
46 | function: /\b\w+(?=\s*\()/,
|
---|
47 | number:
|
---|
48 | /(?:\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)(?:f|u?l?)?/i,
|
---|
49 | operator:
|
---|
50 | /\+\+|--|&&|\|\||<<=?|>>=?|=>|->|~|[+\-*\/%&^|=!<>]=?|\?\??|\.\.\./,
|
---|
51 | punctuation: /[{}[\];(),.:]/,
|
---|
52 | constant: /\b[A-Z0-9_]+\b/
|
---|
53 | })
|
---|
54 | Prism.languages.insertBefore('vala', 'string', {
|
---|
55 | 'raw-string': {
|
---|
56 | pattern: /"""[\s\S]*?"""/,
|
---|
57 | greedy: true,
|
---|
58 | alias: 'string'
|
---|
59 | },
|
---|
60 | 'template-string': {
|
---|
61 | pattern: /@"[\s\S]*?"/,
|
---|
62 | greedy: true,
|
---|
63 | inside: {
|
---|
64 | interpolation: {
|
---|
65 | pattern: /\$(?:\([^)]*\)|[a-zA-Z]\w*)/,
|
---|
66 | inside: {
|
---|
67 | delimiter: {
|
---|
68 | pattern: /^\$\(?|\)$/,
|
---|
69 | alias: 'punctuation'
|
---|
70 | },
|
---|
71 | rest: Prism.languages.vala
|
---|
72 | }
|
---|
73 | },
|
---|
74 | string: /[\s\S]+/
|
---|
75 | }
|
---|
76 | }
|
---|
77 | })
|
---|
78 | Prism.languages.insertBefore('vala', 'keyword', {
|
---|
79 | regex: {
|
---|
80 | pattern:
|
---|
81 | /\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[imsx]{0,4}(?=\s*(?:$|[\r\n,.;})\]]))/,
|
---|
82 | greedy: true,
|
---|
83 | inside: {
|
---|
84 | 'regex-source': {
|
---|
85 | pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
---|
86 | lookbehind: true,
|
---|
87 | alias: 'language-regex',
|
---|
88 | inside: Prism.languages.regex
|
---|
89 | },
|
---|
90 | 'regex-delimiter': /^\//,
|
---|
91 | 'regex-flags': /^[a-z]+$/
|
---|
92 | }
|
---|
93 | }
|
---|
94 | })
|
---|
95 | }
|
---|