vbscript_highlight_rules.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. * ***** END LICENSE BLOCK ***** */
  30. /*
  31. THIS FILE WAS AUTOGENERATED BY mode_highlight_rules.tmpl.js (UUID: 7F9C9343-D48E-4E7D-BFE8-F680714DCD3E) */
  32. define(function(require, exports, module) {
  33. "use strict";
  34. var oop = require("../lib/oop");
  35. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  36. var VBScriptHighlightRules = function() {
  37. // regexp must not have capturing parentheses. Use (?:) instead.
  38. // regexps are ordered -> the first match is used
  39. this.$rules = {
  40. "start": [
  41. {
  42. token: [
  43. "meta.ending-space"
  44. ],
  45. regex: "$"
  46. },
  47. // {
  48. // token: [
  49. // "#round-brackets"
  50. // ],
  51. // regex: ""
  52. // },
  53. {
  54. token: [
  55. null
  56. ],
  57. regex: "^(?=\\t)",
  58. next: "state_3"
  59. },
  60. {
  61. token: [null],
  62. regex: "^(?= )",
  63. next: "state_4"
  64. },
  65. {
  66. token: [
  67. "text",
  68. "storage.type.function.asp",
  69. "text",
  70. "entity.name.function.asp",
  71. "text",
  72. "punctuation.definition.parameters.asp",
  73. "variable.parameter.function.asp",
  74. "punctuation.definition.parameters.asp"
  75. ],
  76. regex: "^(\\s*)(Function|Sub)(\\s*)([a-zA-Z_]\\w*)(\\s*)(\\()([^)]*)(\\))"
  77. },
  78. {
  79. token: "punctuation.definition.comment.asp",
  80. regex: "'|REM",
  81. next: "comment",
  82. caseInsensitive: true
  83. },
  84. {
  85. token: [
  86. "keyword.control.asp"
  87. ],
  88. 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",
  89. caseInsensitive: true
  90. },
  91. {
  92. token: "keyword.operator.asp",
  93. regex: "\\b(?:Mod|And|Not|Or|Xor|as)\\b",
  94. caseInsensitive: true
  95. },
  96. {
  97. token: "storage.type.asp",
  98. 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",
  99. caseInsensitive: true
  100. },
  101. {
  102. token: "storage.modifier.asp",
  103. regex: "\\b(?:Private|Public|Default)\\b",
  104. caseInsensitive: true
  105. },
  106. {
  107. token: "constant.language.asp",
  108. regex: "\\b(?:Empty|False|Nothing|Null|True)\\b",
  109. caseInsensitive: true
  110. },
  111. {
  112. token: "punctuation.definition.string.begin.asp",
  113. regex: '"',
  114. next: "string"
  115. },
  116. {
  117. token: [
  118. "punctuation.definition.variable.asp"
  119. ],
  120. regex: "(\\$)[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\\b\\s*"
  121. },
  122. {
  123. token: "support.class.asp",
  124. regex: "\\b(?:Application|ObjectContext|Request|Response|Server|Session)\\b",
  125. caseInsensitive: true
  126. },
  127. {
  128. token: "support.class.collection.asp",
  129. regex: "\\b(?:Contents|StaticObjects|ClientCertificate|Cookies|Form|QueryString|ServerVariables)\\b",
  130. caseInsensitive: true
  131. },
  132. {
  133. token: "support.constant.asp",
  134. regex: "\\b(?:TotalBytes|Buffer|CacheControl|Charset|ContentType|Expires|ExpiresAbsolute|IsClientConnected|PICS|Status|ScriptTimeout|CodePage|LCID|SessionID|Timeout)\\b",
  135. caseInsensitive: true
  136. },
  137. {
  138. token: "support.function.asp",
  139. regex: "\\b(?:Lock|Unlock|SetAbort|SetComplete|BinaryRead|AddHeader|AppendToLog|BinaryWrite|Clear|End|Flush|Redirect|Write|CreateObject|HTMLEncode|MapPath|URLEncode|Abandon|Convert|Regex)\\b",
  140. caseInsensitive: true
  141. },
  142. {
  143. token: "support.function.event.asp",
  144. regex: "\\b(?:Application_OnEnd|Application_OnStart|OnTransactionAbort|OnTransactionCommit|Session_OnEnd|Session_OnStart)\\b",
  145. caseInsensitive: true
  146. },
  147. // {
  148. // token: [
  149. // "support.type.vb.asp"
  150. // ],
  151. // 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 :("
  152. // },
  153. {
  154. token: "support.function.vb.asp",
  155. 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",
  156. caseInsensitive: true
  157. },
  158. {
  159. token: [
  160. "constant.numeric.asp"
  161. ],
  162. 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"
  163. },
  164. {
  165. token: "support.type.vb.asp",
  166. regex: "\\b(?:vbtrue|vbfalse|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",
  167. caseInsensitive: true
  168. },
  169. {
  170. token: [
  171. "entity.name.function.asp"
  172. ],
  173. regex: "(?:(\\b[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\\b)(?=\\(\\)?))"
  174. },
  175. // {
  176. // token: [
  177. // "variable.other.asp"
  178. // ],
  179. // 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 :("
  180. // },
  181. {
  182. token: [
  183. "keyword.operator.asp"
  184. ],
  185. regex: "\\-|\\+|\\*\\\/|\\>|\\<|\\=|\\&"
  186. }
  187. ],
  188. "state_3": [
  189. {
  190. token: [
  191. "meta.odd-tab.tabs",
  192. "meta.even-tab.tabs"
  193. ],
  194. regex: "(\\t)(\\t)?"
  195. },
  196. {
  197. token: "meta.leading-space",
  198. regex: "(?=[^\\t])",
  199. next: "start"
  200. },
  201. {
  202. token: "meta.leading-space",
  203. regex: ".",
  204. next: "state_3"
  205. }
  206. ],
  207. "state_4": [
  208. {
  209. token: ["meta.odd-tab.spaces", "meta.even-tab.spaces"],
  210. regex: "( )( )?"
  211. },
  212. {
  213. token: "meta.leading-space",
  214. regex: "(?=[^ ])",
  215. next: "start"
  216. },
  217. {
  218. defaultToken: "meta.leading-space"
  219. }
  220. ],
  221. "comment": [
  222. {
  223. token: "comment.line.apostrophe.asp",
  224. regex: "$|(?=(?:%>))",
  225. next: "start"
  226. },
  227. {
  228. defaultToken: "comment.line.apostrophe.asp"
  229. }
  230. ],
  231. "string": [
  232. {
  233. token: "constant.character.escape.apostrophe.asp",
  234. regex: '""'
  235. },
  236. {
  237. token: "string.quoted.double.asp",
  238. regex: '"',
  239. next: "start"
  240. },
  241. {
  242. defaultToken: "string.quoted.double.asp"
  243. }
  244. ]
  245. }
  246. };
  247. oop.inherits(VBScriptHighlightRules, TextHighlightRules);
  248. exports.VBScriptHighlightRules = VBScriptHighlightRules;
  249. });