Fixed MEL Syntax Highlighter

Fixed grouping errors. Added mel.mel file to test.
This commit is contained in:
Nicholas Breslow 2013-10-02 14:17:35 -04:00
commit 55a947ec68
4 changed files with 76 additions and 38 deletions

View file

@ -3,7 +3,7 @@
*
* Copyright (c) 2012, Ajax.org B.V.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
@ -14,7 +14,7 @@
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
*
* 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
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* Contributor(s):
*
*
*
* ***** END LICENSE BLOCK ***** */
/*
THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
*/
define(function(require, exports, module) {
"use strict";
@ -44,20 +35,20 @@ var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var MELHighlightRules = require("./mel_highlight_rules").MELHighlightRules;
// TODO: pick appropriate fold mode
var FoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() {
this.HighlightRules = new MELHighlightRules();
this.foldingRules = new FoldMode();
var highlighter = new MELHighlightRules();
this.$tokenizer = new Tokenizer(highlighter.getRules());
};
oop.inherits(Mode, TextMode);
(function() {
this.lineCommentStart = "//";
this.blockComment = {start: "/*", end: "*/"};
// Extra logic goes here.
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -77,9 +77,10 @@ var MELHighlightRules = function() {
regex: '"',
next: 'pop' },
{ defaultToken: 'string.quoted.double.mel' } ] },
{ todo: 'fix grouping',
token: [ 'variable.other.mel', 'punctuation.definition.variable.mel' ],
regex: '(\\$)[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*?\\b' },
{ token: [ 'variable.other.mel', 'punctuation.definition.variable.mel' ],
regex: '(\\$)([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*?\\b)' },
{ token: 'punctuation.definition.string.begin.mel',
regex: '\'',
push:
@ -88,8 +89,10 @@ var MELHighlightRules = function() {
regex: '\'',
next: 'pop' },
{ defaultToken: 'string.quoted.single.mel' } ] },
{ token: 'constant.language.mel',
regex: '\\b(false|true|yes|no|on|off)\\b' },
{ token: 'punctuation.definition.comment.mel',
regex: '/\\*',
push:
@ -97,35 +100,29 @@ var MELHighlightRules = function() {
regex: '\\*/',
next: 'pop' },
{ defaultToken: 'comment.block.mel' } ] },
{ todo: 'fix grouping',
token:
[ 'comment.line.double-slash.mel',
'punctuation.definition.comment.mel' ],
regex: '(//).*$\\n?' },
{ token: [ 'comment.line.double-slash.mel', 'punctuation.definition.comment.mel' ],
regex: '(//)(.*$\\n?)' },
{ caseInsensitive: true,
token: 'keyword.operator.mel',
regex: '\\b(instanceof)\\b' },
{ token: 'keyword.operator.symbolic.mel',
regex: '[-\\!\\%\\&\\*\\+\\=\\/\\?\\:]' },
{ todo: 'fix grouping',
token:
[ 'meta.preprocessor.mel',
'punctuation.definition.preprocessor.mel' ],
regex: '^[ \\t]*(#)[a-zA-Z]+' },
{ todo: 'fix grouping',
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*(\\()',
{ token: [ 'meta.preprocessor.mel', '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' ],
regex: '((?:global\\s*)?proc)\\s*(\\w+\\s*\\[?\\]?\\s+|\\s+)([A-Za-z_][A-Za-z0-9_\\.]*)(\\s*(\\())',
push:
[ { include: '$self' },
{ token: 'punctuation.section.function.mel',
regex: '\\)',
next: 'pop' },
{ defaultToken: 'meta.function.mel' } ] } ] }
{ defaultToken: 'meta.function.mel' } ] }
] }
this.normalizeRules();
};