main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.8 KB
|
Line | |
---|
1 | Prism.languages.nim = {
|
---|
2 | 'comment': {
|
---|
3 | pattern: /#.*/,
|
---|
4 | greedy: true
|
---|
5 | },
|
---|
6 | 'string': {
|
---|
7 | // Double-quoted strings can be prefixed by an identifier (Generalized raw string literals)
|
---|
8 | pattern: /(?:\b(?!\d)(?:\w|\\x[89a-fA-F][0-9a-fA-F])+)?(?:"""[\s\S]*?"""(?!")|"(?:\\[\s\S]|""|[^"\\])*")/,
|
---|
9 | greedy: true
|
---|
10 | },
|
---|
11 | 'char': {
|
---|
12 | // Character literals are handled specifically to prevent issues with numeric type suffixes
|
---|
13 | pattern: /'(?:\\(?:\d+|x[\da-fA-F]{0,2}|.)|[^'])'/,
|
---|
14 | greedy: true
|
---|
15 | },
|
---|
16 |
|
---|
17 | 'function': {
|
---|
18 | pattern: /(?:(?!\d)(?:\w|\\x[89a-fA-F][0-9a-fA-F])+|`[^`\r\n]+`)\*?(?:\[[^\]]+\])?(?=\s*\()/,
|
---|
19 | greedy: true,
|
---|
20 | inside: {
|
---|
21 | 'operator': /\*$/
|
---|
22 | }
|
---|
23 | },
|
---|
24 | // We don't want to highlight operators (and anything really) inside backticks
|
---|
25 | 'identifier': {
|
---|
26 | pattern: /`[^`\r\n]+`/,
|
---|
27 | greedy: true,
|
---|
28 | inside: {
|
---|
29 | 'punctuation': /`/
|
---|
30 | }
|
---|
31 | },
|
---|
32 |
|
---|
33 | // The negative look ahead prevents wrong highlighting of the .. operator
|
---|
34 | 'number': /\b(?:0[xXoObB][\da-fA-F_]+|\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:[eE][+-]?\d[\d_]*)?)(?:'?[iuf]\d*)?/,
|
---|
35 | 'keyword': /\b(?:addr|as|asm|atomic|bind|block|break|case|cast|concept|const|continue|converter|defer|discard|distinct|do|elif|else|end|enum|except|export|finally|for|from|func|generic|if|import|include|interface|iterator|let|macro|method|mixin|nil|object|out|proc|ptr|raise|ref|return|static|template|try|tuple|type|using|var|when|while|with|without|yield)\b/,
|
---|
36 | 'operator': {
|
---|
37 | // Look behind and look ahead prevent wrong highlighting of punctuations [. .] {. .} (. .)
|
---|
38 | // but allow the slice operator .. to take precedence over them
|
---|
39 | // One can define his own operators in Nim so all combination of operators might be an operator.
|
---|
40 | pattern: /(^|[({\[](?=\.\.)|(?![({\[]\.).)(?:(?:[=+\-*\/<>@$~&%|!?^:\\]|\.\.|\.(?![)}\]]))+|\b(?:and|div|in|is|isnot|mod|not|notin|of|or|shl|shr|xor)\b)/m,
|
---|
41 | lookbehind: true
|
---|
42 | },
|
---|
43 | 'punctuation': /[({\[]\.|\.[)}\]]|[`(){}\[\],:]/
|
---|
44 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.