cameligo.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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/cameligo/cameligo.ts
  8. var conf = {
  9. comments: {
  10. lineComment: "//",
  11. blockComment: ["(*", "*)"]
  12. },
  13. brackets: [
  14. ["{", "}"],
  15. ["[", "]"],
  16. ["(", ")"],
  17. ["<", ">"]
  18. ],
  19. autoClosingPairs: [
  20. { open: "{", close: "}" },
  21. { open: "[", close: "]" },
  22. { open: "(", close: ")" },
  23. { open: "<", close: ">" },
  24. { open: "'", close: "'" },
  25. { open: '"', close: '"' },
  26. { open: "(*", close: "*)" }
  27. ],
  28. surroundingPairs: [
  29. { open: "{", close: "}" },
  30. { open: "[", close: "]" },
  31. { open: "(", close: ")" },
  32. { open: "<", close: ">" },
  33. { open: "'", close: "'" },
  34. { open: '"', close: '"' },
  35. { open: "(*", close: "*)" }
  36. ]
  37. };
  38. var language = {
  39. defaultToken: "",
  40. tokenPostfix: ".cameligo",
  41. ignoreCase: true,
  42. brackets: [
  43. { open: "{", close: "}", token: "delimiter.curly" },
  44. { open: "[", close: "]", token: "delimiter.square" },
  45. { open: "(", close: ")", token: "delimiter.parenthesis" },
  46. { open: "<", close: ">", token: "delimiter.angle" }
  47. ],
  48. keywords: [
  49. "abs",
  50. "assert",
  51. "block",
  52. "Bytes",
  53. "case",
  54. "Crypto",
  55. "Current",
  56. "else",
  57. "failwith",
  58. "false",
  59. "for",
  60. "fun",
  61. "if",
  62. "in",
  63. "let",
  64. "let%entry",
  65. "let%init",
  66. "List",
  67. "list",
  68. "Map",
  69. "map",
  70. "match",
  71. "match%nat",
  72. "mod",
  73. "not",
  74. "operation",
  75. "Operation",
  76. "of",
  77. "record",
  78. "Set",
  79. "set",
  80. "sender",
  81. "skip",
  82. "source",
  83. "String",
  84. "then",
  85. "to",
  86. "true",
  87. "type",
  88. "with"
  89. ],
  90. typeKeywords: ["int", "unit", "string", "tz", "nat", "bool"],
  91. operators: [
  92. "=",
  93. ">",
  94. "<",
  95. "<=",
  96. ">=",
  97. "<>",
  98. ":",
  99. ":=",
  100. "and",
  101. "mod",
  102. "or",
  103. "+",
  104. "-",
  105. "*",
  106. "/",
  107. "@",
  108. "&",
  109. "^",
  110. "%",
  111. "->",
  112. "<-",
  113. "&&",
  114. "||"
  115. ],
  116. symbols: /[=><:@\^&|+\-*\/\^%]+/,
  117. tokenizer: {
  118. root: [
  119. [
  120. /[a-zA-Z_][\w]*/,
  121. {
  122. cases: {
  123. "@keywords": { token: "keyword.$0" },
  124. "@default": "identifier"
  125. }
  126. }
  127. ],
  128. { include: "@whitespace" },
  129. [/[{}()\[\]]/, "@brackets"],
  130. [/[<>](?!@symbols)/, "@brackets"],
  131. [
  132. /@symbols/,
  133. {
  134. cases: {
  135. "@operators": "delimiter",
  136. "@default": ""
  137. }
  138. }
  139. ],
  140. [/\d*\.\d+([eE][\-+]?\d+)?/, "number.float"],
  141. [/\$[0-9a-fA-F]{1,16}/, "number.hex"],
  142. [/\d+/, "number"],
  143. [/[;,.]/, "delimiter"],
  144. [/'([^'\\]|\\.)*$/, "string.invalid"],
  145. [/'/, "string", "@string"],
  146. [/'[^\\']'/, "string"],
  147. [/'/, "string.invalid"],
  148. [/\#\d+/, "string"]
  149. ],
  150. comment: [
  151. [/[^\(\*]+/, "comment"],
  152. [/\*\)/, "comment", "@pop"],
  153. [/\(\*/, "comment"]
  154. ],
  155. string: [
  156. [/[^\\']+/, "string"],
  157. [/\\./, "string.escape.invalid"],
  158. [/'/, { token: "string.quote", bracket: "@close", next: "@pop" }]
  159. ],
  160. whitespace: [
  161. [/[ \t\r\n]+/, "white"],
  162. [/\(\*/, "comment", "@comment"],
  163. [/\/\/.*$/, "comment"]
  164. ]
  165. }
  166. };
  167. export {
  168. conf,
  169. language
  170. };