vbscript_highlight_rules.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. },
  83. {
  84. token: [
  85. "keyword.control.asp"
  86. ],
  87. 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"
  88. },
  89. {
  90. token: "keyword.operator.asp",
  91. regex: "\\b(?:Mod|And|Not|Or|Xor|as)\\b"
  92. },
  93. {
  94. token: "storage.type.asp",
  95. 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"
  96. },
  97. {
  98. token: "storage.modifier.asp",
  99. regex: "\\b(?:Private|Public|Default)\\b"
  100. },
  101. {
  102. token: "constant.language.asp",
  103. regex: "\\b(?:Empty|False|Nothing|Null|True)\\b"
  104. },
  105. {
  106. token: "punctuation.definition.string.begin.asp",
  107. regex: '"',
  108. next: "string"
  109. },
  110. {
  111. token: [
  112. "punctuation.definition.variable.asp"
  113. ],
  114. regex: "(\\$)[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\\b\\s*"
  115. },
  116. {
  117. token: "support.class.asp",
  118. regex: "\\b(?:Application|ObjectContext|Request|Response|Server|Session)\\b"
  119. },
  120. {
  121. token: "support.class.collection.asp",
  122. regex: "\\b(?:Contents|StaticObjects|ClientCertificate|Cookies|Form|QueryString|ServerVariables)\\b"
  123. },
  124. {
  125. token: "support.constant.asp",
  126. regex: "\\b(?:TotalBytes|Buffer|CacheControl|Charset|ContentType|Expires|ExpiresAbsolute|IsClientConnected|PICS|Status|ScriptTimeout|CodePage|LCID|SessionID|Timeout)\\b"
  127. },
  128. {
  129. token: "support.function.asp",
  130. regex: "\\b(?:Lock|Unlock|SetAbort|SetComplete|BinaryRead|AddHeader|AppendToLog|BinaryWrite|Clear|End|Flush|Redirect|Write|CreateObject|HTMLEncode|MapPath|URLEncode|Abandon|Convert|Regex)\\b"
  131. },
  132. {
  133. token: "support.function.event.asp",
  134. regex: "\\b(?:Application_OnEnd|Application_OnStart|OnTransactionAbort|OnTransactionCommit|Session_OnEnd|Session_OnStart)\\b"
  135. },
  136. // {
  137. // token: [
  138. // "support.type.vb.asp"
  139. // ],
  140. // 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 :("
  141. // },
  142. {
  143. token: "support.function.vb.asp",
  144. 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"
  145. },
  146. {
  147. token: [
  148. "constant.numeric.asp"
  149. ],
  150. 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"
  151. },
  152. {
  153. token: "support.type.vb.asp",
  154. 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"
  155. },
  156. {
  157. token: [
  158. "entity.name.function.asp"
  159. ],
  160. regex: "(?:(\\b[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*?\\b)(?=\\(\\)?))"
  161. },
  162. // {
  163. // token: [
  164. // "variable.other.asp"
  165. // ],
  166. // 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 :("
  167. // },
  168. {
  169. token: [
  170. "keyword.operator.asp"
  171. ],
  172. regex: "\\-|\\+|\\*\\\/|\\>|\\<|\\=|\\&"
  173. }
  174. ],
  175. "state_3": [
  176. {
  177. token: [
  178. "meta.odd-tab.tabs",
  179. "meta.even-tab.tabs"
  180. ],
  181. regex: "(\\t)(\\t)?"
  182. },
  183. {
  184. token: "meta.leading-space",
  185. regex: "(?=[^\\t])",
  186. next: "start"
  187. },
  188. {
  189. token: "meta.leading-space",
  190. regex: ".",
  191. next: "state_3"
  192. }
  193. ],
  194. "state_4": [
  195. {
  196. token: ["meta.odd-tab.spaces", "meta.even-tab.spaces"],
  197. regex: "( )( )?"
  198. },
  199. {
  200. token: "meta.leading-space",
  201. regex: "(?=[^ ])",
  202. next: "start"
  203. },
  204. {
  205. defaultToken: "meta.leading-space"
  206. }
  207. ],
  208. "comment": [
  209. {
  210. token: "comment.line.apostrophe.asp",
  211. regex: "$|(?=(?:%>))",
  212. next: "start"
  213. },
  214. {
  215. defaultToken: "comment.line.apostrophe.asp"
  216. }
  217. ],
  218. "string": [
  219. {
  220. token: "constant.character.escape.apostrophe.asp",
  221. regex: '""'
  222. },
  223. {
  224. token: "string.quoted.double.asp",
  225. regex: '"',
  226. next: "start"
  227. },
  228. {
  229. defaultToken: "string.quoted.double.asp"
  230. }
  231. ]
  232. }
  233. };
  234. oop.inherits(VBScriptHighlightRules, TextHighlightRules);
  235. exports.VBScriptHighlightRules = VBScriptHighlightRules;
  236. });