d09c7085a8009dcf81cf78d59c110de92cdc2841ff947b36478661eb43282db6da0626992ae905abe04c543b1d6f9451379958bd55f71fe36ebbe06f9213d5 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.34.1(547870b6881302c5b4ff32173c16d06009e3588f)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. // src/basic-languages/qsharp/qsharp.ts
  8. var conf = {
  9. comments: {
  10. lineComment: "//"
  11. },
  12. brackets: [
  13. ["{", "}"],
  14. ["[", "]"],
  15. ["(", ")"]
  16. ],
  17. autoClosingPairs: [
  18. { open: "{", close: "}" },
  19. { open: "[", close: "]" },
  20. { open: "(", close: ")" },
  21. { open: '"', close: '"', notIn: ["string", "comment"] }
  22. ],
  23. surroundingPairs: [
  24. { open: "{", close: "}" },
  25. { open: "[", close: "]" },
  26. { open: "(", close: ")" },
  27. { open: '"', close: '"' }
  28. ]
  29. };
  30. var language = {
  31. keywords: [
  32. "namespace",
  33. "open",
  34. "as",
  35. "operation",
  36. "function",
  37. "body",
  38. "adjoint",
  39. "newtype",
  40. "controlled",
  41. "if",
  42. "elif",
  43. "else",
  44. "repeat",
  45. "until",
  46. "fixup",
  47. "for",
  48. "in",
  49. "while",
  50. "return",
  51. "fail",
  52. "within",
  53. "apply",
  54. "Adjoint",
  55. "Controlled",
  56. "Adj",
  57. "Ctl",
  58. "is",
  59. "self",
  60. "auto",
  61. "distribute",
  62. "invert",
  63. "intrinsic",
  64. "let",
  65. "set",
  66. "w/",
  67. "new",
  68. "not",
  69. "and",
  70. "or",
  71. "use",
  72. "borrow",
  73. "using",
  74. "borrowing",
  75. "mutable",
  76. "internal"
  77. ],
  78. typeKeywords: [
  79. "Unit",
  80. "Int",
  81. "BigInt",
  82. "Double",
  83. "Bool",
  84. "String",
  85. "Qubit",
  86. "Result",
  87. "Pauli",
  88. "Range"
  89. ],
  90. invalidKeywords: [
  91. "abstract",
  92. "base",
  93. "bool",
  94. "break",
  95. "byte",
  96. "case",
  97. "catch",
  98. "char",
  99. "checked",
  100. "class",
  101. "const",
  102. "continue",
  103. "decimal",
  104. "default",
  105. "delegate",
  106. "do",
  107. "double",
  108. "enum",
  109. "event",
  110. "explicit",
  111. "extern",
  112. "finally",
  113. "fixed",
  114. "float",
  115. "foreach",
  116. "goto",
  117. "implicit",
  118. "int",
  119. "interface",
  120. "lock",
  121. "long",
  122. "null",
  123. "object",
  124. "operator",
  125. "out",
  126. "override",
  127. "params",
  128. "private",
  129. "protected",
  130. "public",
  131. "readonly",
  132. "ref",
  133. "sbyte",
  134. "sealed",
  135. "short",
  136. "sizeof",
  137. "stackalloc",
  138. "static",
  139. "string",
  140. "struct",
  141. "switch",
  142. "this",
  143. "throw",
  144. "try",
  145. "typeof",
  146. "unit",
  147. "ulong",
  148. "unchecked",
  149. "unsafe",
  150. "ushort",
  151. "virtual",
  152. "void",
  153. "volatile"
  154. ],
  155. constants: ["true", "false", "PauliI", "PauliX", "PauliY", "PauliZ", "One", "Zero"],
  156. builtin: [
  157. "X",
  158. "Y",
  159. "Z",
  160. "H",
  161. "HY",
  162. "S",
  163. "T",
  164. "SWAP",
  165. "CNOT",
  166. "CCNOT",
  167. "MultiX",
  168. "R",
  169. "RFrac",
  170. "Rx",
  171. "Ry",
  172. "Rz",
  173. "R1",
  174. "R1Frac",
  175. "Exp",
  176. "ExpFrac",
  177. "Measure",
  178. "M",
  179. "MultiM",
  180. "Message",
  181. "Length",
  182. "Assert",
  183. "AssertProb",
  184. "AssertEqual"
  185. ],
  186. operators: [
  187. "and=",
  188. "<-",
  189. "->",
  190. "*",
  191. "*=",
  192. "@",
  193. "!",
  194. "^",
  195. "^=",
  196. ":",
  197. "::",
  198. "..",
  199. "==",
  200. "...",
  201. "=",
  202. "=>",
  203. ">",
  204. ">=",
  205. "<",
  206. "<=",
  207. "-",
  208. "-=",
  209. "!=",
  210. "or=",
  211. "%",
  212. "%=",
  213. "|",
  214. "+",
  215. "+=",
  216. "?",
  217. "/",
  218. "/=",
  219. "&&&",
  220. "&&&=",
  221. "^^^",
  222. "^^^=",
  223. ">>>",
  224. ">>>=",
  225. "<<<",
  226. "<<<=",
  227. "|||",
  228. "|||=",
  229. "~~~",
  230. "_",
  231. "w/",
  232. "w/="
  233. ],
  234. namespaceFollows: ["namespace", "open"],
  235. symbols: /[=><!~?:&|+\-*\/\^%@._]+/,
  236. escapes: /\\[\s\S]/,
  237. tokenizer: {
  238. root: [
  239. [
  240. /[a-zA-Z_$][\w$]*/,
  241. {
  242. cases: {
  243. "@namespaceFollows": {
  244. token: "keyword.$0",
  245. next: "@namespace"
  246. },
  247. "@typeKeywords": "type",
  248. "@keywords": "keyword",
  249. "@constants": "constant",
  250. "@builtin": "keyword",
  251. "@invalidKeywords": "invalid",
  252. "@default": "identifier"
  253. }
  254. }
  255. ],
  256. { include: "@whitespace" },
  257. [/[{}()\[\]]/, "@brackets"],
  258. [/@symbols/, { cases: { "@operators": "operator", "@default": "" } }],
  259. [/\d*\.\d+([eE][\-+]?\d+)?/, "number.float"],
  260. [/\d+/, "number"],
  261. [/[;,.]/, "delimiter"],
  262. [/"/, { token: "string.quote", bracket: "@open", next: "@string" }]
  263. ],
  264. string: [
  265. [/[^\\"]+/, "string"],
  266. [/@escapes/, "string.escape"],
  267. [/"/, { token: "string.quote", bracket: "@close", next: "@pop" }]
  268. ],
  269. namespace: [
  270. { include: "@whitespace" },
  271. [/[A-Za-z]\w*/, "namespace"],
  272. [/[\.=]/, "delimiter"],
  273. ["", "", "@pop"]
  274. ],
  275. whitespace: [
  276. [/[ \t\r\n]+/, "white"],
  277. [/(\/\/).*/, "comment"]
  278. ]
  279. }
  280. };
  281. export {
  282. conf,
  283. language
  284. };