From ce2638c10b2606965e2bbf5a3302b66fa12e1c1a Mon Sep 17 00:00:00 2001 From: Jan Jongboom Date: Thu, 22 Nov 2012 13:34:31 -0500 Subject: [PATCH 1/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 From b4243b9f079650c942e0f70e8d29aa632440e463 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 28 Dec 2012 02:06:53 +0400 Subject: [PATCH 2/3] cleanup and fix comments --- lib/ace/mode/vbscript_highlight_rules.js | 212 +++++++++-------------- 1 file changed, 85 insertions(+), 127 deletions(-) diff --git a/lib/ace/mode/vbscript_highlight_rules.js b/lib/ace/mode/vbscript_highlight_rules.js index b7e1a3ba..25edae52 100644 --- a/lib/ace/mode/vbscript_highlight_rules.js +++ b/lib/ace/mode/vbscript_highlight_rules.js @@ -26,35 +26,11 @@ * (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"; @@ -67,37 +43,34 @@ var VBScriptHighlightRules = function() { // regexp must not have capturing parentheses. Use (?:) instead. // regexps are ordered -> the first match is used - this.$rules = - { + this.$rules = { "start": [ { - "token": [ + token: [ "meta.ending-space" ], - "regex": "$" + regex: "$" }, // { -// "token": [ +// token: [ // "#round-brackets" // ], -// "regex": "" +// regex: "" // }, { - "token": [ + token: [ null ], - "regex": "^(?=\\t)", - "next": "state_3" + regex: "^(?=\\t)", + next: "state_3" }, { - "token": [ - null - ], - "regex": "^(?= )", - "next": "state_4" + token: [null], + regex: "^(?= )", + next: "state_4" }, { - "token": [ + token: [ "storage.type.function.asp", "text", "entity.name.function.asp", @@ -106,210 +79,195 @@ var VBScriptHighlightRules = function() { "variable.parameter.function.asp", "punctuation.definition.parameters.asp" ], - "regex": "^\\s*((?:Function|Sub))(\\s*)([a-zA-Z_]\\w*)(\\s*)(\\()([^)]*)(\\)).*\\n?" + regex: "^\\s*((?:Function|Sub))(\\s*)([a-zA-Z_]\\w*)(\\s*)(\\()([^)]*)(\\)).*\\n?" }, { - "token": [ - "punctuation.definition.comment.asp" - ], - "regex": "('|REM)", - "next": "state_6" + token: "punctuation.definition.comment.asp", + regex: "'|REM", + next: "comment" }, { - "token": [ + 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)" + 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": [ + token: [ "keyword.operator.asp" ], - "regex": "(?:\\b(Mod|And|Not|Or|Xor|as)\\b)" + regex: "(?:\\b(Mod|And|Not|Or|Xor|as)\\b)" }, { - "token": [ + 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" + 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": [ + token: [ "storage.modifier.asp" ], - "regex": "(?:\\b(Private|Public|Default)\\b)" + regex: "(?:\\b(Private|Public|Default)\\b)" }, { - "token": [ + token: [ "constant.language.asp" ], - "regex": "(?:\\s*\\b(Empty|False|Nothing|Null|True)\\b)" + regex: "(?:\\s*\\b(Empty|False|Nothing|Null|True)\\b)" }, { - "token": [ + token: [ "punctuation.definition.string.begin.asp" ], - "regex": "\"", - "next": "state_13" + regex: '"', + next: "string" }, { - "token": [ + token: [ "punctuation.definition.variable.asp" ], - "regex": "(\\$)[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\\b\\s*" + regex: "(\\$)[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\\b\\s*" }, { - "token": [ + token: [ "support.class.asp" ], - "regex": "(?:\\b(Application|ObjectContext|Request|Response|Server|Session)\\b)" + regex: "(?:\\b(Application|ObjectContext|Request|Response|Server|Session)\\b)" }, { - "token": [ + token: [ "support.class.collection.asp" ], - "regex": "(?:\\b(Contents|StaticObjects|ClientCertificate|Cookies|Form|QueryString|ServerVariables)\\b)" + regex: "(?:\\b(Contents|StaticObjects|ClientCertificate|Cookies|Form|QueryString|ServerVariables)\\b)" }, { - "token": [ + token: [ "support.constant.asp" ], - "regex": "(?:\\b(TotalBytes|Buffer|CacheControl|Charset|ContentType|Expires|ExpiresAbsolute|IsClientConnected|PICS|Status|ScriptTimeout|CodePage|LCID|SessionID|Timeout)\\b)" + regex: "(?:\\b(TotalBytes|Buffer|CacheControl|Charset|ContentType|Expires|ExpiresAbsolute|IsClientConnected|PICS|Status|ScriptTimeout|CodePage|LCID|SessionID|Timeout)\\b)" }, { - "token": [ + 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)" + regex: "(?:\\b(Lock|Unlock|SetAbort|SetComplete|BianryRead|AddHeader|AppendToLog|BinaryWrite|Clear|End|Flush|Redirect|Write|CreateObject|HTMLEncode|MapPath|URLEncode|Abandon|Convert|Regex)\\b)" }, { - "token": [ + token: [ "support.function.event.asp" ], - "regex": "(?:\\b(Application_OnEnd|Application_OnStart|OnTransactionAbort|OnTransactionCommit|Session_OnEnd|Session_OnStart)\\b)" + regex: "(?:\\b(Application_OnEnd|Application_OnStart|OnTransactionAbort|OnTransactionCommit|Session_OnEnd|Session_OnStart)\\b)" }, // { -// "token": [ +// 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 :(" +// 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": [ + 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)" + 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": [ + 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" + 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": [ + 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)" + 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": [ + token: [ "entity.name.function.asp" ], - "regex": "(?:(\\b[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\\b)(?=\\(\\)?))" + regex: "(?:(\\b[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\\b)(?=\\(\\)?))" }, // { -// "token": [ +// 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 :(" +// 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": [ + token: [ "keyword.operator.asp" ], - "regex": "\\-|\\+|\\*\\\/|\\>|\\<|\\=|\\&" + regex: "\\-|\\+|\\*\\\/|\\>|\\<|\\=|\\&" } ], "state_3": [ { - "token": [ + token: [ "meta.odd-tab.tabs", "meta.even-tab.tabs" ], - "regex": "(\\t)(\\t)?" + regex: "(\\t)(\\t)?" }, { - "token": "meta.leading-space", - "regex": "(?=[^\\t])", - "merge": true, - "next": "start" + token: "meta.leading-space", + regex: "(?=[^\\t])", + next: "start" }, { - "token": "meta.leading-space", - "regex": ".", - "merge": true, - "next": "state_3" + token: "meta.leading-space", + regex: ".", + next: "state_3" } ], "state_4": [ { - "token": [ + token: [ "meta.odd-tab.spaces", "meta.even-tab.spaces" ], - "regex": "( )( )?" + regex: "( )( )?" }, { - "token": "meta.leading-space", - "regex": "(?=[^ ])", - "merge": true, - "next": "start" + token: "meta.leading-space", + regex: "(?=[^ ])", + next: "start" }, { - "token": "meta.leading-space", - "regex": ".", - "merge": true, - "next": "state_4" + token: "meta.leading-space", + regex: ".", + next: "state_4" } ], - "state_6": [ + "comment": [ { - "token": "comment.line.apostrophe.asp", - "regex": "(?=(?:$|%>))", - "merge": true, - "next": "start" + token: "comment.line.apostrophe.asp", + regex: "$|(?=(?:%>))", + next: "start" }, { - "token": "comment.line.apostrophe.asp", - "regex": ".", - "merge": true, - "next": "state_6" + token: "comment.line.apostrophe.asp", + regex: ".", } ], - "state_13": [ + "string": [ { - "token": "constant.character.escape.apostrophe.asp", - "regex": "\"\"" + token: "constant.character.escape.apostrophe.asp", + regex: '""' }, { - "token": "string.quoted.double.asp", - "regex": "\"", - "merge": true, - "next": "start" + token: "string.quoted.double.asp", + regex: '"', + next: "start" }, { - "token": "string.quoted.double.asp", - "regex": ".", - "merge": true, - "next": "state_13" + token: "string.quoted.double.asp", + regex: "." } ] } - /*** START REPOSITORY RULES -[object Object] -END REPOSITORY RULES ***/ }; oop.inherits(VBScriptHighlightRules, TextHighlightRules); From b6094d9472f2bbfaa339ed13bc6616149eb85ab6 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 28 Dec 2012 02:07:29 +0400 Subject: [PATCH 3/3] add vbscript demo --- demo/kitchen-sink/doclist.js | 1 + demo/kitchen-sink/docs/vbscript.vbs | 23 +++++++++++++++++++++++ demo/kitchen-sink/modelist.js | 1 + 3 files changed, 25 insertions(+) create mode 100644 demo/kitchen-sink/docs/vbscript.vbs diff --git a/demo/kitchen-sink/doclist.js b/demo/kitchen-sink/doclist.js index db1383fe..7e970d22 100644 --- a/demo/kitchen-sink/doclist.js +++ b/demo/kitchen-sink/doclist.js @@ -119,6 +119,7 @@ var docs = { "docs/tex.tex": "Tex", "docs/textile.textile": {name: "Textile", wrapped: true}, "docs/typescript.ts": "Typescript", + "docs/vbscript.vbs": "VBScript", "docs/xml.xml": "XML", "docs/xquery.xq": "XQuery", "docs/yaml.yaml": "YAML", diff --git a/demo/kitchen-sink/docs/vbscript.vbs b/demo/kitchen-sink/docs/vbscript.vbs new file mode 100644 index 00000000..ace5c9f9 --- /dev/null +++ b/demo/kitchen-sink/docs/vbscript.vbs @@ -0,0 +1,23 @@ +myfilename = "C:\Wikipedia - VBScript - Example - Hello World.txt" +MakeHelloWorldFile myfilename + +Sub MakeHelloWorldFile (FileName) +'Create a new file in C: drive or overwrite existing file + Set FSO = CreateObject("Scripting.FileSystemObject") + If FSO.FileExists(FileName) Then + Answer = MsgBox ("File " & FileName & " exists ... OK to overwrite?", vbOKCancel) + 'If button selected is not OK, then quit now + 'vbOK is a language constant + If Answer <> vbOK Then Exit Sub + Else + 'Confirm OK to create + Answer = MsgBox ("File " & FileName & " ... OK to create?", vbOKCancel) + If Answer <> vbOK Then Exit Sub + End If + 'Create new file (or replace an existing file) + Set FileObject = FSO.CreateTextFile (FileName) + FileObject.WriteLine "Time ... " & Now() + FileObject.WriteLine "Hello World" + FileObject.Close() + MsgBox "File " & FileName & " ... updated." +End Sub \ No newline at end of file diff --git a/demo/kitchen-sink/modelist.js b/demo/kitchen-sink/modelist.js index 6c87f851..20e86659 100644 --- a/demo/kitchen-sink/modelist.js +++ b/demo/kitchen-sink/modelist.js @@ -91,6 +91,7 @@ var modesByName = { text: ["Text" , "txt"], textile: ["Textile" , "textile"], typescript: ["Typescript" , "typescript|ts|str"], + vbscript: ["VBScript" , "vbs"], xml: ["XML" , "xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"], xquery: ["XQuery" , "xq"], yaml: ["YAML" , "yaml"]