From a64855b8bf7c455dde8b14adea4771b30b8385db Mon Sep 17 00:00:00 2001 From: Jan Jongboom Date: Fri, 16 Nov 2012 10:08:56 -0500 Subject: [PATCH 1/3] Wip --- tool/tmlanguage.js | 54 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/tool/tmlanguage.js b/tool/tmlanguage.js index 988409c3..3694d003 100644 --- a/tool/tmlanguage.js +++ b/tool/tmlanguage.js @@ -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,6 +102,7 @@ function removeXFlag(str) { function transformRegExp(str) { str = removeXFlag(str); str = checkForLookBehind(str); + str = checkForInvariantRegex(str); return str; } @@ -121,19 +126,19 @@ function assembleStateObjs(strState, pattern) { } stateObj = {}; - stateObj.token = "TODO"; + stateObj.token = []; stateObj.regex = transformRegExp(pattern.end); stateObj.next = "start"; } else { - stateObj.token = "TODO"; + stateObj.token = []; stateObj.regex = transformRegExp(pattern.end); stateObj.next = "start"; statesObj[strState].push(stateObj); stateObj = {}; - stateObj.token = "TODO"; + stateObj.token = []; stateObj.regex = ".+"; stateObj.next = strState; } @@ -141,14 +146,32 @@ function assembleStateObjs(strState, pattern) { 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 +181,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 +212,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); } @@ -211,9 +233,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); }); @@ -266,7 +288,11 @@ 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, From bf586857321c4b11a81167924f600f9bb406244a Mon Sep 17 00:00:00 2001 From: Jan Jongboom Date: Thu, 22 Nov 2012 13:34:18 -0500 Subject: [PATCH 2/3] Tool shizzle --- tool/test.tmlanguage | 58 +++++++ tool/tmlanguage.js | 45 ++++-- tool/vbs.tmlanguage | 362 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 450 insertions(+), 15 deletions(-) create mode 100644 tool/test.tmlanguage create mode 100644 tool/vbs.tmlanguage diff --git a/tool/test.tmlanguage b/tool/test.tmlanguage new file mode 100644 index 00000000..5481f2d8 --- /dev/null +++ b/tool/test.tmlanguage @@ -0,0 +1,58 @@ + + + + + comment + Modified from the original ASP bundle. Originally modified by Thomas Aylott subtleGradient.com + fileTypes + + vbs + vbe + wsf + wsc + + foldingStartMarker + (<(?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*.*$) + foldingStopMarker + (</(?i:(head|table|div|style|script|ul|ol|form|dl))>?|\}|^\s*<?%?\s*\s*'?\s*(?i:(end|Next))\s*.*$) + keyEquivalent + ^~A + name + VBScript + patterns + + + begin + ^(?=\t) + end + (?=[^\t]) + name + meta.leading-space + patterns + + + captures + + 1 + + name + meta.odd-tab.tabs + + 2 + + name + meta.even-tab.tabs + + + match + (\t)(\t)? + + + + + scopeName + source.vbs + uuid + 7F9C9343-D48E-4E7D-BFE8-F680714DCD3E + + \ No newline at end of file diff --git a/tool/tmlanguage.js b/tool/tmlanguage.js index 3694d003..5f024eba 100644 --- a/tool/tmlanguage.js +++ b/tool/tmlanguage.js @@ -103,13 +103,14 @@ 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) { @@ -119,27 +120,41 @@ 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 = []; - stateObj.regex = transformRegExp(pattern.end); - stateObj.next = "start"; + stateObj.token = pattern.name; + stateObj.regex = "."; + stateObj.merge = true; + stateObj.next = strState; } else { - stateObj.token = []; - 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 = []; - stateObj.regex = ".+"; + stateObj.token = pattern.name; + stateObj.regex = "."; + stateObj.merge = true; stateObj.next = strState; } @@ -222,8 +237,8 @@ function extractPatterns(patterns) { } else if (pattern.include) { - tokenObj.token.push(pattern.include); - tokenObj.regex = ""; + // f*ck it + return; } else { diff --git a/tool/vbs.tmlanguage b/tool/vbs.tmlanguage new file mode 100644 index 00000000..fb46c054 --- /dev/null +++ b/tool/vbs.tmlanguage @@ -0,0 +1,362 @@ + + + + + comment + Modified from the original ASP bundle. Originally modified by Thomas Aylott subtleGradient.com + fileTypes + + vbs + vbe + wsf + wsc + + foldingStartMarker + (<(?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*.*$) + foldingStopMarker + (</(?i:(head|table|div|style|script|ul|ol|form|dl))>?|\}|^\s*<?%?\s*\s*'?\s*(?i:(end|Next))\s*.*$) + keyEquivalent + ^~A + name + VBScript + patterns + + + match + \n + name + meta.ending-space + + + include + #round-brackets + + + begin + ^(?=\t) + end + (?=[^\t]) + name + meta.leading-space + patterns + + + captures + + 1 + + name + meta.odd-tab.tabs + + 2 + + name + meta.even-tab.tabs + + + match + (\t)(\t)? + + + + + begin + ^(?= ) + end + (?=[^ ]) + name + meta.leading-space + patterns + + + captures + + 1 + + name + meta.odd-tab.spaces + + 2 + + name + meta.even-tab.spaces + + + match + ( )( )? + + + + + captures + + 1 + + name + storage.type.function.asp + + 2 + + name + entity.name.function.asp + + 3 + + name + punctuation.definition.parameters.asp + + 4 + + name + variable.parameter.function.asp + + 5 + + name + punctuation.definition.parameters.asp + + + match + ^\s*((?i:function|sub))\s*([a-zA-Z_]\w*)\s*(\()([^)]*)(\)).*\n? + name + meta.function.asp + + + begin + ('|REM) + beginCaptures + + 0 + + name + punctuation.definition.comment.asp + + + end + (?=(\n|%>)) + name + comment.line.apostrophe.asp + + + match + (?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) + name + keyword.control.asp + + + match + (?i:\b(Mod|And|Not|Or|Xor|as)\b) + name + keyword.operator.asp + + + captures + + 1 + + name + storage.type.asp + + 2 + + name + variable.other.bfeac.asp + + 3 + + name + meta.separator.comma.asp + + + match + (?i:(dim)\s*(?:(\b[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\b)\s*(,?))) + name + variable.other.dim.asp + + + match + (?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*) + name + storage.type.asp + + + match + (?i:\b(Private|Public|Default)\b) + name + storage.modifier.asp + + + match + (?i:\s*\b(Empty|False|Nothing|Null|True)\b) + name + constant.language.asp + + + begin + " + beginCaptures + + 0 + + name + punctuation.definition.string.begin.asp + + + end + " + endCaptures + + 0 + + name + punctuation.definition.string.end.asp + + + name + string.quoted.double.asp + patterns + + + match + "" + name + constant.character.escape.apostrophe.asp + + + + + captures + + 1 + + name + punctuation.definition.variable.asp + + + match + (\$)[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\b\s* + name + variable.other.asp + + + match + (?i:\b(Application|ObjectContext|Request|Response|Server|Session)\b) + name + support.class.asp + + + match + (?i:\b(Contents|StaticObjects|ClientCertificate|Cookies|Form|QueryString|ServerVariables)\b) + name + support.class.collection.asp + + + match + (?i:\b(TotalBytes|Buffer|CacheControl|Charset|ContentType|Expires|ExpiresAbsolute|IsClientConnected|PICS|Status|ScriptTimeout|CodePage|LCID|SessionID|Timeout)\b) + name + support.constant.asp + + + match + (?i:\b(Lock|Unlock|SetAbort|SetComplete|BianryRead|AddHeader|AppendToLog|BinaryWrite|Clear|End|Flush|Redirect|Write|CreateObject|HTMLEncode|MapPath|URLEncode|Abandon|Convert|Regex)\b) + name + support.function.asp + + + match + (?i:\b(Application_OnEnd|Application_OnStart|OnTransactionAbort|OnTransactionCommit|Session_OnEnd|Session_OnStart)\b) + name + support.function.event.asp + + + match + (?i:(?<=as )(\b[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\b)) + name + support.type.vb.asp + + + match + (?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) + name + support.function.vb.asp + + + match + -?\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 + name + constant.numeric.asp + + + match + (?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) + name + support.type.vb.asp + + + captures + + 1 + + name + entity.name.function.asp + + + match + (?i:(\b[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\b)(?=\(\)?)) + name + support.function.asp + + + match + (?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*(\+|=|-|\&|\\|/|<|>|\(|\))))) + name + variable.other.asp + + + match + !|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|/=|%=|\+=|\-=|&=|\^=|\b(in|instanceof|new|delete|typeof|void)\b + name + keyword.operator.js + + + repository + + round-brackets + + begin + \( + beginCaptures + + 0 + + name + punctuation.section.round-brackets.begin.asp + + + end + \) + endCaptures + + 0 + + name + punctuation.section.round-brackets.end.asp + + + name + meta.round-brackets + patterns + + + include + source.vbs + + + + + scopeName + source.vbs + uuid + 7F9C9343-D48E-4E7D-BFE8-F680714DCD3E + + \ No newline at end of file From f74824a9b46fd3a64ed766600c50945b11498c4f Mon Sep 17 00:00:00 2001 From: Jan Jongboom Date: Thu, 22 Nov 2012 13:34:31 -0500 Subject: [PATCH 3/3] Add vbscript mode --- lib/ace/mode/vbscript.js | 60 +++++ lib/ace/mode/vbscript_highlight_rules.js | 318 +++++++++++++++++++++++ 2 files changed, 378 insertions(+) create mode 100644 lib/ace/mode/vbscript.js create mode 100644 lib/ace/mode/vbscript_highlight_rules.js diff --git a/lib/ace/mode/vbscript.js b/lib/ace/mode/vbscript.js new file mode 100644 index 00000000..a2d52c44 --- /dev/null +++ b/lib/ace/mode/vbscript.js @@ -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; +}); \ No newline at end of file diff --git a/lib/ace/mode/vbscript_highlight_rules.js b/lib/ace/mode/vbscript_highlight_rules.js new file mode 100644 index 00000000..b7e1a3ba --- /dev/null +++ b/lib/ace/mode/vbscript_highlight_rules.js @@ -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; +}); \ No newline at end of file