libqasm
library for handling cQASM files
cqasm-v1-ast.cpp
Go to the documentation of this file.
1 
5 #include "cqasm-v1-ast.hpp"
6 #include <stdexcept>
7 
8 namespace cqasm {
9 namespace v1 {
10 namespace ast {
11 
15 void StringBuilder::push_string(const std::string &str) {
16  stream << str;
17 }
18 
22 void StringBuilder::push_escape(const std::string &escape) {
23  if (escape == "\\t") {
24  stream << '\t';
25  } else if (escape == "\\n") {
26  stream << '\n';
27  } else if (escape == "\\r") {
28  stream << '\r';
29  } else if (escape == "\\'") {
30  stream << '\'';
31  } else if (escape == "\\\"") {
32  stream << '\"';
33  } else if (escape == "\\\\") {
34  stream << '\\';
35  } else {
36  stream << escape;
37  }
38 }
39 
40 } // namespace ast
41 } // namespace v1
42 } // namespace cqasm
Defines the types for the cQASM abstract syntax tree, based on the classes from cqasm::tree.
void push_escape(const std::string &escape)
Pushes an escape sequence into the string.
Toplevel namespace with entry points for the new API.
Namespace for the "new" cQASM 1.x API.
void push_string(const std::string &str)
Pushes a string fragment into the string.