fsharp.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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/fsharp/fsharp',["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. comments: {
  11. lineComment: '//',
  12. blockComment: ['(*', '*)']
  13. },
  14. brackets: [
  15. ['{', '}'],
  16. ['[', ']'],
  17. ['(', ')']
  18. ],
  19. autoClosingPairs: [
  20. { open: '{', close: '}' },
  21. { open: '[', close: ']' },
  22. { open: '(', close: ')' },
  23. { open: '"', close: '"' }
  24. ],
  25. surroundingPairs: [
  26. { open: '{', close: '}' },
  27. { open: '[', close: ']' },
  28. { open: '(', close: ')' },
  29. { open: '"', close: '"' },
  30. { open: "'", close: "'" }
  31. ],
  32. folding: {
  33. markers: {
  34. start: new RegExp('^\\s*//\\s*#region\\b|^\\s*\\(\\*\\s*#region(.*)\\*\\)'),
  35. end: new RegExp('^\\s*//\\s*#endregion\\b|^\\s*\\(\\*\\s*#endregion\\s*\\*\\)')
  36. }
  37. }
  38. };
  39. exports.language = {
  40. defaultToken: '',
  41. tokenPostfix: '.fs',
  42. keywords: [
  43. 'abstract',
  44. 'and',
  45. 'atomic',
  46. 'as',
  47. 'assert',
  48. 'asr',
  49. 'base',
  50. 'begin',
  51. 'break',
  52. 'checked',
  53. 'component',
  54. 'const',
  55. 'constraint',
  56. 'constructor',
  57. 'continue',
  58. 'class',
  59. 'default',
  60. 'delegate',
  61. 'do',
  62. 'done',
  63. 'downcast',
  64. 'downto',
  65. 'elif',
  66. 'else',
  67. 'end',
  68. 'exception',
  69. 'eager',
  70. 'event',
  71. 'external',
  72. 'extern',
  73. 'false',
  74. 'finally',
  75. 'for',
  76. 'fun',
  77. 'function',
  78. 'fixed',
  79. 'functor',
  80. 'global',
  81. 'if',
  82. 'in',
  83. 'include',
  84. 'inherit',
  85. 'inline',
  86. 'interface',
  87. 'internal',
  88. 'land',
  89. 'lor',
  90. 'lsl',
  91. 'lsr',
  92. 'lxor',
  93. 'lazy',
  94. 'let',
  95. 'match',
  96. 'member',
  97. 'mod',
  98. 'module',
  99. 'mutable',
  100. 'namespace',
  101. 'method',
  102. 'mixin',
  103. 'new',
  104. 'not',
  105. 'null',
  106. 'of',
  107. 'open',
  108. 'or',
  109. 'object',
  110. 'override',
  111. 'private',
  112. 'parallel',
  113. 'process',
  114. 'protected',
  115. 'pure',
  116. 'public',
  117. 'rec',
  118. 'return',
  119. 'static',
  120. 'sealed',
  121. 'struct',
  122. 'sig',
  123. 'then',
  124. 'to',
  125. 'true',
  126. 'tailcall',
  127. 'trait',
  128. 'try',
  129. 'type',
  130. 'upcast',
  131. 'use',
  132. 'val',
  133. 'void',
  134. 'virtual',
  135. 'volatile',
  136. 'when',
  137. 'while',
  138. 'with',
  139. 'yield'
  140. ],
  141. // we include these common regular expressions
  142. symbols: /[=><!~?:&|+\-*\^%;\.,\/]+/,
  143. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  144. integersuffix: /[uU]?[yslnLI]?/,
  145. floatsuffix: /[fFmM]?/,
  146. // The main tokenizer for our languages
  147. tokenizer: {
  148. root: [
  149. // identifiers and keywords
  150. [
  151. /[a-zA-Z_]\w*/,
  152. {
  153. cases: {
  154. '@keywords': { token: 'keyword.$0' },
  155. '@default': 'identifier'
  156. }
  157. }
  158. ],
  159. // whitespace
  160. { include: '@whitespace' },
  161. // [< attributes >].
  162. [/\[<.*>\]/, 'annotation'],
  163. // Preprocessor directive
  164. [/^#(if|else|endif)/, 'keyword'],
  165. // delimiters and operators
  166. [/[{}()\[\]]/, '@brackets'],
  167. [/[<>](?!@symbols)/, '@brackets'],
  168. [/@symbols/, 'delimiter'],
  169. // numbers
  170. [/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, 'number.float'],
  171. [/\d*\.\d+([eE][\-+]?\d+)?(@floatsuffix)/, 'number.float'],
  172. [/0x[0-9a-fA-F]+LF/, 'number.float'],
  173. [/0x[0-9a-fA-F]+(@integersuffix)/, 'number.hex'],
  174. [/0b[0-1]+(@integersuffix)/, 'number.bin'],
  175. [/\d+(@integersuffix)/, 'number'],
  176. // delimiter: after number because of .\d floats
  177. [/[;,.]/, 'delimiter'],
  178. // strings
  179. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  180. [/"""/, 'string', '@string."""'],
  181. [/"/, 'string', '@string."'],
  182. // literal string
  183. [/\@"/, { token: 'string.quote', next: '@litstring' }],
  184. // characters
  185. [/'[^\\']'B?/, 'string'],
  186. [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
  187. [/'/, 'string.invalid']
  188. ],
  189. whitespace: [
  190. [/[ \t\r\n]+/, ''],
  191. [/\(\*(?!\))/, 'comment', '@comment'],
  192. [/\/\/.*$/, 'comment']
  193. ],
  194. comment: [
  195. [/[^*(]+/, 'comment'],
  196. [/\*\)/, 'comment', '@pop'],
  197. [/\*/, 'comment'],
  198. [/\(\*\)/, 'comment'],
  199. [/\(/, 'comment']
  200. ],
  201. string: [
  202. [/[^\\"]+/, 'string'],
  203. [/@escapes/, 'string.escape'],
  204. [/\\./, 'string.escape.invalid'],
  205. [
  206. /("""|"B?)/,
  207. {
  208. cases: {
  209. '$#==$S2': { token: 'string', next: '@pop' },
  210. '@default': 'string'
  211. }
  212. }
  213. ]
  214. ],
  215. litstring: [
  216. [/[^"]+/, 'string'],
  217. [/""/, 'string.escape'],
  218. [/"/, { token: 'string.quote', next: '@pop' }]
  219. ]
  220. }
  221. };
  222. });