Skip to content
This repository
Browse code

Add vbscript mode

  • Loading branch information...
commit f74824a9b46fd3a64ed766600c50945b11498c4f 1 parent bf58685
Jan Jongboom janjongboom authored
60 lib/ace/mode/vbscript.js
... ... @@ -0,0 +1,60 @@
  1 +/* ***** BEGIN LICENSE BLOCK *****
  2 + * Distributed under the BSD license:
  3 + *
  4 + * Copyright (c) 2012, Ajax.org B.V.
  5 + * All rights reserved.
  6 + *
  7 + * Redistribution and use in source and binary forms, with or without
  8 + * modification, are permitted provided that the following conditions are met:
  9 + * * Redistributions of source code must retain the above copyright
  10 + * notice, this list of conditions and the following disclaimer.
  11 + * * Redistributions in binary form must reproduce the above copyright
  12 + * notice, this list of conditions and the following disclaimer in the
  13 + * documentation and/or other materials provided with the distribution.
  14 + * * Neither the name of Ajax.org B.V. nor the
  15 + * names of its contributors may be used to endorse or promote products
  16 + * derived from this software without specific prior written permission.
  17 + *
  18 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21 + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  22 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28 + *
  29 + *
  30 + * Contributor(s):
  31 + *
  32 + *
  33 + *
  34 + * ***** END LICENSE BLOCK ***** */
  35 +
  36 +/*
  37 + THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
  38 +*/
  39 +
  40 +define(function(require, exports, module) {
  41 +"use strict";
  42 +
  43 +var oop = require("../lib/oop");
  44 +var TextMode = require("./text").Mode;
  45 +var Tokenizer = require("../tokenizer").Tokenizer;
  46 +var VBScriptHighlightRules = require("./vbscript_highlight_rules").VBScriptHighlightRules;
  47 +
  48 +var Mode = function() {
  49 + var highlighter = new VBScriptHighlightRules();
  50 +
  51 + this.$tokenizer = new Tokenizer(highlighter.getRules());
  52 +};
  53 +oop.inherits(Mode, TextMode);
  54 +
  55 +(function() {
  56 + // Extra logic goes here.
  57 +}).call(Mode.prototype);
  58 +
  59 +exports.Mode = Mode;
  60 +});
