UNPKG

929 BJavaScriptView Raw
1// https://qiskit.github.io/openqasm/grammar/index.html
2
3Prism.languages.openqasm = {
4 'comment': /\/\*[\s\S]*?\*\/|\/\/.*/,
5 'string': {
6 pattern: /"[^"\r\n\t]*"|'[^'\r\n\t]*'/,
7 greedy: true
8 },
9
10 'keyword': /\b(?:CX|OPENQASM|U|barrier|boxas|boxto|break|const|continue|ctrl|def|defcal|defcalgrammar|delay|else|end|for|gate|gphase|if|in|include|inv|kernel|lengthof|let|measure|pow|reset|return|rotary|stretchinf|while)\b|#pragma\b/,
11 'class-name': /\b(?:angle|bit|bool|creg|fixed|float|int|length|qreg|qubit|stretch|uint)\b/,
12 'function': /\b(?:cos|exp|ln|popcount|rotl|rotr|sin|sqrt|tan)\b(?=\s*\()/,
13
14 'constant': /\b(?:euler|pi|tau)\b|π|𝜏|ℇ/,
15 'number': {
16 pattern: /(^|[^.\w$])(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?(?:dt|ns|us|µs|ms|s)?/i,
17 lookbehind: true
18 },
19 'operator': /->|>>=?|<<=?|&&|\|\||\+\+|--|[!=<>&|~^+\-*/%]=?|@/,
20 'punctuation': /[(){}\[\];,:.]/
21};
22
23Prism.languages.qasm = Prism.languages.openqasm;