libqasm
library for handling cQASM files
libQasm.hpp
Go to the documentation of this file.
1 #ifndef LIBQASM_HPP
2 #define LIBQASM_HPP
3 // This is a simple interface for the python checker
4 
5 #include <stdio.h>
6 #include <string>
7 #include <vector>
8 #include "qasm_ast.hpp"
9 #include "qasm_semantic.hpp"
10 
11 class libQasm
12 {
13  public:
15  {
16  }
17 
18  void parse_string(const char* qasm_str)
19  {
20  sm_ = new compiler::QasmSemanticChecker(qasm_str);
21  qasm_rep_ = sm_->getQasmRepresentation();
22  parse_result_ = sm_->parseResult();
23  }
24 
25  void parse_file(const char* qasm_file_path)
26  {
27  FILE* qasm_file = fopen(qasm_file_path, "r");
28  if (!qasm_file) {
29  std::string file_not_found = std::string("File ")
30  + qasm_file_path
31  + std::string(" not found!\n");
32  throw std::runtime_error(file_not_found);
33  }
34  sm_ = new compiler::QasmSemanticChecker(qasm_file);
35  qasm_rep_ = sm_->getQasmRepresentation();
36  parse_result_ = sm_->parseResult();
37  }
38 
39  int getParseResult() const
40  {
41  return parse_result_;
42  }
43 
45  {
46  return qasm_rep_;
47  }
48 
49  private:
52  int parse_result_;
53 };
54 
55 #endif // LIBQASM_HPP
const compiler::QasmRepresentation & getQasmRepresentation() const
int getParseResult() const
Definition: libQasm.hpp:39
void parse_string(const char *qasm_str)
Definition: libQasm.hpp:18
const compiler::QasmRepresentation & getQasmRepresentation() const
Definition: libQasm.hpp:44
libQasm()
Definition: libQasm.hpp:14
void parse_file(const char *qasm_file_path)
Definition: libQasm.hpp:25