prism-openqasm.js 929 B

1234567891011121314151617181920212223
  1. // https://qiskit.github.io/openqasm/grammar/index.html
  2. Prism.languages.openqasm = {
  3. 'comment': /\/\*[\s\S]*?\*\/|\/\/.*/,
  4. 'string': {
  5. pattern: /"[^"\r\n\t]*"|'[^'\r\n\t]*'/,
  6. greedy: true
  7. },
  8. '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/,
  9. 'class-name': /\b(?:angle|bit|bool|creg|fixed|float|int|length|qreg|qubit|stretch|uint)\b/,
  10. 'function': /\b(?:cos|exp|ln|popcount|rotl|rotr|sin|sqrt|tan)\b(?=\s*\()/,
  11. 'constant': /\b(?:euler|pi|tau)\b|π|𝜏|ℇ/,
  12. 'number': {
  13. pattern: /(^|[^.\w$])(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?(?:dt|ns|us|µs|ms|s)?/i,
  14. lookbehind: true
  15. },
  16. 'operator': /->|>>=?|<<=?|&&|\|\||\+\+|--|[!=<>&|~^+\-*/%]=?|@/,
  17. 'punctuation': /[(){}\[\];,:.]/
  18. };
  19. Prism.languages.qasm = Prism.languages.openqasm;