libqasm
library for handling cQASM files
cqasm-py.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 // Don't include any libqasm headers! We don't want SWIG to generate Python
10 // wrappers for the entire world. Those headers are only included in the source
11 // file that provides the implementations.
12 #include <string>
13 #include <memory>
14 #include <vector>
15 
16 // Forward declarations for internal types.
17 namespace cqasm {
18 namespace v1 {
19 namespace analyzer {
20 class Analyzer;
21 } // namespace analyzer
22 } // namespace v1
23 } // namespace cqasm
24 
28 class V1Analyzer {
29 private:
30 
34  std::unique_ptr<cqasm::v1::analyzer::Analyzer> a;
35 
36 public:
37 
47  V1Analyzer(const std::string &max_version = "1.0", bool without_defaults=false);
48 
53  void register_instruction(
54  const std::string &name,
55  const std::string &param_types = "",
56  bool allow_conditional = true,
57  bool allow_parallel = true,
58  bool allow_reused_qubits = false,
59  bool allow_different_index_sizes = false
60  );
61 
66  void register_error_model(
67  const std::string &name,
68  const std::string &param_types = ""
69  );
70 
77  static std::vector<std::string> parse_file(
78  const std::string &filename
79  );
80 
85  static std::vector<std::string> parse_string(
86  const std::string &data,
87  const std::string &filename = "<unknown>"
88  );
89 
98  std::vector<std::string> analyze_file(
99  const std::string &filename
100  ) const;
101 
106  std::vector<std::string> analyze_string(
107  const std::string &data,
108  const std::string &filename = "<unknown>"
109  ) const;
110 
111 };
tree::One< semantic::Program > analyze_string(const std::string &data, const std::string &filename, const std::string &api_version)
Parses and analyzes the given string with the default analyzer, dumping error messages to stderr and ...
Definition: cqasm-v1.cpp:43
Main class for parsing and analyzing cQASM files with the v1 API.
Definition: cqasm-py.hpp:28
Toplevel namespace with entry points for the new API.
Namespace for the "new" cQASM 1.x API.
ParseResult parse_string(const std::string &data, const std::string &filename)
Parse the given string.
ParseResult parse_file(const std::string &filename)
Parse the given file.