flow9.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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/flow9/flow9.ts
  8. var conf = {
  9. comments: {
  10. blockComment: ["/*", "*/"],
  11. lineComment: "//"
  12. },
  13. brackets: [
  14. ["{", "}"],
  15. ["[", "]"],
  16. ["(", ")"]
  17. ],
  18. autoClosingPairs: [
  19. { open: "{", close: "}", notIn: ["string"] },
  20. { open: "[", close: "]", notIn: ["string"] },
  21. { open: "(", close: ")", notIn: ["string"] },
  22. { open: '"', close: '"', notIn: ["string"] },
  23. { open: "'", close: "'", notIn: ["string"] }
  24. ],
  25. surroundingPairs: [
  26. { open: "{", close: "}" },
  27. { open: "[", close: "]" },
  28. { open: "(", close: ")" },
  29. { open: '"', close: '"' },
  30. { open: "'", close: "'" },
  31. { open: "<", close: ">" }
  32. ]
  33. };
  34. var language = {
  35. defaultToken: "",
  36. tokenPostfix: ".flow",
  37. keywords: [
  38. "import",
  39. "require",
  40. "export",
  41. "forbid",
  42. "native",
  43. "if",
  44. "else",
  45. "cast",
  46. "unsafe",
  47. "switch",
  48. "default"
  49. ],
  50. types: [
  51. "io",
  52. "mutable",
  53. "bool",
  54. "int",
  55. "double",
  56. "string",
  57. "flow",
  58. "void",
  59. "ref",
  60. "true",
  61. "false",
  62. "with"
  63. ],
  64. operators: [
  65. "=",
  66. ">",
  67. "<",
  68. "<=",
  69. ">=",
  70. "==",
  71. "!",
  72. "!=",
  73. ":=",
  74. "::=",
  75. "&&",
  76. "||",
  77. "+",
  78. "-",
  79. "*",
  80. "/",
  81. "@",
  82. "&",
  83. "%",
  84. ":",
  85. "->",
  86. "\\",
  87. "$",
  88. "??",
  89. "^"
  90. ],
  91. symbols: /[@$=><!~?:&|+\-*\\\/\^%]+/,
  92. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  93. tokenizer: {
  94. root: [
  95. [
  96. /[a-zA-Z_]\w*/,
  97. {
  98. cases: {
  99. "@keywords": "keyword",
  100. "@types": "type",
  101. "@default": "identifier"
  102. }
  103. }
  104. ],
  105. { include: "@whitespace" },
  106. [/[{}()\[\]]/, "delimiter"],
  107. [/[<>](?!@symbols)/, "delimiter"],
  108. [
  109. /@symbols/,
  110. {
  111. cases: {
  112. "@operators": "delimiter",
  113. "@default": ""
  114. }
  115. }
  116. ],
  117. [/((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)/, "number"],
  118. [/[;,.]/, "delimiter"],
  119. [/"([^"\\]|\\.)*$/, "string.invalid"],
  120. [/"/, "string", "@string"]
  121. ],
  122. whitespace: [
  123. [/[ \t\r\n]+/, ""],
  124. [/\/\*/, "comment", "@comment"],
  125. [/\/\/.*$/, "comment"]
  126. ],
  127. comment: [
  128. [/[^\/*]+/, "comment"],
  129. [/\*\//, "comment", "@pop"],
  130. [/[\/*]/, "comment"]
  131. ],
  132. string: [
  133. [/[^\\"]+/, "string"],
  134. [/@escapes/, "string.escape"],
  135. [/\\./, "string.escape.invalid"],
  136. [/"/, "string", "@pop"]
  137. ]
  138. }
  139. };
  140. export {
  141. conf,
  142. language
  143. };