1 | (function (Prism) {
|
---|
2 |
|
---|
3 | var keywords = /\b(?:about|and|animate|as|at|attributes|by|case|catch|collect|continue|coordsys|do|else|exit|fn|for|from|function|global|if|in|local|macroscript|mapped|max|not|of|off|on|or|parameters|persistent|plugin|rcmenu|return|rollout|set|struct|then|throw|to|tool|try|undo|utility|when|where|while|with)\b/i;
|
---|
4 |
|
---|
5 |
|
---|
6 | Prism.languages.maxscript = {
|
---|
7 | 'comment': {
|
---|
8 | pattern: /\/\*[\s\S]*?(?:\*\/|$)|--.*/,
|
---|
9 | greedy: true
|
---|
10 | },
|
---|
11 | 'string': {
|
---|
12 | pattern: /(^|[^"\\@])(?:"(?:[^"\\]|\\[\s\S])*"|@"[^"]*")/,
|
---|
13 | lookbehind: true,
|
---|
14 | greedy: true
|
---|
15 | },
|
---|
16 | 'path': {
|
---|
17 | pattern: /\$(?:[\w/\\.*?]|'[^']*')*/,
|
---|
18 | greedy: true,
|
---|
19 | alias: 'string'
|
---|
20 | },
|
---|
21 |
|
---|
22 | 'function-call': {
|
---|
23 | pattern: RegExp(
|
---|
24 | '((?:' + (
|
---|
25 | // start of line
|
---|
26 | /^/.source +
|
---|
27 | '|' +
|
---|
28 | // operators and other language constructs
|
---|
29 | /[;=<>+\-*/^({\[]/.source +
|
---|
30 | '|' +
|
---|
31 | // keywords as part of statements
|
---|
32 | /\b(?:and|by|case|catch|collect|do|else|if|in|not|or|return|then|to|try|where|while|with)\b/.source
|
---|
33 | ) + ')[ \t]*)' +
|
---|
34 |
|
---|
35 | '(?!' + keywords.source + ')' + /[a-z_]\w*\b/.source +
|
---|
36 |
|
---|
37 | '(?=[ \t]*(?:' + (
|
---|
38 | // variable
|
---|
39 | '(?!' + keywords.source + ')' + /[a-z_]/.source +
|
---|
40 | '|' +
|
---|
41 | // number
|
---|
42 | /\d|-\.?\d/.source +
|
---|
43 | '|' +
|
---|
44 | // other expressions or literals
|
---|
45 | /[({'"$@#?]/.source
|
---|
46 | ) + '))',
|
---|
47 | 'im'
|
---|
48 | ),
|
---|
49 | lookbehind: true,
|
---|
50 | greedy: true,
|
---|
51 | alias: 'function'
|
---|
52 | },
|
---|
53 |
|
---|
54 | 'function-definition': {
|
---|
55 | pattern: /(\b(?:fn|function)\s+)\w+\b/i,
|
---|
56 | lookbehind: true,
|
---|
57 | alias: 'function'
|
---|
58 | },
|
---|
59 |
|
---|
60 | 'argument': {
|
---|
61 | pattern: /\b[a-z_]\w*(?=:)/i,
|
---|
62 | alias: 'attr-name'
|
---|
63 | },
|
---|
64 |
|
---|
65 | 'keyword': keywords,
|
---|
66 | 'boolean': /\b(?:false|true)\b/,
|
---|
67 |
|
---|
68 | 'time': {
|
---|
69 | pattern: /(^|[^\w.])(?:(?:(?:\d+(?:\.\d*)?|\.\d+)(?:[eEdD][+-]\d+|[LP])?[msft])+|\d+:\d+(?:\.\d*)?)(?![\w.:])/,
|
---|
70 | lookbehind: true,
|
---|
71 | alias: 'number'
|
---|
72 | },
|
---|
73 | 'number': [
|
---|
74 | {
|
---|
75 | pattern: /(^|[^\w.])(?:(?:\d+(?:\.\d*)?|\.\d+)(?:[eEdD][+-]\d+|[LP])?|0x[a-fA-F0-9]+)(?![\w.:])/,
|
---|
76 | lookbehind: true
|
---|
77 | },
|
---|
78 | /\b(?:e|pi)\b/
|
---|
79 | ],
|
---|
80 |
|
---|
81 | 'constant': /\b(?:dontcollect|ok|silentValue|undefined|unsupplied)\b/,
|
---|
82 | 'color': {
|
---|
83 | pattern: /\b(?:black|blue|brown|gray|green|orange|red|white|yellow)\b/i,
|
---|
84 | alias: 'constant'
|
---|
85 | },
|
---|
86 |
|
---|
87 | 'operator': /[-+*/<>=!]=?|[&^?]|#(?!\()/,
|
---|
88 | 'punctuation': /[()\[\]{}.:,;]|#(?=\()|\\$/m
|
---|
89 | };
|
---|
90 |
|
---|
91 | }(Prism));
|
---|