Fixed MEL Syntax Highlighter
Fixed grouping errors. Added mel.mel file to test.
This commit is contained in:
parent
c2f1838dca
commit
55a947ec68
4 changed files with 76 additions and 38 deletions
|
|
@ -78,6 +78,7 @@ var docs = {
|
||||||
"docs/textile.textile": {name: "Textile", wrapped: true},
|
"docs/textile.textile": {name: "Textile", wrapped: true},
|
||||||
|
|
||||||
"docs/c9search.c9search_results": "C9 Search Results",
|
"docs/c9search.c9search_results": "C9 Search Results",
|
||||||
|
"docs/mel.mel": "MEL",
|
||||||
"docs/Nix.nix": "Nix"
|
"docs/Nix.nix": "Nix"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
49
demo/kitchen-sink/docs/mel.mel
Normal file
49
demo/kitchen-sink/docs/mel.mel
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
proc float edgeCalc(string $edge)
|
||||||
|
{
|
||||||
|
|
||||||
|
float $distance;
|
||||||
|
select -r `polyListComponentConversion -tv`;
|
||||||
|
string $connectedVerts[] = `filterExpand -ex 1 -sm 31`;
|
||||||
|
vector $PT1 = `pointPosition -w $connectedVerts[0]`;
|
||||||
|
vector $PT2 = `pointPosition -w $connectedVerts[1]`;
|
||||||
|
float $distance = mag(($PT1-$PT2));
|
||||||
|
|
||||||
|
return $distance;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
global proc edgeLength()
|
||||||
|
{
|
||||||
|
source roundoff.mel;
|
||||||
|
string $edges[]= `filterExpand -ex 1 -sm 32`;
|
||||||
|
string $unit = `currentUnit -q -l`;
|
||||||
|
float $edgeLength[];
|
||||||
|
int $conversion = 10;
|
||||||
|
|
||||||
|
float $totalLength=0; // <= Init your sum variable
|
||||||
|
//save edgelength to var for later
|
||||||
|
for($i=0;$i<`size $edges`;$i++)
|
||||||
|
{
|
||||||
|
select -r $edges[$i]; // Select only one edge
|
||||||
|
$edgeLength[$i] = edgeCalc($edges[$i]);
|
||||||
|
$totalLength += $edgeLength[$i] * $conversion;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
float $rounded_mm = `roundoff $totalLength 0`;
|
||||||
|
float $rounded_m = `roundoff (($totalLength)/1000) 2`;
|
||||||
|
string $edgeno = (size($edgeLength));
|
||||||
|
string $edgenoprint;
|
||||||
|
|
||||||
|
if(size($edgeLength)>1) {
|
||||||
|
$edgenoprint = " edges";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$edgenoprint = " edge";
|
||||||
|
}
|
||||||
|
|
||||||
|
print ($rounded_mm + " mm / " +$rounded_m+ " m - Total length of " + $edgeno + $edgenoprint +"\n");
|
||||||
|
select -r $edges; // restore previous selection
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 2012, Ajax.org B.V.
|
* Copyright (c) 2012, Ajax.org B.V.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* * Neither the name of Ajax.org B.V. nor the
|
* * Neither the name of Ajax.org B.V. nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
|
@ -26,17 +26,8 @@
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
/*
|
|
||||||
THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -44,20 +35,20 @@ var oop = require("../lib/oop");
|
||||||
var TextMode = require("./text").Mode;
|
var TextMode = require("./text").Mode;
|
||||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
var MELHighlightRules = require("./mel_highlight_rules").MELHighlightRules;
|
var MELHighlightRules = require("./mel_highlight_rules").MELHighlightRules;
|
||||||
// TODO: pick appropriate fold mode
|
|
||||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
this.HighlightRules = new MELHighlightRules();
|
var highlighter = new MELHighlightRules();
|
||||||
this.foldingRules = new FoldMode();
|
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||||
};
|
};
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.lineCommentStart = "//";
|
this.lineCommentStart = "//";
|
||||||
this.blockComment = {start: "/*", end: "*/"};
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
// Extra logic goes here.
|
|
||||||
}).call(Mode.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -77,9 +77,10 @@ var MELHighlightRules = function() {
|
||||||
regex: '"',
|
regex: '"',
|
||||||
next: 'pop' },
|
next: 'pop' },
|
||||||
{ defaultToken: 'string.quoted.double.mel' } ] },
|
{ defaultToken: 'string.quoted.double.mel' } ] },
|
||||||
{ todo: 'fix grouping',
|
|
||||||
token: [ 'variable.other.mel', 'punctuation.definition.variable.mel' ],
|
{ token: [ 'variable.other.mel', 'punctuation.definition.variable.mel' ],
|
||||||
regex: '(\\$)[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*?\\b' },
|
regex: '(\\$)([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*?\\b)' },
|
||||||
|
|
||||||
{ token: 'punctuation.definition.string.begin.mel',
|
{ token: 'punctuation.definition.string.begin.mel',
|
||||||
regex: '\'',
|
regex: '\'',
|
||||||
push:
|
push:
|
||||||
|
|
@ -88,8 +89,10 @@ var MELHighlightRules = function() {
|
||||||
regex: '\'',
|
regex: '\'',
|
||||||
next: 'pop' },
|
next: 'pop' },
|
||||||
{ defaultToken: 'string.quoted.single.mel' } ] },
|
{ defaultToken: 'string.quoted.single.mel' } ] },
|
||||||
|
|
||||||
{ token: 'constant.language.mel',
|
{ token: 'constant.language.mel',
|
||||||
regex: '\\b(false|true|yes|no|on|off)\\b' },
|
regex: '\\b(false|true|yes|no|on|off)\\b' },
|
||||||
|
|
||||||
{ token: 'punctuation.definition.comment.mel',
|
{ token: 'punctuation.definition.comment.mel',
|
||||||
regex: '/\\*',
|
regex: '/\\*',
|
||||||
push:
|
push:
|
||||||
|
|
@ -97,35 +100,29 @@ var MELHighlightRules = function() {
|
||||||
regex: '\\*/',
|
regex: '\\*/',
|
||||||
next: 'pop' },
|
next: 'pop' },
|
||||||
{ defaultToken: 'comment.block.mel' } ] },
|
{ defaultToken: 'comment.block.mel' } ] },
|
||||||
{ todo: 'fix grouping',
|
|
||||||
token:
|
{ token: [ 'comment.line.double-slash.mel', 'punctuation.definition.comment.mel' ],
|
||||||
[ 'comment.line.double-slash.mel',
|
regex: '(//)(.*$\\n?)' },
|
||||||
'punctuation.definition.comment.mel' ],
|
|
||||||
regex: '(//).*$\\n?' },
|
|
||||||
{ caseInsensitive: true,
|
{ caseInsensitive: true,
|
||||||
token: 'keyword.operator.mel',
|
token: 'keyword.operator.mel',
|
||||||
regex: '\\b(instanceof)\\b' },
|
regex: '\\b(instanceof)\\b' },
|
||||||
{ token: 'keyword.operator.symbolic.mel',
|
{ token: 'keyword.operator.symbolic.mel',
|
||||||
regex: '[-\\!\\%\\&\\*\\+\\=\\/\\?\\:]' },
|
regex: '[-\\!\\%\\&\\*\\+\\=\\/\\?\\:]' },
|
||||||
{ todo: 'fix grouping',
|
|
||||||
token:
|
{ token: [ 'meta.preprocessor.mel', 'punctuation.definition.preprocessor.mel' ],
|
||||||
[ 'meta.preprocessor.mel',
|
regex: '(^[ \\t]*)((?:#)[a-zA-Z]+)' },
|
||||||
'punctuation.definition.preprocessor.mel' ],
|
|
||||||
regex: '^[ \\t]*(#)[a-zA-Z]+' },
|
{ token: [ 'meta.function.mel', 'keyword.other.mel', 'storage.type.mel', 'entity.name.function.mel', 'punctuation.section.function.mel' ],
|
||||||
{ todo: 'fix grouping',
|
regex: '((?:global\\s*)?proc)\\s*(\\w+\\s*\\[?\\]?\\s+|\\s+)([A-Za-z_][A-Za-z0-9_\\.]*)(\\s*(\\())',
|
||||||
token:
|
|
||||||
[ 'meta.function.mel',
|
|
||||||
'keyword.other.mel',
|
|
||||||
'storage.type.mel',
|
|
||||||
'entity.name.function.mel',
|
|
||||||
'punctuation.section.function.mel' ],
|
|
||||||
regex: '((?:global\\s*)?proc)\\s*(\\w+\\s*\\[?\\]?\\s+|\\s+)([A-Za-z_][A-Za-z0-9_\\.]*)\\s*(\\()',
|
|
||||||
push:
|
push:
|
||||||
[ { include: '$self' },
|
[ { include: '$self' },
|
||||||
{ token: 'punctuation.section.function.mel',
|
{ token: 'punctuation.section.function.mel',
|
||||||
regex: '\\)',
|
regex: '\\)',
|
||||||
next: 'pop' },
|
next: 'pop' },
|
||||||
{ defaultToken: 'meta.function.mel' } ] } ] }
|
{ defaultToken: 'meta.function.mel' } ] }
|
||||||
|
|
||||||
|
] }
|
||||||
|
|
||||||
this.normalizeRules();
|
this.normalizeRules();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue