qasm-ts 1.1.3 → 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.
- package/.eslintrc.json +13 -0
- package/.github/workflows/draft-pdf.yml +24 -0
- package/CONTRIBUTING.md +3 -0
- package/LICENSE +201 -0
- package/dist/errors.js +128 -2
- package/dist/lexer.js +110 -291
- package/dist/main.js +123 -18
- package/dist/parser.js +117 -482
- package/dist/{ast.js → qasm2/ast.js} +71 -2
- package/dist/qasm2/lexer.js +489 -0
- package/dist/qasm2/parser.js +659 -0
- package/dist/qasm2/token.js +160 -0
- package/dist/qasm3/ast.js +1081 -0
- package/dist/qasm3/lexer.js +673 -0
- package/dist/qasm3/parser.js +2083 -0
- package/dist/qasm3/token.js +425 -0
- package/dist/version.js +57 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/custom.css +3 -0
- package/docs/docs-readme.md +208 -0
- package/docs/index.html +17 -0
- package/docs/typedoc/.nojekyll +1 -0
- package/docs/typedoc/assets/custom.css +3 -0
- package/docs/typedoc/assets/hierarchy.js +1 -0
- package/docs/typedoc/assets/highlight.css +99 -0
- package/docs/typedoc/assets/icons.js +18 -0
- package/docs/typedoc/assets/icons.svg +1 -0
- package/docs/typedoc/assets/main.js +60 -0
- package/docs/typedoc/assets/navigation.js +1 -0
- package/docs/typedoc/assets/search.js +1 -0
- package/docs/typedoc/assets/style.css +1633 -0
- package/docs/typedoc/classes/Error_Handling.BadArgumentError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadBarrierError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadClassicalTypeError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadConditionalError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadCregError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadEqualsError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadExpressionError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadGateError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadIncludeError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadLoopError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadMeasurementError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadParameterError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadQregError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadQuantumInstructionError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadStringLiteralError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.BadSubroutineError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.MissingBraceError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.MissingSemicolonError.html +12 -0
- package/docs/typedoc/classes/Error_Handling.UnsupportedOpenQASMVersionError.html +12 -0
- package/docs/typedoc/classes/Version_Management.OpenQASMVersion.html +16 -0
- package/docs/typedoc/classes/qasm2_ast.ApplyGate.html +6 -0
- package/docs/typedoc/classes/qasm2_ast.AstNode.html +3 -0
- package/docs/typedoc/classes/qasm2_ast.Barrier.html +5 -0
- package/docs/typedoc/classes/qasm2_ast.CReg.html +5 -0
- package/docs/typedoc/classes/qasm2_ast.Cos.html +3 -0
- package/docs/typedoc/classes/qasm2_ast.Divide.html +3 -0
- package/docs/typedoc/classes/qasm2_ast.Exp.html +3 -0
- package/docs/typedoc/classes/qasm2_ast.Gate.html +7 -0
- package/docs/typedoc/classes/qasm2_ast.Id.html +4 -0
- package/docs/typedoc/classes/qasm2_ast.If.html +6 -0
- package/docs/typedoc/classes/qasm2_ast.Include.html +4 -0
- package/docs/typedoc/classes/qasm2_ast.Ln.html +3 -0
- package/docs/typedoc/classes/qasm2_ast.Measure.html +7 -0
- package/docs/typedoc/classes/qasm2_ast.Minus.html +3 -0
- package/docs/typedoc/classes/qasm2_ast.NNInteger.html +4 -0
- package/docs/typedoc/classes/qasm2_ast.Opaque.html +6 -0
- package/docs/typedoc/classes/qasm2_ast.Pi.html +3 -0
- package/docs/typedoc/classes/qasm2_ast.Plus.html +3 -0
- package/docs/typedoc/classes/qasm2_ast.Power.html +3 -0
- package/docs/typedoc/classes/qasm2_ast.QReg.html +5 -0
- package/docs/typedoc/classes/qasm2_ast.Real.html +4 -0
- package/docs/typedoc/classes/qasm2_ast.Sin.html +3 -0
- package/docs/typedoc/classes/qasm2_ast.Sqrt.html +3 -0
- package/docs/typedoc/classes/qasm2_ast.Tan.html +3 -0
- package/docs/typedoc/classes/qasm2_ast.Times.html +3 -0
- package/docs/typedoc/classes/qasm2_ast.Variable.html +4 -0
- package/docs/typedoc/classes/qasm2_ast.Version.html +4 -0
- package/docs/typedoc/classes/qasm2_lexer.default.html +57 -0
- package/docs/typedoc/classes/qasm2_parser.default.html +93 -0
- package/docs/typedoc/classes/qasm3_ast.AliasStatement.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.AngleType.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.Arithmetic.html +6 -0
- package/docs/typedoc/classes/qasm3_ast.ArrayAccess.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.ArrayDeclaration.html +7 -0
- package/docs/typedoc/classes/qasm3_ast.ArrayInitializer.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.ArrayReference.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.AssignmentStatement.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.AstNode.html +3 -0
- package/docs/typedoc/classes/qasm3_ast.Binary.html +6 -0
- package/docs/typedoc/classes/qasm3_ast.BitType.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.BitstringLiteral.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.BoolType.html +3 -0
- package/docs/typedoc/classes/qasm3_ast.BooleanLiteral.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.BoxDefinition.html +7 -0
- package/docs/typedoc/classes/qasm3_ast.BranchingStatement.html +8 -0
- package/docs/typedoc/classes/qasm3_ast.BreakStatement.html +3 -0
- package/docs/typedoc/classes/qasm3_ast.CalibrationGrammarDeclaration.html +6 -0
- package/docs/typedoc/classes/qasm3_ast.CaseStatement.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.Cast.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.ClassicalDeclaration.html +7 -0
- package/docs/typedoc/classes/qasm3_ast.ClassicalType.html +3 -0
- package/docs/typedoc/classes/qasm3_ast.ComplexType.html +6 -0
- package/docs/typedoc/classes/qasm3_ast.ContinueStatement.html +3 -0
- package/docs/typedoc/classes/qasm3_ast.DefaultStatement.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.DurationLiteral.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.DurationOf.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.DurationType.html +3 -0
- package/docs/typedoc/classes/qasm3_ast.Euler.html +3 -0
- package/docs/typedoc/classes/qasm3_ast.Expression.html +3 -0
- package/docs/typedoc/classes/qasm3_ast.ExternSignature.html +8 -0
- package/docs/typedoc/classes/qasm3_ast.FloatLiteral.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.FloatType.html +6 -0
- package/docs/typedoc/classes/qasm3_ast.ForLoopStatement.html +12 -0
- package/docs/typedoc/classes/qasm3_ast.HardwareQubit.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.IODeclaration.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.Identifier.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.ImaginaryLiteral.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.Include.html +6 -0
- package/docs/typedoc/classes/qasm3_ast.IndexSet.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.IntType.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.IntegerLiteral.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.MathFunction.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.NumericLiteral.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.Parameters.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.Pi.html +3 -0
- package/docs/typedoc/classes/qasm3_ast.ProgramBlock.html +7 -0
- package/docs/typedoc/classes/qasm3_ast.QuantumBarrier.html +6 -0
- package/docs/typedoc/classes/qasm3_ast.QuantumBlock.html +6 -0
- package/docs/typedoc/classes/qasm3_ast.QuantumDeclaration.html +8 -0
- package/docs/typedoc/classes/qasm3_ast.QuantumDelay.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.QuantumGateCall.html +9 -0
- package/docs/typedoc/classes/qasm3_ast.QuantumGateDefinition.html +9 -0
- package/docs/typedoc/classes/qasm3_ast.QuantumGateModifier.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.QuantumMeasurement.html +6 -0
- package/docs/typedoc/classes/qasm3_ast.QuantumMeasurementAssignment.html +8 -0
- package/docs/typedoc/classes/qasm3_ast.QuantumReset.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.Range.html +6 -0
- package/docs/typedoc/classes/qasm3_ast.ReturnStatement.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.SizeOf.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.Statement.html +12 -0
- package/docs/typedoc/classes/qasm3_ast.StretchType.html +3 -0
- package/docs/typedoc/classes/qasm3_ast.SubroutineBlock.html +6 -0
- package/docs/typedoc/classes/qasm3_ast.SubroutineCall.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.SubroutineDefinition.html +10 -0
- package/docs/typedoc/classes/qasm3_ast.SubscriptedIdentifier.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.SwitchStatement.html +6 -0
- package/docs/typedoc/classes/qasm3_ast.Tau.html +3 -0
- package/docs/typedoc/classes/qasm3_ast.TrigFunction.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.UIntType.html +4 -0
- package/docs/typedoc/classes/qasm3_ast.Unary.html +5 -0
- package/docs/typedoc/classes/qasm3_ast.Version.html +6 -0
- package/docs/typedoc/classes/qasm3_ast.WhileLoopStatement.html +6 -0
- package/docs/typedoc/classes/qasm3_lexer.default.html +71 -0
- package/docs/typedoc/classes/qasm3_parser.default.html +237 -0
- package/docs/typedoc/enums/Version_Management.OpenQASMMajorVersion.html +4 -0
- package/docs/typedoc/enums/qasm2_token.Token.html +42 -0
- package/docs/typedoc/enums/qasm3_ast.ArithmeticOp.html +9 -0
- package/docs/typedoc/enums/qasm3_ast.ArrayReferenceModifier.html +4 -0
- package/docs/typedoc/enums/qasm3_ast.BinaryOp.html +15 -0
- package/docs/typedoc/enums/qasm3_ast.DurationUnit.html +7 -0
- package/docs/typedoc/enums/qasm3_ast.IOModifier.html +4 -0
- package/docs/typedoc/enums/qasm3_ast.MathFunctionTypes.html +12 -0
- package/docs/typedoc/enums/qasm3_ast.QuantumGateModifierName.html +6 -0
- package/docs/typedoc/enums/qasm3_ast.TrigFunctionTypes.html +8 -0
- package/docs/typedoc/enums/qasm3_ast.UnaryOp.html +5 -0
- package/docs/typedoc/enums/qasm3_token.Token.html +113 -0
- package/docs/typedoc/functions/Lexing.lex.html +24 -0
- package/docs/typedoc/functions/Main_Functions.parseFile.html +13 -0
- package/docs/typedoc/functions/Main_Functions.parseString.html +19 -0
- package/docs/typedoc/functions/Parsing.parse.html +15 -0
- package/docs/typedoc/functions/qasm2_token.inverseLookup.html +3 -0
- package/docs/typedoc/functions/qasm2_token.lookup.html +4 -0
- package/docs/typedoc/functions/qasm2_token.notParam.html +3 -0
- package/docs/typedoc/functions/qasm3_token.inverseLookup.html +9 -0
- package/docs/typedoc/functions/qasm3_token.lookup.html +10 -0
- package/docs/typedoc/functions/qasm3_token.notParam.html +11 -0
- package/docs/typedoc/hierarchy.html +1 -0
- package/docs/typedoc/index.html +76 -0
- package/docs/typedoc/modules/Error_Handling.html +5 -0
- package/docs/typedoc/modules/Lexing.html +20 -0
- package/docs/typedoc/modules/Main_Functions.html +2 -0
- package/docs/typedoc/modules/Parsing.html +24 -0
- package/docs/typedoc/modules/Version_Management.html +8 -0
- package/docs/typedoc/modules/qasm2_ast.html +22 -0
- package/docs/typedoc/modules/qasm2_lexer.html +24 -0
- package/docs/typedoc/modules/qasm2_parser.html +21 -0
- package/docs/typedoc/modules/qasm2_token.html +15 -0
- package/docs/typedoc/modules/qasm3_ast.html +26 -0
- package/docs/typedoc/modules/qasm3_lexer.html +25 -0
- package/docs/typedoc/modules/qasm3_parser.html +25 -0
- package/docs/typedoc/modules/qasm3_token.html +15 -0
- package/docs/typedoc/modules.html +1 -0
- package/docs/typedoc/types/Error_Handling.ReturnErrorConstructor.html +2 -0
- package/docs/typedoc.json +47 -0
- package/package.json +10 -5
- package/paper/jats/paper.jats +464 -0
- package/paper/main.bib +191 -0
- package/paper/paper.md +166 -0
- package/paper/paper.pdf +0 -0
- package/readme.md +117 -47
- package/dist/example.js +0 -22
- package/dist/token.js +0 -89
package/dist/token.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.inverseLookup = exports.lookup = exports.notParam = exports.Token = void 0;
|
|
4
|
-
var Token;
|
|
5
|
-
(function (Token) {
|
|
6
|
-
Token[Token["Illegal"] = 0] = "Illegal";
|
|
7
|
-
Token[Token["EndOfFile"] = 1] = "EndOfFile";
|
|
8
|
-
Token[Token["Real"] = 2] = "Real";
|
|
9
|
-
Token[Token["NNInteger"] = 3] = "NNInteger";
|
|
10
|
-
Token[Token["Id"] = 4] = "Id";
|
|
11
|
-
Token[Token["OpenQASM"] = 5] = "OpenQASM";
|
|
12
|
-
Token[Token["Semicolon"] = 6] = "Semicolon";
|
|
13
|
-
Token[Token["Comma"] = 7] = "Comma";
|
|
14
|
-
Token[Token["LParen"] = 8] = "LParen";
|
|
15
|
-
Token[Token["LSParen"] = 9] = "LSParen";
|
|
16
|
-
Token[Token["LCParen"] = 10] = "LCParen";
|
|
17
|
-
Token[Token["RParen"] = 11] = "RParen";
|
|
18
|
-
Token[Token["RSParen"] = 12] = "RSParen";
|
|
19
|
-
Token[Token["RCParen"] = 13] = "RCParen";
|
|
20
|
-
Token[Token["Arrow"] = 14] = "Arrow";
|
|
21
|
-
Token[Token["Equals"] = 15] = "Equals";
|
|
22
|
-
Token[Token["Plus"] = 16] = "Plus";
|
|
23
|
-
Token[Token["Minus"] = 17] = "Minus";
|
|
24
|
-
Token[Token["Times"] = 18] = "Times";
|
|
25
|
-
Token[Token["Divide"] = 19] = "Divide";
|
|
26
|
-
Token[Token["Power"] = 20] = "Power";
|
|
27
|
-
Token[Token["Sin"] = 21] = "Sin";
|
|
28
|
-
Token[Token["Cos"] = 22] = "Cos";
|
|
29
|
-
Token[Token["Tan"] = 23] = "Tan";
|
|
30
|
-
Token[Token["Exp"] = 24] = "Exp";
|
|
31
|
-
Token[Token["Ln"] = 25] = "Ln";
|
|
32
|
-
Token[Token["Sqrt"] = 26] = "Sqrt";
|
|
33
|
-
Token[Token["Pi"] = 27] = "Pi";
|
|
34
|
-
Token[Token["QReg"] = 28] = "QReg";
|
|
35
|
-
Token[Token["CReg"] = 29] = "CReg";
|
|
36
|
-
Token[Token["Barrier"] = 30] = "Barrier";
|
|
37
|
-
Token[Token["Gate"] = 31] = "Gate";
|
|
38
|
-
Token[Token["Measure"] = 32] = "Measure";
|
|
39
|
-
Token[Token["Reset"] = 33] = "Reset";
|
|
40
|
-
Token[Token["Include"] = 34] = "Include";
|
|
41
|
-
Token[Token["If"] = 35] = "If";
|
|
42
|
-
Token[Token["String"] = 36] = "String";
|
|
43
|
-
})(Token || (Token = {}));
|
|
44
|
-
exports.Token = Token;
|
|
45
|
-
var lookupMap = {
|
|
46
|
-
'if': Token.If,
|
|
47
|
-
'sin': Token.Sin,
|
|
48
|
-
'cos': Token.Cos,
|
|
49
|
-
'tan': Token.Tan,
|
|
50
|
-
'exp': Token.Exp,
|
|
51
|
-
'ln': Token.Ln,
|
|
52
|
-
'sqrt': Token.Sqrt,
|
|
53
|
-
'pi': Token.Pi,
|
|
54
|
-
'+': Token.Plus,
|
|
55
|
-
'-': Token.Minus,
|
|
56
|
-
'/': Token.Divide,
|
|
57
|
-
'*': Token.Times,
|
|
58
|
-
'^': Token.Power
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Returns the token that represents a given string.
|
|
62
|
-
* @param ident - The string.
|
|
63
|
-
* @return The corresponding token.
|
|
64
|
-
*/
|
|
65
|
-
function lookup(ident) {
|
|
66
|
-
return ident in lookupMap ? lookupMap[ident] : Token.Id;
|
|
67
|
-
}
|
|
68
|
-
exports.lookup = lookup;
|
|
69
|
-
/**
|
|
70
|
-
* Returns the string representation of a token.
|
|
71
|
-
* @param tokens - The token.
|
|
72
|
-
* @return The string representation of the token.
|
|
73
|
-
*/
|
|
74
|
-
function inverseLookup(token) {
|
|
75
|
-
return Object.keys(lookupMap).find(function (ident) { return lookupMap[ident] == token; });
|
|
76
|
-
}
|
|
77
|
-
exports.inverseLookup = inverseLookup;
|
|
78
|
-
/**
|
|
79
|
-
* Determines whether a token denotes a parameter.
|
|
80
|
-
* @param tokens - The token.
|
|
81
|
-
* @return Whether the token does NOT denote a parameter.
|
|
82
|
-
*/
|
|
83
|
-
function notParam(token) {
|
|
84
|
-
if (token == Token.NNInteger || token == Token.Real || token == Token.Id || this.inverseLookup(token)) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
exports.notParam = notParam;
|