Skip to content

Commit

Permalink
Merge pull request #618 from Golmote/prism-mel
Browse files Browse the repository at this point in the history
Add support for MEL (Maya Embedded Language)
  • Loading branch information
Golmote committed Sep 7, 2015
2 parents 53b6915 + 4c9b105 commit 8496c14
Show file tree
Hide file tree
Showing 15 changed files with 2,816 additions and 2 deletions.
4 changes: 4 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ var components = {
"title": "MATLAB",
"owner": "Golmote"
},
"mel": {
"title": "MEL",
"owner": "Golmote"
},
"nasm": {
"title": "NASM",
"owner": "rbmj"
Expand Down
39 changes: 39 additions & 0 deletions components/prism-mel.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions components/prism-mel.min.js

Large diffs are not rendered by default.

150 changes: 150 additions & 0 deletions examples/prism-mel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<h1>MEL (Maya Embedded Language)</h1>
<p>To use this language, use the class "language-mel".</p>

<h2>Comments</h2>
<pre><code>// This is a comment</code></pre>

<h2>Strings</h2>
<pre><code>"This is a string"
"foo \"bar\" baz"</code></pre>

<h2>Numbers</h2>
<pre><code>42
3.14159
0xA2F</code></pre>

<h2>Variables</h2>
<pre><code>$x
$floaty5000
$longDescriptiveName
$name_with_underscores
$_line

float $param;
int $counter;
string $name;
vector $position;</code></pre>

<h2>Arrays, vectors and matrices</h2>
<pre><code>string $array[3] = {"first\n", "second\n", "third\n"};
print($array[0]); // Prints "first\n"
print($array[1]); // Prints "second\n"
print($array[2]); // Prints "third\n"

vector $roger = <<3.0, 7.7, 9.1>>;
vector $more = <<4.5, 6.789, 9.12356>>;
// Assign a vector to variable $test:
vector $test = <<3.0, 7.7, 9.1>>;
$test = <<$test.x, 5.5, $test.z>>
// $test is now <<3.0, 5.5, 9.1>>

matrix $a3[3][4] = <<2.5, 4.5, 3.25, 8.05;
1.12, 1.3, 9.5, 5.2;
7.23, 6.006, 2.34, 4.67>></code></pre>

<h2>Commands</h2>
<pre><code>pickWalk -d down;
string $mySelection[] = `ls -selection`;

setAttr ($mySelection[0]+".particleRenderType") 5;

addAttr -is true -ln "spriteTwist" -at "float" -min -180 -max 180 -dv 0.0 blue_nParticleShape;</code></pre>

<h2>Full example</h2>
<pre><code>// From http://help.autodesk.com/view/MAYAUL/2015/ENU/?guid=Example_scripts_Dynamics_Time_Playback
// Alias Script File
// MODIFY THIS AT YOUR OWN RISK
//
// Creation Date: 8 May 1996
// Author: rh
//
// Description:
// Playback from frame 0 to frame &lt;n> and return the
// the playback rate in frames/sec. If a negative frame
// count is given, this indicates silent mode. In silent
// mode, no output is printed.
//
// This version is intended for use in batch tests of dynamics.
// It requests particle and rigid body positions every frame.
//
// RETURN
// Frame rate in frames/sec
//
global proc float dynTimePlayback( float $frames )
{
int $silent;
// Get the list of particle shapes.
//
string $particleObjects[] = `ls -type particle`;
int $particleCount = size( $particleObjects );
// Get the list of transforms.
// This will include rigid bodies.
//
string $transforms[] = `ls -tr`;
int $trCount = size( $transforms );
// Check for negative $frames. This indicates
// $silent mode.
//
if ($frames < 0)
{
$silent = 1;
$frames = -$frames;
}
else
{
$silent = 0;
}
// Setup the playback options.
//
playbackOptions -min 1 -max $frames -loop "once";
currentTime -edit 0;
// Playback the animation using the timerX command
// to compute the $elapsed time.
//
float $startTime, $elapsed;
$startTime = `timerX`;
// play -wait;
int $i;
for ($i = 1; $i < $frames; $i++ )
{
// Set time
//
currentTime -e $i;
int $obj;
// Request count for every particle object.
//
for ($obj = 0; $obj < $particleCount; $obj++)
{
string $cmd = "getAttr " + $particleObjects[$obj]+".count";
eval( $cmd );
}
// Request position for every transform
// (includes every rigid body).
//
for ($obj = 0; $obj < $trCount; $obj++)
{
string $cmd = "getAttr " + $transforms[$obj]+".translate";
eval ($cmd);
}
}
$elapsed = `timerX -st $startTime`;
// Compute the playback frame $rate. Print results.
//
float $rate = ($elapsed == 0 ? 0.0 : $frames / $elapsed) ;
if ( ! $silent)
{
print( "Playback time: " + $elapsed + " secs\n" );
print( "Playback $rate: " + $rate + " $frames/sec\n" );
}
return ( $rate );
} // timePlayback //</code></pre>

<h2>Known failures</h2>
<p>There are certain edge cases where Prism will fail.
There are always such cases in every regex-based syntax highlighter.
However, Prism dares to be open and honest about them.
If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
</p>

<h3>Comment-like substrings</h3>
<pre><code>"This // string is broken"</code></pre>
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (typeof self === 'undefined' || !self.Prism || !self.document) {
}

// The languages map is built automatically with gulp
var Languages = /*languages_placeholder[*/{"css":"CSS","clike":"C-like","javascript":"JavaScript","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","http":"HTTP","inform7":"Inform 7","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","nasm":"NASM","nsis":"NSIS","objectivec":"Objective-C","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","wiki":"Wiki markup","yaml":"YAML"}/*]*/;
var Languages = /*languages_placeholder[*/{"css":"CSS","clike":"C-like","javascript":"JavaScript","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","http":"HTTP","inform7":"Inform 7","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nsis":"NSIS","objectivec":"Objective-C","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","wiki":"Wiki markup","yaml":"YAML"}/*]*/;
Prism.hooks.add('before-highlight', function(env) {
var pre = env.element.parentNode;
if (!pre || !/pre/i.test(pre.nodeName)) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions tests/languages/mel/code_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
`ls -selection`

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

[
["code", [
["delimiter", "`"],
["function", "ls"],
["flag", "-selection"],
["delimiter", "`"]
]]
]

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

Checks for code.
13 changes: 13 additions & 0 deletions tests/languages/mel/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Foobar

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

[
["comment", "//"],
["comment", "// Foobar"]
]

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

Checks for comments.
15 changes: 15 additions & 0 deletions tests/languages/mel/flag_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-d
-foo
-foo42

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

[
["flag", "-d"],
["flag", "-foo"],
["flag", "-foo42"]
]

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

Checks for flags.
Loading

0 comments on commit 8496c14

Please sign in to comment.