[d24f17c] | 1 | Prism.languages.haxe = Prism.languages.extend('clike', {
|
---|
| 2 | 'string': {
|
---|
| 3 | // Strings can be multi-line
|
---|
| 4 | pattern: /"(?:[^"\\]|\\[\s\S])*"/,
|
---|
| 5 | greedy: true
|
---|
| 6 | },
|
---|
| 7 | 'class-name': [
|
---|
| 8 | {
|
---|
| 9 | pattern: /(\b(?:abstract|class|enum|extends|implements|interface|new|typedef)\s+)[A-Z_]\w*/,
|
---|
| 10 | lookbehind: true,
|
---|
| 11 | },
|
---|
| 12 | // based on naming convention
|
---|
| 13 | /\b[A-Z]\w*/
|
---|
| 14 | ],
|
---|
| 15 | // The final look-ahead prevents highlighting of keywords if expressions such as "haxe.macro.Expr"
|
---|
| 16 | 'keyword': /\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/,
|
---|
| 17 | 'function': {
|
---|
| 18 | pattern: /\b[a-z_]\w*(?=\s*(?:<[^<>]*>\s*)?\()/i,
|
---|
| 19 | greedy: true
|
---|
| 20 | },
|
---|
| 21 | 'operator': /\.{3}|\+\+|--|&&|\|\||->|=>|(?:<<?|>{1,3}|[-+*/%!=&|^])=?|[?:~]/
|
---|
| 22 | });
|
---|
| 23 |
|
---|
| 24 | Prism.languages.insertBefore('haxe', 'string', {
|
---|
| 25 | 'string-interpolation': {
|
---|
| 26 | pattern: /'(?:[^'\\]|\\[\s\S])*'/,
|
---|
| 27 | greedy: true,
|
---|
| 28 | inside: {
|
---|
| 29 | 'interpolation': {
|
---|
| 30 | pattern: /(^|[^\\])\$(?:\w+|\{[^{}]+\})/,
|
---|
| 31 | lookbehind: true,
|
---|
| 32 | inside: {
|
---|
| 33 | 'interpolation-punctuation': {
|
---|
| 34 | pattern: /^\$\{?|\}$/,
|
---|
| 35 | alias: 'punctuation'
|
---|
| 36 | },
|
---|
| 37 | 'expression': {
|
---|
| 38 | pattern: /[\s\S]+/,
|
---|
| 39 | inside: Prism.languages.haxe
|
---|
| 40 | },
|
---|
| 41 | }
|
---|
| 42 | },
|
---|
| 43 | 'string': /[\s\S]+/
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 | });
|
---|
| 47 |
|
---|
| 48 | Prism.languages.insertBefore('haxe', 'class-name', {
|
---|
| 49 | 'regex': {
|
---|
| 50 | pattern: /~\/(?:[^\/\\\r\n]|\\.)+\/[a-z]*/,
|
---|
| 51 | greedy: true,
|
---|
| 52 | inside: {
|
---|
| 53 | 'regex-flags': /\b[a-z]+$/,
|
---|
| 54 | 'regex-source': {
|
---|
| 55 | pattern: /^(~\/)[\s\S]+(?=\/$)/,
|
---|
| 56 | lookbehind: true,
|
---|
| 57 | alias: 'language-regex',
|
---|
| 58 | inside: Prism.languages.regex
|
---|
| 59 | },
|
---|
| 60 | 'regex-delimiter': /^~\/|\/$/,
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 | });
|
---|
| 64 |
|
---|
| 65 | Prism.languages.insertBefore('haxe', 'keyword', {
|
---|
| 66 | 'preprocessor': {
|
---|
| 67 | pattern: /#(?:else|elseif|end|if)\b.*/,
|
---|
| 68 | alias: 'property'
|
---|
| 69 | },
|
---|
| 70 | 'metadata': {
|
---|
| 71 | pattern: /@:?[\w.]+/,
|
---|
| 72 | alias: 'symbol'
|
---|
| 73 | },
|
---|
| 74 | 'reification': {
|
---|
| 75 | pattern: /\$(?:\w+|(?=\{))/,
|
---|
| 76 | alias: 'important'
|
---|
| 77 | }
|
---|
| 78 | });
|
---|