qasm-ts 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/.github/workflows/draft-pdf.yml +24 -0
  2. package/CONTRIBUTING.md +3 -0
  3. package/LICENSE +201 -0
  4. package/dist/errors.js +9 -0
  5. package/dist/lexer.js +74 -0
  6. package/dist/main.js +82 -7
  7. package/dist/parser.js +71 -0
  8. package/dist/qasm2/ast.js +33 -0
  9. package/dist/qasm2/lexer.js +54 -1
  10. package/dist/qasm2/parser.js +51 -1
  11. package/dist/qasm2/token.js +30 -0
  12. package/dist/qasm3/lexer.js +59 -1
  13. package/dist/qasm3/parser.js +55 -2
  14. package/dist/qasm3/token.js +93 -10
  15. package/dist/version.js +17 -1
  16. package/docs/assets/hierarchy.js +1 -0
  17. package/docs/custom.css +3 -0
  18. package/docs/docs-readme.md +208 -0
  19. package/docs/index.html +17 -55
  20. package/docs/typedoc/assets/custom.css +3 -0
  21. package/docs/typedoc/assets/hierarchy.js +1 -0
  22. package/docs/{assets → typedoc/assets}/highlight.css +20 -20
  23. package/docs/{assets → typedoc/assets}/icons.js +1 -1
  24. package/docs/{assets → typedoc/assets}/icons.svg +1 -1
  25. package/docs/typedoc/assets/main.js +60 -0
  26. package/docs/typedoc/assets/navigation.js +1 -0
  27. package/docs/typedoc/assets/search.js +1 -0
  28. package/docs/typedoc/assets/style.css +1633 -0
  29. package/docs/typedoc/classes/Error_Handling.BadArgumentError.html +12 -0
  30. package/docs/typedoc/classes/Error_Handling.BadBarrierError.html +12 -0
  31. package/docs/typedoc/classes/Error_Handling.BadClassicalTypeError.html +12 -0
  32. package/docs/typedoc/classes/Error_Handling.BadConditionalError.html +12 -0
  33. package/docs/typedoc/classes/Error_Handling.BadCregError.html +12 -0
  34. package/docs/typedoc/classes/Error_Handling.BadEqualsError.html +12 -0
  35. package/docs/typedoc/classes/Error_Handling.BadExpressionError.html +12 -0
  36. package/docs/typedoc/classes/Error_Handling.BadGateError.html +12 -0
  37. package/docs/typedoc/classes/Error_Handling.BadIncludeError.html +12 -0
  38. package/docs/typedoc/classes/Error_Handling.BadLoopError.html +12 -0
  39. package/docs/typedoc/classes/Error_Handling.BadMeasurementError.html +12 -0
  40. package/docs/typedoc/classes/Error_Handling.BadParameterError.html +12 -0
  41. package/docs/typedoc/classes/Error_Handling.BadQregError.html +12 -0
  42. package/docs/typedoc/classes/Error_Handling.BadQuantumInstructionError.html +12 -0
  43. package/docs/typedoc/classes/Error_Handling.BadStringLiteralError.html +12 -0
  44. package/docs/typedoc/classes/Error_Handling.BadSubroutineError.html +12 -0
  45. package/docs/typedoc/classes/Error_Handling.MissingBraceError.html +12 -0
  46. package/docs/typedoc/classes/Error_Handling.MissingSemicolonError.html +12 -0
  47. package/docs/typedoc/classes/Error_Handling.UnsupportedOpenQASMVersionError.html +12 -0
  48. package/docs/typedoc/classes/Version_Management.OpenQASMVersion.html +16 -0
  49. package/docs/typedoc/classes/qasm2_ast.ApplyGate.html +6 -0
  50. package/docs/typedoc/classes/qasm2_ast.AstNode.html +3 -0
  51. package/docs/typedoc/classes/qasm2_ast.Barrier.html +5 -0
  52. package/docs/typedoc/classes/qasm2_ast.CReg.html +5 -0
  53. package/docs/typedoc/classes/qasm2_ast.Cos.html +3 -0
  54. package/docs/typedoc/classes/qasm2_ast.Divide.html +3 -0
  55. package/docs/typedoc/classes/qasm2_ast.Exp.html +3 -0
  56. package/docs/typedoc/classes/qasm2_ast.Gate.html +7 -0
  57. package/docs/typedoc/classes/qasm2_ast.Id.html +4 -0
  58. package/docs/typedoc/classes/qasm2_ast.If.html +6 -0
  59. package/docs/typedoc/classes/qasm2_ast.Include.html +4 -0
  60. package/docs/typedoc/classes/qasm2_ast.Ln.html +3 -0
  61. package/docs/typedoc/classes/qasm2_ast.Measure.html +7 -0
  62. package/docs/typedoc/classes/qasm2_ast.Minus.html +3 -0
  63. package/docs/typedoc/classes/qasm2_ast.NNInteger.html +4 -0
  64. package/docs/typedoc/classes/qasm2_ast.Opaque.html +6 -0
  65. package/docs/typedoc/classes/qasm2_ast.Pi.html +3 -0
  66. package/docs/typedoc/classes/qasm2_ast.Plus.html +3 -0
  67. package/docs/typedoc/classes/qasm2_ast.Power.html +3 -0
  68. package/docs/typedoc/classes/qasm2_ast.QReg.html +5 -0
  69. package/docs/typedoc/classes/qasm2_ast.Real.html +4 -0
  70. package/docs/typedoc/classes/qasm2_ast.Sin.html +3 -0
  71. package/docs/typedoc/classes/qasm2_ast.Sqrt.html +3 -0
  72. package/docs/typedoc/classes/qasm2_ast.Tan.html +3 -0
  73. package/docs/typedoc/classes/qasm2_ast.Times.html +3 -0
  74. package/docs/typedoc/classes/qasm2_ast.Variable.html +4 -0
  75. package/docs/typedoc/classes/qasm2_ast.Version.html +4 -0
  76. package/docs/typedoc/classes/qasm2_lexer.default.html +57 -0
  77. package/docs/typedoc/classes/qasm2_parser.default.html +93 -0
  78. package/docs/typedoc/classes/qasm3_ast.AliasStatement.html +5 -0
  79. package/docs/typedoc/classes/qasm3_ast.AngleType.html +4 -0
  80. package/docs/typedoc/classes/qasm3_ast.Arithmetic.html +6 -0
  81. package/docs/typedoc/classes/qasm3_ast.ArrayAccess.html +5 -0
  82. package/docs/typedoc/classes/qasm3_ast.ArrayDeclaration.html +7 -0
  83. package/docs/typedoc/classes/qasm3_ast.ArrayInitializer.html +4 -0
  84. package/docs/typedoc/classes/qasm3_ast.ArrayReference.html +5 -0
  85. package/docs/typedoc/classes/qasm3_ast.AssignmentStatement.html +5 -0
  86. package/docs/typedoc/classes/qasm3_ast.AstNode.html +3 -0
  87. package/docs/typedoc/classes/qasm3_ast.Binary.html +6 -0
  88. package/docs/typedoc/classes/qasm3_ast.BitType.html +4 -0
  89. package/docs/typedoc/classes/qasm3_ast.BitstringLiteral.html +4 -0
  90. package/docs/typedoc/classes/qasm3_ast.BoolType.html +3 -0
  91. package/docs/typedoc/classes/qasm3_ast.BooleanLiteral.html +4 -0
  92. package/docs/typedoc/classes/qasm3_ast.BoxDefinition.html +7 -0
  93. package/docs/typedoc/classes/qasm3_ast.BranchingStatement.html +8 -0
  94. package/docs/typedoc/classes/qasm3_ast.BreakStatement.html +3 -0
  95. package/docs/typedoc/classes/qasm3_ast.CalibrationGrammarDeclaration.html +6 -0
  96. package/docs/typedoc/classes/qasm3_ast.CaseStatement.html +5 -0
  97. package/docs/typedoc/classes/qasm3_ast.Cast.html +5 -0
  98. package/docs/typedoc/classes/qasm3_ast.ClassicalDeclaration.html +7 -0
  99. package/docs/typedoc/classes/qasm3_ast.ClassicalType.html +3 -0
  100. package/docs/typedoc/classes/qasm3_ast.ComplexType.html +6 -0
  101. package/docs/typedoc/classes/qasm3_ast.ContinueStatement.html +3 -0
  102. package/docs/typedoc/classes/qasm3_ast.DefaultStatement.html +4 -0
  103. package/docs/typedoc/classes/qasm3_ast.DurationLiteral.html +5 -0
  104. package/docs/typedoc/classes/qasm3_ast.DurationOf.html +4 -0
  105. package/docs/typedoc/classes/qasm3_ast.DurationType.html +3 -0
  106. package/docs/typedoc/classes/qasm3_ast.Euler.html +3 -0
  107. package/docs/typedoc/classes/qasm3_ast.Expression.html +3 -0
  108. package/docs/typedoc/classes/qasm3_ast.ExternSignature.html +8 -0
  109. package/docs/typedoc/classes/qasm3_ast.FloatLiteral.html +4 -0
  110. package/docs/typedoc/classes/qasm3_ast.FloatType.html +6 -0
  111. package/docs/typedoc/classes/qasm3_ast.ForLoopStatement.html +12 -0
  112. package/docs/typedoc/classes/qasm3_ast.HardwareQubit.html +5 -0
  113. package/docs/typedoc/classes/qasm3_ast.IODeclaration.html +5 -0
  114. package/docs/typedoc/classes/qasm3_ast.Identifier.html +4 -0
  115. package/docs/typedoc/classes/qasm3_ast.ImaginaryLiteral.html +4 -0
  116. package/docs/typedoc/classes/qasm3_ast.Include.html +6 -0
  117. package/docs/typedoc/classes/qasm3_ast.IndexSet.html +5 -0
  118. package/docs/typedoc/classes/qasm3_ast.IntType.html +4 -0
  119. package/docs/typedoc/classes/qasm3_ast.IntegerLiteral.html +4 -0
  120. package/docs/typedoc/classes/qasm3_ast.MathFunction.html +5 -0
  121. package/docs/typedoc/classes/qasm3_ast.NumericLiteral.html +4 -0
  122. package/docs/typedoc/classes/qasm3_ast.Parameters.html +4 -0
  123. package/docs/typedoc/classes/qasm3_ast.Pi.html +3 -0
  124. package/docs/typedoc/classes/qasm3_ast.ProgramBlock.html +7 -0
  125. package/docs/typedoc/classes/qasm3_ast.QuantumBarrier.html +6 -0
  126. package/docs/typedoc/classes/qasm3_ast.QuantumBlock.html +6 -0
  127. package/docs/typedoc/classes/qasm3_ast.QuantumDeclaration.html +8 -0
  128. package/docs/typedoc/classes/qasm3_ast.QuantumDelay.html +5 -0
  129. package/docs/typedoc/classes/qasm3_ast.QuantumGateCall.html +9 -0
  130. package/docs/typedoc/classes/qasm3_ast.QuantumGateDefinition.html +9 -0
  131. package/docs/typedoc/classes/qasm3_ast.QuantumGateModifier.html +5 -0
  132. package/docs/typedoc/classes/qasm3_ast.QuantumMeasurement.html +6 -0
  133. package/docs/typedoc/classes/qasm3_ast.QuantumMeasurementAssignment.html +8 -0
  134. package/docs/typedoc/classes/qasm3_ast.QuantumReset.html +4 -0
  135. package/docs/typedoc/classes/qasm3_ast.Range.html +6 -0
  136. package/docs/typedoc/classes/qasm3_ast.ReturnStatement.html +4 -0
  137. package/docs/typedoc/classes/qasm3_ast.SizeOf.html +5 -0
  138. package/docs/typedoc/classes/qasm3_ast.Statement.html +12 -0
  139. package/docs/typedoc/classes/qasm3_ast.StretchType.html +3 -0
  140. package/docs/typedoc/classes/qasm3_ast.SubroutineBlock.html +6 -0
  141. package/docs/typedoc/classes/qasm3_ast.SubroutineCall.html +5 -0
  142. package/docs/typedoc/classes/qasm3_ast.SubroutineDefinition.html +10 -0
  143. package/docs/typedoc/classes/qasm3_ast.SubscriptedIdentifier.html +5 -0
  144. package/docs/typedoc/classes/qasm3_ast.SwitchStatement.html +6 -0
  145. package/docs/typedoc/classes/qasm3_ast.Tau.html +3 -0
  146. package/docs/typedoc/classes/qasm3_ast.TrigFunction.html +5 -0
  147. package/docs/typedoc/classes/qasm3_ast.UIntType.html +4 -0
  148. package/docs/typedoc/classes/qasm3_ast.Unary.html +5 -0
  149. package/docs/typedoc/classes/qasm3_ast.Version.html +6 -0
  150. package/docs/typedoc/classes/qasm3_ast.WhileLoopStatement.html +6 -0
  151. package/docs/typedoc/classes/qasm3_lexer.default.html +71 -0
  152. package/docs/typedoc/classes/qasm3_parser.default.html +237 -0
  153. package/docs/typedoc/enums/Version_Management.OpenQASMMajorVersion.html +4 -0
  154. package/docs/typedoc/enums/qasm2_token.Token.html +42 -0
  155. package/docs/typedoc/enums/qasm3_ast.ArithmeticOp.html +9 -0
  156. package/docs/typedoc/enums/qasm3_ast.ArrayReferenceModifier.html +4 -0
  157. package/docs/typedoc/enums/qasm3_ast.BinaryOp.html +15 -0
  158. package/docs/typedoc/enums/qasm3_ast.DurationUnit.html +7 -0
  159. package/docs/typedoc/enums/qasm3_ast.IOModifier.html +4 -0
  160. package/docs/typedoc/enums/qasm3_ast.MathFunctionTypes.html +12 -0
  161. package/docs/typedoc/enums/qasm3_ast.QuantumGateModifierName.html +6 -0
  162. package/docs/typedoc/enums/qasm3_ast.TrigFunctionTypes.html +8 -0
  163. package/docs/typedoc/enums/qasm3_ast.UnaryOp.html +5 -0
  164. package/docs/typedoc/enums/qasm3_token.Token.html +113 -0
  165. package/docs/typedoc/functions/Lexing.lex.html +24 -0
  166. package/docs/typedoc/functions/Main_Functions.parseFile.html +13 -0
  167. package/docs/typedoc/functions/Main_Functions.parseString.html +19 -0
  168. package/docs/typedoc/functions/Parsing.parse.html +15 -0
  169. package/docs/typedoc/functions/qasm2_token.inverseLookup.html +3 -0
  170. package/docs/typedoc/functions/qasm2_token.lookup.html +4 -0
  171. package/docs/typedoc/functions/qasm2_token.notParam.html +3 -0
  172. package/docs/typedoc/functions/qasm3_token.inverseLookup.html +9 -0
  173. package/docs/typedoc/functions/qasm3_token.lookup.html +10 -0
  174. package/docs/typedoc/functions/qasm3_token.notParam.html +11 -0
  175. package/docs/typedoc/hierarchy.html +1 -0
  176. package/docs/typedoc/index.html +76 -0
  177. package/docs/typedoc/modules/Error_Handling.html +5 -0
  178. package/docs/typedoc/modules/Lexing.html +20 -0
  179. package/docs/typedoc/modules/Main_Functions.html +2 -0
  180. package/docs/typedoc/modules/Parsing.html +24 -0
  181. package/docs/typedoc/modules/Version_Management.html +8 -0
  182. package/docs/typedoc/modules/qasm2_ast.html +22 -0
  183. package/docs/typedoc/modules/qasm2_lexer.html +24 -0
  184. package/docs/typedoc/modules/qasm2_parser.html +21 -0
  185. package/docs/typedoc/modules/qasm2_token.html +15 -0
  186. package/docs/typedoc/modules/qasm3_ast.html +26 -0
  187. package/docs/typedoc/modules/qasm3_lexer.html +25 -0
  188. package/docs/typedoc/modules/qasm3_parser.html +25 -0
  189. package/docs/typedoc/modules/qasm3_token.html +15 -0
  190. package/docs/typedoc/modules.html +1 -0
  191. package/docs/typedoc/types/Error_Handling.ReturnErrorConstructor.html +2 -0
  192. package/docs/typedoc.json +47 -0
  193. package/package.json +6 -2
  194. package/paper/jats/paper.jats +464 -0
  195. package/paper/main.bib +191 -0
  196. package/paper/paper.md +166 -0
  197. package/paper/paper.pdf +0 -0
  198. package/readme.md +63 -9
  199. package/docs/assets/main.js +0 -60
  200. package/docs/assets/navigation.js +0 -1
  201. package/docs/assets/search.js +0 -1
  202. package/docs/assets/style.css +0 -1493
  203. package/docs/classes/errors.BadArgumentError.html +0 -12
  204. package/docs/classes/errors.BadBarrierError.html +0 -12
  205. package/docs/classes/errors.BadClassicalTypeError.html +0 -12
  206. package/docs/classes/errors.BadConditionalError.html +0 -12
  207. package/docs/classes/errors.BadCregError.html +0 -12
  208. package/docs/classes/errors.BadEqualsError.html +0 -12
  209. package/docs/classes/errors.BadExpressionError.html +0 -12
  210. package/docs/classes/errors.BadGateError.html +0 -12
  211. package/docs/classes/errors.BadIncludeError.html +0 -12
  212. package/docs/classes/errors.BadLoopError.html +0 -12
  213. package/docs/classes/errors.BadMeasurementError.html +0 -12
  214. package/docs/classes/errors.BadParameterError.html +0 -12
  215. package/docs/classes/errors.BadQregError.html +0 -12
  216. package/docs/classes/errors.BadQuantumInstructionError.html +0 -12
  217. package/docs/classes/errors.BadStringLiteralError.html +0 -12
  218. package/docs/classes/errors.BadSubroutineError.html +0 -12
  219. package/docs/classes/errors.MissingBraceError.html +0 -12
  220. package/docs/classes/errors.MissingSemicolonError.html +0 -12
  221. package/docs/classes/errors.UnsupportedOpenQASMVersionError.html +0 -12
  222. package/docs/classes/qasm2_ast.ApplyGate.html +0 -6
  223. package/docs/classes/qasm2_ast.AstNode.html +0 -3
  224. package/docs/classes/qasm2_ast.Barrier.html +0 -5
  225. package/docs/classes/qasm2_ast.CReg.html +0 -5
  226. package/docs/classes/qasm2_ast.Cos.html +0 -3
  227. package/docs/classes/qasm2_ast.Divide.html +0 -3
  228. package/docs/classes/qasm2_ast.Exp.html +0 -3
  229. package/docs/classes/qasm2_ast.Gate.html +0 -7
  230. package/docs/classes/qasm2_ast.Id.html +0 -4
  231. package/docs/classes/qasm2_ast.If.html +0 -6
  232. package/docs/classes/qasm2_ast.Include.html +0 -4
  233. package/docs/classes/qasm2_ast.Ln.html +0 -3
  234. package/docs/classes/qasm2_ast.Measure.html +0 -7
  235. package/docs/classes/qasm2_ast.Minus.html +0 -3
  236. package/docs/classes/qasm2_ast.NNInteger.html +0 -4
  237. package/docs/classes/qasm2_ast.Opaque.html +0 -6
  238. package/docs/classes/qasm2_ast.Pi.html +0 -3
  239. package/docs/classes/qasm2_ast.Plus.html +0 -3
  240. package/docs/classes/qasm2_ast.Power.html +0 -3
  241. package/docs/classes/qasm2_ast.QReg.html +0 -5
  242. package/docs/classes/qasm2_ast.Real.html +0 -4
  243. package/docs/classes/qasm2_ast.Sin.html +0 -3
  244. package/docs/classes/qasm2_ast.Sqrt.html +0 -3
  245. package/docs/classes/qasm2_ast.Tan.html +0 -3
  246. package/docs/classes/qasm2_ast.Times.html +0 -3
  247. package/docs/classes/qasm2_ast.Variable.html +0 -4
  248. package/docs/classes/qasm2_ast.Version.html +0 -4
  249. package/docs/classes/qasm2_lexer.default.html +0 -50
  250. package/docs/classes/qasm2_parser.default.html +0 -87
  251. package/docs/classes/qasm3_ast.AliasStatement.html +0 -5
  252. package/docs/classes/qasm3_ast.AngleType.html +0 -4
  253. package/docs/classes/qasm3_ast.Arithmetic.html +0 -6
  254. package/docs/classes/qasm3_ast.ArrayAccess.html +0 -5
  255. package/docs/classes/qasm3_ast.ArrayDeclaration.html +0 -7
  256. package/docs/classes/qasm3_ast.ArrayInitializer.html +0 -4
  257. package/docs/classes/qasm3_ast.ArrayReference.html +0 -5
  258. package/docs/classes/qasm3_ast.AssignmentStatement.html +0 -5
  259. package/docs/classes/qasm3_ast.AstNode.html +0 -3
  260. package/docs/classes/qasm3_ast.Binary.html +0 -6
  261. package/docs/classes/qasm3_ast.BitType.html +0 -4
  262. package/docs/classes/qasm3_ast.BitstringLiteral.html +0 -4
  263. package/docs/classes/qasm3_ast.BoolType.html +0 -3
  264. package/docs/classes/qasm3_ast.BooleanLiteral.html +0 -4
  265. package/docs/classes/qasm3_ast.BoxDefinition.html +0 -7
  266. package/docs/classes/qasm3_ast.BranchingStatement.html +0 -8
  267. package/docs/classes/qasm3_ast.BreakStatement.html +0 -3
  268. package/docs/classes/qasm3_ast.CalibrationGrammarDeclaration.html +0 -6
  269. package/docs/classes/qasm3_ast.CaseStatement.html +0 -5
  270. package/docs/classes/qasm3_ast.Cast.html +0 -5
  271. package/docs/classes/qasm3_ast.ClassicalDeclaration.html +0 -7
  272. package/docs/classes/qasm3_ast.ClassicalType.html +0 -3
  273. package/docs/classes/qasm3_ast.ComplexType.html +0 -6
  274. package/docs/classes/qasm3_ast.ContinueStatement.html +0 -3
  275. package/docs/classes/qasm3_ast.DefaultStatement.html +0 -4
  276. package/docs/classes/qasm3_ast.DurationLiteral.html +0 -5
  277. package/docs/classes/qasm3_ast.DurationOf.html +0 -4
  278. package/docs/classes/qasm3_ast.DurationType.html +0 -3
  279. package/docs/classes/qasm3_ast.Euler.html +0 -3
  280. package/docs/classes/qasm3_ast.Expression.html +0 -3
  281. package/docs/classes/qasm3_ast.ExternSignature.html +0 -8
  282. package/docs/classes/qasm3_ast.FloatLiteral.html +0 -4
  283. package/docs/classes/qasm3_ast.FloatType.html +0 -6
  284. package/docs/classes/qasm3_ast.ForLoopStatement.html +0 -12
  285. package/docs/classes/qasm3_ast.HardwareQubit.html +0 -5
  286. package/docs/classes/qasm3_ast.IODeclaration.html +0 -5
  287. package/docs/classes/qasm3_ast.Identifier.html +0 -4
  288. package/docs/classes/qasm3_ast.ImaginaryLiteral.html +0 -4
  289. package/docs/classes/qasm3_ast.Include.html +0 -6
  290. package/docs/classes/qasm3_ast.IndexSet.html +0 -5
  291. package/docs/classes/qasm3_ast.IntType.html +0 -4
  292. package/docs/classes/qasm3_ast.IntegerLiteral.html +0 -4
  293. package/docs/classes/qasm3_ast.MathFunction.html +0 -5
  294. package/docs/classes/qasm3_ast.NumericLiteral.html +0 -4
  295. package/docs/classes/qasm3_ast.Parameters.html +0 -4
  296. package/docs/classes/qasm3_ast.Pi.html +0 -3
  297. package/docs/classes/qasm3_ast.ProgramBlock.html +0 -7
  298. package/docs/classes/qasm3_ast.QuantumBarrier.html +0 -6
  299. package/docs/classes/qasm3_ast.QuantumBlock.html +0 -6
  300. package/docs/classes/qasm3_ast.QuantumDeclaration.html +0 -8
  301. package/docs/classes/qasm3_ast.QuantumDelay.html +0 -5
  302. package/docs/classes/qasm3_ast.QuantumGateCall.html +0 -9
  303. package/docs/classes/qasm3_ast.QuantumGateDefinition.html +0 -9
  304. package/docs/classes/qasm3_ast.QuantumGateModifier.html +0 -5
  305. package/docs/classes/qasm3_ast.QuantumMeasurement.html +0 -6
  306. package/docs/classes/qasm3_ast.QuantumMeasurementAssignment.html +0 -8
  307. package/docs/classes/qasm3_ast.QuantumReset.html +0 -4
  308. package/docs/classes/qasm3_ast.Range.html +0 -6
  309. package/docs/classes/qasm3_ast.ReturnStatement.html +0 -4
  310. package/docs/classes/qasm3_ast.SizeOf.html +0 -5
  311. package/docs/classes/qasm3_ast.Statement.html +0 -12
  312. package/docs/classes/qasm3_ast.StretchType.html +0 -3
  313. package/docs/classes/qasm3_ast.SubroutineBlock.html +0 -6
  314. package/docs/classes/qasm3_ast.SubroutineCall.html +0 -5
  315. package/docs/classes/qasm3_ast.SubroutineDefinition.html +0 -10
  316. package/docs/classes/qasm3_ast.SubscriptedIdentifier.html +0 -5
  317. package/docs/classes/qasm3_ast.SwitchStatement.html +0 -6
  318. package/docs/classes/qasm3_ast.Tau.html +0 -3
  319. package/docs/classes/qasm3_ast.TrigFunction.html +0 -5
  320. package/docs/classes/qasm3_ast.UIntType.html +0 -4
  321. package/docs/classes/qasm3_ast.Unary.html +0 -5
  322. package/docs/classes/qasm3_ast.Version.html +0 -6
  323. package/docs/classes/qasm3_ast.WhileLoopStatement.html +0 -6
  324. package/docs/classes/qasm3_lexer.default.html +0 -60
  325. package/docs/classes/qasm3_parser.default.html +0 -227
  326. package/docs/classes/version.OpenQASMVersion.html +0 -16
  327. package/docs/enums/qasm2_token.Token.html +0 -39
  328. package/docs/enums/qasm3_ast.ArithmeticOp.html +0 -9
  329. package/docs/enums/qasm3_ast.ArrayReferenceModifier.html +0 -4
  330. package/docs/enums/qasm3_ast.BinaryOp.html +0 -15
  331. package/docs/enums/qasm3_ast.DurationUnit.html +0 -7
  332. package/docs/enums/qasm3_ast.IOModifier.html +0 -4
  333. package/docs/enums/qasm3_ast.MathFunctionTypes.html +0 -12
  334. package/docs/enums/qasm3_ast.QuantumGateModifierName.html +0 -6
  335. package/docs/enums/qasm3_ast.TrigFunctionTypes.html +0 -8
  336. package/docs/enums/qasm3_ast.UnaryOp.html +0 -5
  337. package/docs/enums/qasm3_token.Token.html +0 -101
  338. package/docs/enums/version.OpenQASMMajorVersion.html +0 -4
  339. package/docs/functions/lexer.lex.html +0 -1
  340. package/docs/functions/main.parseFile.html +0 -4
  341. package/docs/functions/main.parseString.html +0 -4
  342. package/docs/functions/parser.parse.html +0 -1
  343. package/docs/functions/qasm2_token.inverseLookup.html +0 -3
  344. package/docs/functions/qasm2_token.lookup.html +0 -4
  345. package/docs/functions/qasm2_token.notParam.html +0 -3
  346. package/docs/functions/qasm3_token.inverseLookup.html +0 -3
  347. package/docs/functions/qasm3_token.lookup.html +0 -4
  348. package/docs/functions/qasm3_token.notParam.html +0 -3
  349. package/docs/hierarchy.html +0 -1
  350. package/docs/modules/errors.html +0 -21
  351. package/docs/modules/lexer.html +0 -2
  352. package/docs/modules/main.html +0 -3
  353. package/docs/modules/parser.html +0 -2
  354. package/docs/modules/qasm2_ast.html +0 -28
  355. package/docs/modules/qasm2_lexer.html +0 -2
  356. package/docs/modules/qasm2_parser.html +0 -2
  357. package/docs/modules/qasm2_token.html +0 -5
  358. package/docs/modules/qasm3_ast.html +0 -83
  359. package/docs/modules/qasm3_lexer.html +0 -2
  360. package/docs/modules/qasm3_parser.html +0 -2
  361. package/docs/modules/qasm3_token.html +0 -5
  362. package/docs/modules/version.html +0 -3
  363. package/docs/modules.html +0 -14
  364. package/docs/types/errors.ReturnErrorConstructor.html +0 -2
  365. /package/docs/{.nojekyll → typedoc/.nojekyll} +0 -0
