OLD | NEW |
(Empty) | |
| 1 Prism.languages.nim = { |
| 2 'comment': /#.*/, |
| 3 // Double-quoted strings can be prefixed by an identifier (Generalized r
aw string literals) |
| 4 // Character literals are handled specifically to prevent issues with nu
meric type suffixes |
| 5 'string': /(?:(?:\b(?!\d)(?:\w|\\x[8-9a-fA-F][0-9a-fA-F])+)?(?:"""[\s\S]
*?"""(?!")|"(?:\\[\s\S]|""|[^"\\])*")|'(?:\\(?:\d+|x[\da-fA-F]{2}|.)|[^'])')/, |
| 6 // The negative look ahead prevents wrong highlighting of the .. operato
r |
| 7 'number': /\b(?:0[xXoObB][\da-fA-F_]+|\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:[e
E][+-]?\d[\d_]*)?)(?:'?[iuf]\d*)?/, |
| 8 'keyword': /\b(?:addr|as|asm|atomic|bind|block|break|case|cast|concept|c
onst|continue|converter|defer|discard|distinct|do|elif|else|end|enum|except|expo
rt|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/, |
| 9 'function': { |
| 10 pattern: /(?:(?!\d)(?:\w|\\x[8-9a-fA-F][0-9a-fA-F])+|`[^`\r\n]+`
)\*?(?:\[[^\]]+\])?(?=\s*\()/, |
| 11 inside: { |
| 12 'operator': /\*$/ |
| 13 } |
| 14 }, |
| 15 // We don't want to highlight operators inside backticks |
| 16 'ignore': { |
| 17 pattern: /`[^`\r\n]+`/, |
| 18 inside: { |
| 19 'punctuation': /`/ |
| 20 } |
| 21 }, |
| 22 'operator': { |
| 23 // Look behind and look ahead prevent wrong highlighting of punc
tuations [. .] {. .} (. .) |
| 24 // but allow the slice operator .. to take precedence over them |
| 25 // One can define his own operators in Nim so all combination of
operators might be an operator. |
| 26 pattern: /(^|[({\[](?=\.\.)|(?![({\[]\.).)(?:(?:[=+\-*\/<>@$~&%|
!?^:\\]|\.\.|\.(?![)}\]]))+|\b(?:and|div|of|or|in|is|isnot|mod|not|notin|shl|shr
|xor)\b)/m, |
| 27 lookbehind: true |
| 28 }, |
| 29 'punctuation': /[({\[]\.|\.[)}\]]|[`(){}\[\],:]/ |
| 30 }; |
OLD | NEW |