318 lib/ace/mode/vbscript_highlight_rules.js
... ... @@ -0,0 +1,318 @@
  1 +/* ***** BEGIN LICENSE BLOCK *****
  2 + * Distributed under the BSD license:
  3 + *
  4 + * Copyright (c) 2012, Ajax.org B.V.
  5 + * All rights reserved.
  6 + *
  7 + * Redistribution and use in source and binary forms, with or without
  8 + * modification, are permitted provided that the following conditions are met:
  9 + * * Redistributions of source code must retain the above copyright
  10 + * notice, this list of conditions and the following disclaimer.
  11 + * * Redistributions in binary form must reproduce the above copyright
  12 + * notice, this list of conditions and the following disclaimer in the
  13 + * documentation and/or other materials provided with the distribution.
  14 + * * Neither the name of Ajax.org B.V. nor the
  15 + * names of its contributors may be used to endorse or promote products
  16 + * derived from this software without specific prior written permission.
  17 + *
  18 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21 + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  22 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28 + *
  29 + *
  30 + * Contributor(s):
  31 + *
  32 + *
  33 + *
  34 + * ***** END LICENSE BLOCK ***** */
  35 +
  36 +/*
  37 + THIS FILE WAS AUTOGENERATED BY mode_highlight_rules.tmpl.js (UUID: 7F9C9343-D48E-4E7D-BFE8-F680714DCD3E) */
  38 +
  39 +/*******
  40 +
  41 + THIS FILE MIGHT NOT BE PERFECT, PARTICULARLY:
  42 +
  43 + IN DECIDING STATES TO TRANSITION TO,
  44 +
  45 + IGNORING WHITESPACE,
  46 +
  47 + IGNORING GROUPS WITH ?:,
  48 +
  49 + EXTENDING EXISTING MODES,
  50 +
  51 + GATHERING KEYWORDS, OR
  52 +
  53 + RULE PREFERENCE ORDER.
  54 +
  55 + ...But it's a good start from an existing *.tmlanguage file.
  56 +
  57 +*******/
  58 +
  59 +define(function(require, exports, module) {
  60 +"use strict";
  61 +
  62 +var oop = require("../lib/oop");
  63 +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  64 +
  65 +var VBScriptHighlightRules = function() {
  66 +
  67 + // regexp must not have capturing parentheses. Use (?:) instead.
  68 + // regexps are ordered -> the first match is used
  69 +
  70 + this.$rules =
  71 + {
  72 + "start": [
  73 + {
  74 + "token": [
  75 + "meta.ending-space"
  76 + ],
  77 + "regex": "$"
  78 + },
  79 +// {
  80 +// "token": [
  81 +// "#round-brackets"
  82 +// ],
  83 +// "regex": ""
  84 +// },
  85 + {
  86 + "token": [
  87 + null
  88 + ],
  89 + "regex": "^(?=\\t)",
  90 + "next": "state_3"
  91 + },
  92 + {
  93 + "token": [
  94 + null
  95 + ],
  96 + "regex": "^(?= )",
  97 + "next": "state_4"
  98 + },
  99 + {
  100 + "token": [
  101 + "storage.type.function.asp",
  102 + "text",
  103 + "entity.name.function.asp",
  104 + "text",
  105 + "punctuation.definition.parameters.asp",
  106 + "variable.parameter.function.asp",
  107 + "punctuation.definition.parameters.asp"
  108 + ],
  109 + "regex": "^\\s*((?:Function|Sub))(\\s*)([a-zA-Z_]\\w*)(\\s*)(\\()([^)]*)(\\)).*\\n?"
  110 + },
  111 + {
  112 + "token": [
  113 + "punctuation.definition.comment.asp"
  114 + ],
  115 + "regex": "('|REM)",
  116 + "next": "state_6"
  117 + },
  118 + {
  119 + "token": [
  120 + "keyword.control.asp"
  121 + ],
  122 + "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)"
  123 + },
  124 + {
  125 + "token": [
  126 + "keyword.operator.asp"
  127 + ],
  128 + "regex": "(?:\\b(Mod|And|Not|Or|Xor|as)\\b)"
  129 + },
  130 + {
  131 + "token": [
  132 + "storage.type.asp"
  133 + ],
  134 + "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"
  135 + },
  136 + {
  137 + "token": [
  138 + "storage.modifier.asp"
  139 + ],
  140 + "regex": "(?:\\b(Private|Public|Default)\\b)"
  141 + },
  142 + {
  143 + "token": [
  144 + "constant.language.asp"
  145 + ],
  146 + "regex": "(?:\\s*\\b(Empty|False|Nothing|Null|True)\\b)"
  147 + },
  148 + {
  149 + "token": [
  150 + "punctuation.definition.string.begin.asp"
  151 + ],
  152 + "regex": "\"",
  153 + "next": "state_13"
  154 + },
  155 + {
  156 + "token": [
  157 + "punctuation.definition.variable.asp"
  158 + ],
  159 + "regex": "(\\$)[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\\b\\s*"
  160 + },
  161 + {
  162 + "token": [
  163 + "support.class.asp"
  164 + ],
  165 + "regex": "(?:\\b(Application|ObjectContext|Request|Response|Server|Session)\\b)"
  166 + },
  167 + {
  168 + "token": [
  169 + "support.class.collection.asp"
  170 + ],
  171 + "regex": "(?:\\b(Contents|StaticObjects|ClientCertificate|Cookies|Form|QueryString|ServerVariables)\\b)"
  172 + },
  173 + {
  174 + "token": [
  175 + "support.constant.asp"
  176 + ],
  177 + "regex": "(?:\\b(TotalBytes|Buffer|CacheControl|Charset|ContentType|Expires|ExpiresAbsolute|IsClientConnected|PICS|Status|ScriptTimeout|CodePage|LCID|SessionID|Timeout)\\b)"
  178 + },
  179 + {
  180 + "token": [
  181 + "support.function.asp"
  182 + ],
  183 + "regex": "(?:\\b(Lock|Unlock|SetAbort|SetComplete|BianryRead|AddHeader|AppendToLog|BinaryWrite|Clear|End|Flush|Redirect|Write|CreateObject|HTMLEncode|MapPath|URLEncode|Abandon|Convert|Regex)\\b)"
  184 + },
  185 + {
  186 + "token": [
  187 + "support.function.event.asp"
  188 + ],
  189 + "regex": "(?:\\b(Application_OnEnd|Application_OnStart|OnTransactionAbort|OnTransactionCommit|Session_OnEnd|Session_OnStart)\\b)"
  190 + },
  191 +// {
  192 +// "token": [
  193 +// "support.type.vb.asp"
  194 +// ],
  195 +// "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 :("
  196 +// },
  197 + {
  198 + "token": [
  199 + "support.function.vb.asp"
  200 + ],
  201 + "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)"
  202 + },
  203 + {
  204 + "token": [
  205 + "constant.numeric.asp"
  206 + ],
  207 + "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"
  208 + },
  209 + {
  210 + "token": [
  211 + "support.type.vb.asp"
  212 + ],
  213 + "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)"
  214 + },
  215 + {
  216 + "token": [
  217 + "entity.name.function.asp"
  218 + ],
  219 + "regex": "(?:(\\b[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\\b)(?=\\(\\)?))"
  220 + },
  221 +// {
  222 +// "token": [
  223 +// "variable.other.asp"
  224 +// ],
  225 +// "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 :("
  226 +// },
  227 + {
  228 + "token": [
  229 + "keyword.operator.asp"
  230 + ],
  231 + "regex": "\\-|\\+|\\*\\\/|\\>|\\<|\\=|\\&"
  232 + }
  233 + ],
  234 + "state_3": [
  235 + {
  236 + "token": [
  237 + "meta.odd-tab.tabs",
  238 + "meta.even-tab.tabs"
  239 + ],
  240 + "regex": "(\\t)(\\t)?"
  241 + },
  242 + {
  243 + "token": "meta.leading-space",
  244 + "regex": "(?=[^\\t])",
  245 + "merge": true,
  246 + "next": "start"
  247 + },
  248 + {
  249 + "token": "meta.leading-space",
  250 + "regex": ".",
  251 + "merge": true,
  252 + "next": "state_3"
  253 + }
  254 + ],
  255 + "state_4": [
  256 + {
  257 + "token": [
  258 + "meta.odd-tab.spaces",
  259 + "meta.even-tab.spaces"
  260 + ],
  261 + "regex": "( )( )?"
  262 + },
  263 + {
  264 + "token": "meta.leading-space",
  265 + "regex": "(?=[^ ])",
  266 + "merge": true,
  267 + "next": "start"
  268 + },
  269 + {
  270 + "token": "meta.leading-space",
  271 + "regex": ".",
  272 + "merge": true,
  273 + "next": "state_4"
  274 + }
  275 + ],
  276 + "state_6": [
  277 + {
  278 + "token": "comment.line.apostrophe.asp",
  279 + "regex": "(?=(?:$|%>))",
  280 + "merge": true,
  281 + "next": "start"
  282 + },
  283 + {
  284 + "token": "comment.line.apostrophe.asp",
  285 + "regex": ".",
  286 + "merge": true,
  287 + "next": "state_6"
  288 + }
  289 + ],
  290 + "state_13": [
  291 + {
  292 + "token": "constant.character.escape.apostrophe.asp",
  293 + "regex": "\"\""
  294 + },
  295 + {
  296 + "token": "string.quoted.double.asp",
  297 + "regex": "\"",
  298 + "merge": true,
  299 + "next": "start"
  300 + },
  301 + {
  302 + "token": "string.quoted.double.asp",
  303 + "regex": ".",
  304 + "merge": true,
  305 + "next": "state_13"
  306 + }
  307 + ]
  308 +}
  309 +
  310 + /*** START REPOSITORY RULES
  311 +[object Object]
  312 +END REPOSITORY RULES ***/
  313 +};
  314 +
  315 +oop.inherits(VBScriptHighlightRules, TextHighlightRules);
  316 +
  317 +exports.VBScriptHighlightRules = VBScriptHighlightRules;
  318 +});

0 comments on commit f74824a

Please sign in to comment.
Something went wrong with that request. Please try again.