Compare commits
3 commits
master
...
tmlanguage
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f74824a9b4 | ||
|
|
bf58685732 | ||
|
|
a64855b8bf |
5 changed files with 865 additions and 26 deletions
60
lib/ace/mode/vbscript.js
Normal file
60
lib/ace/mode/vbscript.js
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * 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
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (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";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var VBScriptHighlightRules = require("./vbscript_highlight_rules").VBScriptHighlightRules;
|
||||
|
||||
var Mode = function() {
|
||||
var highlighter = new VBScriptHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
// Extra logic goes here.
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
318
lib/ace/mode/vbscript_highlight_rules.js
Normal file
318
lib/ace/mode/vbscript_highlight_rules.js
Normal file
|
|
@ -0,0 +1,318 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * 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
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (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_highlight_rules.tmpl.js (UUID: 7F9C9343-D48E-4E7D-BFE8-F680714DCD3E) */
|
||||
|
||||
/*******
|
||||
|
||||
THIS FILE MIGHT NOT BE PERFECT, PARTICULARLY:
|
||||
|
||||
IN DECIDING STATES TO TRANSITION TO,
|
||||
|
||||
IGNORING WHITESPACE,
|
||||
|
||||
IGNORING GROUPS WITH ?:,
|
||||
|
||||
EXTENDING EXISTING MODES,
|
||||
|
||||
GATHERING KEYWORDS, OR
|
||||
|
||||
RULE PREFERENCE ORDER.
|
||||
|
||||
...But it's a good start from an existing *.tmlanguage file.
|
||||
|
||||
*******/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var VBScriptHighlightRules = function() {
|
||||
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this.$rules =
|
||||
{
|
||||
"start": [
|
||||
{
|
||||
"token": [
|
||||
"meta.ending-space"
|
||||
],
|
||||
"regex": "$"
|
||||
},
|
||||
// {
|
||||
// "token": [
|
||||
// "#round-brackets"
|
||||
// ],
|
||||
// "regex": ""
|
||||
// },
|
||||
{
|
||||
"token": [
|
||||
null
|
||||
],
|
||||
"regex": "^(?=\\t)",
|
||||
"next": "state_3"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
null
|
||||
],
|
||||
"regex": "^(?= )",
|
||||
"next": "state_4"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"storage.type.function.asp",
|
||||
"text",
|
||||
"entity.name.function.asp",
|
||||
"text",
|
||||
"punctuation.definition.parameters.asp",
|
||||
"variable.parameter.function.asp",
|
||||
"punctuation.definition.parameters.asp"
|
||||
],
|
||||
"regex": "^\\s*((?:Function|Sub))(\\s*)([a-zA-Z_]\\w*)(\\s*)(\\()([^)]*)(\\)).*\\n?"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"punctuation.definition.comment.asp"
|
||||
],
|
||||
"regex": "('|REM)",
|
||||
"next": "state_6"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"keyword.control.asp"
|
||||
],
|
||||
"regex": "(?:\\b(If|Then|Else|ElseIf|Else If|End If|While|Wend|For|To|Each|Case|Select|End Select|Return|Continue|Do|Until|Loop|Next|With|Exit Do|Exit For|Exit Function|Exit Property|Exit Sub|IIf)\\b)"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"keyword.operator.asp"
|
||||
],
|
||||
"regex": "(?:\\b(Mod|And|Not|Or|Xor|as)\\b)"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"storage.type.asp"
|
||||
],
|
||||
"regex": "Dim|Call|Class|Const|Dim|Redim|Function|Sub|Private Sub|Public Sub|End sub|End Function|Set|Let|Get|New|Randomize|Option Explicit|On Error Resume Next|On Error GoTo"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"storage.modifier.asp"
|
||||
],
|
||||
"regex": "(?:\\b(Private|Public|Default)\\b)"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"constant.language.asp"
|
||||
],
|
||||
"regex": "(?:\\s*\\b(Empty|False|Nothing|Null|True)\\b)"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"punctuation.definition.string.begin.asp"
|
||||
],
|
||||
"regex": "\"",
|
||||
"next": "state_13"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"punctuation.definition.variable.asp"
|
||||
],
|
||||
"regex": "(\\$)[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\\b\\s*"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"support.class.asp"
|
||||
],
|
||||
"regex": "(?:\\b(Application|ObjectContext|Request|Response|Server|Session)\\b)"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"support.class.collection.asp"
|
||||
],
|
||||
"regex": "(?:\\b(Contents|StaticObjects|ClientCertificate|Cookies|Form|QueryString|ServerVariables)\\b)"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"support.constant.asp"
|
||||
],
|
||||
"regex": "(?:\\b(TotalBytes|Buffer|CacheControl|Charset|ContentType|Expires|ExpiresAbsolute|IsClientConnected|PICS|Status|ScriptTimeout|CodePage|LCID|SessionID|Timeout)\\b)"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"support.function.asp"
|
||||
],
|
||||
"regex": "(?:\\b(Lock|Unlock|SetAbort|SetComplete|BianryRead|AddHeader|AppendToLog|BinaryWrite|Clear|End|Flush|Redirect|Write|CreateObject|HTMLEncode|MapPath|URLEncode|Abandon|Convert|Regex)\\b)"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"support.function.event.asp"
|
||||
],
|
||||
"regex": "(?:\\b(Application_OnEnd|Application_OnStart|OnTransactionAbort|OnTransactionCommit|Session_OnEnd|Session_OnStart)\\b)"
|
||||
},
|
||||
// {
|
||||
// "token": [
|
||||
// "support.type.vb.asp"
|
||||
// ],
|
||||
// "regex": "(?:(?<=as )(\\b[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\\b))", // ERROR: This contains a lookbehind, which JS does not support :("
|
||||
// },
|
||||
{
|
||||
"token": [
|
||||
"support.function.vb.asp"
|
||||
],
|
||||
"regex": "(?:\\b(Array|Add|Asc|Atn|CBool|CByte|CCur|CDate|CDbl|Chr|CInt|CLng|Conversions|Cos|CreateObject|CSng|CStr|Date|DateAdd|DateDiff|DatePart|DateSerial|DateValue|Day|Derived|Math|Escape|Eval|Exists|Exp|Filter|FormatCurrency|FormatDateTime|FormatNumber|FormatPercent|GetLocale|GetObject|GetRef|Hex|Hour|InputBox|InStr|InStrRev|Int|Fix|IsArray|IsDate|IsEmpty|IsNull|IsNumeric|IsObject|Item|Items|Join|Keys|LBound|LCase|Left|Len|LoadPicture|Log|LTrim|RTrim|Trim|Maths|Mid|Minute|Month|MonthName|MsgBox|Now|Oct|Remove|RemoveAll|Replace|RGB|Right|Rnd|Round|ScriptEngine|ScriptEngineBuildVersion|ScriptEngineMajorVersion|ScriptEngineMinorVersion|Second|SetLocale|Sgn|Sin|Space|Split|Sqr|StrComp|String|StrReverse|Tan|Time|Timer|TimeSerial|TimeValue|TypeName|UBound|UCase|Unescape|VarType|Weekday|WeekdayName|Year)\\b)"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"constant.numeric.asp"
|
||||
],
|
||||
"regex": "-?\\b(?:(?:0(?:x|X)[0-9a-fA-F]*)|(?:(?:[0-9]+\\.?[0-9]*)|(?:\\.[0-9]+))(?:(?:e|E)(?:\\+|-)?[0-9]+)?)(?:L|l|UL|ul|u|U|F|f)?\\b"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"support.type.vb.asp"
|
||||
],
|
||||
"regex": "(?:\\b(vbtrue|fvbalse|vbcr|vbcrlf|vbformfeed|vblf|vbnewline|vbnullchar|vbnullstring|int32|vbtab|vbverticaltab|vbbinarycompare|vbtextcomparevbsunday|vbmonday|vbtuesday|vbwednesday|vbthursday|vbfriday|vbsaturday|vbusesystemdayofweek|vbfirstjan1|vbfirstfourdays|vbfirstfullweek|vbgeneraldate|vblongdate|vbshortdate|vblongtime|vbshorttime|vbobjecterror|vbEmpty|vbNull|vbInteger|vbLong|vbSingle|vbDouble|vbCurrency|vbDate|vbString|vbObject|vbError|vbBoolean|vbVariant|vbDataObject|vbDecimal|vbByte|vbArray)\\b)"
|
||||
},
|
||||
{
|
||||
"token": [
|
||||
"entity.name.function.asp"
|
||||
],
|
||||
"regex": "(?:(\\b[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\\b)(?=\\(\\)?))"
|
||||
},
|
||||
// {
|
||||
// "token": [
|
||||
// "variable.other.asp"
|
||||
// ],
|
||||
// "regex": "(?:((?<=(\\+|=|-|\\&|\\\\|/|<|>|\\(|,))\\s*\\b([a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?)\\b(?!(\\(|\\.))|\\b([a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?)\\b(?=\\s*(\\+|=|-|\\&|\\\\|/|<|>|\\(|\\)))))", // ERROR: This contains a lookbehind, which JS does not support :("
|
||||
// },
|
||||
{
|
||||
"token": [
|
||||
"keyword.operator.asp"
|
||||
],
|
||||
"regex": "\\-|\\+|\\*\\\/|\\>|\\<|\\=|\\&"
|
||||
}
|
||||
],
|
||||
"state_3": [
|
||||
{
|
||||
"token": [
|
||||
"meta.odd-tab.tabs",
|
||||
"meta.even-tab.tabs"
|
||||
],
|
||||
"regex": "(\\t)(\\t)?"
|
||||
},
|
||||
{
|
||||
"token": "meta.leading-space",
|
||||
"regex": "(?=[^\\t])",
|
||||
"merge": true,
|
||||
"next": "start"
|
||||
},
|
||||
{
|
||||
"token": "meta.leading-space",
|
||||
"regex": ".",
|
||||
"merge": true,
|
||||
"next": "state_3"
|
||||
}
|
||||
],
|
||||
"state_4": [
|
||||
{
|
||||
"token": [
|
||||
"meta.odd-tab.spaces",
|
||||
"meta.even-tab.spaces"
|
||||
],
|
||||
"regex": "( )( )?"
|
||||
},
|
||||
{
|
||||
"token": "meta.leading-space",
|
||||
"regex": "(?=[^ ])",
|
||||
"merge": true,
|
||||
"next": "start"
|
||||
},
|
||||
{
|
||||
"token": "meta.leading-space",
|
||||
"regex": ".",
|
||||
"merge": true,
|
||||
"next": "state_4"
|
||||
}
|
||||
],
|
||||
"state_6": [
|
||||
{
|
||||
"token": "comment.line.apostrophe.asp",
|
||||
"regex": "(?=(?:$|%>))",
|
||||
"merge": true,
|
||||
"next": "start"
|
||||
},
|
||||
{
|
||||
"token": "comment.line.apostrophe.asp",
|
||||
"regex": ".",
|
||||
"merge": true,
|
||||
"next": "state_6"
|
||||
}
|
||||
],
|
||||
"state_13": [
|
||||
{
|
||||
"token": "constant.character.escape.apostrophe.asp",
|
||||
"regex": "\"\""
|
||||
},
|
||||
{
|
||||
"token": "string.quoted.double.asp",
|
||||
"regex": "\"",
|
||||
"merge": true,
|
||||
"next": "start"
|
||||
},
|
||||
{
|
||||
"token": "string.quoted.double.asp",
|
||||
"regex": ".",
|
||||
"merge": true,
|
||||
"next": "state_13"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
/*** START REPOSITORY RULES
|
||||
[object Object]
|
||||
END REPOSITORY RULES ***/
|
||||
};
|
||||
|
||||
oop.inherits(VBScriptHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.VBScriptHighlightRules = VBScriptHighlightRules;
|
||||
});
|
||||
58
tool/test.tmlanguage
Normal file
58
tool/test.tmlanguage
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Modified from the original ASP bundle. Originally modified by Thomas Aylott subtleGradient.com</string>
|
||||
<key>fileTypes</key>
|
||||
<array>
|
||||
<string>vbs</string>
|
||||
<string>vbe</string>
|
||||
<string>wsf</string>
|
||||
<string>wsc</string>
|
||||
</array>
|
||||
<key>foldingStartMarker</key>
|
||||
<string>(<(?i:(head|table|div|style|script|ul|ol|form|dl))\b.*?>|\{|^\s*<?%?\s*'?\s*(?i:(sub|private\s+Sub|public\s+Sub|function|if|while|For))\s*.*$)</string>
|
||||
<key>foldingStopMarker</key>
|
||||
<string>(</(?i:(head|table|div|style|script|ul|ol|form|dl))>?|\}|^\s*<?%?\s*\s*'?\s*(?i:(end|Next))\s*.*$)</string>
|
||||
<key>keyEquivalent</key>
|
||||
<string>^~A</string>
|
||||
<key>name</key>
|
||||
<string>VBScript</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>^(?=\t)</string>
|
||||
<key>end</key>
|
||||
<string>(?=[^\t])</string>
|
||||
<key>name</key>
|
||||
<string>meta.leading-space</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.odd-tab.tabs</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.even-tab.tabs</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>(\t)(\t)?</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>scopeName</key>
|
||||
<string>source.vbs</string>
|
||||
<key>uuid</key>
|
||||
<string>7F9C9343-D48E-4E7D-BFE8-F680714DCD3E</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -82,6 +82,10 @@ function checkForLookBehind(str) {
|
|||
return lookbehindRegExp.test(str) ? str + " // ERROR: This contains a lookbehind, which JS does not support :(" : str;
|
||||
}
|
||||
|
||||
function checkForInvariantRegex(str) {
|
||||
return str.replace(/\?i\:/, "?:");
|
||||
}
|
||||
|
||||
function removeXFlag(str) {
|
||||
if (str.slice(0,4) == "(?x)") {
|
||||
str = str.replace(/\\.|\[([^\]\\]|\\.)*?\]|\s+|(?:#[^\n]*)/g, function(s) {
|
||||
|
|
@ -98,13 +102,15 @@ function removeXFlag(str) {
|
|||
function transformRegExp(str) {
|
||||
str = removeXFlag(str);
|
||||
str = checkForLookBehind(str);
|
||||
str = checkForInvariantRegex(str);
|
||||
str = str.replace(/\\n(?!\?).?/, '$'); // replace newlines by $ except if its postfixed by ?
|
||||
return str;
|
||||
}
|
||||
|
||||
function assembleStateObjs(strState, pattern) {
|
||||
console.log("assembleStateObjs", strState, pattern);
|
||||
var patterns = pattern.patterns;
|
||||
var stateObj = {};
|
||||
var tokenElem = [];
|
||||
|
||||
if (patterns) {
|
||||
for (var p in patterns) {
|
||||
|
|
@ -114,41 +120,73 @@ function assembleStateObjs(strState, pattern) {
|
|||
stateObj.include = patterns[p].include;
|
||||
}
|
||||
else {
|
||||
stateObj.token = patterns[p].name;
|
||||
if (patterns[p].captures)
|
||||
stateObj.token = extractCaptures(patterns[p].captures);
|
||||
else
|
||||
stateObj.token = patterns[p].name;
|
||||
|
||||
stateObj.regex = transformRegExp(patterns[p].match);
|
||||
}
|
||||
statesObj[strState].push(stateObj);
|
||||
}
|
||||
|
||||
statesObj[strState].push({
|
||||
token: pattern.name,
|
||||
regex: transformRegExp(pattern.end),
|
||||
merge: true,
|
||||
next: "start"
|
||||
});
|
||||
|
||||
stateObj = {};
|
||||
stateObj.token = "TODO";
|
||||
stateObj.regex = transformRegExp(pattern.end);
|
||||
stateObj.next = "start";
|
||||
stateObj.token = pattern.name;
|
||||
stateObj.regex = ".";
|
||||
stateObj.merge = true;
|
||||
stateObj.next = strState;
|
||||
}
|
||||
else {
|
||||
stateObj.token = "TODO";
|
||||
stateObj.regex = transformRegExp(pattern.end);
|
||||
stateObj.next = "start";
|
||||
|
||||
statesObj[strState].push(stateObj);
|
||||
statesObj[strState].push({
|
||||
token: pattern.name,
|
||||
regex: transformRegExp(pattern.end),
|
||||
merge: true,
|
||||
next: "start"
|
||||
});
|
||||
|
||||
stateObj = {};
|
||||
stateObj.token = "TODO";
|
||||
stateObj.regex = ".+";
|
||||
stateObj.token = pattern.name;
|
||||
stateObj.regex = ".";
|
||||
stateObj.merge = true;
|
||||
stateObj.next = strState;
|
||||
}
|
||||
|
||||
return stateObj;
|
||||
}
|
||||
|
||||
function extractCaptures (captures) {
|
||||
if (typeof captures === "object") {
|
||||
var token = [];
|
||||
|
||||
Object.keys(captures).forEach(function (k) {
|
||||
if (captures[k].name) {
|
||||
token.push(captures[k].name);
|
||||
}
|
||||
else {
|
||||
token.push(captures[k]);
|
||||
}
|
||||
});
|
||||
|
||||
return token;
|
||||
}
|
||||
else {
|
||||
return captures;
|
||||
}
|
||||
}
|
||||
|
||||
function extractPatterns(patterns) {
|
||||
var state = 0;
|
||||
patterns.forEach(function(pattern) {
|
||||
state++;
|
||||
var i = 1;
|
||||
var tokenArray = [];
|
||||
var tokenObj = { token: [] };
|
||||
var stateObj = {};
|
||||
|
||||
if (pattern.comment) {
|
||||
startState.start.push(" // " + pattern.comment.trim());
|
||||
|
|
@ -158,13 +196,13 @@ function extractPatterns(patterns) {
|
|||
if (pattern.begin && pattern.end) {
|
||||
var strState = "state_" + state;
|
||||
if ( pattern.beginCaptures === undefined && pattern.endCaptures === undefined) {
|
||||
tokenObj.token.push(pattern.captures);
|
||||
tokenObj.token = tokenObj.token.concat(extractCaptures(pattern.captures));
|
||||
}
|
||||
else if (pattern.beginCaptures) {
|
||||
tokenObj.token.push(pattern.beginCaptures);
|
||||
tokenObj.token = tokenObj.token.concat(extractCaptures(pattern.beginCaptures));
|
||||
}
|
||||
else if (pattern.endCaptures) {
|
||||
tokenObj.token.push(pattern.endCaptures);
|
||||
tokenObj.token = tokenObj.token.concat(extractCaptures(pattern.endCaptures));
|
||||
}
|
||||
|
||||
if (tokenObj.token === undefined) {
|
||||
|
|
@ -189,8 +227,7 @@ function extractPatterns(patterns) {
|
|||
}
|
||||
|
||||
else if (pattern.captures) {
|
||||
tokenObj.token.push([]);
|
||||
tokenObj.token.push(pattern.captures);
|
||||
tokenObj.token = tokenObj.token.concat(extractCaptures(pattern.captures));
|
||||
tokenObj.regex = transformRegExp(pattern.match);
|
||||
}
|
||||
|
||||
|
|
@ -200,8 +237,8 @@ function extractPatterns(patterns) {
|
|||
}
|
||||
|
||||
else if (pattern.include) {
|
||||
tokenObj.token.push(pattern.include);
|
||||
tokenObj.regex = "";
|
||||
// f*ck it
|
||||
return;
|
||||
}
|
||||
|
||||
else {
|
||||
|
|
@ -211,9 +248,9 @@ function extractPatterns(patterns) {
|
|||
}
|
||||
|
||||
// sometimes captures have names--not sure when or why
|
||||
if (pattern.name) {
|
||||
tokenObj.token.push(pattern.name);
|
||||
}
|
||||
// if (pattern.name && tokenObj.token.indexOf(pattern.name) === -1) {
|
||||
// tokenObj.token.push(pattern.name);
|
||||
// }
|
||||
|
||||
startState.start.push(tokenObj);
|
||||
});
|
||||
|
|
@ -267,6 +304,10 @@ function convertLanguage(name) {
|
|||
repository = restoreComments(JSON.stringify(repository, null, " "));
|
||||
}
|
||||
|
||||
if (typeof repository === "string") {
|
||||
repository = JSON.parse(repository);
|
||||
}
|
||||
|
||||
var languageHighlightRules = fillTemplate(modeHighlightTemplate, {
|
||||
language: languageNameSanitized,
|
||||
languageTokens: patterns,
|
||||
|
|
|
|||
362
tool/vbs.tmlanguage
Normal file
362
tool/vbs.tmlanguage
Normal file
|
|
@ -0,0 +1,362 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Modified from the original ASP bundle. Originally modified by Thomas Aylott subtleGradient.com</string>
|
||||
<key>fileTypes</key>
|
||||
<array>
|
||||
<string>vbs</string>
|
||||
<string>vbe</string>
|
||||
<string>wsf</string>
|
||||
<string>wsc</string>
|
||||
</array>
|
||||
<key>foldingStartMarker</key>
|
||||
<string>(<(?i:(head|table|div|style|script|ul|ol|form|dl))\b.*?>|\{|^\s*<?%?\s*'?\s*(?i:(sub|private\s+Sub|public\s+Sub|function|if|while|For))\s*.*$)</string>
|
||||
<key>foldingStopMarker</key>
|
||||
<string>(</(?i:(head|table|div|style|script|ul|ol|form|dl))>?|\}|^\s*<?%?\s*\s*'?\s*(?i:(end|Next))\s*.*$)</string>
|
||||
<key>keyEquivalent</key>
|
||||
<string>^~A</string>
|
||||
<key>name</key>
|
||||
<string>VBScript</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>\n</string>
|
||||
<key>name</key>
|
||||
<string>meta.ending-space</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#round-brackets</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>^(?=\t)</string>
|
||||
<key>end</key>
|
||||
<string>(?=[^\t])</string>
|
||||
<key>name</key>
|
||||
<string>meta.leading-space</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.odd-tab.tabs</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.even-tab.tabs</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>(\t)(\t)?</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>^(?= )</string>
|
||||
<key>end</key>
|
||||
<string>(?=[^ ])</string>
|
||||
<key>name</key>
|
||||
<string>meta.leading-space</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.odd-tab.spaces</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.even-tab.spaces</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>( )( )?</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.type.function.asp</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>entity.name.function.asp</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.parameters.asp</string>
|
||||
</dict>
|
||||
<key>4</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>variable.parameter.function.asp</string>
|
||||
</dict>
|
||||
<key>5</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.parameters.asp</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>^\s*((?i:function|sub))\s*([a-zA-Z_]\w*)\s*(\()([^)]*)(\)).*\n?</string>
|
||||
<key>name</key>
|
||||
<string>meta.function.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>('|REM)</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.comment.asp</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?=(\n|%>))</string>
|
||||
<key>name</key>
|
||||
<string>comment.line.apostrophe.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\b(If|Then|Else|ElseIf|Else If|End If|While|Wend|For|To|Each|Case|Select|End Select|Return|Continue|Do|Until|Loop|Next|With|Exit Do|Exit For|Exit Function|Exit Property|Exit Sub|IIf)\b)</string>
|
||||
<key>name</key>
|
||||
<string>keyword.control.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\b(Mod|And|Not|Or|Xor|as)\b)</string>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.type.asp</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>variable.other.bfeac.asp</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.separator.comma.asp</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>(?i:(dim)\s*(?:(\b[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\b)\s*(,?)))</string>
|
||||
<key>name</key>
|
||||
<string>variable.other.dim.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\s*\b(Call|Class|Const|Dim|Redim|Function|Sub|Private Sub|Public Sub|End sub|End Function|Set|Let|Get|New|Randomize|Option Explicit|On Error Resume Next|On Error GoTo)\b\s*)</string>
|
||||
<key>name</key>
|
||||
<string>storage.type.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\b(Private|Public|Default)\b)</string>
|
||||
<key>name</key>
|
||||
<string>storage.modifier.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\s*\b(Empty|False|Nothing|Null|True)\b)</string>
|
||||
<key>name</key>
|
||||
<string>constant.language.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>"</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.string.begin.asp</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>"</string>
|
||||
<key>endCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.string.end.asp</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>name</key>
|
||||
<string>string.quoted.double.asp</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>""</string>
|
||||
<key>name</key>
|
||||
<string>constant.character.escape.apostrophe.asp</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.definition.variable.asp</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>(\$)[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\b\s*</string>
|
||||
<key>name</key>
|
||||
<string>variable.other.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\b(Application|ObjectContext|Request|Response|Server|Session)\b)</string>
|
||||
<key>name</key>
|
||||
<string>support.class.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\b(Contents|StaticObjects|ClientCertificate|Cookies|Form|QueryString|ServerVariables)\b)</string>
|
||||
<key>name</key>
|
||||
<string>support.class.collection.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\b(TotalBytes|Buffer|CacheControl|Charset|ContentType|Expires|ExpiresAbsolute|IsClientConnected|PICS|Status|ScriptTimeout|CodePage|LCID|SessionID|Timeout)\b)</string>
|
||||
<key>name</key>
|
||||
<string>support.constant.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\b(Lock|Unlock|SetAbort|SetComplete|BianryRead|AddHeader|AppendToLog|BinaryWrite|Clear|End|Flush|Redirect|Write|CreateObject|HTMLEncode|MapPath|URLEncode|Abandon|Convert|Regex)\b)</string>
|
||||
<key>name</key>
|
||||
<string>support.function.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\b(Application_OnEnd|Application_OnStart|OnTransactionAbort|OnTransactionCommit|Session_OnEnd|Session_OnStart)\b)</string>
|
||||
<key>name</key>
|
||||
<string>support.function.event.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:(?<=as )(\b[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\b))</string>
|
||||
<key>name</key>
|
||||
<string>support.type.vb.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\b(Array|Add|Asc|Atn|CBool|CByte|CCur|CDate|CDbl|Chr|CInt|CLng|Conversions|Cos|CreateObject|CSng|CStr|Date|DateAdd|DateDiff|DatePart|DateSerial|DateValue|Day|Derived|Math|Escape|Eval|Exists|Exp|Filter|FormatCurrency|FormatDateTime|FormatNumber|FormatPercent|GetLocale|GetObject|GetRef|Hex|Hour|InputBox|InStr|InStrRev|Int|Fix|IsArray|IsDate|IsEmpty|IsNull|IsNumeric|IsObject|Item|Items|Join|Keys|LBound|LCase|Left|Len|LoadPicture|Log|LTrim|RTrim|Trim|Maths|Mid|Minute|Month|MonthName|MsgBox|Now|Oct|Remove|RemoveAll|Replace|RGB|Right|Rnd|Round|ScriptEngine|ScriptEngineBuildVersion|ScriptEngineMajorVersion|ScriptEngineMinorVersion|Second|SetLocale|Sgn|Sin|Space|Split|Sqr|StrComp|String|StrReverse|Tan|Time|Timer|TimeSerial|TimeValue|TypeName|UBound|UCase|Unescape|VarType|Weekday|WeekdayName|Year)\b)</string>
|
||||
<key>name</key>
|
||||
<string>support.function.vb.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>-?\b(?:(?:0(?:x|X)[0-9a-fA-F]*)|(?:(?:[0-9]+\.?[0-9]*)|(?:\.[0-9]+))(?:(?:e|E)(?:\+|-)?[0-9]+)?)(?:L|l|UL|ul|u|U|F|f)?\b</string>
|
||||
<key>name</key>
|
||||
<string>constant.numeric.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:\b(vbtrue|fvbalse|vbcr|vbcrlf|vbformfeed|vblf|vbnewline|vbnullchar|vbnullstring|int32|vbtab|vbverticaltab|vbbinarycompare|vbtextcomparevbsunday|vbmonday|vbtuesday|vbwednesday|vbthursday|vbfriday|vbsaturday|vbusesystemdayofweek|vbfirstjan1|vbfirstfourdays|vbfirstfullweek|vbgeneraldate|vblongdate|vbshortdate|vblongtime|vbshorttime|vbobjecterror|vbEmpty|vbNull|vbInteger|vbLong|vbSingle|vbDouble|vbCurrency|vbDate|vbString|vbObject|vbError|vbBoolean|vbVariant|vbDataObject|vbDecimal|vbByte|vbArray)\b)</string>
|
||||
<key>name</key>
|
||||
<string>support.type.vb.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>entity.name.function.asp</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>match</key>
|
||||
<string>(?i:(\b[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\b)(?=\(\)?))</string>
|
||||
<key>name</key>
|
||||
<string>support.function.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?i:((?<=(\+|=|-|\&|\\|/|<|>|\(|,))\s*\b([a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?)\b(?!(\(|\.))|\b([a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?)\b(?=\s*(\+|=|-|\&|\\|/|<|>|\(|\)))))</string>
|
||||
<key>name</key>
|
||||
<string>variable.other.asp</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|/=|%=|\+=|\-=|&=|\^=|\b(in|instanceof|new|delete|typeof|void)\b</string>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.js</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>repository</key>
|
||||
<dict>
|
||||
<key>round-brackets</key>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>\(</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.section.round-brackets.begin.asp</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>\)</string>
|
||||
<key>endCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.section.round-brackets.end.asp</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>name</key>
|
||||
<string>meta.round-brackets</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>source.vbs</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>scopeName</key>
|
||||
<string>source.vbs</string>
|
||||
<key>uuid</key>
|
||||
<string>7F9C9343-D48E-4E7D-BFE8-F680714DCD3E</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Loading…
Add table
Add a link
Reference in a new issue