fsharp.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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(["require", "exports"], function (require, exports) {
  6. 'use strict';
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.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. exports.language = {
  39. defaultToken: '',
  40. tokenPostfix: '.fs',
  41. keywords: [
  42. 'abstract', 'and', 'atomic', 'as',
  43. 'assert', 'asr', 'base', 'begin',
  44. 'break', 'checked', 'component',
  45. 'const', 'constraint', 'constructor',
  46. 'continue', 'class', 'default',
  47. 'delegate', 'do', 'done', 'downcast',
  48. 'downto', 'elif', 'else', 'end',
  49. 'exception', 'eager', 'event', 'external',
  50. 'extern', 'false', 'finally', 'for',
  51. 'fun', 'function', 'fixed', 'functor',
  52. 'global', 'if', 'in', 'include', 'inherit',
  53. 'inline', 'interface', 'internal', 'land',
  54. 'lor', 'lsl', 'lsr', 'lxor', 'lazy', 'let',
  55. 'match', 'member', 'mod', 'module', 'mutable',
  56. 'namespace', 'method', 'mixin', 'new', 'not',
  57. 'null', 'of', 'open', 'or', 'object',
  58. 'override', 'private', 'parallel', 'process',
  59. 'protected', 'pure', 'public', 'rec', 'return',
  60. 'static', 'sealed', 'struct', 'sig', 'then',
  61. 'to', 'true', 'tailcall', 'trait',
  62. 'try', 'type', 'upcast', 'use',
  63. 'val', 'void', 'virtual', 'volatile',
  64. 'when', 'while', 'with', 'yield'
  65. ],
  66. // we include these common regular expressions
  67. symbols: /[=><!~?:&|+\-*\^%;\.,\/]+/,
  68. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  69. integersuffix: /[uU]?[yslnLI]?/,
  70. floatsuffix: /[fFmM]?/,
  71. // The main tokenizer for our languages
  72. tokenizer: {
  73. root: [
  74. // identifiers and keywords
  75. [/[a-zA-Z_]\w*/, {
  76. cases: {
  77. '@keywords': { token: 'keyword.$0' },
  78. '@default': 'identifier'
  79. }
  80. }],
  81. // whitespace
  82. { include: '@whitespace' },
  83. // [< attributes >].
  84. [/\[<.*>\]/, 'annotation'],
  85. // Preprocessor directive
  86. [/^#(if|else|endif)/, 'keyword'],
  87. // delimiters and operators
  88. [/[{}()\[\]]/, '@brackets'],
  89. [/[<>](?!@symbols)/, '@brackets'],
  90. [/@symbols/, 'delimiter'],
  91. // numbers
  92. [/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, 'number.float'],
  93. [/\d*\.\d+([eE][\-+]?\d+)?(@floatsuffix)/, 'number.float'],
  94. [/0x[0-9a-fA-F]+LF/, 'number.float'],
  95. [/0x[0-9a-fA-F]+(@integersuffix)/, 'number.hex'],
  96. [/0b[0-1]+(@integersuffix)/, 'number.bin'],
  97. [/\d+(@integersuffix)/, 'number'],
  98. // delimiter: after number because of .\d floats
  99. [/[;,.]/, 'delimiter'],
  100. // strings
  101. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  102. [/"""/, 'string', '@string."""'],
  103. [/"/, 'string', '@string."'],
  104. // literal string
  105. [/\@"/, { token: 'string.quote', next: '@litstring' }],
  106. // characters
  107. [/'[^\\']'B?/, 'string'],
  108. [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
  109. [/'/, 'string.invalid']
  110. ],
  111. whitespace: [
  112. [/[ \t\r\n]+/, ''],
  113. [/\(\*(?!\))/, 'comment', '@comment'],
  114. [/\/\/.*$/, 'comment'],
  115. ],
  116. comment: [
  117. [/[^*(]+/, 'comment'],
  118. [/\*\)/, 'comment', '@pop'],
  119. [/\*/, 'comment'],
  120. [/\(\*\)/, 'comment'],
  121. [/\(/, 'comment']
  122. ],
  123. string: [
  124. [/[^\\"]+/, 'string'],
  125. [/@escapes/, 'string.escape'],
  126. [/\\./, 'string.escape.invalid'],
  127. [/("""|"B?)/, {
  128. cases: {
  129. '$#==$S2': { token: 'string', next: '@pop' },
  130. '@default': 'string'
  131. }
  132. }]
  133. ],
  134. litstring: [
  135. [/[^"]+/, 'string'],
  136. [/""/, 'string.escape'],
  137. [/"/, { token: 'string.quote', next: '@pop' }]
  138. ],
  139. },
  140. };
  141. });