csharp.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. define('vs/basic-languages/csharp/csharp',["require", "exports"], function (require, exports) {
  6. "use strict";
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.language = exports.conf = void 0;
  9. exports.conf = {
  10. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
  11. comments: {
  12. lineComment: '//',
  13. blockComment: ['/*', '*/']
  14. },
  15. brackets: [
  16. ['{', '}'],
  17. ['[', ']'],
  18. ['(', ')']
  19. ],
  20. autoClosingPairs: [
  21. { open: '{', close: '}' },
  22. { open: '[', close: ']' },
  23. { open: '(', close: ')' },
  24. { open: "'", close: "'", notIn: ['string', 'comment'] },
  25. { open: '"', close: '"', notIn: ['string', 'comment'] }
  26. ],
  27. surroundingPairs: [
  28. { open: '{', close: '}' },
  29. { open: '[', close: ']' },
  30. { open: '(', close: ')' },
  31. { open: '<', close: '>' },
  32. { open: "'", close: "'" },
  33. { open: '"', close: '"' }
  34. ],
  35. folding: {
  36. markers: {
  37. start: new RegExp('^\\s*#region\\b'),
  38. end: new RegExp('^\\s*#endregion\\b')
  39. }
  40. }
  41. };
  42. exports.language = {
  43. defaultToken: '',
  44. tokenPostfix: '.cs',
  45. brackets: [
  46. { open: '{', close: '}', token: 'delimiter.curly' },
  47. { open: '[', close: ']', token: 'delimiter.square' },
  48. { open: '(', close: ')', token: 'delimiter.parenthesis' },
  49. { open: '<', close: '>', token: 'delimiter.angle' }
  50. ],
  51. keywords: [
  52. 'extern',
  53. 'alias',
  54. 'using',
  55. 'bool',
  56. 'decimal',
  57. 'sbyte',
  58. 'byte',
  59. 'short',
  60. 'ushort',
  61. 'int',
  62. 'uint',
  63. 'long',
  64. 'ulong',
  65. 'char',
  66. 'float',
  67. 'double',
  68. 'object',
  69. 'dynamic',
  70. 'string',
  71. 'assembly',
  72. 'is',
  73. 'as',
  74. 'ref',
  75. 'out',
  76. 'this',
  77. 'base',
  78. 'new',
  79. 'typeof',
  80. 'void',
  81. 'checked',
  82. 'unchecked',
  83. 'default',
  84. 'delegate',
  85. 'var',
  86. 'const',
  87. 'if',
  88. 'else',
  89. 'switch',
  90. 'case',
  91. 'while',
  92. 'do',
  93. 'for',
  94. 'foreach',
  95. 'in',
  96. 'break',
  97. 'continue',
  98. 'goto',
  99. 'return',
  100. 'throw',
  101. 'try',
  102. 'catch',
  103. 'finally',
  104. 'lock',
  105. 'yield',
  106. 'from',
  107. 'let',
  108. 'where',
  109. 'join',
  110. 'on',
  111. 'equals',
  112. 'into',
  113. 'orderby',
  114. 'ascending',
  115. 'descending',
  116. 'select',
  117. 'group',
  118. 'by',
  119. 'namespace',
  120. 'partial',
  121. 'class',
  122. 'field',
  123. 'event',
  124. 'method',
  125. 'param',
  126. 'public',
  127. 'protected',
  128. 'internal',
  129. 'private',
  130. 'abstract',
  131. 'sealed',
  132. 'static',
  133. 'struct',
  134. 'readonly',
  135. 'volatile',
  136. 'virtual',
  137. 'override',
  138. 'params',
  139. 'get',
  140. 'set',
  141. 'add',
  142. 'remove',
  143. 'operator',
  144. 'true',
  145. 'false',
  146. 'implicit',
  147. 'explicit',
  148. 'interface',
  149. 'enum',
  150. 'null',
  151. 'async',
  152. 'await',
  153. 'fixed',
  154. 'sizeof',
  155. 'stackalloc',
  156. 'unsafe',
  157. 'nameof',
  158. 'when'
  159. ],
  160. namespaceFollows: ['namespace', 'using'],
  161. parenFollows: ['if', 'for', 'while', 'switch', 'foreach', 'using', 'catch', 'when'],
  162. operators: [
  163. '=',
  164. '??',
  165. '||',
  166. '&&',
  167. '|',
  168. '^',
  169. '&',
  170. '==',
  171. '!=',
  172. '<=',
  173. '>=',
  174. '<<',
  175. '+',
  176. '-',
  177. '*',
  178. '/',
  179. '%',
  180. '!',
  181. '~',
  182. '++',
  183. '--',
  184. '+=',
  185. '-=',
  186. '*=',
  187. '/=',
  188. '%=',
  189. '&=',
  190. '|=',
  191. '^=',
  192. '<<=',
  193. '>>=',
  194. '>>',
  195. '=>'
  196. ],
  197. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  198. // escape sequences
  199. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  200. // The main tokenizer for our languages
  201. tokenizer: {
  202. root: [
  203. // identifiers and keywords
  204. [
  205. /\@?[a-zA-Z_]\w*/,
  206. {
  207. cases: {
  208. '@namespaceFollows': {
  209. token: 'keyword.$0',
  210. next: '@namespace'
  211. },
  212. '@keywords': {
  213. token: 'keyword.$0',
  214. next: '@qualified'
  215. },
  216. '@default': { token: 'identifier', next: '@qualified' }
  217. }
  218. }
  219. ],
  220. // whitespace
  221. { include: '@whitespace' },
  222. // delimiters and operators
  223. [
  224. /}/,
  225. {
  226. cases: {
  227. '$S2==interpolatedstring': {
  228. token: 'string.quote',
  229. next: '@pop'
  230. },
  231. '$S2==litinterpstring': {
  232. token: 'string.quote',
  233. next: '@pop'
  234. },
  235. '@default': '@brackets'
  236. }
  237. }
  238. ],
  239. [/[{}()\[\]]/, '@brackets'],
  240. [/[<>](?!@symbols)/, '@brackets'],
  241. [
  242. /@symbols/,
  243. {
  244. cases: {
  245. '@operators': 'delimiter',
  246. '@default': ''
  247. }
  248. }
  249. ],
  250. // numbers
  251. [/[0-9_]*\.[0-9_]+([eE][\-+]?\d+)?[fFdD]?/, 'number.float'],
  252. [/0[xX][0-9a-fA-F_]+/, 'number.hex'],
  253. [/0[bB][01_]+/, 'number.hex'],
  254. [/[0-9_]+/, 'number'],
  255. // delimiter: after number because of .\d floats
  256. [/[;,.]/, 'delimiter'],
  257. // strings
  258. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  259. [/"/, { token: 'string.quote', next: '@string' }],
  260. [/\$\@"/, { token: 'string.quote', next: '@litinterpstring' }],
  261. [/\@"/, { token: 'string.quote', next: '@litstring' }],
  262. [/\$"/, { token: 'string.quote', next: '@interpolatedstring' }],
  263. // characters
  264. [/'[^\\']'/, 'string'],
  265. [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
  266. [/'/, 'string.invalid']
  267. ],
  268. qualified: [
  269. [
  270. /[a-zA-Z_][\w]*/,
  271. {
  272. cases: {
  273. '@keywords': { token: 'keyword.$0' },
  274. '@default': 'identifier'
  275. }
  276. }
  277. ],
  278. [/\./, 'delimiter'],
  279. ['', '', '@pop']
  280. ],
  281. namespace: [
  282. { include: '@whitespace' },
  283. [/[A-Z]\w*/, 'namespace'],
  284. [/[\.=]/, 'delimiter'],
  285. ['', '', '@pop']
  286. ],
  287. comment: [
  288. [/[^\/*]+/, 'comment'],
  289. // [/\/\*/, 'comment', '@push' ], // no nested comments :-(
  290. ['\\*/', 'comment', '@pop'],
  291. [/[\/*]/, 'comment']
  292. ],
  293. string: [
  294. [/[^\\"]+/, 'string'],
  295. [/@escapes/, 'string.escape'],
  296. [/\\./, 'string.escape.invalid'],
  297. [/"/, { token: 'string.quote', next: '@pop' }]
  298. ],
  299. litstring: [
  300. [/[^"]+/, 'string'],
  301. [/""/, 'string.escape'],
  302. [/"/, { token: 'string.quote', next: '@pop' }]
  303. ],
  304. litinterpstring: [
  305. [/[^"{]+/, 'string'],
  306. [/""/, 'string.escape'],
  307. [/{{/, 'string.escape'],
  308. [/}}/, 'string.escape'],
  309. [/{/, { token: 'string.quote', next: 'root.litinterpstring' }],
  310. [/"/, { token: 'string.quote', next: '@pop' }]
  311. ],
  312. interpolatedstring: [
  313. [/[^\\"{]+/, 'string'],
  314. [/@escapes/, 'string.escape'],
  315. [/\\./, 'string.escape.invalid'],
  316. [/{{/, 'string.escape'],
  317. [/}}/, 'string.escape'],
  318. [/{/, { token: 'string.quote', next: 'root.interpolatedstring' }],
  319. [/"/, { token: 'string.quote', next: '@pop' }]
  320. ],
  321. whitespace: [
  322. [/^[ \t\v\f]*#((r)|(load))(?=\s)/, 'directive.csx'],
  323. [/^[ \t\v\f]*#\w.*$/, 'namespace.cpp'],
  324. [/[ \t\v\f\r\n]+/, ''],
  325. [/\/\*/, 'comment', '@comment'],
  326. [/\/\/.*$/, 'comment']
  327. ]
  328. }
  329. };
  330. });