main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
2.1 KB
|
Line | |
---|
1 | 'use strict'
|
---|
2 |
|
---|
3 | module.exports = nim
|
---|
4 | nim.displayName = 'nim'
|
---|
5 | nim.aliases = []
|
---|
6 | function nim(Prism) {
|
---|
7 | Prism.languages.nim = {
|
---|
8 | comment: {
|
---|
9 | pattern: /#.*/,
|
---|
10 | greedy: true
|
---|
11 | },
|
---|
12 | string: {
|
---|
13 | // Double-quoted strings can be prefixed by an identifier (Generalized raw string literals)
|
---|
14 | pattern:
|
---|
15 | /(?:\b(?!\d)(?:\w|\\x[89a-fA-F][0-9a-fA-F])+)?(?:"""[\s\S]*?"""(?!")|"(?:\\[\s\S]|""|[^"\\])*")/,
|
---|
16 | greedy: true
|
---|
17 | },
|
---|
18 | char: {
|
---|
19 | // Character literals are handled specifically to prevent issues with numeric type suffixes
|
---|
20 | pattern: /'(?:\\(?:\d+|x[\da-fA-F]{0,2}|.)|[^'])'/,
|
---|
21 | greedy: true
|
---|
22 | },
|
---|
23 | function: {
|
---|
24 | pattern:
|
---|
25 | /(?:(?!\d)(?:\w|\\x[89a-fA-F][0-9a-fA-F])+|`[^`\r\n]+`)\*?(?:\[[^\]]+\])?(?=\s*\()/,
|
---|
26 | greedy: true,
|
---|
27 | inside: {
|
---|
28 | operator: /\*$/
|
---|
29 | }
|
---|
30 | },
|
---|
31 | // We don't want to highlight operators (and anything really) inside backticks
|
---|
32 | identifier: {
|
---|
33 | pattern: /`[^`\r\n]+`/,
|
---|
34 | greedy: true,
|
---|
35 | inside: {
|
---|
36 | punctuation: /`/
|
---|
37 | }
|
---|
38 | },
|
---|
39 | // The negative look ahead prevents wrong highlighting of the .. operator
|
---|
40 | number:
|
---|
41 | /\b(?:0[xXoObB][\da-fA-F_]+|\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:[eE][+-]?\d[\d_]*)?)(?:'?[iuf]\d*)?/,
|
---|
42 | keyword:
|
---|
43 | /\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/,
|
---|
44 | operator: {
|
---|
45 | // Look behind and look ahead prevent wrong highlighting of punctuations [. .] {. .} (. .)
|
---|
46 | // but allow the slice operator .. to take precedence over them
|
---|
47 | // One can define his own operators in Nim so all combination of operators might be an operator.
|
---|
48 | pattern:
|
---|
49 | /(^|[({\[](?=\.\.)|(?![({\[]\.).)(?:(?:[=+\-*\/<>@$~&%|!?^:\\]|\.\.|\.(?![)}\]]))+|\b(?:and|div|in|is|isnot|mod|not|notin|of|or|shl|shr|xor)\b)/m,
|
---|
50 | lookbehind: true
|
---|
51 | },
|
---|
52 | punctuation: /[({\[]\.|\.[)}\]]|[`(){}\[\],:]/
|
---|
53 | }
|
---|
54 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.