[d24f17c] | 1 | Prism.languages.vala = Prism.languages.extend('clike', {
|
---|
| 2 | // Classes copied from prism-csharp
|
---|
| 3 | 'class-name': [
|
---|
| 4 | {
|
---|
| 5 | // (Foo bar, Bar baz)
|
---|
| 6 | pattern: /\b[A-Z]\w*(?:\.\w+)*\b(?=(?:\?\s+|\*?\s+\*?)\w)/,
|
---|
| 7 | inside: {
|
---|
| 8 | punctuation: /\./
|
---|
| 9 | }
|
---|
| 10 | },
|
---|
| 11 | {
|
---|
| 12 | // [Foo]
|
---|
| 13 | pattern: /(\[)[A-Z]\w*(?:\.\w+)*\b/,
|
---|
| 14 | lookbehind: true,
|
---|
| 15 | inside: {
|
---|
| 16 | punctuation: /\./
|
---|
| 17 | }
|
---|
| 18 | },
|
---|
| 19 | {
|
---|
| 20 | // class Foo : Bar
|
---|
| 21 | pattern: /(\b(?:class|interface)\s+[A-Z]\w*(?:\.\w+)*\s*:\s*)[A-Z]\w*(?:\.\w+)*\b/,
|
---|
| 22 | lookbehind: true,
|
---|
| 23 | inside: {
|
---|
| 24 | punctuation: /\./
|
---|
| 25 | }
|
---|
| 26 | },
|
---|
| 27 | {
|
---|
| 28 | // class Foo
|
---|
| 29 | pattern: /((?:\b(?:class|enum|interface|new|struct)\s+)|(?:catch\s+\())[A-Z]\w*(?:\.\w+)*\b/,
|
---|
| 30 | lookbehind: true,
|
---|
| 31 | inside: {
|
---|
| 32 | punctuation: /\./
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
| 35 | ],
|
---|
| 36 | 'keyword': /\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,
|
---|
| 37 | 'function': /\b\w+(?=\s*\()/,
|
---|
| 38 | 'number': /(?:\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)(?:f|u?l?)?/i,
|
---|
| 39 | 'operator': /\+\+|--|&&|\|\||<<=?|>>=?|=>|->|~|[+\-*\/%&^|=!<>]=?|\?\??|\.\.\./,
|
---|
| 40 | 'punctuation': /[{}[\];(),.:]/,
|
---|
| 41 | 'constant': /\b[A-Z0-9_]+\b/
|
---|
| 42 | });
|
---|
| 43 |
|
---|
| 44 | Prism.languages.insertBefore('vala', 'string', {
|
---|
| 45 | 'raw-string': {
|
---|
| 46 | pattern: /"""[\s\S]*?"""/,
|
---|
| 47 | greedy: true,
|
---|
| 48 | alias: 'string'
|
---|
| 49 | },
|
---|
| 50 | 'template-string': {
|
---|
| 51 | pattern: /@"[\s\S]*?"/,
|
---|
| 52 | greedy: true,
|
---|
| 53 | inside: {
|
---|
| 54 | 'interpolation': {
|
---|
| 55 | pattern: /\$(?:\([^)]*\)|[a-zA-Z]\w*)/,
|
---|
| 56 | inside: {
|
---|
| 57 | 'delimiter': {
|
---|
| 58 | pattern: /^\$\(?|\)$/,
|
---|
| 59 | alias: 'punctuation'
|
---|
| 60 | },
|
---|
| 61 | rest: Prism.languages.vala
|
---|
| 62 | }
|
---|
| 63 | },
|
---|
| 64 | 'string': /[\s\S]+/
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 | });
|
---|
| 68 |
|
---|
| 69 | Prism.languages.insertBefore('vala', 'keyword', {
|
---|
| 70 | 'regex': {
|
---|
| 71 | pattern: /\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[imsx]{0,4}(?=\s*(?:$|[\r\n,.;})\]]))/,
|
---|
| 72 | greedy: true,
|
---|
| 73 | inside: {
|
---|
| 74 | 'regex-source': {
|
---|
| 75 | pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
---|
| 76 | lookbehind: true,
|
---|
| 77 | alias: 'language-regex',
|
---|
| 78 | inside: Prism.languages.regex
|
---|
| 79 | },
|
---|
| 80 | 'regex-delimiter': /^\//,
|
---|
| 81 | 'regex-flags': /^[a-z]+$/,
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
| 84 | });
|
---|