libqasm 0.6.6__cp39-cp39-macosx_11_0_universal2.whl
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.
- cqasm/__init__.py +1 -0
- cqasm/v3x/__init__.py +65 -0
- cqasm/v3x/ast.py +10963 -0
- cqasm/v3x/instruction.py +42 -0
- cqasm/v3x/primitives.py +67 -0
- cqasm/v3x/semantic.py +2367 -0
- cqasm/v3x/types.py +1742 -0
- cqasm/v3x/values.py +1714 -0
- libqasm/__init__.py +25 -0
- libqasm/_libqasm.cpython-39-darwin.so +0 -0
- libqasm/libqasm.py +1082 -0
- libqasm-0.6.6.dist-info/LICENSE.md +13 -0
- libqasm-0.6.6.dist-info/METADATA +224 -0
- libqasm-0.6.6.dist-info/RECORD +16 -0
- libqasm-0.6.6.dist-info/WHEEL +5 -0
- libqasm-0.6.6.dist-info/top_level.txt +2 -0
cqasm/__init__.py
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
#
|
cqasm/v3x/__init__.py
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
import cqasm.v3x.ast as ast
|
2
|
+
import cqasm.v3x.semantic as semantic
|
3
|
+
import libqasm
|
4
|
+
|
5
|
+
|
6
|
+
class Analyzer(libqasm.V3xAnalyzer):
|
7
|
+
# parse_file and parse_string are static methods because they do not change the status of the analyzer
|
8
|
+
# Instead, they just invoke free functions that create a temporary instance of a parser
|
9
|
+
# analyze_file and analyze_string are not static methods because they change the status of the analyzer
|
10
|
+
|
11
|
+
# parse_file, parse_string, analyze_file, and analyze_string return a vector of strings
|
12
|
+
# If the length of the vector is 1, the string is a serialization of the AST
|
13
|
+
# Otherwise, it is a list of errors
|
14
|
+
|
15
|
+
@staticmethod
|
16
|
+
def parse_file(*args):
|
17
|
+
ret = libqasm.V3xAnalyzer.parse_file(*args)
|
18
|
+
if len(ret) == 1:
|
19
|
+
serialized_ast_str = str(ret[0])
|
20
|
+
serialized_ast_bytes = serialized_ast_str.encode(encoding='utf-8', errors="surrogateescape")
|
21
|
+
deserialized_ast = ast.Root.deserialize(serialized_ast_bytes)
|
22
|
+
return deserialized_ast
|
23
|
+
return [str(error) for error in ret[1:]]
|
24
|
+
|
25
|
+
@staticmethod
|
26
|
+
def parse_string(*args):
|
27
|
+
ret = libqasm.V3xAnalyzer.parse_string(*args)
|
28
|
+
if len(ret) == 1:
|
29
|
+
serialized_ast_str = str(ret[0])
|
30
|
+
serialized_ast_bytes = serialized_ast_str.encode(encoding='utf-8', errors="surrogateescape")
|
31
|
+
deserialized_ast = ast.Root.deserialize(serialized_ast_bytes)
|
32
|
+
return deserialized_ast
|
33
|
+
return [str(error) for error in ret[1:]]
|
34
|
+
|
35
|
+
def analyze_file(self, *args):
|
36
|
+
ret = super().analyze_file(*args)
|
37
|
+
if len(ret) == 1:
|
38
|
+
serialized_ast_str = str(ret[0])
|
39
|
+
serialized_ast_bytes = serialized_ast_str.encode(encoding='utf-8', errors="surrogateescape")
|
40
|
+
deserialized_ast = semantic.Program.deserialize(serialized_ast_bytes)
|
41
|
+
return deserialized_ast
|
42
|
+
return [str(error) for error in ret[1:]]
|
43
|
+
|
44
|
+
def analyze_string(self, *args):
|
45
|
+
ret = super().analyze_string(*args)
|
46
|
+
if len(ret) == 1:
|
47
|
+
serialized_ast_str = str(ret[0])
|
48
|
+
serialized_ast_bytes = serialized_ast_str.encode(encoding='utf-8', errors="surrogateescape")
|
49
|
+
deserialized_ast = semantic.Program.deserialize(serialized_ast_bytes)
|
50
|
+
return deserialized_ast
|
51
|
+
return [str(error) for error in ret[1:]]
|
52
|
+
|
53
|
+
@staticmethod
|
54
|
+
def parse_file_to_json(*args):
|
55
|
+
return libqasm.V3xAnalyzer.parse_file_to_json(*args)
|
56
|
+
|
57
|
+
@staticmethod
|
58
|
+
def parse_string_to_json(*args):
|
59
|
+
return libqasm.V3xAnalyzer.parse_string_to_json(*args)
|
60
|
+
|
61
|
+
def analyze_file_to_json(self, *args):
|
62
|
+
return super().analyze_file_to_json(*args)
|
63
|
+
|
64
|
+
def analyze_string_to_json(self, *args):
|
65
|
+
return super().analyze_string_to_json(*args)
|