package/paper/main.bib ADDED
@@ -0,0 +1,191 @@
1
+ @misc{di_matteo_abstraction_2024,
2
+ title = {An Abstraction Hierarchy Toward Productive Quantum Programming},
3
+ url = {https://ieeexplore.ieee.org/document/10821267},
4
+ abstract = {Experience from seven decades of classical computing suggests that a sustainable computer industry depends on a community of software engineers writing programs to address a wide variety of specific end-user needs, achieving both performance and utility in the process. Quantum computing is an emerging technology, and we do not yet have the insight to understand what quantum software tools and practices will best support researchers, software engineers, or applications specialists. Developers for today's quantum computers are grappling with the low-level details of the hardware, and progress towards scalable devices does not yet suggest what higher-level abstractions may look like. In this paper, we analyze and reframe the current state of the quantum software stack using the language of programming models. We propose an abstraction hierarchy to support quantum software engineering and discuss the consequences of overlaps across the programming, execution, and hardware models found in current technologies. We exercise this hierarchy for solving the eigenvalue estimation problem in two ways (a variational algorithm with error mitigation, and phase estimation with error correction) and pinpoint key differences in these approaches in terms of these layered models and their overlaps. While our work points to concrete conceptual challenges and gaps in quantum programming and proposes some specific steps forward, our primary thesis is that progress hinges on thinking about the abstraction hierarchy holistically, and not just about its components.},
5
+ language = {en},
6
+ urldate = {2025-08-13},
7
+ journal = {IEEE International Conference on Quantum Computing and Engineering (QCE) 2024},
8
+ author = {Di Matteo, Olivia and Nunez-Corrales, Santiago and Stechly, Michal and Reinhardt, Steven P. and Mattson, Tim},
9
+ month = september,
10
+ year = {2024},
11
+ DOI = {10.1109/qce60285.2024.00117},
12
+ }
13
+
14
+ @article{Cross_2022,
15
+ title={OpenQASM 3: A Broader and Deeper Quantum Assembly Language},
16
+ volume={3},
17
+ ISSN={2643-6817},
18
+ url={http://dx.doi.org/10.1145/3505636},
19
+ DOI={10.1145/3505636},
20
+ number={3},
21
+ journal={ACM Transactions on Quantum Computing},
22
+ publisher={Association for Computing Machinery (ACM)},
23
+ author={Cross, Andrew and Javadi-Abhari, Ali and Alexander, Thomas and De Beaudrap, Niel and Bishop, Lev S. and Heidel, Steven and Ryan, Colm A. and Sivarajah, Prasahnt and Smolin, John and Gambetta, Jay M. and Johnson, Blake R.},
24
+ year={2022},
25
+ month=sep, pages={1–50}
26
+ }
27
+
28
+
29
+ @misc{seidel2024qrispframeworkcompilablehighlevel,
30
+ title={Qrisp: A Framework for Compilable High-Level Programming of Gate-Based Quantum Computers},
31
+ author={Raphael Seidel and Sebastian Bock and René Zander and Matic Petrič and Niklas Steinmann and Nikolay Tcholtchev and Manfred Hauswirth},
32
+ year={2024},
33
+ eprint={2406.14792},
34
+ archivePrefix={arXiv},
35
+ primaryClass={quant-ph},
36
+ url={https://arxiv.org/abs/2406.14792},
37
+ }
38
+
39
+ @article{shammah_open_2024,
40
+ title = {Open Hardware Solutions in Quantum Technology},
41
+ volume = {1},
42
+ issn = {2835-0103},
43
+ url = {http://arxiv.org/abs/2309.17233},
44
+ doi = {10.1063/5.0180987},
45
+ abstract = {Quantum technologies such as communications, computing, and sensing offer vast opportunities for advanced research and development. While an open-source ethos currently exists within some quantum technologies, especially in quantum computer programming, we argue that there are additional advantages in developing open quantum hardware (OQH). Open quantum hardware encompasses open-source software for the control of quantum devices in labs, blueprints and open-source toolkits for chip design and other hardware components, as well as openly-accessible testbeds and facilities that allow cloud-access to a wider scientific community. We provide an overview of current projects in the OQH ecosystem, identify gaps, and make recommendations on how to close them today. More open quantum hardware would accelerate technology transfer to and growth of the quantum industry and increase accessibility in science.},
46
+ number = {1},
47
+ urldate = {2024-09-09},
48
+ journal = {APL Quantum},
49
+ author = {Shammah, Nathan and Roy, Anurag Saha and Almudever, Carmen G. and Bourdeauducq, Sébastien and Butko, Anastasiia and Cancelo, Gustavo and Clark, Susan M. and Heinsoo, Johannes and Henriet, Loïc and Huang, Gang and Jurczak, Christophe and Kotilahti, Janne and Landra, Alessandro and LaRose, Ryan and Mari, Andrea and Nowrouzi, Kasra and Ockeloen-Korppi, Caspar and Prawiroatmodjo, Guen and Siddiqi, Irfan and Zeng, William J.},
50
+ month = mar,
51
+ year = {2024},
52
+ note = {arXiv:2309.17233 [physics]},
53
+ keywords = {Physics - Applied Physics},
54
+ pages = {011501},
55
+ annote = {Comment: 22 pages, 5 figures},
56
+ file = {arXiv Fulltext PDF:/Users/marcusedwards/Zotero/storage/ANMVI27I/Shammah et al. - 2024 - Open Hardware Solutions in Quantum Technology.pdf:application/pdf;arXiv.org Snapshot:/Users/marcusedwards/Zotero/storage/BVXLYT5I/2309.html:text/html},
57
+ }
58
+
59
+ @misc{edwards_three_2023,
60
+ title = {Three Quantum Programming Language Parser Implementations for the Web},
61
+ url = {http://arxiv.org/abs/2310.10802},
62
+ doi = {10.48550/arXiv.2310.10802},
63
+ abstract = {IBM has developed a quantum assembly (QASM) language particular to gate model quantum computing since 2017 [CBSG17]. Version 3.0 which adds timing, pulse control, and gate modifiers is currently undergoing finalization in 2023 [CJA+21]. In a similar vein, Pakin of Los Alamos National Laboratory published a quantum macro assembler (QMASM) for D-Wave quantum annealers in 2016 [Pak16]. This assembler specifically targets quantum annealers like D-Wave's. A comparable technology that targets continuous-variable (CV) quantum computing is the Blackbird language developed by Xanadu since 2018 [KIQ+19]. We implement parsers for each of these languages in TypeScript with a singular approach. In the cases of Blackbird and QMASM these are the first parser implementations that are web compatible and so bring these languages to a new audience and to new runtimes. This makes the parsing and execution of QMASM, QASM and Blackbird possible in web and mobile environments that don't have access to heavy compile toolchains, enabling adoption and scientific research.},
64
+ urldate = {2024-11-20},
65
+ publisher = {arXiv},
66
+ author = {Edwards, Marcus},
67
+ month = oct,
68
+ year = {2023},
69
+ note = {arXiv:2310.10802},
70
+ keywords = {Computer Science - Programming Languages, Quantum Physics},
71
+ file = {Preprint PDF:/Users/marcusedwards/Zotero/storage/68WTYTLM/Edwards - 2023 - Three Quantum Programming Language Parser Implemen.pdf:application/pdf;Snapshot:/Users/marcusedwards/Zotero/storage/ITANF7WM/2310.html:text/html},
72
+ }
73
+
74
+ @misc{noauthor_qasm_grammar_nodate,
75
+ title = {{OpenQASM} {3.0} {Grammar}},
76
+ url = {https://openqasm.com/grammar/index.html},
77
+ urldate = {2024-11-24},
78
+ note = {https://openqasm.com/grammar/index.html},
79
+ }
80
+
81
+ @misc{noauthor_qec_nodate,
82
+ title = {{QEC} {Decoder} {Toolkit} - {H}-{Series}},
83
+ url = {https://www.quantinuum.com/blog/making-fault-tolerance-a-reality-introducing-our-qec-decoder-toolkit},
84
+ urldate = {2024-11-20},
85
+ file = {QEC Decoder Toolkit - H-Series:/Users/marcusedwards/Zotero/storage/DEG3AT5Z/Quantinuum_hseries_qec_decoder_toolkit.html:text/html},
86
+ note = {https://www.quantinuum.com/blog/making-fault-tolerance-a-reality-introducing-our-qec-decoder-toolkit},
87
+ }
88
+
89
+ @inproceedings{qdmi,
90
+ title = {QDMI -- {Q}uantum {D}evice {M}anagement {I}nterface: A Standardized Interface for Quantum Computing Platforms},
91
+ shorttitle = {{QDMI -- Quantum Device Management Interface}},
92
+ booktitle = {IEEE International Conference on Quantum Computing and Engineering (QCE)},
93
+ author = {Wille, Robert and Schmid, Ludwig and Stade, Yannick and Echavarria, Jorge and Schulz, Martin and Schulz, Laura and Burgholzer, Lukas},
94
+ date = {2024},
95
+ }
96
+
97
+ @misc{noauthor_qiskit_openqasm2_nodate,
98
+ title = {{OpenQasm2} - {Qiskit} {SDK}},
99
+ url = {https://docs.quantum.ibm.com/api/qiskit/qasm2},
100
+ urldate = {2024-11-21},
101
+ note = {https://docs.quantum.ibm.com/api/qiskit/qasm2},
102
+ }
103
+
104
+ @incollection{exman_verification_2024,
105
+ address = {Cham},
106
+ title = {Verification and Validation of Quantum Software},
107
+ isbn = {978-3-031-64135-0 978-3-031-64136-7},
108
+ url = {https://link.springer.com/10.1007/978-3-031-64136-7_5},
109
+ abstract = {Abstract
110
+ Quantum software—like classic software—needs to be designed, specified, developed, and, most importantly, tested by developers. Writing tests is a complex, error-prone, and time-consuming task. Due to the particular properties of quantum physics (e.g., superposition), quantum software is inherently more complex to develop and effectively test than classical software. Nevertheless, some preliminary works have tried to bring commonly used classical testing practices for quantum computing to assess and improve the quality of quantum programs. In this chapter, we first gather 16 quantum software testing techniques that have been proposed for the IBM quantum framework, Qiskit. Then, whenever possible, we illustrate the usage of each technique (through the proposed tool that implements it, if available) on a given running example. We showcase that although several works have been proposed to ease the burn of testing quantum software, we are still in the early stages of testing in the quantum world. Researchers should focus on delivering artifacts that are usable without much hindrance to the rest of the community, and the development of quantum benchmarks should be a priority to facilitate reproducibility, replicability, and comparison between different testing techniques.},
111
+ language = {en},
112
+ urldate = {2024-11-21},
113
+ booktitle = {Quantum {Software}},
114
+ publisher = {Springer Nature Switzerland},
115
+ author = {Fortunato, Daniel and Jiménez-Navajas, Luis and Campos, José and Abreu, Rui},
116
+ editor = {Exman, Iaakov and Pérez-Castillo, Ricardo and Piattini, Mario and Felderer, Michael},
117
+ year = {2024},
118
+ doi = {10.1007/978-3-031-64136-7_5},
119
+ pages = {93--123},
120
+ file = {Full Text:/Users/marcusedwards/Zotero/storage/54MM6VMX/Fortunato et al. - 2024 - Verification and Validation of Quantum Software.pdf:application/pdf},
121
+ }
122
+
123
+ @article{zeng_first_2017,
124
+ title = {First quantum computers need smart software},
125
+ volume = {549},
126
+ copyright = {2017 Springer Nature Limited},
127
+ issn = {1476-4687},
128
+ url = {https://www.nature.com/articles/549149a},
129
+ doi = {10.1038/549149a},
130
+ abstract = {Early devices must solve real-world problems, urge Will Zeng and colleagues.},
131
+ language = {en},
132
+ number = {7671},
133
+ urldate = {2024-08-11},
134
+ journal = {Nature},
135
+ author = {Zeng, Will and Johnson, Blake and Smith, Robert and Rubin, Nick and Reagor, Matt and Ryan, Colm and Rigetti, Chad},
136
+ month = sep,
137
+ year = {2017},
138
+ note = {Publisher: Nature Publishing Group},
139
+ keywords = {Applied physics, Mathematics and computing, Quantum information, Quantum physics},
140
+ pages = {149--151},
141
+ file = {Full Text:/Users/marcusedwards/Zotero/storage/J8BV8J98/Zeng et al. - 2017 - First quantum computers need smart software.pdf:application/pdf},
142
+ }
143
+
144
+ @article{ying_floyd--hoare_2012,
145
+ title = {Floyd--hoare logic for quantum programs},
146
+ volume = {33},
147
+ issn = {0164-0925},
148
+ url = {https://dl.acm.org/doi/10.1145/2049706.2049708},
149
+ doi = {10.1145/2049706.2049708},
150
+ abstract = {Floyd--Hoare logic is a foundation of axiomatic semantics of classical programs, and it provides effective proof techniques for reasoning about correctness of classical programs. To offer similar techniques for quantum program verification and to build a logical foundation of programming methodology for quantum computers, we develop a full-fledged Floyd--Hoare logic for both partial and total correctness of quantum programs. It is proved that this logic is (relatively) complete by exploiting the power of weakest preconditions and weakest liberal preconditions for quantum programs.},
151
+ number = {6},
152
+ urldate = {2024-11-22},
153
+ journal = {ACM Trans. Program. Lang. Syst.},
154
+ author = {Ying, Mingsheng},
155
+ month = jan,
156
+ year = {2012},
157
+ pages = {19:1--19:49},
158
+ file = {Full Text PDF:/Users/marcusedwards/Zotero/storage/CUQGJ2EH/Ying - 2012 - Floyd--hoare logic for quantum programs.pdf:application/pdf},
159
+ }
160
+
161
+ @misc{noauthor_types_nodate,
162
+ title = {Types and {Casting} — {OpenQASM} {Live} {Specification} documentation},
163
+ url = {https://openqasm.com/language/types.html},
164
+ urldate = {2024-11-22},
165
+ file = {Types and Casting — OpenQASM Live Specification documentation:/Users/marcusedwards/Zotero/storage/C7FTLQJZ/types.html:text/html},
166
+ note = {https://openqasm.com/language/types.html},
167
+ }
168
+
169
+ @misc{zhao_qchecker_2023,
170
+ title = {{QChecker}: Detecting Bugs in Quantum Programs via Static Analysis},
171
+ shorttitle = {{QChecker}},
172
+ url = {http://arxiv.org/abs/2304.04387},
173
+ doi = {10.48550/arXiv.2304.04387},
174
+ abstract = {Static analysis is the process of analyzing software code without executing the software. It can help find bugs and potential problems in software that may only appear at runtime. Although many static analysis tools have been developed for classical software, due to the nature of quantum programs, these existing tools are unsuitable for analyzing quantum programs. This paper presents QChecker, a static analysis tool that supports finding bugs in quantum programs in Qiskit. QChecker consists of two main modules: a module for extracting program information based on abstract syntax tree (AST), and a module for detecting bugs based on patterns. We evaluate the performance of QChecker using the Bugs4Q benchmark. The evaluation results show that QChecker can effectively detect various bugs in quantum programs.},
175
+ urldate = {2024-11-25},
176
+ publisher = {arXiv},
177
+ author = {Zhao, Pengzhan and Wu, Xiongfei and Li, Zhuo and Zhao, Jianjun},
178
+ month = apr,
179
+ year = {2023},
180
+ note = {arXiv:2304.04387},
181
+ keywords = {Computer Science - Programming Languages, Computer Science - Software Engineering},
182
+ file = {Preprint PDF:/Users/marcusedwards/Zotero/storage/D29EPA49/Zhao et al. - 2023 - QChecker Detecting Bugs in Quantum Programs via S.pdf:application/pdf;Snapshot:/Users/marcusedwards/Zotero/storage/QNX2SHXM/2304.html:text/html},
183
+ }
184
+
185
+ @misc{osaka_2025,
186
+ author = {Aso, Noriyasu and Feluś, Karolina and Gaj, Adrian and Gokita, Shun and Góralczyk, Sławomir and Kakuko, Norihiro and Masumoto, Naoyuki and Miyaji, Kosuke and Miyanaga, Takafumi and Mori, Toshio and Noda, Kunihiro and Tsukano, Satoyuki and Ymaguchi, Masaomi and Żybort, Dobrosław},
187
+ month = {9},
188
+ title = {OQTOPUS Cloud},
189
+ url = {https://github.com/oqtopus-team/oqtopus-cloud},
190
+ year = {2024}
191
+ }
package/paper/paper.md ADDED
@@ -0,0 +1,166 @@
1
+ ---
2
+ authors:
3
+ - name: Sean Kim[^1]
4
+ affiliation: "1"
5
+ orcid: 0009-0006-1223-1895
6
+ - name: Marcus Edwards[^2]
7
+ affiliation: "2"
8
+ orcid: 0000-0001-6591-9585
9
+ tags:
10
+ - TypeScript
11
+ - Quantum computing
12
+ - Compiling
13
+ bibliography: main.bib
14
+ date: 30 July 2025
15
+ title: Enabling the Verification and Formalization of Hybrid
16
+ Quantum-Classical Computing with OpenQASM 3.0 compatible QASM-TS 2.0
17
+ affiliations:
18
+ - name: George Washington University, United States of America
19
+ index: 1
20
+ - name: University of British Columbia, Canada
21
+ index: 2
22
+ ---
23
+
24
+ # Summary
25
+
26
+ The unique features of the hybrid quantum-classical computing model
27
+ implied by the specification of OpenQASM 3.0 motivate new approaches to
28
+ quantum program verification. We implement and thoroughly test a QASM 3.0
29
+ parser in TypeScript to enable implementations of verification and validation
30
+ software, compilers, and more. We aim to
31
+ help the community to formalize the logic of hybrid quantum-classical
32
+ computing by providing tools that may help with such efforts.
33
+
34
+ ### Top Level Abstractions
35
+
36
+ The parser implements recursive descent parsing with support for
37
+ expression precedence and type checking. At a high
38
+ level, the parsing can be split into three logical sections: expression
39
+ parsing, quantum-specific parsing, and classical parsing.
40
+
41
+ Expression parsing forms the foundation for both quantum and classical
42
+ parsing by breaking down expressions into their constituent parts and
43
+ rebuilding them according to the mathematical and operator syntax
44
+ defined in the OpenQASM 3.0 official grammar
45
+ [@noauthor_qasm_grammar_nodate]. Starting with basic elements like
46
+ numbers, variables, and operators, the parser constructs an abstract
47
+ syntax tree that reflects proper operator precedence and nesting. This process handles not only mathematical
48
+ operations but also array accesses, function calls, and parameter lists,
49
+ creating a structured representation that maintains the logical
50
+ relationships between all parts of the expression.
51
+
52
+ Quantum operation parsing manages the core quantum computing elements of
53
+ QASM, ensuring that quantum operations are syntactically correct. The
54
+ parser maintains strict tracking of quantum resources through its
55
+ *gates*, *standardGates*, and *customGates* sets, validating that each
56
+ quantum operation references only properly defined gates and qubits. It
57
+ processes quantum register declarations, custom gate definitions, gate
58
+ applications (including gate modifiers), measurement operations, and
59
+ timing-critical operations like barriers and delays. Each quantum
60
+ operation is validated in its context.
61
+
62
+ The classical parsing processes classical variable declarations with
63
+ strict type checking, function definitions with parameter and return
64
+ type validation, control flow structures like conditional statements and
65
+ loops, and array operations. The parser maintains separate tracking for
66
+ classical and quantum resources while ensuring they can interact in
67
+ well-defined ways. This enables
68
+ QASM programs to express complex quantum algorithms that require
69
+ classical processing while maintaining type safety and operational
70
+ validity.
71
+
72
+ Our parser produces a strongly-typed AST that captures the full
73
+ structure of QASM programs and is designed to enable subsequent semantic
74
+ analysis.
75
+
76
+ # Statement of Need
77
+
78
+ The OpenQASM 3.0 type system supports classical and
79
+ quantum types as well as functions which can be used to specify hybrid
80
+ quantum-classical programs.
81
+
82
+ There is need for formal analysis and verification of hybrid quantum
83
+ classical programs and we argue that mathematical frameworks and
84
+ software frameworks are needed to address this gap.
85
+
86
+ Hand-in-hand with formalization efforts are the development of community
87
+ standards for quantum programming. The standardization of quantum computer programming is ongoing
88
+ [@di_matteo_abstraction_2024; @Cross_2022] and relies significantly on
89
+ open source software and frameworks including some released only last
90
+ year [@seidel2024qrispframeworkcompilablehighlevel; @qdmi]. Some
91
+ community standards such as the 2022 Open Quantum Assembly (OpenQASM)
92
+ 3.0 specification boast typing as well as interoperability and
93
+ portability between quantum systems of different types. However, others such as the QUASAR
94
+ instruction set architecture assume some backend details such as a
95
+ classical co-processor to complement the Quantum Processing Unit (QPU)
96
+ [@shammah_open_2024]. To what extent the classical surrounds of a
97
+ quantum processing unit should be assumed or specified and at what part
98
+ of the stack is an open question. This "piping" can leverage many
99
+ classical programming paradigms including web technology. What we refer
100
+ to here is distinct from cloud quantum computing which simply offers a
101
+ web-accessible front-end to users of quantum computers. Instead, we are
102
+ interested in parts of the programming model itself, such as pieces of
103
+ the compile toolchain (compilers, transpilers, assemblers, noise
104
+ profilers, schedulers) that are implemented using web technology. An
105
+ example of this is Quantinuum's QEC decoder toolkit, which uses a
106
+ WebAssembly (WASM) virtual machine (WAVM) as a real-time classical
107
+ compute environment for QEC decoding [@noauthor_qec_nodate]. Other examples include our
108
+ ports of Quantum Assembly (QASM), Quantum Macro Assembler (QMASM), and
109
+ Blackbrid to TypeScript [@edwards_three_2023].
110
+
111
+ An important part of standardization is verification. Our typed OpenQASM 3.0 parser implements a system that infers types from QASM syntax. This opens the
112
+ door to the type-based formal verification of QASM code. A body of work
113
+ exists regarding the verification of quantum software, and it is
114
+ summarized in @exman_verification_2024.
115
+
116
+ The primary future direction that we see is the development of
117
+ verification tools such as static analysis tools based on QASM-TS in the
118
+ vein of QChecker [@zhao_qchecker_2023]. This could be complemented by a
119
+ formal type theory of OpenQASM 3.0.
120
+
121
+ Virtually every quantum computing company has provided access through a hybrid cloud. This
122
+ demands that parts of the stack be implemented in web
123
+ technology, and we argue that it is optimal in a sense to use technology
124
+ that is designed for this environment when we find ourselves working in
125
+ a hybrid quantum / classical cloud. We
126
+ suggest that a closer marriage of open source efforts to the
127
+ inherently web-based stack supporting existing quantum computing
128
+ offerings is desirable.
129
+
130
+ We note that Osaka University's open-source quantum computer operating system project "Oqtopus"
131
+ already depends on and makes use of Qasm-ts [@osaka_2025] and thank the Oqtopus team for their interest
132
+ in our work.
133
+
134
+ # Outcomes
135
+
136
+ Our comparative analysis focused on two promiment OpenQASM 3.0 parsers:
137
+ Qiskit's Python ANLTR-based reference implementation and Qiskit's
138
+ experimental Rust parser.
139
+
140
+ ## Performance Benchmarking
141
+
142
+ Benchmark Results
143
+ ------------------- -------------------- -------------------- --------------------
144
+ Result ANTLR Parser Rust Parser Qasm-ts
145
+ Success Rate 100% (11/11 files) 18.2% (2/11 files) 100% (11/11 files)
146
+ Average Time 8.53 ms 0.59 ms 0.90 ms
147
+ Min Time 1.93 ms 0.55 ms 0.36 ms
148
+ Max Time 30.54 ms 0.62 ms 3.68 ms
149
+
150
+ The benchmarking reveals that when just taking into account the AST
151
+ generation, the Rust implementation generally offers superior raw
152
+ performance, but suffers from only currently supporting a subset of the
153
+ full OpenQASM 3.0 specification. The QASM-TS parser provides competitive
154
+ performance for web deployment scenarios, while the ANTLR parser offers
155
+ a balance of features and performance suitable for development and
156
+ testing.
157
+
158
+ # Acknowledgements
159
+
160
+ We would like to thank Dr. Shohini Ghose for support and helpful discussions regarding the previous version of this software package, QASM-TS 1.0, which has had use in the community by hundreds (counted by npm downloads).
161
+
162
+ [^1]: skim658\@gwu.edu
163
+
164
+ [^2]: msedward\@student.ubc.ca
165
+
166
+ # References
Binary file
package/readme.md CHANGED
@@ -1,12 +1,19 @@
1
1
  # QASM TypeScript
2
2
 
3
+ ![NPM Downloads](https://img.shields.io/npm/dy/qasm-ts)
4
+
5
+
3
6
  OpenQASM, the low-level programming language for quantum circuit specification, implemented in TypeScript.
4
7
 
5
- Language documentation is provided by IBM [here](https://github.com/Qiskit/openqasm/blob/master/spec/qasm2.rst).
8
+ QASM-TS 2.0 is an implementation of a compiler frontend for OpenQASM 2.0 and 3.0. It includes a lexer and a parser of the OpenQASM language. The source is parsed into an Intermediate Representation (IR): an Abstract Syntax Tree (AST) that captures program structure including control flow and data flow.
9
+
10
+ The package is aimed at enabling implementations of verification and validation software (such as semantic and static analyzers), compilers and more. These tools may be instrumental in the formalization of hybrid quantum-classical computing.
11
+
12
+ Language documentation is provided by IBM [here](https://openqasm.com).
6
13
 
7
14
  ## New in Version 2.0.0
8
15
 
9
- - Support for the OpenQASM 3.0 spec while retaining OpenQASM 2.0 backwards compatability.
16
+ - Support for the OpenQASM 3.0 spec while retaining OpenQASM 2.0 backwards compatibility.
10
17
 
11
18
  ## Usage
12
19
 
@@ -16,21 +23,29 @@ Import the parse function or parseString function from the package.
16
23
  import { parseFile, parseString } from 'qasm-ts';
17
24
  ```
18
25
 
19
- `parseFile` can be called with a file path to a `.qasm` file. It will parse the file and return the abstract syntax tree representation. `parseFile` can also take 3 optional parameters:
20
- 1. `version`: A `number`, `OpenQASMVersion`, or `OpenQASMMajorVersion` to specify whether to use the Qasm 2 or 3 lexer/parser (defaults to version 3).
21
- 2. `verbose`: Whether to return verbose objects that includes an extra key for each node's class name (defaults to `false`).
22
- 3. `stringify`: Whether to stringify and format the return object (defaults to `false`).
26
+ `parseFile` can be called with a `String` file path to a `.qasm` file. It will parse the file and return the abstract syntax tree representation. `parseFile` can also take 3 optional parameters:
27
+ 1. `version`: A `number`, `OpenQASMVersion`, or `OpenQASMMajorVersion`. Specifies whether to use the Qasm 2 or 3 lexer/parser (defaults to version 3).
28
+ 2. `verbose`: A `Boolean`. Whether to return verbose objects that includes an extra key for each node's class name (defaults to `false`).
29
+ 3. `stringify`: A `Boolean`. Whether to stringify and format the return object (defaults to `false`).
23
30
 
24
31
  ```ts
25
32
  let ast = parseFile("<file-path>");
26
33
  ```
27
34
 
28
- `parseString` should be called with a string of QASM code. It will parse the code and return the abstract syntax tree representation. `parseString` also takes the same optional arguments as `parseFile`.
35
+ `parseString` should be called with a `String` of QASM code. It will parse the code and return the abstract syntax tree representation. `parseString` also takes the same optional arguments as `parseFile`.
29
36
 
30
37
  ```ts
31
38
  let ast = parseString("<qasm-string>");
32
39
  ```
33
40
 
41
+ The return type for both `parseFile` and `parseString` is `Array<AstNode>`, unless the `stringify` parameter is `true`, in which case the return is a `String`.
42
+
43
+ The parser is able to recognize and handle 19 distinct types of syntax errors, which are defined and
44
+ exported in `errors.ts`. While this is not an advanced semantic or static analysis, it should enable
45
+ users to basically validate their OpenQASM 2.0 or 3.0 code.
46
+
47
+ Comprehensive API docs can be found in the `docs/` directory.
48
+
34
49
  ## Example I/O
35
50
 
36
51
  ### Input: `alignment.qasm` ([source](https://github.com/openqasm/openqasm/blob/main/examples/alignment.qasm))
@@ -52,8 +67,6 @@ barrier q;
52
67
 
53
68
  ### Output: Abstract Syntax Tree
54
69
 
55
- Run with: `const ast = parseFile("./alignment.qasm", 3);`.
56
-
57
70
  ```
58
71
  [
59
72
  Include { filename: '"stdgates.inc"' },
@@ -92,10 +105,31 @@ Run with: `const ast = parseFile("./alignment.qasm", 3);`.
92
105
  ]
93
106
  ```
94
107
 
108
+ To reproduce this output, you could run the following script in the directory where `alignment.qasm` is located.
109
+
110
+ ```
111
+ import { parseFile } from 'qasm-ts';
112
+
113
+ const ast = parseFile("./alignment.qasm", 3);
114
+
115
+ console.log(ast);
116
+ ```
117
+
118
+ To run TypeScript files, you can use any number of compilers, but we recommend `ts-node`. For more information on `ts-node`, refer to [the docs](https://www.npmjs.com/package/ts-node).
119
+
120
+ ```
121
+ ts-node script.ts
122
+ ```
123
+
95
124
  ## Source code
96
125
 
97
126
  Feel free to clone, fork, comment or contribute on [GitHub](https://github.com/comp-phys-marc/qasm-ts)!
98
127
 
128
+ ## Contributing
129
+
130
+ To get started contributing to QASM-TS, please see the open issues for a place to start.
131
+ Alternatively, you are welcome to create any issues which you feel may capture changes, improvements or additions to the package that would be useful. These may be bug reports or enhancement requests. These will be reviewed in a timely manner by a maintainer. If you are able to implement any desired functionality or bug fixes yourself, we also welcome and promise to review any pull requests. Please simply fork the repository and create a branch in your fork with the changes in question. When you create your pull request, make sure to target our repo.
132
+
99
133
  ## Transpiling
100
134
 
101
135
  ```
@@ -114,6 +148,10 @@ npm install
114
148
  npm test
115
149
  ```
116
150
 
151
+ ## Run benchmarks
152
+
153
+ To run benchmarks that compare this package's performance against pre-existing ANTLR and Rust based parsers, see the [benchmarking repo](https://github.com/seankim658/qasm-parser-testing) and its instructions.
154
+
117
155
  ## References
118
156
 
119
157
  The original OpenQASM authors:
@@ -136,3 +174,19 @@ http://www.apache.org/licenses/LICENSE-2.0
136
174
  ```
137
175
 
138
176
  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
177
+
178
+ ## How to Cite
179
+
180
+ If you are using QASM-TS for research we appreciate any citations. Please read and cite our pre-print at https://arxiv.org/abs/2412.12578.
181
+
182
+ ```
183
+ @misc{kim2024enablingverificationformalizationhybrid,
184
+ title={Enabling the Verification and Formalization of Hybrid Quantum-Classical Computing with OpenQASM 3.0 compatible QASM-TS 2.0},
185
+ author={Sean Kim and Marcus Edwards},
186
+ year={2024},
187
+ eprint={2412.12578},
188
+ archivePrefix={arXiv},
189
+ primaryClass={cs.PL},
190
+ url={https://arxiv.org/abs/2412.12578},
191
+ }
192
+ ```