qsharp.js 5.7 KB

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