sophia.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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/sophia/sophia.ts
  8. var conf = {
  9. comments: {
  10. lineComment: "//",
  11. blockComment: ["/*", "*/"]
  12. },
  13. brackets: [
  14. ["{", "}"],
  15. ["[", "]"],
  16. ["(", ")"],
  17. ["<", ">"]
  18. ],
  19. autoClosingPairs: [
  20. { open: '"', close: '"', notIn: ["string", "comment"] },
  21. { open: "{", close: "}", notIn: ["string", "comment"] },
  22. { open: "[", close: "]", notIn: ["string", "comment"] },
  23. { open: "(", close: ")", notIn: ["string", "comment"] }
  24. ]
  25. };
  26. var language = {
  27. defaultToken: "",
  28. tokenPostfix: ".aes",
  29. brackets: [
  30. { token: "delimiter.curly", open: "{", close: "}" },
  31. { token: "delimiter.parenthesis", open: "(", close: ")" },
  32. { token: "delimiter.square", open: "[", close: "]" },
  33. { token: "delimiter.angle", open: "<", close: ">" }
  34. ],
  35. keywords: [
  36. "contract",
  37. "library",
  38. "entrypoint",
  39. "function",
  40. "stateful",
  41. "state",
  42. "hash",
  43. "signature",
  44. "tuple",
  45. "list",
  46. "address",
  47. "string",
  48. "bool",
  49. "int",
  50. "record",
  51. "datatype",
  52. "type",
  53. "option",
  54. "oracle",
  55. "oracle_query",
  56. "Call",
  57. "Bits",
  58. "Bytes",
  59. "Oracle",
  60. "String",
  61. "Crypto",
  62. "Address",
  63. "Auth",
  64. "Chain",
  65. "None",
  66. "Some",
  67. "bits",
  68. "bytes",
  69. "event",
  70. "let",
  71. "map",
  72. "private",
  73. "public",
  74. "true",
  75. "false",
  76. "var",
  77. "if",
  78. "else",
  79. "throw"
  80. ],
  81. operators: [
  82. "=",
  83. ">",
  84. "<",
  85. "!",
  86. "~",
  87. "?",
  88. "::",
  89. ":",
  90. "==",
  91. "<=",
  92. ">=",
  93. "!=",
  94. "&&",
  95. "||",
  96. "++",
  97. "--",
  98. "+",
  99. "-",
  100. "*",
  101. "/",
  102. "&",
  103. "|",
  104. "^",
  105. "%",
  106. "<<",
  107. ">>",
  108. ">>>",
  109. "+=",
  110. "-=",
  111. "*=",
  112. "/=",
  113. "&=",
  114. "|=",
  115. "^=",
  116. "%=",
  117. "<<=",
  118. ">>=",
  119. ">>>="
  120. ],
  121. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  122. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  123. integersuffix: /(ll|LL|u|U|l|L)?(ll|LL|u|U|l|L)?/,
  124. floatsuffix: /[fFlL]?/,
  125. tokenizer: {
  126. root: [
  127. [
  128. /[a-zA-Z_]\w*/,
  129. {
  130. cases: {
  131. "@keywords": { token: "keyword.$0" },
  132. "@default": "identifier"
  133. }
  134. }
  135. ],
  136. { include: "@whitespace" },
  137. [/\[\[.*\]\]/, "annotation"],
  138. [/^\s*#\w+/, "keyword"],
  139. [/int\d*/, "keyword"],
  140. [/[{}()\[\]]/, "@brackets"],
  141. [/[<>](?!@symbols)/, "@brackets"],
  142. [
  143. /@symbols/,
  144. {
  145. cases: {
  146. "@operators": "delimiter",
  147. "@default": ""
  148. }
  149. }
  150. ],
  151. [/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, "number.float"],
  152. [/\d*\.\d+([eE][\-+]?\d+)?(@floatsuffix)/, "number.float"],
  153. [/0[xX][0-9a-fA-F']*[0-9a-fA-F](@integersuffix)/, "number.hex"],
  154. [/0[0-7']*[0-7](@integersuffix)/, "number.octal"],
  155. [/0[bB][0-1']*[0-1](@integersuffix)/, "number.binary"],
  156. [/\d[\d']*\d(@integersuffix)/, "number"],
  157. [/\d(@integersuffix)/, "number"],
  158. [/[;,.]/, "delimiter"],
  159. [/"([^"\\]|\\.)*$/, "string.invalid"],
  160. [/"/, "string", "@string"],
  161. [/'[^\\']'/, "string"],
  162. [/(')(@escapes)(')/, ["string", "string.escape", "string"]],
  163. [/'/, "string.invalid"]
  164. ],
  165. whitespace: [
  166. [/[ \t\r\n]+/, ""],
  167. [/\/\*\*(?!\/)/, "comment.doc", "@doccomment"],
  168. [/\/\*/, "comment", "@comment"],
  169. [/\/\/.*$/, "comment"]
  170. ],
  171. comment: [
  172. [/[^\/*]+/, "comment"],
  173. [/\*\//, "comment", "@pop"],
  174. [/[\/*]/, "comment"]
  175. ],
  176. doccomment: [
  177. [/[^\/*]+/, "comment.doc"],
  178. [/\*\//, "comment.doc", "@pop"],
  179. [/[\/*]/, "comment.doc"]
  180. ],
  181. string: [
  182. [/[^\\"]+/, "string"],
  183. [/@escapes/, "string.escape"],
  184. [/\\./, "string.escape.invalid"],
  185. [/"/, "string", "@pop"]
  186. ]
  187. }
  188. };
  189. export {
  190. conf,
  191. language
  192. };