-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9b6952
commit 1a2347a
Showing
16 changed files
with
296 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// https://qiskit.github.io/openqasm/grammar/index.html | ||
|
||
Prism.languages.openqasm = { | ||
'comment': /\/\*[\s\S]*?\*\/|\/\/.*/, | ||
'string': { | ||
pattern: /"[^"\r\n\t]*"|'[^'\r\n\t]*'/, | ||
greedy: true | ||
}, | ||
|
||
'keyword': /\b(?: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|CX|OPENQASM|U)\b|#pragma\b/, | ||
'class-name': /\b(?:angle|bit|bool|creg|fixed|float|int|length|qreg|qubit|stretch|uint)\b/, | ||
'function': /\b(?:sin|cos|tan|exp|ln|sqrt|rotl|rotr|popcount)\b(?=\s*\()/, | ||
|
||
'constant': /\b(?:pi|tau|euler)\b|[π𝜏ℇ]/, | ||
'number': { | ||
pattern: /(^|[^.\w$])(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?(?:dt|ns|us|µs|ms|s)?/i, | ||
lookbehind: true | ||
}, | ||
'operator': /->|>>=?|<<=?|&&|\|\||\+\+|--|[!=<>&|~^+\-*/%]=?|@/, | ||
'punctuation': /[(){}\[\];,:.]/ | ||
}; | ||
|
||
Prism.languages.qasm = Prism.languages.openqasm; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<h2>Full example</h2> | ||
<pre class="language-cpp"><code>// https://github.com/Qiskit/openqasm | ||
/* | ||
* Repeat-until-success circuit for Rz(theta), | ||
* cos(theta-pi)=3/5, from Nielsen and Chuang, Chapter 4. | ||
*/ | ||
OPENQASM 3; | ||
include "stdgates.inc"; | ||
|
||
/* | ||
* Applies identity if out is 01, 10, or 11 and a Z-rotation by | ||
* theta + pi where cos(theta)=3/5 if out is 00. | ||
* The 00 outcome occurs with probability 5/8. | ||
*/ | ||
def segment qubit[2]:anc, qubit:psi -> bit[2] { | ||
bit[2] b; | ||
reset anc; | ||
h anc; | ||
ccx anc[0], anc[1], psi; | ||
s psi; | ||
ccx anc[0], anc[1], psi; | ||
z psi; | ||
h anc; | ||
measure anc -> b; | ||
return b; | ||
} | ||
|
||
qubit input; | ||
qubit ancilla[2]; | ||
bit flags[2] = "11"; | ||
bit output; | ||
|
||
reset input; | ||
h input; | ||
|
||
// braces are optional in this case | ||
while(int(flags) != 0) { | ||
flags = segment ancilla, input; | ||
} | ||
rz(pi - arccos(3 / 5)) input; | ||
h input; | ||
output = measure input; // should get zero | ||
</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.