fsharp.js 4.4 KB

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