vb.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.31.1(337587859b1c171314b40503171188b6cea6a32a)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. // src/basic-languages/vb/vb.ts
  8. var conf = {
  9. comments: {
  10. lineComment: "'",
  11. blockComment: ["/*", "*/"]
  12. },
  13. brackets: [
  14. ["{", "}"],
  15. ["[", "]"],
  16. ["(", ")"],
  17. ["<", ">"],
  18. ["addhandler", "end addhandler"],
  19. ["class", "end class"],
  20. ["enum", "end enum"],
  21. ["event", "end event"],
  22. ["function", "end function"],
  23. ["get", "end get"],
  24. ["if", "end if"],
  25. ["interface", "end interface"],
  26. ["module", "end module"],
  27. ["namespace", "end namespace"],
  28. ["operator", "end operator"],
  29. ["property", "end property"],
  30. ["raiseevent", "end raiseevent"],
  31. ["removehandler", "end removehandler"],
  32. ["select", "end select"],
  33. ["set", "end set"],
  34. ["structure", "end structure"],
  35. ["sub", "end sub"],
  36. ["synclock", "end synclock"],
  37. ["try", "end try"],
  38. ["while", "end while"],
  39. ["with", "end with"],
  40. ["using", "end using"],
  41. ["do", "loop"],
  42. ["for", "next"]
  43. ],
  44. autoClosingPairs: [
  45. { open: "{", close: "}", notIn: ["string", "comment"] },
  46. { open: "[", close: "]", notIn: ["string", "comment"] },
  47. { open: "(", close: ")", notIn: ["string", "comment"] },
  48. { open: '"', close: '"', notIn: ["string", "comment"] },
  49. { open: "<", close: ">", notIn: ["string", "comment"] }
  50. ],
  51. folding: {
  52. markers: {
  53. start: new RegExp("^\\s*#Region\\b"),
  54. end: new RegExp("^\\s*#End Region\\b")
  55. }
  56. }
  57. };
  58. var language = {
  59. defaultToken: "",
  60. tokenPostfix: ".vb",
  61. ignoreCase: true,
  62. brackets: [
  63. { token: "delimiter.bracket", open: "{", close: "}" },
  64. { token: "delimiter.array", open: "[", close: "]" },
  65. { token: "delimiter.parenthesis", open: "(", close: ")" },
  66. { token: "delimiter.angle", open: "<", close: ">" },
  67. {
  68. token: "keyword.tag-addhandler",
  69. open: "addhandler",
  70. close: "end addhandler"
  71. },
  72. { token: "keyword.tag-class", open: "class", close: "end class" },
  73. { token: "keyword.tag-enum", open: "enum", close: "end enum" },
  74. { token: "keyword.tag-event", open: "event", close: "end event" },
  75. {
  76. token: "keyword.tag-function",
  77. open: "function",
  78. close: "end function"
  79. },
  80. { token: "keyword.tag-get", open: "get", close: "end get" },
  81. { token: "keyword.tag-if", open: "if", close: "end if" },
  82. {
  83. token: "keyword.tag-interface",
  84. open: "interface",
  85. close: "end interface"
  86. },
  87. { token: "keyword.tag-module", open: "module", close: "end module" },
  88. {
  89. token: "keyword.tag-namespace",
  90. open: "namespace",
  91. close: "end namespace"
  92. },
  93. {
  94. token: "keyword.tag-operator",
  95. open: "operator",
  96. close: "end operator"
  97. },
  98. {
  99. token: "keyword.tag-property",
  100. open: "property",
  101. close: "end property"
  102. },
  103. {
  104. token: "keyword.tag-raiseevent",
  105. open: "raiseevent",
  106. close: "end raiseevent"
  107. },
  108. {
  109. token: "keyword.tag-removehandler",
  110. open: "removehandler",
  111. close: "end removehandler"
  112. },
  113. { token: "keyword.tag-select", open: "select", close: "end select" },
  114. { token: "keyword.tag-set", open: "set", close: "end set" },
  115. {
  116. token: "keyword.tag-structure",
  117. open: "structure",
  118. close: "end structure"
  119. },
  120. { token: "keyword.tag-sub", open: "sub", close: "end sub" },
  121. {
  122. token: "keyword.tag-synclock",
  123. open: "synclock",
  124. close: "end synclock"
  125. },
  126. { token: "keyword.tag-try", open: "try", close: "end try" },
  127. { token: "keyword.tag-while", open: "while", close: "end while" },
  128. { token: "keyword.tag-with", open: "with", close: "end with" },
  129. { token: "keyword.tag-using", open: "using", close: "end using" },
  130. { token: "keyword.tag-do", open: "do", close: "loop" },
  131. { token: "keyword.tag-for", open: "for", close: "next" }
  132. ],
  133. keywords: [
  134. "AddHandler",
  135. "AddressOf",
  136. "Alias",
  137. "And",
  138. "AndAlso",
  139. "As",
  140. "Async",
  141. "Boolean",
  142. "ByRef",
  143. "Byte",
  144. "ByVal",
  145. "Call",
  146. "Case",
  147. "Catch",
  148. "CBool",
  149. "CByte",
  150. "CChar",
  151. "CDate",
  152. "CDbl",
  153. "CDec",
  154. "Char",
  155. "CInt",
  156. "Class",
  157. "CLng",
  158. "CObj",
  159. "Const",
  160. "Continue",
  161. "CSByte",
  162. "CShort",
  163. "CSng",
  164. "CStr",
  165. "CType",
  166. "CUInt",
  167. "CULng",
  168. "CUShort",
  169. "Date",
  170. "Decimal",
  171. "Declare",
  172. "Default",
  173. "Delegate",
  174. "Dim",
  175. "DirectCast",
  176. "Do",
  177. "Double",
  178. "Each",
  179. "Else",
  180. "ElseIf",
  181. "End",
  182. "EndIf",
  183. "Enum",
  184. "Erase",
  185. "Error",
  186. "Event",
  187. "Exit",
  188. "False",
  189. "Finally",
  190. "For",
  191. "Friend",
  192. "Function",
  193. "Get",
  194. "GetType",
  195. "GetXMLNamespace",
  196. "Global",
  197. "GoSub",
  198. "GoTo",
  199. "Handles",
  200. "If",
  201. "Implements",
  202. "Imports",
  203. "In",
  204. "Inherits",
  205. "Integer",
  206. "Interface",
  207. "Is",
  208. "IsNot",
  209. "Let",
  210. "Lib",
  211. "Like",
  212. "Long",
  213. "Loop",
  214. "Me",
  215. "Mod",
  216. "Module",
  217. "MustInherit",
  218. "MustOverride",
  219. "MyBase",
  220. "MyClass",
  221. "NameOf",
  222. "Namespace",
  223. "Narrowing",
  224. "New",
  225. "Next",
  226. "Not",
  227. "Nothing",
  228. "NotInheritable",
  229. "NotOverridable",
  230. "Object",
  231. "Of",
  232. "On",
  233. "Operator",
  234. "Option",
  235. "Optional",
  236. "Or",
  237. "OrElse",
  238. "Out",
  239. "Overloads",
  240. "Overridable",
  241. "Overrides",
  242. "ParamArray",
  243. "Partial",
  244. "Private",
  245. "Property",
  246. "Protected",
  247. "Public",
  248. "RaiseEvent",
  249. "ReadOnly",
  250. "ReDim",
  251. "RemoveHandler",
  252. "Resume",
  253. "Return",
  254. "SByte",
  255. "Select",
  256. "Set",
  257. "Shadows",
  258. "Shared",
  259. "Short",
  260. "Single",
  261. "Static",
  262. "Step",
  263. "Stop",
  264. "String",
  265. "Structure",
  266. "Sub",
  267. "SyncLock",
  268. "Then",
  269. "Throw",
  270. "To",
  271. "True",
  272. "Try",
  273. "TryCast",
  274. "TypeOf",
  275. "UInteger",
  276. "ULong",
  277. "UShort",
  278. "Using",
  279. "Variant",
  280. "Wend",
  281. "When",
  282. "While",
  283. "Widening",
  284. "With",
  285. "WithEvents",
  286. "WriteOnly",
  287. "Xor"
  288. ],
  289. tagwords: [
  290. "If",
  291. "Sub",
  292. "Select",
  293. "Try",
  294. "Class",
  295. "Enum",
  296. "Function",
  297. "Get",
  298. "Interface",
  299. "Module",
  300. "Namespace",
  301. "Operator",
  302. "Set",
  303. "Structure",
  304. "Using",
  305. "While",
  306. "With",
  307. "Do",
  308. "Loop",
  309. "For",
  310. "Next",
  311. "Property",
  312. "Continue",
  313. "AddHandler",
  314. "RemoveHandler",
  315. "Event",
  316. "RaiseEvent",
  317. "SyncLock"
  318. ],
  319. symbols: /[=><!~?;\.,:&|+\-*\/\^%]+/,
  320. integersuffix: /U?[DI%L&S@]?/,
  321. floatsuffix: /[R#F!]?/,
  322. tokenizer: {
  323. root: [
  324. { include: "@whitespace" },
  325. [/next(?!\w)/, { token: "keyword.tag-for" }],
  326. [/loop(?!\w)/, { token: "keyword.tag-do" }],
  327. [
  328. /end\s+(?!for|do)(addhandler|class|enum|event|function|get|if|interface|module|namespace|operator|property|raiseevent|removehandler|select|set|structure|sub|synclock|try|while|with|using)/,
  329. { token: "keyword.tag-$1" }
  330. ],
  331. [
  332. /[a-zA-Z_]\w*/,
  333. {
  334. cases: {
  335. "@tagwords": { token: "keyword.tag-$0" },
  336. "@keywords": { token: "keyword.$0" },
  337. "@default": "identifier"
  338. }
  339. }
  340. ],
  341. [/^\s*#\w+/, "keyword"],
  342. [/\d*\d+e([\-+]?\d+)?(@floatsuffix)/, "number.float"],
  343. [/\d*\.\d+(e[\-+]?\d+)?(@floatsuffix)/, "number.float"],
  344. [/&H[0-9a-f]+(@integersuffix)/, "number.hex"],
  345. [/&0[0-7]+(@integersuffix)/, "number.octal"],
  346. [/\d+(@integersuffix)/, "number"],
  347. [/#.*#/, "number"],
  348. [/[{}()\[\]]/, "@brackets"],
  349. [/@symbols/, "delimiter"],
  350. [/["\u201c\u201d]/, { token: "string.quote", next: "@string" }]
  351. ],
  352. whitespace: [
  353. [/[ \t\r\n]+/, ""],
  354. [/(\'|REM(?!\w)).*$/, "comment"]
  355. ],
  356. string: [
  357. [/[^"\u201c\u201d]+/, "string"],
  358. [/["\u201c\u201d]{2}/, "string.escape"],
  359. [/["\u201c\u201d]C?/, { token: "string.quote", next: "@pop" }]
  360. ]
  361. }
  362. };
  363. export {
  364. conf,
  365. language
  366. };