Skip to content
Permalink
Browse files
MAXScript: Various improvements (#3181)
  • Loading branch information
RunDevelopment committed Nov 22, 2021
1 parent 0ecdbdc commit e9b856c89da35f92678745029b58bd387c8594c9
@@ -1,52 +1,91 @@
Prism.languages.maxscript = {
'comment': {
pattern: /\/\*[\s\S]*?(?:\*\/|$)|--.*/,
greedy: true
},
'string': {
pattern: /(^|[^"\\@])(?:"(?:[^"\\]|\\[\s\S])*"|@"[^"]*")/,
lookbehind: true,
greedy: true
},
'path': {
pattern: /\$(?:[\w/\\.*?]|'[^']*')*/,
greedy: true,
alias: 'string'
},

'function-definition': {
pattern: /(\b(?:fn|function)\s+)\w+\b/,
lookbehind: true,
alias: 'function'
},

'argument': {
pattern: /\b[a-z_]\w*(?=:)/i,
alias: 'attr-name'
},

'keyword': /\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|or|parameters|persistent|plugin|rcmenu|return|rollout|set|struct|then|throw|to|tool|try|undo|utility|when|where|while|with)\b/i,
'boolean': /\b(?:false|off|on|true)\b/,

'time': {
pattern: /(^|[^\w.])(?:(?:(?:\d+(?:\.\d*)?|\.\d+)(?:[eEdD][+-]\d+|[LP])?[msft])+|\d+:\d+(?:\.\d*)?)(?![\w.:])/,
lookbehind: true,
alias: 'number'
},
'number': [
{
pattern: /(^|[^\w.])(?:(?:\d+(?:\.\d*)?|\.\d+)(?:[eEdD][+-]\d+|[LP])?|0x[a-fA-F0-9]+)(?![\w.:])/,
lookbehind: true
},
/\b(?:e|pi)\b/
],

'constant': /\b(?:black|blue|brown|gray|green|orange|red|white|yellow)\b/,
'color': {
pattern: /\b(?:dontcollect|ok|silentValue|undefined|unsupplied)\b/i,
alias: 'constant'
},

'operator': /[-+*/<>=!]=?|[&^]|#(?!\()/,
'punctuation': /[()\[\]{}.:,;]|#(?=\()|\\$/m
};
(function (Prism) {

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;


Prism.languages.maxscript = {
'comment': {
pattern: /\/\*[\s\S]*?(?:\*\/|$)|--.*/,
greedy: true
},
'string': {
pattern: /(^|[^"\\@])(?:"(?:[^"\\]|\\[\s\S])*"|@"[^"]*")/,
lookbehind: true,
greedy: true
},
'path': {
pattern: /\$(?:[\w/\\.*?]|'[^']*')*/,
greedy: true,
alias: 'string'
},

'function-call': {
pattern: RegExp(
'((?:' + (
// start of line
/^/.source +
'|' +
// operators and other language constructs
/[;=<>+\-*/^({\[]/.source +
'|' +
// keywords as part of statements
/\b(?:and|by|case|catch|collect|do|else|if|in|not|or|return|then|to|try|where|while|with)\b/.source
) + ')[ \t]*)' +

'(?!' + keywords.source + ')' + /[a-z_]\w*\b/.source +

'(?=[ \t]*(?:' + (
// variable
'(?!' + keywords.source + ')' + /[a-z_]/.source +
'|' +
// number
/\d|-\.?\d/.source +
'|' +
// other expressions or literals
/[({'"$@#?]/.source
) + '))',
'im'
),
lookbehind: true,
greedy: true,
alias: 'function'
},

'function-definition': {
pattern: /(\b(?:fn|function)\s+)\w+\b/i,
lookbehind: true,
alias: 'function'
},

'argument': {
pattern: /\b[a-z_]\w*(?=:)/i,
alias: 'attr-name'
},

'keyword': keywords,
'boolean': /\b(?:false|true)\b/,

'time': {
pattern: /(^|[^\w.])(?:(?:(?:\d+(?:\.\d*)?|\.\d+)(?:[eEdD][+-]\d+|[LP])?[msft])+|\d+:\d+(?:\.\d*)?)(?![\w.:])/,
lookbehind: true,
alias: 'number'
},
'number': [
{
pattern: /(^|[^\w.])(?:(?:\d+(?:\.\d*)?|\.\d+)(?:[eEdD][+-]\d+|[LP])?|0x[a-fA-F0-9]+)(?![\w.:])/,
lookbehind: true
},
/\b(?:e|pi)\b/
],

'constant': /\b(?:dontcollect|ok|silentValue|undefined|unsupplied)\b/,
'color': {
pattern: /\b(?:black|blue|brown|gray|green|orange|red|white|yellow)\b/i,
alias: 'constant'
},

'operator': /[-+*/<>=!]=?|[&^?]|#(?!\()/,
'punctuation': /[()\[\]{}.:,;]|#(?=\()|\\$/m
};

}(Prism));

Some generated files are not rendered by default. Learn more.

@@ -1,9 +1,11 @@
true false
on off
true;
false;

----------------------------------------------------

[
["boolean", "true"], ["boolean", "false"],
["boolean", "on"], ["boolean", "off"]
["boolean", "true"],
["punctuation", ";"],
["boolean", "false"],
["punctuation", ";"]
]
@@ -11,13 +11,13 @@ yellow
----------------------------------------------------

[
["constant", "black"],
["constant", "blue"],
["constant", "brown"],
["constant", "gray"],
["constant", "green"],
["constant", "orange"],
["constant", "red"],
["constant", "white"],
["constant", "yellow"]
["color", "black"],
["color", "blue"],
["color", "brown"],
["color", "gray"],
["color", "green"],
["color", "orange"],
["color", "red"],
["color", "white"],
["color", "yellow"]
]
@@ -7,9 +7,9 @@ unsupplied
----------------------------------------------------

[
["color", "dontcollect"],
["color", "ok"],
["color", "silentValue"],
["color", "undefined"],
["color", "unsupplied"]
["constant", "dontcollect"],
["constant", "ok"],
["constant", "silentValue"],
["constant", "undefined"],
["constant", "unsupplied"]
]
@@ -10,6 +10,15 @@ fn starfield count extent:[200,200,200] pos:[0,0,0] =
-- something
)

fn saddle x y = sin x * sin y

print "build math mesh"
in_name = getOpenFileName()
val.x=random -100 100
append vert_array (readValue in_file)
while not eof f do
on pressme pressed do print "Pressed!"

----------------------------------------------------

[
@@ -34,7 +43,7 @@ fn starfield count extent:[200,200,200] pos:[0,0,0] =
["keyword", "else"],
" n ",
["operator", "*"],
" factorial ",
["function-call", "factorial"],
["punctuation", "("],
"n ",
["operator", "-"],
@@ -51,15 +60,15 @@ fn starfield count extent:[200,200,200] pos:[0,0,0] =
["punctuation", "."],
"wireColor ",
["operator", "="],
" random ",
["function-call", "random"],
["punctuation", "("],
"color ",
["function-call", "color"],
["number", "0"],
["number", "0"],
["number", "0"],
["punctuation", ")"],
["punctuation", "("],
"color ",
["function-call", "color"],
["number", "255"],
["number", "255"],
["number", "255"],
@@ -92,5 +101,52 @@ fn starfield count extent:[200,200,200] pos:[0,0,0] =

["comment", "-- something"],

["punctuation", ")"]
["punctuation", ")"],

["keyword", "fn"],
["function-definition", "saddle"],
" x y ",
["operator", "="],
["function-call", "sin"],
" x ",
["operator", "*"],
["function-call", "sin"],
" y\r\n\r\n",

["function-call", "print"],
["string", "\"build math mesh\""],

"\r\nin_name ",
["operator", "="],
["function-call", "getOpenFileName"],
["punctuation", "("],
["punctuation", ")"],

"\r\nval",
["punctuation", "."],
"x",
["operator", "="],
["function-call", "random"],
["operator", "-"],
["number", "100"],
["number", "100"],

["function-call", "append"],
" vert_array ",
["punctuation", "("],
["function-call", "readValue"],
" in_file",
["punctuation", ")"],

["keyword", "while"],
["keyword", "not"],
["function-call", "eof"],
" f ",
["keyword", "do"],

["keyword", "on"],
" pressme pressed ",
["keyword", "do"],
["function-call", "print"],
["string", "\"Pressed!\""]
]
@@ -26,6 +26,8 @@ mapped;
max;
not;
of;
off;
on;
or;
parameters;
persistent;
@@ -78,6 +80,8 @@ with;
["keyword", "max"], ["punctuation", ";"],
["keyword", "not"], ["punctuation", ";"],
["keyword", "of"], ["punctuation", ";"],
["keyword", "off"], ["punctuation", ";"],
["keyword", "on"], ["punctuation", ";"],
["keyword", "or"], ["punctuation", ";"],
["keyword", "parameters"], ["punctuation", ";"],
["keyword", "persistent"], ["punctuation", ";"],
@@ -5,7 +5,8 @@
0x0E
.1

e pi
e
pi

----------------------------------------------------

@@ -17,5 +18,6 @@ e pi
["number", "0x0E"],
["number", ".1"],

["number", "e"], ["number", "pi"]
["number", "e"],
["number", "pi"]
]
@@ -74,10 +74,10 @@ bodyPart=$Bip01_L_UpperArm
["number", "0"],
["punctuation", "]"],

"\r\nhide ",
["function-call", "hide"],
["path", "$"],

"\r\nrotate ",
["function-call", "rotate"],
["path", "$"],
["number", "35"],
" z_axis\r\n\r\n",

0 comments on commit e9b856c

Please sign in to comment.