source: node_modules/refractor/lang/haxe.js

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.4 KB
Line 
1'use strict'
2
3module.exports = haxe
4haxe.displayName = 'haxe'
5haxe.aliases = []
6function haxe(Prism) {
7 Prism.languages.haxe = Prism.languages.extend('clike', {
8 string: {
9 // Strings can be multi-line
10 pattern: /"(?:[^"\\]|\\[\s\S])*"/,
11 greedy: true
12 },
13 'class-name': [
14 {
15 pattern:
16 /(\b(?:abstract|class|enum|extends|implements|interface|new|typedef)\s+)[A-Z_]\w*/,
17 lookbehind: true
18 }, // based on naming convention
19 /\b[A-Z]\w*/
20 ],
21 // The final look-ahead prevents highlighting of keywords if expressions such as "haxe.macro.Expr"
22 keyword:
23 /\bthis\b|\b(?:abstract|as|break|case|cast|catch|class|continue|default|do|dynamic|else|enum|extends|extern|final|for|from|function|if|implements|import|in|inline|interface|macro|new|null|operator|overload|override|package|private|public|return|static|super|switch|throw|to|try|typedef|untyped|using|var|while)(?!\.)\b/,
24 function: {
25 pattern: /\b[a-z_]\w*(?=\s*(?:<[^<>]*>\s*)?\()/i,
26 greedy: true
27 },
28 operator: /\.{3}|\+\+|--|&&|\|\||->|=>|(?:<<?|>{1,3}|[-+*/%!=&|^])=?|[?:~]/
29 })
30 Prism.languages.insertBefore('haxe', 'string', {
31 'string-interpolation': {
32 pattern: /'(?:[^'\\]|\\[\s\S])*'/,
33 greedy: true,
34 inside: {
35 interpolation: {
36 pattern: /(^|[^\\])\$(?:\w+|\{[^{}]+\})/,
37 lookbehind: true,
38 inside: {
39 'interpolation-punctuation': {
40 pattern: /^\$\{?|\}$/,
41 alias: 'punctuation'
42 },
43 expression: {
44 pattern: /[\s\S]+/,
45 inside: Prism.languages.haxe
46 }
47 }
48 },
49 string: /[\s\S]+/
50 }
51 }
52 })
53 Prism.languages.insertBefore('haxe', 'class-name', {
54 regex: {
55 pattern: /~\/(?:[^\/\\\r\n]|\\.)+\/[a-z]*/,
56 greedy: true,
57 inside: {
58 'regex-flags': /\b[a-z]+$/,
59 'regex-source': {
60 pattern: /^(~\/)[\s\S]+(?=\/$)/,
61 lookbehind: true,
62 alias: 'language-regex',
63 inside: Prism.languages.regex
64 },
65 'regex-delimiter': /^~\/|\/$/
66 }
67 }
68 })
69 Prism.languages.insertBefore('haxe', 'keyword', {
70 preprocessor: {
71 pattern: /#(?:else|elseif|end|if)\b.*/,
72 alias: 'property'
73 },
74 metadata: {
75 pattern: /@:?[\w.]+/,
76 alias: 'symbol'
77 },
78 reification: {
79 pattern: /\$(?:\w+|(?=\{))/,
80 alias: 'important'
81 }
82 })
83}
Note: See TracBrowser for help on using the repository browser.