libqasm
library for handling cQASM files
cqasm-v1-ast-gen.hpp
Go to the documentation of this file.
1 
5 #pragma once
6 
7 #include <iostream>
8 #include "cqasm-tree.hpp"
10 
11 namespace cqasm {
12 namespace v1 {
13 
221 namespace ast {
222 
223 // Base classes used to construct the tree.
225 template <class T> using Maybe = cqasm::tree::Maybe<T>;
226 template <class T> using One = cqasm::tree::One<T>;
227 template <class T> using Any = cqasm::tree::Any<T>;
228 template <class T> using Many = cqasm::tree::Many<T>;
229 template <class T> using OptLink = cqasm::tree::OptLink<T>;
230 template <class T> using Link = cqasm::tree::Link<T>;
231 
232 // Forward declarations for all classes.
233 class Node;
234 class Add;
235 class Annotated;
236 class AnnotationData;
237 class ArithOp;
238 class Assignment;
239 class BinaryOp;
240 class BitwiseAnd;
241 class BitwiseNot;
242 class BitwiseOp;
243 class BitwiseOr;
244 class BitwiseXor;
245 class BreakStatement;
246 class Bundle;
247 class CmpEq;
248 class CmpGe;
249 class CmpGt;
250 class CmpLe;
251 class CmpLt;
252 class CmpNe;
253 class CmpOp;
254 class ContinueStatement;
255 class Divide;
256 class ErroneousExpression;
257 class ErroneousProgram;
258 class ErroneousStatement;
259 class Expression;
260 class ExpressionList;
261 class FloatLiteral;
262 class ForLoop;
263 class ForeachLoop;
264 class FunctionCall;
265 class Identifier;
266 class IfElse;
267 class IfElseBranch;
268 class Index;
269 class IndexEntry;
270 class IndexItem;
271 class IndexList;
272 class IndexRange;
273 class Instruction;
274 class IntDivide;
275 class IntegerLiteral;
276 class JsonLiteral;
277 class LogicalAnd;
278 class LogicalNot;
279 class LogicalOp;
280 class LogicalOr;
281 class LogicalXor;
282 class Mapping;
283 class MatrixLiteral;
284 class Modulo;
285 class Multiply;
286 class Negate;
287 class Power;
288 class Program;
289 class RepeatUntilLoop;
290 class Root;
291 class ShiftLeft;
292 class ShiftOp;
293 class ShiftRightArith;
294 class ShiftRightLogic;
295 class Statement;
296 class StatementList;
297 class StringLiteral;
298 class Structured;
299 class Subcircuit;
300 class Subtract;
301 class TernaryCond;
302 class UnaryOp;
303 class Variables;
304 class Version;
305 class WhileLoop;
306 class VisitorBase;
307 template <typename T = void>
308 class Visitor;
309 class RecursiveVisitor;
310 class Dumper;
311 
315 enum class NodeType {
316  Add,
318  Assignment,
319  BitwiseAnd,
320  BitwiseNot,
321  BitwiseOr,
322  BitwiseXor,
324  Bundle,
325  CmpEq,
326  CmpGe,
327  CmpGt,
328  CmpLe,
329  CmpLt,
330  CmpNe,
332  Divide,
337  FloatLiteral,
338  ForLoop,
339  ForeachLoop,
340  FunctionCall,
341  Identifier,
342  IfElse,
343  IfElseBranch,
344  Index,
345  IndexItem,
346  IndexList,
347  IndexRange,
348  Instruction,
349  IntDivide,
351  JsonLiteral,
352  LogicalAnd,
353  LogicalNot,
354  LogicalOr,
355  LogicalXor,
356  Mapping,
358  Modulo,
359  Multiply,
360  Negate,
361  Power,
362  Program,
364  ShiftLeft,
369  Subcircuit,
370  Subtract,
371  TernaryCond,
372  Variables,
373  Version,
374  WhileLoop
375 };
376 
380 class Node : public Base {
381 public:
382 
386  virtual NodeType type() const = 0;
387 
391  virtual One<Node> copy() const = 0;
392 
396  virtual One<Node> clone() const = 0;
397 
401  virtual bool equals(const Node& rhs) const = 0;
402 
406  virtual bool operator==(const Node& rhs) const = 0;
407 
411  inline bool operator!=(const Node& rhs) const {
412  return !(*this == rhs);
413  }
414 
415 protected:
416 
420  virtual void visit_internal(VisitorBase &visitor, void *retval=nullptr) = 0;
421 
422 public:
423 
427  template <typename T>
428  T visit(Visitor<T> &visitor);
429 
433  void dump(std::ostream &out=std::cout, int indent=0);
434 
439  void dump_seq(std::ostream &out=std::cout, int indent=0);
440 
445  virtual Add *as_add();
446 
451  virtual const Add *as_add() const;
452 
457  virtual Annotated *as_annotated();
458 
463  virtual const Annotated *as_annotated() const;
464 
469  virtual AnnotationData *as_annotation_data();
470 
475  virtual const AnnotationData *as_annotation_data() const;
476 
481  virtual ArithOp *as_arith_op();
482 
487  virtual const ArithOp *as_arith_op() const;
488 
493  virtual Assignment *as_assignment();
494 
499  virtual const Assignment *as_assignment() const;
500 
505  virtual BinaryOp *as_binary_op();
506 
511  virtual const BinaryOp *as_binary_op() const;
512 
517  virtual BitwiseAnd *as_bitwise_and();
518 
523  virtual const BitwiseAnd *as_bitwise_and() const;
524 
529  virtual BitwiseNot *as_bitwise_not();
530 
535  virtual const BitwiseNot *as_bitwise_not() const;
536 
541  virtual BitwiseOp *as_bitwise_op();
542 
547  virtual const BitwiseOp *as_bitwise_op() const;
548 
553  virtual BitwiseOr *as_bitwise_or();
554 
559  virtual const BitwiseOr *as_bitwise_or() const;
560 
565  virtual BitwiseXor *as_bitwise_xor();
566 
571  virtual const BitwiseXor *as_bitwise_xor() const;
572 
577  virtual BreakStatement *as_break_statement();
578 
583  virtual const BreakStatement *as_break_statement() const;
584 
589  virtual Bundle *as_bundle();
590 
595  virtual const Bundle *as_bundle() const;
596 
601  virtual CmpEq *as_cmp_eq();
602 
607  virtual const CmpEq *as_cmp_eq() const;
608 
613  virtual CmpGe *as_cmp_ge();
614 
619  virtual const CmpGe *as_cmp_ge() const;
620 
625  virtual CmpGt *as_cmp_gt();
626 
631  virtual const CmpGt *as_cmp_gt() const;
632 
637  virtual CmpLe *as_cmp_le();
638 
643  virtual const CmpLe *as_cmp_le() const;
644 
649  virtual CmpLt *as_cmp_lt();
650 
655  virtual const CmpLt *as_cmp_lt() const;
656 
661  virtual CmpNe *as_cmp_ne();
662 
667  virtual const CmpNe *as_cmp_ne() const;
668 
673  virtual CmpOp *as_cmp_op();
674 
679  virtual const CmpOp *as_cmp_op() const;
680 
685  virtual ContinueStatement *as_continue_statement();
686 
691  virtual const ContinueStatement *as_continue_statement() const;
692 
697  virtual Divide *as_divide();
698 
703  virtual const Divide *as_divide() const;
704 
709  virtual ErroneousExpression *as_erroneous_expression();
710 
715  virtual const ErroneousExpression *as_erroneous_expression() const;
716 
721  virtual ErroneousProgram *as_erroneous_program();
722 
727  virtual const ErroneousProgram *as_erroneous_program() const;
728 
733  virtual ErroneousStatement *as_erroneous_statement();
734 
739  virtual const ErroneousStatement *as_erroneous_statement() const;
740 
745  virtual Expression *as_expression();
746 
751  virtual const Expression *as_expression() const;
752 
757  virtual ExpressionList *as_expression_list();
758 
763  virtual const ExpressionList *as_expression_list() const;
764 
769  virtual FloatLiteral *as_float_literal();
770 
775  virtual const FloatLiteral *as_float_literal() const;
776 
781  virtual ForLoop *as_for_loop();
782 
787  virtual const ForLoop *as_for_loop() const;
788 
793  virtual ForeachLoop *as_foreach_loop();
794 
799  virtual const ForeachLoop *as_foreach_loop() const;
800 
805  virtual FunctionCall *as_function_call();
806 
811  virtual const FunctionCall *as_function_call() const;
812 
817  virtual Identifier *as_identifier();
818 
823  virtual const Identifier *as_identifier() const;
824 
829  virtual IfElse *as_if_else();
830 
835  virtual const IfElse *as_if_else() const;
836 
841  virtual IfElseBranch *as_if_else_branch();
842 
847  virtual const IfElseBranch *as_if_else_branch() const;
848 
853  virtual Index *as_index();
854 
859  virtual const Index *as_index() const;
860 
865  virtual IndexEntry *as_index_entry();
866 
871  virtual const IndexEntry *as_index_entry() const;
872 
877  virtual IndexItem *as_index_item();
878 
883  virtual const IndexItem *as_index_item() const;
884 
889  virtual IndexList *as_index_list();
890 
895  virtual const IndexList *as_index_list() const;
896 
901  virtual IndexRange *as_index_range();
902 
907  virtual const IndexRange *as_index_range() const;
908 
913  virtual Instruction *as_instruction();
914 
919  virtual const Instruction *as_instruction() const;
920 
925  virtual IntDivide *as_int_divide();
926 
931  virtual const IntDivide *as_int_divide() const;
932 
937  virtual IntegerLiteral *as_integer_literal();
938 
943  virtual const IntegerLiteral *as_integer_literal() const;
944 
949  virtual JsonLiteral *as_json_literal();
950 
955  virtual const JsonLiteral *as_json_literal() const;
956 
961  virtual LogicalAnd *as_logical_and();
962 
967  virtual const LogicalAnd *as_logical_and() const;
968 
973  virtual LogicalNot *as_logical_not();
974 
979  virtual const LogicalNot *as_logical_not() const;
980 
985  virtual LogicalOp *as_logical_op();
986 
991  virtual const LogicalOp *as_logical_op() const;
992 
997  virtual LogicalOr *as_logical_or();
998 
1003  virtual const LogicalOr *as_logical_or() const;
1004 
1009  virtual LogicalXor *as_logical_xor();
1010 
1015  virtual const LogicalXor *as_logical_xor() const;
1016 
1021  virtual Mapping *as_mapping();
1022 
1027  virtual const Mapping *as_mapping() const;
1028 
1033  virtual MatrixLiteral *as_matrix_literal();
1034 
1039  virtual const MatrixLiteral *as_matrix_literal() const;
1040 
1045  virtual Modulo *as_modulo();
1046 
1051  virtual const Modulo *as_modulo() const;
1052 
1057  virtual Multiply *as_multiply();
1058 
1063  virtual const Multiply *as_multiply() const;
1064 
1069  virtual Negate *as_negate();
1070 
1075  virtual const Negate *as_negate() const;
1076 
1081  virtual Power *as_power();
1082 
1087  virtual const Power *as_power() const;
1088 
1093  virtual Program *as_program();
1094 
1099  virtual const Program *as_program() const;
1100 
1105  virtual RepeatUntilLoop *as_repeat_until_loop();
1106 
1111  virtual const RepeatUntilLoop *as_repeat_until_loop() const;
1112 
1117  virtual Root *as_root();
1118 
1123  virtual const Root *as_root() const;
1124 
1129  virtual ShiftLeft *as_shift_left();
1130 
1135  virtual const ShiftLeft *as_shift_left() const;
1136 
1141  virtual ShiftOp *as_shift_op();
1142 
1147  virtual const ShiftOp *as_shift_op() const;
1148 
1153  virtual ShiftRightArith *as_shift_right_arith();
1154 
1159  virtual const ShiftRightArith *as_shift_right_arith() const;
1160 
1165  virtual ShiftRightLogic *as_shift_right_logic();
1166 
1171  virtual const ShiftRightLogic *as_shift_right_logic() const;
1172 
1177  virtual Statement *as_statement();
1178 
1183  virtual const Statement *as_statement() const;
1184 
1189  virtual StatementList *as_statement_list();
1190 
1195  virtual const StatementList *as_statement_list() const;
1196 
1201  virtual StringLiteral *as_string_literal();
1202 
1207  virtual const StringLiteral *as_string_literal() const;
1208 
1213  virtual Structured *as_structured();
1214 
1219  virtual const Structured *as_structured() const;
1220 
1225  virtual Subcircuit *as_subcircuit();
1226 
1231  virtual const Subcircuit *as_subcircuit() const;
1232 
1237  virtual Subtract *as_subtract();
1238 
1243  virtual const Subtract *as_subtract() const;
1244 
1249  virtual TernaryCond *as_ternary_cond();
1250 
1255  virtual const TernaryCond *as_ternary_cond() const;
1256 
1261  virtual UnaryOp *as_unary_op();
1262 
1267  virtual const UnaryOp *as_unary_op() const;
1268 
1273  virtual Variables *as_variables();
1274 
1279  virtual const Variables *as_variables() const;
1280 
1285  virtual Version *as_version();
1286 
1291  virtual const Version *as_version() const;
1292 
1297  virtual WhileLoop *as_while_loop();
1298 
1303  virtual const WhileLoop *as_while_loop() const;
1304 
1308  virtual void serialize(
1309  ::tree::cbor::MapWriter &map,
1310  const ::tree::base::PointerMap &ids
1311  ) const = 0;
1312 
1316  static std::shared_ptr<Node> deserialize(
1317  const ::tree::cbor::MapReader &map,
1318  ::tree::base::IdentifierMap &ids
1319  );
1320 
1321 };
1322 
1326 class Expression : public Node {
1327 public:
1328 
1333  Expression *as_expression() override;
1334 
1339  const Expression *as_expression() const override;
1340 
1344  static std::shared_ptr<Expression> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1345 
1346 };
1347 
1351 class BinaryOp : public Expression {
1352 public:
1353 
1358 
1363 
1368 
1373  BinaryOp *as_binary_op() override;
1374 
1379  const BinaryOp *as_binary_op() const override;
1380 
1384  static std::shared_ptr<BinaryOp> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1385 
1386 };
1387 
1391 class ArithOp : public BinaryOp {
1392 public:
1393 
1397  ArithOp(const One<Expression> &lhs = One<Expression>(), const One<Expression> &rhs = One<Expression>());
1398 
1403  ArithOp *as_arith_op() override;
1404 
1409  const ArithOp *as_arith_op() const override;
1410 
1414  static std::shared_ptr<ArithOp> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1415 
1416 };
1417 
1421 class Add : public ArithOp {
1422 public:
1423 
1427  Add(const One<Expression> &lhs = One<Expression>(), const One<Expression> &rhs = One<Expression>());
1428 
1432  void find_reachable(::tree::base::PointerMap &map) const override;
1433 
1437  void check_complete(const ::tree::base::PointerMap &map) const override;
1438 
1442  NodeType type() const override;
1443 
1444 protected:
1445 
1449  void visit_internal(VisitorBase &visitor, void *retval) override;
1450 
1451 public:
1452 
1457  Add *as_add() override;
1458 
1463  const Add *as_add() const override;
1464 
1468  One<Node> copy() const override;
1469 
1473  One<Node> clone() const override;
1474 
1478  bool equals(const Node &rhs) const override;
1479 
1483  bool operator==(const Node &rhs) const override;
1484 
1488  void serialize(
1489  ::tree::cbor::MapWriter &map,
1490  const ::tree::base::PointerMap &ids
1491  ) const override;
1492 
1496  static std::shared_ptr<Add> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1497 
1498 };
1499 
1503 class Annotated : public Node {
1504 public:
1505 
1510 
1514  Annotated(const Any<AnnotationData> &annotations = Any<AnnotationData>());
1515 
1520  Annotated *as_annotated() override;
1521 
1526  const Annotated *as_annotated() const override;
1527 
1531  static std::shared_ptr<Annotated> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1532 
1533 };
1534 
1538 class AnnotationData : public Node {
1539 public:
1540 
1546 
1553 
1558 
1562  AnnotationData(const One<Identifier> &interface = One<Identifier>(), const One<Identifier> &operation = One<Identifier>(), const One<ExpressionList> &operands = One<ExpressionList>());
1563 
1567  void find_reachable(::tree::base::PointerMap &map) const override;
1568 
1572  void check_complete(const ::tree::base::PointerMap &map) const override;
1573 
1577  NodeType type() const override;
1578 
1579 protected:
1580 
1584  void visit_internal(VisitorBase &visitor, void *retval) override;
1585 
1586 public:
1587 
1592  AnnotationData *as_annotation_data() override;
1593 
1598  const AnnotationData *as_annotation_data() const override;
1599 
1603  One<Node> copy() const override;
1604 
1608  One<Node> clone() const override;
1609 
1613  bool equals(const Node &rhs) const override;
1614 
1618  bool operator==(const Node &rhs) const override;
1619 
1623  void serialize(
1624  ::tree::cbor::MapWriter &map,
1625  const ::tree::base::PointerMap &ids
1626  ) const override;
1627 
1631  static std::shared_ptr<AnnotationData> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1632 
1633 };
1634 
1638 class Assignment : public Node {
1639 public:
1640 
1645 
1650 
1655 
1659  void find_reachable(::tree::base::PointerMap &map) const override;
1660 
1664  void check_complete(const ::tree::base::PointerMap &map) const override;
1665 
1669  NodeType type() const override;
1670 
1671 protected:
1672 
1676  void visit_internal(VisitorBase &visitor, void *retval) override;
1677 
1678 public:
1679 
1684  Assignment *as_assignment() override;
1685 
1690  const Assignment *as_assignment() const override;
1691 
1695  One<Node> copy() const override;
1696 
1700  One<Node> clone() const override;
1701 
1705  bool equals(const Node &rhs) const override;
1706 
1710  bool operator==(const Node &rhs) const override;
1711 
1715  void serialize(
1716  ::tree::cbor::MapWriter &map,
1717  const ::tree::base::PointerMap &ids
1718  ) const override;
1719 
1723  static std::shared_ptr<Assignment> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1724 
1725 };
1726 
1730 class BitwiseOp : public BinaryOp {
1731 public:
1732 
1737 
1742  BitwiseOp *as_bitwise_op() override;
1743 
1748  const BitwiseOp *as_bitwise_op() const override;
1749 
1753  static std::shared_ptr<BitwiseOp> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1754 
1755 };
1756 
1760 class BitwiseAnd : public BitwiseOp {
1761 public:
1762 
1767 
1771  void find_reachable(::tree::base::PointerMap &map) const override;
1772 
1776  void check_complete(const ::tree::base::PointerMap &map) const override;
1777 
1781  NodeType type() const override;
1782 
1783 protected:
1784 
1788  void visit_internal(VisitorBase &visitor, void *retval) override;
1789 
1790 public:
1791 
1796  BitwiseAnd *as_bitwise_and() override;
1797 
1802  const BitwiseAnd *as_bitwise_and() const override;
1803 
1807  One<Node> copy() const override;
1808 
1812  One<Node> clone() const override;
1813 
1817  bool equals(const Node &rhs) const override;
1818 
1822  bool operator==(const Node &rhs) const override;
1823 
1827  void serialize(
1828  ::tree::cbor::MapWriter &map,
1829  const ::tree::base::PointerMap &ids
1830  ) const override;
1831 
1835  static std::shared_ptr<BitwiseAnd> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1836 
1837 };
1838 
1842 class UnaryOp : public Expression {
1843 public:
1844 
1849 
1853  UnaryOp(const One<Expression> &expr = One<Expression>());
1854 
1859  UnaryOp *as_unary_op() override;
1860 
1865  const UnaryOp *as_unary_op() const override;
1866 
1870  static std::shared_ptr<UnaryOp> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1871 
1872 };
1873 
1877 class BitwiseNot : public UnaryOp {
1878 public:
1879 
1883  BitwiseNot(const One<Expression> &expr = One<Expression>());
1884 
1888  void find_reachable(::tree::base::PointerMap &map) const override;
1889 
1893  void check_complete(const ::tree::base::PointerMap &map) const override;
1894 
1898  NodeType type() const override;
1899 
1900 protected:
1901 
1905  void visit_internal(VisitorBase &visitor, void *retval) override;
1906 
1907 public:
1908 
1913  BitwiseNot *as_bitwise_not() override;
1914 
1919  const BitwiseNot *as_bitwise_not() const override;
1920 
1924  One<Node> copy() const override;
1925 
1929  One<Node> clone() const override;
1930 
1934  bool equals(const Node &rhs) const override;
1935 
1939  bool operator==(const Node &rhs) const override;
1940 
1944  void serialize(
1945  ::tree::cbor::MapWriter &map,
1946  const ::tree::base::PointerMap &ids
1947  ) const override;
1948 
1952  static std::shared_ptr<BitwiseNot> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
1953 
1954 };
1955 
1959 class BitwiseOr : public BitwiseOp {
1960 public:
1961 
1966 
1970  void find_reachable(::tree::base::PointerMap &map) const override;
1971 
1975  void check_complete(const ::tree::base::PointerMap &map) const override;
1976 
1980  NodeType type() const override;
1981 
1982 protected:
1983 
1987  void visit_internal(VisitorBase &visitor, void *retval) override;
1988 
1989 public:
1990 
1995  BitwiseOr *as_bitwise_or() override;
1996 
2001  const BitwiseOr *as_bitwise_or() const override;
2002 
2006  One<Node> copy() const override;
2007 
2011  One<Node> clone() const override;
2012 
2016  bool equals(const Node &rhs) const override;
2017 
2021  bool operator==(const Node &rhs) const override;
2022 
2026  void serialize(
2027  ::tree::cbor::MapWriter &map,
2028  const ::tree::base::PointerMap &ids
2029  ) const override;
2030 
2034  static std::shared_ptr<BitwiseOr> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2035 
2036 };
2037 
2041 class BitwiseXor : public BitwiseOp {
2042 public:
2043 
2048 
2052  void find_reachable(::tree::base::PointerMap &map) const override;
2053 
2057  void check_complete(const ::tree::base::PointerMap &map) const override;
2058 
2062  NodeType type() const override;
2063 
2064 protected:
2065 
2069  void visit_internal(VisitorBase &visitor, void *retval) override;
2070 
2071 public:
2072 
2077  BitwiseXor *as_bitwise_xor() override;
2078 
2083  const BitwiseXor *as_bitwise_xor() const override;
2084 
2088  One<Node> copy() const override;
2089 
2093  One<Node> clone() const override;
2094 
2098  bool equals(const Node &rhs) const override;
2099 
2103  bool operator==(const Node &rhs) const override;
2104 
2108  void serialize(
2109  ::tree::cbor::MapWriter &map,
2110  const ::tree::base::PointerMap &ids
2111  ) const override;
2112 
2116  static std::shared_ptr<BitwiseXor> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2117 
2118 };
2119 
2123 class Statement : public Annotated {
2124 public:
2125 
2129  Statement(const Any<AnnotationData> &annotations = Any<AnnotationData>());
2130 
2135  Statement *as_statement() override;
2136 
2141  const Statement *as_statement() const override;
2142 
2146  static std::shared_ptr<Statement> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2147 
2148 };
2149 
2153 class Structured : public Statement {
2154 public:
2155 
2159  Structured(const Any<AnnotationData> &annotations = Any<AnnotationData>());
2160 
2165  Structured *as_structured() override;
2166 
2171  const Structured *as_structured() const override;
2172 
2176  static std::shared_ptr<Structured> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2177 
2178 };
2179 
2183 class BreakStatement : public Structured {
2184 public:
2185 
2189  BreakStatement(const Any<AnnotationData> &annotations = Any<AnnotationData>());
2190 
2194  void find_reachable(::tree::base::PointerMap &map) const override;
2195 
2199  void check_complete(const ::tree::base::PointerMap &map) const override;
2200 
2204  NodeType type() const override;
2205 
2206 protected:
2207 
2211  void visit_internal(VisitorBase &visitor, void *retval) override;
2212 
2213 public:
2214 
2219  BreakStatement *as_break_statement() override;
2220 
2225  const BreakStatement *as_break_statement() const override;
2226 
2230  One<Node> copy() const override;
2231 
2235  One<Node> clone() const override;
2236 
2240  bool equals(const Node &rhs) const override;
2241 
2245  bool operator==(const Node &rhs) const override;
2246 
2250  void serialize(
2251  ::tree::cbor::MapWriter &map,
2252  const ::tree::base::PointerMap &ids
2253  ) const override;
2254 
2258  static std::shared_ptr<BreakStatement> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2259 
2260 };
2261 
2265 class Bundle : public Statement {
2266 public:
2267 
2272 
2276  Bundle(const Many<Instruction> &items = Many<Instruction>(), const Any<AnnotationData> &annotations = Any<AnnotationData>());
2277 
2281  void find_reachable(::tree::base::PointerMap &map) const override;
2282 
2286  void check_complete(const ::tree::base::PointerMap &map) const override;
2287 
2291  NodeType type() const override;
2292 
2293 protected:
2294 
2298  void visit_internal(VisitorBase &visitor, void *retval) override;
2299 
2300 public:
2301 
2306  Bundle *as_bundle() override;
2307 
2312  const Bundle *as_bundle() const override;
2313 
2317  One<Node> copy() const override;
2318 
2322  One<Node> clone() const override;
2323 
2327  bool equals(const Node &rhs) const override;
2328 
2332  bool operator==(const Node &rhs) const override;
2333 
2337  void serialize(
2338  ::tree::cbor::MapWriter &map,
2339  const ::tree::base::PointerMap &ids
2340  ) const override;
2341 
2345  static std::shared_ptr<Bundle> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2346 
2347 };
2348 
2352 class CmpOp : public BinaryOp {
2353 public:
2354 
2358  CmpOp(const One<Expression> &lhs = One<Expression>(), const One<Expression> &rhs = One<Expression>());
2359 
2364  CmpOp *as_cmp_op() override;
2365 
2370  const CmpOp *as_cmp_op() const override;
2371 
2375  static std::shared_ptr<CmpOp> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2376 
2377 };
2378 
2382 class CmpEq : public CmpOp {
2383 public:
2384 
2388  CmpEq(const One<Expression> &lhs = One<Expression>(), const One<Expression> &rhs = One<Expression>());
2389 
2393  void find_reachable(::tree::base::PointerMap &map) const override;
2394 
2398  void check_complete(const ::tree::base::PointerMap &map) const override;
2399 
2403  NodeType type() const override;
2404 
2405 protected:
2406 
2410  void visit_internal(VisitorBase &visitor, void *retval) override;
2411 
2412 public:
2413 
2418  CmpEq *as_cmp_eq() override;
2419 
2424  const CmpEq *as_cmp_eq() const override;
2425 
2429  One<Node> copy() const override;
2430 
2434  One<Node> clone() const override;
2435 
2439  bool equals(const Node &rhs) const override;
2440 
2444  bool operator==(const Node &rhs) const override;
2445 
2449  void serialize(
2450  ::tree::cbor::MapWriter &map,
2451  const ::tree::base::PointerMap &ids
2452  ) const override;
2453 
2457  static std::shared_ptr<CmpEq> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2458 
2459 };
2460 
2464 class CmpGe : public CmpOp {
2465 public:
2466 
2470  CmpGe(const One<Expression> &lhs = One<Expression>(), const One<Expression> &rhs = One<Expression>());
2471 
2475  void find_reachable(::tree::base::PointerMap &map) const override;
2476 
2480  void check_complete(const ::tree::base::PointerMap &map) const override;
2481 
2485  NodeType type() const override;
2486 
2487 protected:
2488 
2492  void visit_internal(VisitorBase &visitor, void *retval) override;
2493 
2494 public:
2495 
2500  CmpGe *as_cmp_ge() override;
2501 
2506  const CmpGe *as_cmp_ge() const override;
2507 
2511  One<Node> copy() const override;
2512 
2516  One<Node> clone() const override;
2517 
2521  bool equals(const Node &rhs) const override;
2522 
2526  bool operator==(const Node &rhs) const override;
2527 
2531  void serialize(
2532  ::tree::cbor::MapWriter &map,
2533  const ::tree::base::PointerMap &ids
2534  ) const override;
2535 
2539  static std::shared_ptr<CmpGe> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2540 
2541 };
2542 
2546 class CmpGt : public CmpOp {
2547 public:
2548 
2552  CmpGt(const One<Expression> &lhs = One<Expression>(), const One<Expression> &rhs = One<Expression>());
2553 
2557  void find_reachable(::tree::base::PointerMap &map) const override;
2558 
2562  void check_complete(const ::tree::base::PointerMap &map) const override;
2563 
2567  NodeType type() const override;
2568 
2569 protected:
2570 
2574  void visit_internal(VisitorBase &visitor, void *retval) override;
2575 
2576 public:
2577 
2582  CmpGt *as_cmp_gt() override;
2583 
2588  const CmpGt *as_cmp_gt() const override;
2589 
2593  One<Node> copy() const override;
2594 
2598  One<Node> clone() const override;
2599 
2603  bool equals(const Node &rhs) const override;
2604 
2608  bool operator==(const Node &rhs) const override;
2609 
2613  void serialize(
2614  ::tree::cbor::MapWriter &map,
2615  const ::tree::base::PointerMap &ids
2616  ) const override;
2617 
2621  static std::shared_ptr<CmpGt> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2622 
2623 };
2624 
2628 class CmpLe : public CmpOp {
2629 public:
2630 
2634  CmpLe(const One<Expression> &lhs = One<Expression>(), const One<Expression> &rhs = One<Expression>());
2635 
2639  void find_reachable(::tree::base::PointerMap &map) const override;
2640 
2644  void check_complete(const ::tree::base::PointerMap &map) const override;
2645 
2649  NodeType type() const override;
2650 
2651 protected:
2652 
2656  void visit_internal(VisitorBase &visitor, void *retval) override;
2657 
2658 public:
2659 
2664  CmpLe *as_cmp_le() override;
2665 
2670  const CmpLe *as_cmp_le() const override;
2671 
2675  One<Node> copy() const override;
2676 
2680  One<Node> clone() const override;
2681 
2685  bool equals(const Node &rhs) const override;
2686 
2690  bool operator==(const Node &rhs) const override;
2691 
2695  void serialize(
2696  ::tree::cbor::MapWriter &map,
2697  const ::tree::base::PointerMap &ids
2698  ) const override;
2699 
2703  static std::shared_ptr<CmpLe> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2704 
2705 };
2706 
2710 class CmpLt : public CmpOp {
2711 public:
2712 
2716  CmpLt(const One<Expression> &lhs = One<Expression>(), const One<Expression> &rhs = One<Expression>());
2717 
2721  void find_reachable(::tree::base::PointerMap &map) const override;
2722 
2726  void check_complete(const ::tree::base::PointerMap &map) const override;
2727 
2731  NodeType type() const override;
2732 
2733 protected:
2734 
2738  void visit_internal(VisitorBase &visitor, void *retval) override;
2739 
2740 public:
2741 
2746  CmpLt *as_cmp_lt() override;
2747 
2752  const CmpLt *as_cmp_lt() const override;
2753 
2757  One<Node> copy() const override;
2758 
2762  One<Node> clone() const override;
2763 
2767  bool equals(const Node &rhs) const override;
2768 
2772  bool operator==(const Node &rhs) const override;
2773 
2777  void serialize(
2778  ::tree::cbor::MapWriter &map,
2779  const ::tree::base::PointerMap &ids
2780  ) const override;
2781 
2785  static std::shared_ptr<CmpLt> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2786 
2787 };
2788 
2792 class CmpNe : public CmpOp {
2793 public:
2794 
2798  CmpNe(const One<Expression> &lhs = One<Expression>(), const One<Expression> &rhs = One<Expression>());
2799 
2803  void find_reachable(::tree::base::PointerMap &map) const override;
2804 
2808  void check_complete(const ::tree::base::PointerMap &map) const override;
2809 
2813  NodeType type() const override;
2814 
2815 protected:
2816 
2820  void visit_internal(VisitorBase &visitor, void *retval) override;
2821 
2822 public:
2823 
2828  CmpNe *as_cmp_ne() override;
2829 
2834  const CmpNe *as_cmp_ne() const override;
2835 
2839  One<Node> copy() const override;
2840 
2844  One<Node> clone() const override;
2845 
2849  bool equals(const Node &rhs) const override;
2850 
2854  bool operator==(const Node &rhs) const override;
2855 
2859  void serialize(
2860  ::tree::cbor::MapWriter &map,
2861  const ::tree::base::PointerMap &ids
2862  ) const override;
2863 
2867  static std::shared_ptr<CmpNe> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2868 
2869 };
2870 
2875 public:
2876 
2881 
2885  void find_reachable(::tree::base::PointerMap &map) const override;
2886 
2890  void check_complete(const ::tree::base::PointerMap &map) const override;
2891 
2895  NodeType type() const override;
2896 
2897 protected:
2898 
2902  void visit_internal(VisitorBase &visitor, void *retval) override;
2903 
2904 public:
2905 
2910  ContinueStatement *as_continue_statement() override;
2911 
2916  const ContinueStatement *as_continue_statement() const override;
2917 
2921  One<Node> copy() const override;
2922 
2926  One<Node> clone() const override;
2927 
2931  bool equals(const Node &rhs) const override;
2932 
2936  bool operator==(const Node &rhs) const override;
2937 
2941  void serialize(
2942  ::tree::cbor::MapWriter &map,
2943  const ::tree::base::PointerMap &ids
2944  ) const override;
2945 
2949  static std::shared_ptr<ContinueStatement> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
2950 
2951 };
2952 
2956 class Divide : public ArithOp {
2957 public:
2958 
2962  Divide(const One<Expression> &lhs = One<Expression>(), const One<Expression> &rhs = One<Expression>());
2963 
2967  void find_reachable(::tree::base::PointerMap &map) const override;
2968 
2972  void check_complete(const ::tree::base::PointerMap &map) const override;
2973 
2977  NodeType type() const override;
2978 
2979 protected:
2980 
2984  void visit_internal(VisitorBase &visitor, void *retval) override;
2985 
2986 public:
2987 
2992  Divide *as_divide() override;
2993 
2998  const Divide *as_divide() const override;
2999 
3003  One<Node> copy() const override;
3004 
3008  One<Node> clone() const override;
3009 
3013  bool equals(const Node &rhs) const override;
3014 
3018  bool operator==(const Node &rhs) const override;
3019 
3023  void serialize(
3024  ::tree::cbor::MapWriter &map,
3025  const ::tree::base::PointerMap &ids
3026  ) const override;
3027 
3031  static std::shared_ptr<Divide> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
3032 
3033 };
3034 
3039 public:
3040 
3044  void find_reachable(::tree::base::PointerMap &map) const override;
3045 
3049  void check_complete(const ::tree::base::PointerMap &map) const override;
3050 
3054  NodeType type() const override;
3055 
3056 protected:
3057 
3061  void visit_internal(VisitorBase &visitor, void *retval) override;
3062 
3063 public:
3064 
3069  ErroneousExpression *as_erroneous_expression() override;
3070 
3075  const ErroneousExpression *as_erroneous_expression() const override;
3076 
3080  One<Node> copy() const override;
3081 
3085  One<Node> clone() const override;
3086 
3090  bool equals(const Node &rhs) const override;
3091 
3095  bool operator==(const Node &rhs) const override;
3096 
3100  void serialize(
3101  ::tree::cbor::MapWriter &map,
3102  const ::tree::base::PointerMap &ids
3103  ) const override;
3104 
3108  static std::shared_ptr<ErroneousExpression> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
3109 
3110 };
3111 
3115 class Root : public Node {
3116 public:
3117 
3122  Root *as_root() override;
3123 
3128  const Root *as_root() const override;
3129 
3133  static std::shared_ptr<Root> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
3134 
3135 };
3136 
3140 class ErroneousProgram : public Root {
3141 public:
3142 
3146  void find_reachable(::tree::base::PointerMap &map) const override;
3147 
3151  void check_complete(const ::tree::base::PointerMap &map) const override;
3152 
3156  NodeType type() const override;
3157 
3158 protected:
3159 
3163  void visit_internal(VisitorBase &visitor, void *retval) override;
3164 
3165 public:
3166 
3171  ErroneousProgram *as_erroneous_program() override;
3172 
3177  const ErroneousProgram *as_erroneous_program() const override;
3178 
3182  One<Node> copy() const override;
3183 
3187  One<Node> clone() const override;
3188 
3192  bool equals(const Node &rhs) const override;
3193 
3197  bool operator==(const Node &rhs) const override;
3198 
3202  void serialize(
3203  ::tree::cbor::MapWriter &map,
3204  const ::tree::base::PointerMap &ids
3205  ) const override;
3206 
3210  static std::shared_ptr<ErroneousProgram> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
3211 
3212 };
3213 
3218 public:
3219 
3224 
3228  void find_reachable(::tree::base::PointerMap &map) const override;
3229 
3233  void check_complete(const ::tree::base::PointerMap &map) const override;
3234 
3238  NodeType type() const override;
3239 
3240 protected:
3241 
3245  void visit_internal(VisitorBase &visitor, void *retval) override;
3246 
3247 public:
3248 
3253  ErroneousStatement *as_erroneous_statement() override;
3254 
3259  const ErroneousStatement *as_erroneous_statement() const override;
3260 
3264  One<Node> copy() const override;
3265 
3269  One<Node> clone() const override;
3270 
3274  bool equals(const Node &rhs) const override;
3275 
3279  bool operator==(const Node &rhs) const override;
3280 
3284  void serialize(
3285  ::tree::cbor::MapWriter &map,
3286  const ::tree::base::PointerMap &ids
3287  ) const override;
3288 
3292  static std::shared_ptr<ErroneousStatement> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
3293 
3294 };
3295 
3299 class ExpressionList : public Node {
3300 public:
3301 
3306 
3311 
3315  void find_reachable(::tree::base::PointerMap &map) const override;
3316 
3320  void check_complete(const ::tree::base::PointerMap &map) const override;
3321 
3325  NodeType type() const override;
3326 
3327 protected:
3328 
3332  void visit_internal(VisitorBase &visitor, void *retval) override;
3333 
3334 public:
3335 
3340  ExpressionList *as_expression_list() override;
3341 
3346  const ExpressionList *as_expression_list() const override;
3347 
3351  One<Node> copy() const override;
3352 
3356  One<Node> clone() const override;
3357 
3361  bool equals(const Node &rhs) const override;
3362 
3366  bool operator==(const Node &rhs) const override;
3367 
3371  void serialize(
3372  ::tree::cbor::MapWriter &map,
3373  const ::tree::base::PointerMap &ids
3374  ) const override;
3375 
3379  static std::shared_ptr<ExpressionList> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
3380 
3381 };
3382 
3386 class FloatLiteral : public Expression {
3387 public:
3388 
3393 
3397  FloatLiteral(const cqasm::v1::primitives::Real &value = cqasm::v1::primitives::initialize<cqasm::v1::primitives::Real>());
3398 
3402  void find_reachable(::tree::base::PointerMap &map) const override;
3403 
3407  void check_complete(const ::tree::base::PointerMap &map) const override;
3408 
3412  NodeType type() const override;
3413 
3414 protected:
3415 
3419  void visit_internal(VisitorBase &visitor, void *retval) override;
3420 
3421 public:
3422 
3427  FloatLiteral *as_float_literal() override;
3428 
3433  const FloatLiteral *as_float_literal() const override;
3434 
3438  One<Node> copy() const override;
3439 
3443  One<Node> clone() const override;
3444 
3448  bool equals(const Node &rhs) const override;
3449 
3453  bool operator==(const Node &rhs) const override;
3454 
3458  void serialize(
3459  ::tree::cbor::MapWriter &map,
3460  const ::tree::base::PointerMap &ids
3461  ) const override;
3462 
3466  static std::shared_ptr<FloatLiteral> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
3467 
3468 };
3469 
3473 class ForLoop : public Structured {
3474 public:
3475 
3480 
3485 
3491 
3496 
3500  ForLoop(const Maybe<Assignment> &initialize = Maybe<Assignment>(), const One<Expression> &condition = One<Expression>(), const Maybe<Assignment> &update = Maybe<Assignment>(), const One<StatementList> &body = One<StatementList>(), const Any<AnnotationData> &annotations = Any<AnnotationData>());
3501 
3505  void find_reachable(::tree::base::PointerMap &map) const override;
3506 
3510  void check_complete(const ::tree::base::PointerMap &map) const override;
3511 
3515  NodeType type() const override;
3516 
3517 protected:
3518 
3522  void visit_internal(VisitorBase &visitor, void *retval) override;
3523 
3524 public:
3525 
3530  ForLoop *as_for_loop() override;
3531 
3536  const ForLoop *as_for_loop() const override;
3537 
3541  One<Node> copy() const override;
3542 
3546  One<Node> clone() const override;
3547 
3551  bool equals(const Node &rhs) const override;
3552 
3556  bool operator==(const Node &rhs) const override;
3557 
3561  void serialize(
3562  ::tree::cbor::MapWriter &map,
3563  const ::tree::base::PointerMap &ids
3564  ) const override;
3565 
3569  static std::shared_ptr<ForLoop> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
3570 
3571 };
3572 
3578 class ForeachLoop : public Structured {
3579 public:
3580 
3585 
3590 
3595 
3600 
3605 
3609  void find_reachable(::tree::base::PointerMap &map) const override;
3610 
3614  void check_complete(const ::tree::base::PointerMap &map) const override;
3615 
3619  NodeType type() const override;
3620 
3621 protected:
3622 
3626  void visit_internal(VisitorBase &visitor, void *retval) override;
3627 
3628 public:
3629 
3634  ForeachLoop *as_foreach_loop() override;
3635 
3640  const ForeachLoop *as_foreach_loop() const override;
3641 
3645  One<Node> copy() const override;
3646 
3650  One<Node> clone() const override;
3651 
3655  bool equals(const Node &rhs) const override;
3656 
3660  bool operator==(const Node &rhs) const override;
3661 
3665  void serialize(
3666  ::tree::cbor::MapWriter &map,
3667  const ::tree::base::PointerMap &ids
3668  ) const override;
3669 
3673  static std::shared_ptr<ForeachLoop> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
3674 
3675 };
3676 
3680 class FunctionCall : public Expression {
3681 public:
3682 
3687 
3692 
3697 
3701  void find_reachable(::tree::base::PointerMap &map) const override;
3702 
3706  void check_complete(const ::tree::base::PointerMap &map) const override;
3707 
3711  NodeType type() const override;
3712 
3713 protected:
3714 
3718  void visit_internal(VisitorBase &visitor, void *retval) override;
3719 
3720 public:
3721 
3726  FunctionCall *as_function_call() override;
3727 
3732  const FunctionCall *as_function_call() const override;
3733 
3737  One<Node> copy() const override;
3738 
3742  One<Node> clone() const override;
3743 
3747  bool equals(const Node &rhs) const override;
3748 
3752  bool operator==(const Node &rhs) const override;
3753 
3757  void serialize(
3758  ::tree::cbor::MapWriter &map,
3759  const ::tree::base::PointerMap &ids
3760  ) const override;
3761 
3765  static std::shared_ptr<FunctionCall> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
3766 
3767 };
3768 
3772 class Identifier : public Expression {
3773 public:
3774 
3779 
3783  Identifier(const cqasm::v1::primitives::Str &name = cqasm::v1::primitives::initialize<cqasm::v1::primitives::Str>());
3784 
3788  void find_reachable(::tree::base::PointerMap &map) const override;
3789 
3793  void check_complete(const ::tree::base::PointerMap &map) const override;
3794 
3798  NodeType type() const override;
3799 
3800 protected:
3801 
3805  void visit_internal(VisitorBase &visitor, void *retval) override;
3806 
3807 public:
3808 
3813  Identifier *as_identifier() override;
3814 
3819  const Identifier *as_identifier() const override;
3820 
3824  One<Node> copy() const override;
3825 
3829  One<Node> clone() const override;
3830 
3834  bool equals(const Node &rhs) const override;
3835 
3839  bool operator==(const Node &rhs) const override;
3840 
3844  void serialize(
3845  ::tree::cbor::MapWriter &map,
3846  const ::tree::base::PointerMap &ids
3847  ) const override;
3848 
3852  static std::shared_ptr<Identifier> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
3853 
3854 };
3855 
3859 class IfElse : public Structured {
3860 public:
3861 
3866 
3871 
3875  IfElse(const Many<IfElseBranch> &branches = Many<IfElseBranch>(), const Maybe<StatementList> &otherwise = Maybe<StatementList>(), const Any<AnnotationData> &annotations = Any<AnnotationData>());
3876 
3880  void find_reachable(::tree::base::PointerMap &map) const override;
3881 
3885  void check_complete(const ::tree::base::PointerMap &map) const override;
3886 
3890  NodeType type() const override;
3891 
3892 protected:
3893 
3897  void visit_internal(VisitorBase &visitor, void *retval) override;
3898 
3899 public:
3900 
3905  IfElse *as_if_else() override;
3906 
3911  const IfElse *as_if_else() const override;
3912 
3916  One<Node> copy() const override;
3917 
3921  One<Node> clone() const override;
3922 
3926  bool equals(const Node &rhs) const override;
3927 
3931  bool operator==(const Node &rhs) const override;
3932 
3936  void serialize(
3937  ::tree::cbor::MapWriter &map,
3938  const ::tree::base::PointerMap &ids
3939  ) const override;
3940 
3944  static std::shared_ptr<IfElse> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
3945 
3946 };
3947 
3951 class IfElseBranch : public Node {
3952 public:
3953 
3958 
3963 
3967  IfElseBranch(const One<Expression> &condition = One<Expression>(), const One<StatementList> &body = One<StatementList>());
3968 
3972  void find_reachable(::tree::base::PointerMap &map) const override;
3973 
3977  void check_complete(const ::tree::base::PointerMap &map) const override;
3978 
3982  NodeType type() const override;
3983 
3984 protected:
3985 
3989  void visit_internal(VisitorBase &visitor, void *retval) override;
3990 
3991 public:
3992 
3997  IfElseBranch *as_if_else_branch() override;
3998 
4003  const IfElseBranch *as_if_else_branch() const override;
4004 
4008  One<Node> copy() const override;
4009 
4013  One<Node> clone() const override;
4014 
4018  bool equals(const Node &rhs) const override;
4019 
4023  bool operator==(const Node &rhs) const override;
4024 
4028  void serialize(
4029  ::tree::cbor::MapWriter &map,
4030  const ::tree::base::PointerMap &ids
4031  ) const override;
4032 
4036  static std::shared_ptr<IfElseBranch> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
4037 
4038 };
4039 
4043 class Index : public Expression {
4044 public:
4045 
4050 
4055 
4059  Index(const One<Expression> &expr = One<Expression>(), const One<IndexList> &indices = One<IndexList>());
4060 
4064  void find_reachable(::tree::base::PointerMap &map) const override;
4065 
4069  void check_complete(const ::tree::base::PointerMap &map) const override;
4070 
4074  NodeType type() const override;
4075 
4076 protected:
4077 
4081  void visit_internal(VisitorBase &visitor, void *retval) override;
4082 
4083 public:
4084 
4089  Index *as_index() override;
4090 
4095  const Index *as_index() const override;
4096 
4100  One<Node> copy() const override;
4101 
4105  One<Node> clone() const override;
4106 
4110  bool equals(const Node &rhs) const override;
4111 
4115  bool operator==(const Node &rhs) const override;
4116 
4120  void serialize(
4121  ::tree::cbor::MapWriter &map,
4122  const ::tree::base::PointerMap &ids
4123  ) const override;
4124 
4128  static std::shared_ptr<Index> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
4129 
4130 };
4131 
4135 class IndexEntry : public Node {
4136 public:
4137 
4142  IndexEntry *as_index_entry() override;
4143 
4148  const IndexEntry *as_index_entry() const override;
4149 
4153  static std::shared_ptr<IndexEntry> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
4154 
4155 };
4156 
4160 class IndexItem : public IndexEntry {
4161 public:
4162 
4167 
4171  IndexItem(const One<Expression> &index = One<Expression>());
4172 
4176  void find_reachable(::tree::base::PointerMap &map) const override;
4177 
4181  void check_complete(const ::tree::base::PointerMap &map) const override;
4182 
4186  NodeType type() const override;
4187 
4188 protected:
4189 
4193  void visit_internal(VisitorBase &visitor, void *retval) override;
4194 
4195 public:
4196 
4201  IndexItem *as_index_item() override;
4202 
4207  const IndexItem *as_index_item() const override;
4208 
4212  One<Node> copy() const override;
4213 
4217  One<Node> clone() const override;
4218 
4222  bool equals(const Node &rhs) const override;
4223 
4227  bool operator==(const Node &rhs) const override;
4228 
4232  void serialize(
4233  ::tree::cbor::MapWriter &map,
4234  const ::tree::base::PointerMap &ids
4235  ) const override;
4236 
4240  static std::shared_ptr<IndexItem> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
4241 
4242 };
4243 
4247 class IndexList : public Node {
4248 public:
4249 
4254 
4258  IndexList(const Many<IndexEntry> &items = Many<IndexEntry>());
4259 
4263  void find_reachable(::tree::base::PointerMap &map) const override;
4264 
4268  void check_complete(const ::tree::base::PointerMap &map) const override;
4269 
4273  NodeType type() const override;
4274 
4275 protected:
4276 
4280  void visit_internal(VisitorBase &visitor, void *retval) override;
4281 
4282 public:
4283 
4288  IndexList *as_index_list() override;
4289 
4294  const IndexList *as_index_list() const override;
4295 
4299  One<Node> copy() const override;
4300 
4304  One<Node> clone() const override;
4305 
4309  bool equals(const Node &rhs) const override;
4310 
4314  bool operator==(const Node &rhs) const override;
4315 
4319  void serialize(
4320  ::tree::cbor::MapWriter &map,
4321  const ::tree::base::PointerMap &ids
4322  ) const override;
4323 
4327  static std::shared_ptr<IndexList> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
4328 
4329 };
4330 
4334 class IndexRange : public IndexEntry {
4335 public:
4336 
4341 
4346 
4350  IndexRange(const One<Expression> &first = One<Expression>(), const One<Expression> &last = One<Expression>());
4351 
4355  void find_reachable(::tree::base::PointerMap &map) const override;
4356 
4360  void check_complete(const ::tree::base::PointerMap &map) const override;
4361 
4365  NodeType type() const override;
4366 
4367 protected:
4368 
4372  void visit_internal(VisitorBase &visitor, void *retval) override;
4373 
4374 public:
4375 
4380  IndexRange *as_index_range() override;
4381 
4386  const IndexRange *as_index_range() const override;
4387 
4391  One<Node> copy() const override;
4392 
4396  One<Node> clone() const override;
4397 
4401  bool equals(const Node &rhs) const override;
4402 
4406  bool operator==(const Node &rhs) const override;
4407 
4411  void serialize(
4412  ::tree::cbor::MapWriter &map,
4413  const ::tree::base::PointerMap &ids
4414  ) const override;
4415 
4419  static std::shared_ptr<IndexRange> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
4420 
4421 };
4422 
4427 class Instruction : public Annotated {
4428 public:
4429 
4434 
4439 
4444 
4448  Instruction(const One<Identifier> &name = One<Identifier>(), const Maybe<Expression> &condition = Maybe<Expression>(), const One<ExpressionList> &operands = One<ExpressionList>(), const Any<AnnotationData> &annotations = Any<AnnotationData>());
4449 
4453  void find_reachable(::tree::base::PointerMap &map) const override;
4454 
4458  void check_complete(const ::tree::base::PointerMap &map) const override;
4459 
4463  NodeType type() const override;
4464 
4465 protected:
4466 
4470  void visit_internal(VisitorBase &visitor, void *retval) override;
4471 
4472 public:
4473 
4478  Instruction *as_instruction() override;
4479 
4484  const Instruction *as_instruction() const override;
4485 
4489  One<Node> copy() const override;
4490 
4494  One<Node> clone() const override;
4495 
4499  bool equals(const Node &rhs) const override;
4500 
4504  bool operator==(const Node &rhs) const override;
4505 
4509  void serialize(
4510  ::tree::cbor::MapWriter &map,
4511  const ::tree::base::PointerMap &ids
4512  ) const override;
4513 
4517  static std::shared_ptr<Instruction> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
4518 
4519 };
4520 
4524 class IntDivide : public ArithOp {
4525 public:
4526 
4531 
4535  void find_reachable(::tree::base::PointerMap &map) const override;
4536 
4540  void check_complete(const ::tree::base::PointerMap &map) const override;
4541 
4545  NodeType type() const override;
4546 
4547 protected:
4548 
4552  void visit_internal(VisitorBase &visitor, void *retval) override;
4553 
4554 public:
4555 
4560  IntDivide *as_int_divide() override;
4561 
4566  const IntDivide *as_int_divide() const override;
4567 
4571  One<Node> copy() const override;
4572 
4576  One<Node> clone() const override;
4577 
4581  bool equals(const Node &rhs) const override;
4582 
4586  bool operator==(const Node &rhs) const override;
4587 
4591  void serialize(
4592  ::tree::cbor::MapWriter &map,
4593  const ::tree::base::PointerMap &ids
4594  ) const override;
4595 
4599  static std::shared_ptr<IntDivide> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
4600 
4601 };
4602 
4606 class IntegerLiteral : public Expression {
4607 public:
4608 
4613 
4617  IntegerLiteral(const cqasm::v1::primitives::Int &value = cqasm::v1::primitives::initialize<cqasm::v1::primitives::Int>());
4618 
4622  void find_reachable(::tree::base::PointerMap &map) const override;
4623 
4627  void check_complete(const ::tree::base::PointerMap &map) const override;
4628 
4632  NodeType type() const override;
4633 
4634 protected:
4635 
4639  void visit_internal(VisitorBase &visitor, void *retval) override;
4640 
4641 public:
4642 
4647  IntegerLiteral *as_integer_literal() override;
4648 
4653  const IntegerLiteral *as_integer_literal() const override;
4654 
4658  One<Node> copy() const override;
4659 
4663  One<Node> clone() const override;
4664 
4668  bool equals(const Node &rhs) const override;
4669 
4673  bool operator==(const Node &rhs) const override;
4674 
4678  void serialize(
4679  ::tree::cbor::MapWriter &map,
4680  const ::tree::base::PointerMap &ids
4681  ) const override;
4682 
4686  static std::shared_ptr<IntegerLiteral> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
4687 
4688 };
4689 
4693 class JsonLiteral : public Expression {
4694 public:
4695 
4700 
4704  JsonLiteral(const cqasm::v1::primitives::Str &value = cqasm::v1::primitives::initialize<cqasm::v1::primitives::Str>());
4705 
4709  void find_reachable(::tree::base::PointerMap &map) const override;
4710 
4714  void check_complete(const ::tree::base::PointerMap &map) const override;
4715 
4719  NodeType type() const override;
4720 
4721 protected:
4722 
4726  void visit_internal(VisitorBase &visitor, void *retval) override;
4727 
4728 public:
4729 
4734  JsonLiteral *as_json_literal() override;
4735 
4740  const JsonLiteral *as_json_literal() const override;
4741 
4745  One<Node> copy() const override;
4746 
4750  One<Node> clone() const override;
4751 
4755  bool equals(const Node &rhs) const override;
4756 
4760  bool operator==(const Node &rhs) const override;
4761 
4765  void serialize(
4766  ::tree::cbor::MapWriter &map,
4767  const ::tree::base::PointerMap &ids
4768  ) const override;
4769 
4773  static std::shared_ptr<JsonLiteral> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
4774 
4775 };
4776 
4780 class LogicalOp : public BinaryOp {
4781 public:
4782 
4787 
4792  LogicalOp *as_logical_op() override;
4793 
4798  const LogicalOp *as_logical_op() const override;
4799 
4803  static std::shared_ptr<LogicalOp> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
4804 
4805 };
4806 
4810 class LogicalAnd : public LogicalOp {
4811 public:
4812 
4817 
4821  void find_reachable(::tree::base::PointerMap &map) const override;
4822 
4826  void check_complete(const ::tree::base::PointerMap &map) const override;
4827 
4831  NodeType type() const override;
4832 
4833 protected:
4834 
4838  void visit_internal(VisitorBase &visitor, void *retval) override;
4839 
4840 public:
4841 
4846  LogicalAnd *as_logical_and() override;
4847 
4852  const LogicalAnd *as_logical_and() const override;
4853 
4857  One<Node> copy() const override;
4858 
4862  One<Node> clone() const override;
4863 
4867  bool equals(const Node &rhs) const override;
4868 
4872  bool operator==(const Node &rhs) const override;
4873 
4877  void serialize(
4878  ::tree::cbor::MapWriter &map,
4879  const ::tree::base::PointerMap &ids
4880  ) const override;
4881 
4885  static std::shared_ptr<LogicalAnd> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
4886 
4887 };
4888 
4892 class LogicalNot : public UnaryOp {
4893 public:
4894 
4898  LogicalNot(const One<Expression> &expr = One<Expression>());
4899 
4903  void find_reachable(::tree::base::PointerMap &map) const override;
4904 
4908  void check_complete(const ::tree::base::PointerMap &map) const override;
4909 
4913  NodeType type() const override;
4914 
4915 protected:
4916 
4920  void visit_internal(VisitorBase &visitor, void *retval) override;
4921 
4922 public:
4923 
4928  LogicalNot *as_logical_not() override;
4929 
4934  const LogicalNot *as_logical_not() const override;
4935 
4939  One<Node> copy() const override;
4940 
4944  One<Node> clone() const override;
4945 
4949  bool equals(const Node &rhs) const override;
4950 
4954  bool operator==(const Node &rhs) const override;
4955 
4959  void serialize(
4960  ::tree::cbor::MapWriter &map,
4961  const ::tree::base::PointerMap &ids
4962  ) const override;
4963 
4967  static std::shared_ptr<LogicalNot> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
4968 
4969 };
4970 
4974 class LogicalOr : public LogicalOp {
4975 public:
4976 
4981 
4985  void find_reachable(::tree::base::PointerMap &map) const override;
4986 
4990  void check_complete(const ::tree::base::PointerMap &map) const override;
4991 
4995  NodeType type() const override;
4996 
4997 protected:
4998 
5002  void visit_internal(VisitorBase &visitor, void *retval) override;
5003 
5004 public:
5005 
5010  LogicalOr *as_logical_or() override;
5011 
5016  const LogicalOr *as_logical_or() const override;
5017 
5021  One<Node> copy() const override;
5022 
5026  One<Node> clone() const override;
5027 
5031  bool equals(const Node &rhs) const override;
5032 
5036  bool operator==(const Node &rhs) const override;
5037 
5041  void serialize(
5042  ::tree::cbor::MapWriter &map,
5043  const ::tree::base::PointerMap &ids
5044  ) const override;
5045 
5049  static std::shared_ptr<LogicalOr> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
5050 
5051 };
5052 
5056 class LogicalXor : public LogicalOp {
5057 public:
5058 
5063 
5067  void find_reachable(::tree::base::PointerMap &map) const override;
5068 
5072  void check_complete(const ::tree::base::PointerMap &map) const override;
5073 
5077  NodeType type() const override;
5078 
5079 protected:
5080 
5084  void visit_internal(VisitorBase &visitor, void *retval) override;
5085 
5086 public:
5087 
5092  LogicalXor *as_logical_xor() override;
5093 
5098  const LogicalXor *as_logical_xor() const override;
5099 
5103  One<Node> copy() const override;
5104 
5108  One<Node> clone() const override;
5109 
5113  bool equals(const Node &rhs) const override;
5114 
5118  bool operator==(const Node &rhs) const override;
5119 
5123  void serialize(
5124  ::tree::cbor::MapWriter &map,
5125  const ::tree::base::PointerMap &ids
5126  ) const override;
5127 
5131  static std::shared_ptr<LogicalXor> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
5132 
5133 };
5134 
5139 class Mapping : public Statement {
5140 public:
5141 
5146 
5151 
5155  Mapping(const One<Identifier> &alias = One<Identifier>(), const One<Expression> &expr = One<Expression>(), const Any<AnnotationData> &annotations = Any<AnnotationData>());
5156 
5160  void find_reachable(::tree::base::PointerMap &map) const override;
5161 
5165  void check_complete(const ::tree::base::PointerMap &map) const override;
5166 
5170  NodeType type() const override;
5171 
5172 protected:
5173 
5177  void visit_internal(VisitorBase &visitor, void *retval) override;
5178 
5179 public:
5180 
5185  Mapping *as_mapping() override;
5186 
5191  const Mapping *as_mapping() const override;
5192 
5196  One<Node> copy() const override;
5197 
5201  One<Node> clone() const override;
5202 
5206  bool equals(const Node &rhs) const override;
5207 
5211  bool operator==(const Node &rhs) const override;
5212 
5216  void serialize(
5217  ::tree::cbor::MapWriter &map,
5218  const ::tree::base::PointerMap &ids
5219  ) const override;
5220 
5224  static std::shared_ptr<Mapping> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
5225 
5226 };
5227 
5235 class MatrixLiteral : public Expression {
5236 public:
5237 
5242 
5247 
5251  void find_reachable(::tree::base::PointerMap &map) const override;
5252 
5256  void check_complete(const ::tree::base::PointerMap &map) const override;
5257 
5261  NodeType type() const override;
5262 
5263 protected:
5264 
5268  void visit_internal(VisitorBase &visitor, void *retval) override;
5269 
5270 public:
5271 
5276  MatrixLiteral *as_matrix_literal() override;
5277 
5282  const MatrixLiteral *as_matrix_literal() const override;
5283 
5287  One<Node> copy() const override;
5288 
5292  One<Node> clone() const override;
5293 
5297  bool equals(const Node &rhs) const override;
5298 
5302  bool operator==(const Node &rhs) const override;
5303 
5307  void serialize(
5308  ::tree::cbor::MapWriter &map,
5309  const ::tree::base::PointerMap &ids
5310  ) const override;
5311 
5315  static std::shared_ptr<MatrixLiteral> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
5316 
5317 };
5318 
5322 class Modulo : public ArithOp {
5323 public:
5324 
5328  Modulo(const One<Expression> &lhs = One<Expression>(), const One<Expression> &rhs = One<Expression>());
5329 
5333  void find_reachable(::tree::base::PointerMap &map) const override;
5334 
5338  void check_complete(const ::tree::base::PointerMap &map) const override;
5339 
5343  NodeType type() const override;
5344 
5345 protected:
5346 
5350  void visit_internal(VisitorBase &visitor, void *retval) override;
5351 
5352 public:
5353 
5358  Modulo *as_modulo() override;
5359 
5364  const Modulo *as_modulo() const override;
5365 
5369  One<Node> copy() const override;
5370 
5374  One<Node> clone() const override;
5375 
5379  bool equals(const Node &rhs) const override;
5380 
5384  bool operator==(const Node &rhs) const override;
5385 
5389  void serialize(
5390  ::tree::cbor::MapWriter &map,
5391  const ::tree::base::PointerMap &ids
5392  ) const override;
5393 
5397  static std::shared_ptr<Modulo> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
5398 
5399 };
5400 
5404 class Multiply : public ArithOp {
5405 public:
5406 
5411 
5415  void find_reachable(::tree::base::PointerMap &map) const override;
5416 
5420  void check_complete(const ::tree::base::PointerMap &map) const override;
5421 
5425  NodeType type() const override;
5426 
5427 protected:
5428 
5432  void visit_internal(VisitorBase &visitor, void *retval) override;
5433 
5434 public:
5435 
5440  Multiply *as_multiply() override;
5441 
5446  const Multiply *as_multiply() const override;
5447 
5451  One<Node> copy() const override;
5452 
5456  One<Node> clone() const override;
5457 
5461  bool equals(const Node &rhs) const override;
5462 
5466  bool operator==(const Node &rhs) const override;
5467 
5471  void serialize(
5472  ::tree::cbor::MapWriter &map,
5473  const ::tree::base::PointerMap &ids
5474  ) const override;
5475 
5479  static std::shared_ptr<Multiply> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
5480 
5481 };
5482 
5486 class Negate : public UnaryOp {
5487 public:
5488 
5492  Negate(const One<Expression> &expr = One<Expression>());
5493 
5497  void find_reachable(::tree::base::PointerMap &map) const override;
5498 
5502  void check_complete(const ::tree::base::PointerMap &map) const override;
5503 
5507  NodeType type() const override;
5508 
5509 protected:
5510 
5514  void visit_internal(VisitorBase &visitor, void *retval) override;
5515 
5516 public:
5517 
5522  Negate *as_negate() override;
5523 
5528  const Negate *as_negate() const override;
5529 
5533  One<Node> copy() const override;
5534 
5538  One<Node> clone() const override;
5539 
5543  bool equals(const Node &rhs) const override;
5544 
5548  bool operator==(const Node &rhs) const override;
5549 
5553  void serialize(
5554  ::tree::cbor::MapWriter &map,
5555  const ::tree::base::PointerMap &ids
5556  ) const override;
5557 
5561  static std::shared_ptr<Negate> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
5562 
5563 };
5564 
5568 class Power : public ArithOp {
5569 public:
5570 
5574  Power(const One<Expression> &lhs = One<Expression>(), const One<Expression> &rhs = One<Expression>());
5575 
5579  void find_reachable(::tree::base::PointerMap &map) const override;
5580 
5584  void check_complete(const ::tree::base::PointerMap &map) const override;
5585 
5589  NodeType type() const override;
5590 
5591 protected:
5592 
5596  void visit_internal(VisitorBase &visitor, void *retval) override;
5597 
5598 public:
5599 
5604  Power *as_power() override;
5605 
5610  const Power *as_power() const override;
5611 
5615  One<Node> copy() const override;
5616 
5620  One<Node> clone() const override;
5621 
5625  bool equals(const Node &rhs) const override;
5626 
5630  bool operator==(const Node &rhs) const override;
5631 
5635  void serialize(
5636  ::tree::cbor::MapWriter &map,
5637  const ::tree::base::PointerMap &ids
5638  ) const override;
5639 
5643  static std::shared_ptr<Power> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
5644 
5645 };
5646 
5650 class Program : public Root {
5651 public:
5652 
5657 
5662 
5667 
5671  Program(const One<Version> &version = One<Version>(), const Maybe<Expression> &num_qubits = Maybe<Expression>(), const One<StatementList> &statements = One<StatementList>());
5672 
5676  void find_reachable(::tree::base::PointerMap &map) const override;
5677 
5681  void check_complete(const ::tree::base::PointerMap &map) const override;
5682 
5686  NodeType type() const override;
5687 
5688 protected:
5689 
5693  void visit_internal(VisitorBase &visitor, void *retval) override;
5694 
5695 public:
5696 
5701  Program *as_program() override;
5702 
5707  const Program *as_program() const override;
5708 
5712  One<Node> copy() const override;
5713 
5717  One<Node> clone() const override;
5718 
5722  bool equals(const Node &rhs) const override;
5723 
5727  bool operator==(const Node &rhs) const override;
5728 
5732  void serialize(
5733  ::tree::cbor::MapWriter &map,
5734  const ::tree::base::PointerMap &ids
5735  ) const override;
5736 
5740  static std::shared_ptr<Program> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
5741 
5742 };
5743 
5747 class RepeatUntilLoop : public Structured {
5748 public:
5749 
5754 
5759 
5764 
5768  void find_reachable(::tree::base::PointerMap &map) const override;
5769 
5773  void check_complete(const ::tree::base::PointerMap &map) const override;
5774 
5778  NodeType type() const override;
5779 
5780 protected:
5781 
5785  void visit_internal(VisitorBase &visitor, void *retval) override;
5786 
5787 public:
5788 
5793  RepeatUntilLoop *as_repeat_until_loop() override;
5794 
5799  const RepeatUntilLoop *as_repeat_until_loop() const override;
5800 
5804  One<Node> copy() const override;
5805 
5809  One<Node> clone() const override;
5810 
5814  bool equals(const Node &rhs) const override;
5815 
5819  bool operator==(const Node &rhs) const override;
5820 
5824  void serialize(
5825  ::tree::cbor::MapWriter &map,
5826  const ::tree::base::PointerMap &ids
5827  ) const override;
5828 
5832  static std::shared_ptr<RepeatUntilLoop> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
5833 
5834 };
5835 
5839 class ShiftOp : public BinaryOp {
5840 public:
5841 
5845  ShiftOp(const One<Expression> &lhs = One<Expression>(), const One<Expression> &rhs = One<Expression>());
5846 
5851  ShiftOp *as_shift_op() override;
5852 
5857  const ShiftOp *as_shift_op() const override;
5858 
5862  static std::shared_ptr<ShiftOp> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
5863 
5864 };
5865 
5869 class ShiftLeft : public ShiftOp {
5870 public:
5871 
5876 
5880  void find_reachable(::tree::base::PointerMap &map) const override;
5881 
5885  void check_complete(const ::tree::base::PointerMap &map) const override;
5886 
5890  NodeType type() const override;
5891 
5892 protected:
5893 
5897  void visit_internal(VisitorBase &visitor, void *retval) override;
5898 
5899 public:
5900 
5905  ShiftLeft *as_shift_left() override;
5906 
5911  const ShiftLeft *as_shift_left() const override;
5912 
5916  One<Node> copy() const override;
5917 
5921  One<Node> clone() const override;
5922 
5926  bool equals(const Node &rhs) const override;
5927 
5931  bool operator==(const Node &rhs) const override;
5932 
5936  void serialize(
5937  ::tree::cbor::MapWriter &map,
5938  const ::tree::base::PointerMap &ids
5939  ) const override;
5940 
5944  static std::shared_ptr<ShiftLeft> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
5945 
5946 };
5947 
5951 class ShiftRightArith : public ShiftOp {
5952 public:
5953 
5958 
5962  void find_reachable(::tree::base::PointerMap &map) const override;
5963 
5967  void check_complete(const ::tree::base::PointerMap &map) const override;
5968 
5972  NodeType type() const override;
5973 
5974 protected:
5975 
5979  void visit_internal(VisitorBase &visitor, void *retval) override;
5980 
5981 public:
5982 
5987  ShiftRightArith *as_shift_right_arith() override;
5988 
5993  const ShiftRightArith *as_shift_right_arith() const override;
5994 
5998  One<Node> copy() const override;
5999 
6003  One<Node> clone() const override;
6004 
6008  bool equals(const Node &rhs) const override;
6009 
6013  bool operator==(const Node &rhs) const override;
6014 
6018  void serialize(
6019  ::tree::cbor::MapWriter &map,
6020  const ::tree::base::PointerMap &ids
6021  ) const override;
6022 
6026  static std::shared_ptr<ShiftRightArith> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
6027 
6028 };
6029 
6033 class ShiftRightLogic : public ShiftOp {
6034 public:
6035 
6040 
6044  void find_reachable(::tree::base::PointerMap &map) const override;
6045 
6049  void check_complete(const ::tree::base::PointerMap &map) const override;
6050 
6054  NodeType type() const override;
6055 
6056 protected:
6057 
6061  void visit_internal(VisitorBase &visitor, void *retval) override;
6062 
6063 public:
6064 
6069  ShiftRightLogic *as_shift_right_logic() override;
6070 
6075  const ShiftRightLogic *as_shift_right_logic() const override;
6076 
6080  One<Node> copy() const override;
6081 
6085  One<Node> clone() const override;
6086 
6090  bool equals(const Node &rhs) const override;
6091 
6095  bool operator==(const Node &rhs) const override;
6096 
6100  void serialize(
6101  ::tree::cbor::MapWriter &map,
6102  const ::tree::base::PointerMap &ids
6103  ) const override;
6104 
6108  static std::shared_ptr<ShiftRightLogic> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
6109 
6110 };
6111 
6115 class StatementList : public Node {
6116 public:
6117 
6122 
6126  StatementList(const Any<Statement> &items = Any<Statement>());
6127 
6131  void find_reachable(::tree::base::PointerMap &map) const override;
6132 
6136  void check_complete(const ::tree::base::PointerMap &map) const override;
6137 
6141  NodeType type() const override;
6142 
6143 protected:
6144 
6148  void visit_internal(VisitorBase &visitor, void *retval) override;
6149 
6150 public:
6151 
6156  StatementList *as_statement_list() override;
6157 
6162  const StatementList *as_statement_list() const override;
6163 
6167  One<Node> copy() const override;
6168 
6172  One<Node> clone() const override;
6173 
6177  bool equals(const Node &rhs) const override;
6178 
6182  bool operator==(const Node &rhs) const override;
6183 
6187  void serialize(
6188  ::tree::cbor::MapWriter &map,
6189  const ::tree::base::PointerMap &ids
6190  ) const override;
6191 
6195  static std::shared_ptr<StatementList> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
6196 
6197 };
6198 
6202 class StringLiteral : public Expression {
6203 public:
6204 
6209 
6213  StringLiteral(const cqasm::v1::primitives::Str &value = cqasm::v1::primitives::initialize<cqasm::v1::primitives::Str>());
6214 
6218  void find_reachable(::tree::base::PointerMap &map) const override;
6219 
6223  void check_complete(const ::tree::base::PointerMap &map) const override;
6224 
6228  NodeType type() const override;
6229 
6230 protected:
6231 
6235  void visit_internal(VisitorBase &visitor, void *retval) override;
6236 
6237 public:
6238 
6243  StringLiteral *as_string_literal() override;
6244 
6249  const StringLiteral *as_string_literal() const override;
6250 
6254  One<Node> copy() const override;
6255 
6259  One<Node> clone() const override;
6260 
6264  bool equals(const Node &rhs) const override;
6265 
6269  bool operator==(const Node &rhs) const override;
6270 
6274  void serialize(
6275  ::tree::cbor::MapWriter &map,
6276  const ::tree::base::PointerMap &ids
6277  ) const override;
6278 
6282  static std::shared_ptr<StringLiteral> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
6283 
6284 };
6285 
6289 class Subcircuit : public Statement {
6290 public:
6291 
6296 
6302 
6306  Subcircuit(const One<Identifier> &name = One<Identifier>(), const Maybe<Expression> &iterations = Maybe<Expression>(), const Any<AnnotationData> &annotations = Any<AnnotationData>());
6307 
6311  void find_reachable(::tree::base::PointerMap &map) const override;
6312 
6316  void check_complete(const ::tree::base::PointerMap &map) const override;
6317 
6321  NodeType type() const override;
6322 
6323 protected:
6324 
6328  void visit_internal(VisitorBase &visitor, void *retval) override;
6329 
6330 public:
6331 
6336  Subcircuit *as_subcircuit() override;
6337 
6342  const Subcircuit *as_subcircuit() const override;
6343 
6347  One<Node> copy() const override;
6348 
6352  One<Node> clone() const override;
6353 
6357  bool equals(const Node &rhs) const override;
6358 
6362  bool operator==(const Node &rhs) const override;
6363 
6367  void serialize(
6368  ::tree::cbor::MapWriter &map,
6369  const ::tree::base::PointerMap &ids
6370  ) const override;
6371 
6375  static std::shared_ptr<Subcircuit> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
6376 
6377 };
6378 
6382 class Subtract : public ArithOp {
6383 public:
6384 
6389 
6393  void find_reachable(::tree::base::PointerMap &map) const override;
6394 
6398  void check_complete(const ::tree::base::PointerMap &map) const override;
6399 
6403  NodeType type() const override;
6404 
6405 protected:
6406 
6410  void visit_internal(VisitorBase &visitor, void *retval) override;
6411 
6412 public:
6413 
6418  Subtract *as_subtract() override;
6419 
6424  const Subtract *as_subtract() const override;
6425 
6429  One<Node> copy() const override;
6430 
6434  One<Node> clone() const override;
6435 
6439  bool equals(const Node &rhs) const override;
6440 
6444  bool operator==(const Node &rhs) const override;
6445 
6449  void serialize(
6450  ::tree::cbor::MapWriter &map,
6451  const ::tree::base::PointerMap &ids
6452  ) const override;
6453 
6457  static std::shared_ptr<Subtract> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
6458 
6459 };
6460 
6464 class TernaryCond : public Expression {
6465 public:
6466 
6471 
6476 
6481 
6485  TernaryCond(const One<Expression> &cond = One<Expression>(), const One<Expression> &if_true = One<Expression>(), const One<Expression> &if_false = One<Expression>());
6486 
6490  void find_reachable(::tree::base::PointerMap &map) const override;
6491 
6495  void check_complete(const ::tree::base::PointerMap &map) const override;
6496 
6500  NodeType type() const override;
6501 
6502 protected:
6503 
6507  void visit_internal(VisitorBase &visitor, void *retval) override;
6508 
6509 public:
6510 
6515  TernaryCond *as_ternary_cond() override;
6516 
6521  const TernaryCond *as_ternary_cond() const override;
6522 
6526  One<Node> copy() const override;
6527 
6531  One<Node> clone() const override;
6532 
6536  bool equals(const Node &rhs) const override;
6537 
6541  bool operator==(const Node &rhs) const override;
6542 
6546  void serialize(
6547  ::tree::cbor::MapWriter &map,
6548  const ::tree::base::PointerMap &ids
6549  ) const override;
6550 
6554  static std::shared_ptr<TernaryCond> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
6555 
6556 };
6557 
6561 class Variables : public Statement {
6562 public:
6563 
6568 
6573 
6577  Variables(const Many<Identifier> &names = Many<Identifier>(), const One<Identifier> &typ = One<Identifier>(), const Any<AnnotationData> &annotations = Any<AnnotationData>());
6578 
6582  void find_reachable(::tree::base::PointerMap &map) const override;
6583 
6587  void check_complete(const ::tree::base::PointerMap &map) const override;
6588 
6592  NodeType type() const override;
6593 
6594 protected:
6595 
6599  void visit_internal(VisitorBase &visitor, void *retval) override;
6600 
6601 public:
6602 
6607  Variables *as_variables() override;
6608 
6613  const Variables *as_variables() const override;
6614 
6618  One<Node> copy() const override;
6619 
6623  One<Node> clone() const override;
6624 
6628  bool equals(const Node &rhs) const override;
6629 
6633  bool operator==(const Node &rhs) const override;
6634 
6638  void serialize(
6639  ::tree::cbor::MapWriter &map,
6640  const ::tree::base::PointerMap &ids
6641  ) const override;
6642 
6646  static std::shared_ptr<Variables> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
6647 
6648 };
6649 
6653 class Version : public Node {
6654 public:
6655 
6660 
6664  Version(const cqasm::v1::primitives::Version &items = cqasm::v1::primitives::initialize<cqasm::v1::primitives::Version>());
6665 
6669  void find_reachable(::tree::base::PointerMap &map) const override;
6670 
6674  void check_complete(const ::tree::base::PointerMap &map) const override;
6675 
6679  NodeType type() const override;
6680 
6681 protected:
6682 
6686  void visit_internal(VisitorBase &visitor, void *retval) override;
6687 
6688 public:
6689 
6694  Version *as_version() override;
6695 
6700  const Version *as_version() const override;
6701 
6705  One<Node> copy() const override;
6706 
6710  One<Node> clone() const override;
6711 
6715  bool equals(const Node &rhs) const override;
6716 
6720  bool operator==(const Node &rhs) const override;
6721 
6725  void serialize(
6726  ::tree::cbor::MapWriter &map,
6727  const ::tree::base::PointerMap &ids
6728  ) const override;
6729 
6733  static std::shared_ptr<Version> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
6734 
6735 };
6736 
6740 class WhileLoop : public Structured {
6741 public:
6742 
6747 
6752 
6756  WhileLoop(const One<Expression> &condition = One<Expression>(), const One<StatementList> &body = One<StatementList>(), const Any<AnnotationData> &annotations = Any<AnnotationData>());
6757 
6761  void find_reachable(::tree::base::PointerMap &map) const override;
6762 
6766  void check_complete(const ::tree::base::PointerMap &map) const override;
6767 
6771  NodeType type() const override;
6772 
6773 protected:
6774 
6778  void visit_internal(VisitorBase &visitor, void *retval) override;
6779 
6780 public:
6781 
6786  WhileLoop *as_while_loop() override;
6787 
6792  const WhileLoop *as_while_loop() const override;
6793 
6797  One<Node> copy() const override;
6798 
6802  One<Node> clone() const override;
6803 
6807  bool equals(const Node &rhs) const override;
6808 
6812  bool operator==(const Node &rhs) const override;
6813 
6817  void serialize(
6818  ::tree::cbor::MapWriter &map,
6819  const ::tree::base::PointerMap &ids
6820  ) const override;
6821 
6825  static std::shared_ptr<WhileLoop> deserialize(const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids);
6826 
6827 };
6828 
6833 public:
6834 
6838  virtual ~VisitorBase() = default;
6839 
6840 protected:
6841 
6842  friend class Node;
6843  friend class Add;
6844  friend class Annotated;
6845  friend class AnnotationData;
6846  friend class ArithOp;
6847  friend class Assignment;
6848  friend class BinaryOp;
6849  friend class BitwiseAnd;
6850  friend class BitwiseNot;
6851  friend class BitwiseOp;
6852  friend class BitwiseOr;
6853  friend class BitwiseXor;
6854  friend class BreakStatement;
6855  friend class Bundle;
6856  friend class CmpEq;
6857  friend class CmpGe;
6858  friend class CmpGt;
6859  friend class CmpLe;
6860  friend class CmpLt;
6861  friend class CmpNe;
6862  friend class CmpOp;
6863  friend class ContinueStatement;
6864  friend class Divide;
6865  friend class ErroneousExpression;
6866  friend class ErroneousProgram;
6867  friend class ErroneousStatement;
6868  friend class Expression;
6869  friend class ExpressionList;
6870  friend class FloatLiteral;
6871  friend class ForLoop;
6872  friend class ForeachLoop;
6873  friend class FunctionCall;
6874  friend class Identifier;
6875  friend class IfElse;
6876  friend class IfElseBranch;
6877  friend class Index;
6878  friend class IndexEntry;
6879  friend class IndexItem;
6880  friend class IndexList;
6881  friend class IndexRange;
6882  friend class Instruction;
6883  friend class IntDivide;
6884  friend class IntegerLiteral;
6885  friend class JsonLiteral;
6886  friend class LogicalAnd;
6887  friend class LogicalNot;
6888  friend class LogicalOp;
6889  friend class LogicalOr;
6890  friend class LogicalXor;
6891  friend class Mapping;
6892  friend class MatrixLiteral;
6893  friend class Modulo;
6894  friend class Multiply;
6895  friend class Negate;
6896  friend class Power;
6897  friend class Program;
6898  friend class RepeatUntilLoop;
6899  friend class Root;
6900  friend class ShiftLeft;
6901  friend class ShiftOp;
6902  friend class ShiftRightArith;
6903  friend class ShiftRightLogic;
6904  friend class Statement;
6905  friend class StatementList;
6906  friend class StringLiteral;
6907  friend class Structured;
6908  friend class Subcircuit;
6909  friend class Subtract;
6910  friend class TernaryCond;
6911  friend class UnaryOp;
6912  friend class Variables;
6913  friend class Version;
6914  friend class WhileLoop;
6915 
6919  virtual void raw_visit_node(Node &node, void *retval) = 0;
6920 
6924  virtual void raw_visit_add(Add &node, void *retval) = 0;
6925 
6929  virtual void raw_visit_annotated(Annotated &node, void *retval) = 0;
6930 
6934  virtual void raw_visit_annotation_data(AnnotationData &node, void *retval) = 0;
6935 
6939  virtual void raw_visit_arith_op(ArithOp &node, void *retval) = 0;
6940 
6944  virtual void raw_visit_assignment(Assignment &node, void *retval) = 0;
6945 
6949  virtual void raw_visit_binary_op(BinaryOp &node, void *retval) = 0;
6950 
6954  virtual void raw_visit_bitwise_and(BitwiseAnd &node, void *retval) = 0;
6955 
6959  virtual void raw_visit_bitwise_not(BitwiseNot &node, void *retval) = 0;
6960 
6964  virtual void raw_visit_bitwise_op(BitwiseOp &node, void *retval) = 0;
6965 
6969  virtual void raw_visit_bitwise_or(BitwiseOr &node, void *retval) = 0;
6970 
6974  virtual void raw_visit_bitwise_xor(BitwiseXor &node, void *retval) = 0;
6975 
6979  virtual void raw_visit_break_statement(BreakStatement &node, void *retval) = 0;
6980 
6984  virtual void raw_visit_bundle(Bundle &node, void *retval) = 0;
6985 
6989  virtual void raw_visit_cmp_eq(CmpEq &node, void *retval) = 0;
6990 
6994  virtual void raw_visit_cmp_ge(CmpGe &node, void *retval) = 0;
6995 
6999  virtual void raw_visit_cmp_gt(CmpGt &node, void *retval) = 0;
7000 
7004  virtual void raw_visit_cmp_le(CmpLe &node, void *retval) = 0;
7005 
7009  virtual void raw_visit_cmp_lt(CmpLt &node, void *retval) = 0;
7010 
7014  virtual void raw_visit_cmp_ne(CmpNe &node, void *retval) = 0;
7015 
7019  virtual void raw_visit_cmp_op(CmpOp &node, void *retval) = 0;
7020 
7024  virtual void raw_visit_continue_statement(ContinueStatement &node, void *retval) = 0;
7025 
7029  virtual void raw_visit_divide(Divide &node, void *retval) = 0;
7030 
7034  virtual void raw_visit_erroneous_expression(ErroneousExpression &node, void *retval) = 0;
7035 
7039  virtual void raw_visit_erroneous_program(ErroneousProgram &node, void *retval) = 0;
7040 
7044  virtual void raw_visit_erroneous_statement(ErroneousStatement &node, void *retval) = 0;
7045 
7049  virtual void raw_visit_expression(Expression &node, void *retval) = 0;
7050 
7054  virtual void raw_visit_expression_list(ExpressionList &node, void *retval) = 0;
7055 
7059  virtual void raw_visit_float_literal(FloatLiteral &node, void *retval) = 0;
7060 
7064  virtual void raw_visit_for_loop(ForLoop &node, void *retval) = 0;
7065 
7069  virtual void raw_visit_foreach_loop(ForeachLoop &node, void *retval) = 0;
7070 
7074  virtual void raw_visit_function_call(FunctionCall &node, void *retval) = 0;
7075 
7079  virtual void raw_visit_identifier(Identifier &node, void *retval) = 0;
7080 
7084  virtual void raw_visit_if_else(IfElse &node, void *retval) = 0;
7085 
7089  virtual void raw_visit_if_else_branch(IfElseBranch &node, void *retval) = 0;
7090 
7094  virtual void raw_visit_index(Index &node, void *retval) = 0;
7095 
7099  virtual void raw_visit_index_entry(IndexEntry &node, void *retval) = 0;
7100 
7104  virtual void raw_visit_index_item(IndexItem &node, void *retval) = 0;
7105 
7109  virtual void raw_visit_index_list(IndexList &node, void *retval) = 0;
7110 
7114  virtual void raw_visit_index_range(IndexRange &node, void *retval) = 0;
7115 
7119  virtual void raw_visit_instruction(Instruction &node, void *retval) = 0;
7120 
7124  virtual void raw_visit_int_divide(IntDivide &node, void *retval) = 0;
7125 
7129  virtual void raw_visit_integer_literal(IntegerLiteral &node, void *retval) = 0;
7130 
7134  virtual void raw_visit_json_literal(JsonLiteral &node, void *retval) = 0;
7135 
7139  virtual void raw_visit_logical_and(LogicalAnd &node, void *retval) = 0;
7140 
7144  virtual void raw_visit_logical_not(LogicalNot &node, void *retval) = 0;
7145 
7149  virtual void raw_visit_logical_op(LogicalOp &node, void *retval) = 0;
7150 
7154  virtual void raw_visit_logical_or(LogicalOr &node, void *retval) = 0;
7155 
7159  virtual void raw_visit_logical_xor(LogicalXor &node, void *retval) = 0;
7160 
7164  virtual void raw_visit_mapping(Mapping &node, void *retval) = 0;
7165 
7169  virtual void raw_visit_matrix_literal(MatrixLiteral &node, void *retval) = 0;
7170 
7174  virtual void raw_visit_modulo(Modulo &node, void *retval) = 0;
7175 
7179  virtual void raw_visit_multiply(Multiply &node, void *retval) = 0;
7180 
7184  virtual void raw_visit_negate(Negate &node, void *retval) = 0;
7185 
7189  virtual void raw_visit_power(Power &node, void *retval) = 0;
7190 
7194  virtual void raw_visit_program(Program &node, void *retval) = 0;
7195 
7199  virtual void raw_visit_repeat_until_loop(RepeatUntilLoop &node, void *retval) = 0;
7200 
7204  virtual void raw_visit_root(Root &node, void *retval) = 0;
7205 
7209  virtual void raw_visit_shift_left(ShiftLeft &node, void *retval) = 0;
7210 
7214  virtual void raw_visit_shift_op(ShiftOp &node, void *retval) = 0;
7215 
7219  virtual void raw_visit_shift_right_arith(ShiftRightArith &node, void *retval) = 0;
7220 
7224  virtual void raw_visit_shift_right_logic(ShiftRightLogic &node, void *retval) = 0;
7225 
7229  virtual void raw_visit_statement(Statement &node, void *retval) = 0;
7230 
7234  virtual void raw_visit_statement_list(StatementList &node, void *retval) = 0;
7235 
7239  virtual void raw_visit_string_literal(StringLiteral &node, void *retval) = 0;
7240 
7244  virtual void raw_visit_structured(Structured &node, void *retval) = 0;
7245 
7249  virtual void raw_visit_subcircuit(Subcircuit &node, void *retval) = 0;
7250 
7254  virtual void raw_visit_subtract(Subtract &node, void *retval) = 0;
7255 
7259  virtual void raw_visit_ternary_cond(TernaryCond &node, void *retval) = 0;
7260 
7264  virtual void raw_visit_unary_op(UnaryOp &node, void *retval) = 0;
7265 
7269  virtual void raw_visit_variables(Variables &node, void *retval) = 0;
7270 
7274  virtual void raw_visit_version(Version &node, void *retval) = 0;
7275 
7279  virtual void raw_visit_while_loop(WhileLoop &node, void *retval) = 0;
7280 
7281 };
7282 
7293 template <typename T>
7294 class Visitor : public VisitorBase {
7295 protected:
7296 
7300  void raw_visit_node(Node &node, void *retval) override;
7301 
7305  void raw_visit_add(Add &node, void *retval) override;
7306 
7310  void raw_visit_annotated(Annotated &node, void *retval) override;
7311 
7315  void raw_visit_annotation_data(AnnotationData &node, void *retval) override;
7316 
7320  void raw_visit_arith_op(ArithOp &node, void *retval) override;
7321 
7325  void raw_visit_assignment(Assignment &node, void *retval) override;
7326 
7330  void raw_visit_binary_op(BinaryOp &node, void *retval) override;
7331 
7335  void raw_visit_bitwise_and(BitwiseAnd &node, void *retval) override;
7336 
7340  void raw_visit_bitwise_not(BitwiseNot &node, void *retval) override;
7341 
7345  void raw_visit_bitwise_op(BitwiseOp &node, void *retval) override;
7346 
7350  void raw_visit_bitwise_or(BitwiseOr &node, void *retval) override;
7351 
7355  void raw_visit_bitwise_xor(BitwiseXor &node, void *retval) override;
7356 
7360  void raw_visit_break_statement(BreakStatement &node, void *retval) override;
7361 
7365  void raw_visit_bundle(Bundle &node, void *retval) override;
7366 
7370  void raw_visit_cmp_eq(CmpEq &node, void *retval) override;
7371 
7375  void raw_visit_cmp_ge(CmpGe &node, void *retval) override;
7376 
7380  void raw_visit_cmp_gt(CmpGt &node, void *retval) override;
7381 
7385  void raw_visit_cmp_le(CmpLe &node, void *retval) override;
7386 
7390  void raw_visit_cmp_lt(CmpLt &node, void *retval) override;
7391 
7395  void raw_visit_cmp_ne(CmpNe &node, void *retval) override;
7396 
7400  void raw_visit_cmp_op(CmpOp &node, void *retval) override;
7401 
7405  void raw_visit_continue_statement(ContinueStatement &node, void *retval) override;
7406 
7410  void raw_visit_divide(Divide &node, void *retval) override;
7411 
7415  void raw_visit_erroneous_expression(ErroneousExpression &node, void *retval) override;
7416 
7420  void raw_visit_erroneous_program(ErroneousProgram &node, void *retval) override;
7421 
7425  void raw_visit_erroneous_statement(ErroneousStatement &node, void *retval) override;
7426 
7430  void raw_visit_expression(Expression &node, void *retval) override;
7431 
7435  void raw_visit_expression_list(ExpressionList &node, void *retval) override;
7436 
7440  void raw_visit_float_literal(FloatLiteral &node, void *retval) override;
7441 
7445  void raw_visit_for_loop(ForLoop &node, void *retval) override;
7446 
7450  void raw_visit_foreach_loop(ForeachLoop &node, void *retval) override;
7451 
7455  void raw_visit_function_call(FunctionCall &node, void *retval) override;
7456 
7460  void raw_visit_identifier(Identifier &node, void *retval) override;
7461 
7465  void raw_visit_if_else(IfElse &node, void *retval) override;
7466 
7470  void raw_visit_if_else_branch(IfElseBranch &node, void *retval) override;
7471 
7475  void raw_visit_index(Index &node, void *retval) override;
7476 
7480  void raw_visit_index_entry(IndexEntry &node, void *retval) override;
7481 
7485  void raw_visit_index_item(IndexItem &node, void *retval) override;
7486 
7490  void raw_visit_index_list(IndexList &node, void *retval) override;
7491 
7495  void raw_visit_index_range(IndexRange &node, void *retval) override;
7496 
7500  void raw_visit_instruction(Instruction &node, void *retval) override;
7501 
7505  void raw_visit_int_divide(IntDivide &node, void *retval) override;
7506 
7510  void raw_visit_integer_literal(IntegerLiteral &node, void *retval) override;
7511 
7515  void raw_visit_json_literal(JsonLiteral &node, void *retval) override;
7516 
7520  void raw_visit_logical_and(LogicalAnd &node, void *retval) override;
7521 
7525  void raw_visit_logical_not(LogicalNot &node, void *retval) override;
7526 
7530  void raw_visit_logical_op(LogicalOp &node, void *retval) override;
7531 
7535  void raw_visit_logical_or(LogicalOr &node, void *retval) override;
7536 
7540  void raw_visit_logical_xor(LogicalXor &node, void *retval) override;
7541 
7545  void raw_visit_mapping(Mapping &node, void *retval) override;
7546 
7550  void raw_visit_matrix_literal(MatrixLiteral &node, void *retval) override;
7551 
7555  void raw_visit_modulo(Modulo &node, void *retval) override;
7556 
7560  void raw_visit_multiply(Multiply &node, void *retval) override;
7561 
7565  void raw_visit_negate(Negate &node, void *retval) override;
7566 
7570  void raw_visit_power(Power &node, void *retval) override;
7571 
7575  void raw_visit_program(Program &node, void *retval) override;
7576 
7580  void raw_visit_repeat_until_loop(RepeatUntilLoop &node, void *retval) override;
7581 
7585  void raw_visit_root(Root &node, void *retval) override;
7586 
7590  void raw_visit_shift_left(ShiftLeft &node, void *retval) override;
7591 
7595  void raw_visit_shift_op(ShiftOp &node, void *retval) override;
7596 
7600  void raw_visit_shift_right_arith(ShiftRightArith &node, void *retval) override;
7601 
7605  void raw_visit_shift_right_logic(ShiftRightLogic &node, void *retval) override;
7606 
7610  void raw_visit_statement(Statement &node, void *retval) override;
7611 
7615  void raw_visit_statement_list(StatementList &node, void *retval) override;
7616 
7620  void raw_visit_string_literal(StringLiteral &node, void *retval) override;
7621 
7625  void raw_visit_structured(Structured &node, void *retval) override;
7626 
7630  void raw_visit_subcircuit(Subcircuit &node, void *retval) override;
7631 
7635  void raw_visit_subtract(Subtract &node, void *retval) override;
7636 
7640  void raw_visit_ternary_cond(TernaryCond &node, void *retval) override;
7641 
7645  void raw_visit_unary_op(UnaryOp &node, void *retval) override;
7646 
7650  void raw_visit_variables(Variables &node, void *retval) override;
7651 
7655  void raw_visit_version(Version &node, void *retval) override;
7656 
7660  void raw_visit_while_loop(WhileLoop &node, void *retval) override;
7661 
7662 public:
7663 
7667  virtual T visit_node(Node &node) = 0;
7668 
7672  virtual T visit_add(Add &node) {
7673  return visit_arith_op(node);
7674  }
7675 
7679  virtual T visit_annotated(Annotated &node) {
7680  return visit_node(node);
7681  }
7682 
7687  return visit_node(node);
7688  }
7689 
7693  virtual T visit_arith_op(ArithOp &node) {
7694  return visit_binary_op(node);
7695  }
7696 
7700  virtual T visit_assignment(Assignment &node) {
7701  return visit_node(node);
7702  }
7703 
7707  virtual T visit_binary_op(BinaryOp &node) {
7708  return visit_expression(node);
7709  }
7710 
7714  virtual T visit_bitwise_and(BitwiseAnd &node) {
7715  return visit_bitwise_op(node);
7716  }
7717 
7721  virtual T visit_bitwise_not(BitwiseNot &node) {
7722  return visit_unary_op(node);
7723  }
7724 
7728  virtual T visit_bitwise_op(BitwiseOp &node) {
7729  return visit_binary_op(node);
7730  }
7731 
7735  virtual T visit_bitwise_or(BitwiseOr &node) {
7736  return visit_bitwise_op(node);
7737  }
7738 
7742  virtual T visit_bitwise_xor(BitwiseXor &node) {
7743  return visit_bitwise_op(node);
7744  }
7745 
7750  return visit_structured(node);
7751  }
7752 
7756  virtual T visit_bundle(Bundle &node) {
7757  return visit_statement(node);
7758  }
7759 
7763  virtual T visit_cmp_eq(CmpEq &node) {
7764  return visit_cmp_op(node);
7765  }
7766 
7770  virtual T visit_cmp_ge(CmpGe &node) {
7771  return visit_cmp_op(node);
7772  }
7773 
7777  virtual T visit_cmp_gt(CmpGt &node) {
7778  return visit_cmp_op(node);
7779  }
7780 
7784  virtual T visit_cmp_le(CmpLe &node) {
7785  return visit_cmp_op(node);
7786  }
7787 
7791  virtual T visit_cmp_lt(CmpLt &node) {
7792  return visit_cmp_op(node);
7793  }
7794 
7798  virtual T visit_cmp_ne(CmpNe &node) {
7799  return visit_cmp_op(node);
7800  }
7801 
7805  virtual T visit_cmp_op(CmpOp &node) {
7806  return visit_binary_op(node);
7807  }
7808 
7813  return visit_structured(node);
7814  }
7815 
7819  virtual T visit_divide(Divide &node) {
7820  return visit_arith_op(node);
7821  }
7822 
7827  return visit_expression(node);
7828  }
7829 
7834  return visit_root(node);
7835  }
7836 
7841  return visit_statement(node);
7842  }
7843 
7847  virtual T visit_expression(Expression &node) {
7848  return visit_node(node);
7849  }
7850 
7855  return visit_node(node);
7856  }
7857 
7862  return visit_expression(node);
7863  }
7864 
7868  virtual T visit_for_loop(ForLoop &node) {
7869  return visit_structured(node);
7870  }
7871 
7875  virtual T visit_foreach_loop(ForeachLoop &node) {
7876  return visit_structured(node);
7877  }
7878 
7883  return visit_expression(node);
7884  }
7885 
7889  virtual T visit_identifier(Identifier &node) {
7890  return visit_expression(node);
7891  }
7892 
7896  virtual T visit_if_else(IfElse &node) {
7897  return visit_structured(node);
7898  }
7899 
7904  return visit_node(node);
7905  }
7906 
7910  virtual T visit_index(Index &node) {
7911  return visit_expression(node);
7912  }
7913 
7917  virtual T visit_index_entry(IndexEntry &node) {
7918  return visit_node(node);
7919  }
7920 
7924  virtual T visit_index_item(IndexItem &node) {
7925  return visit_index_entry(node);
7926  }
7927 
7931  virtual T visit_index_list(IndexList &node) {
7932  return visit_node(node);
7933  }
7934 
7938  virtual T visit_index_range(IndexRange &node) {
7939  return visit_index_entry(node);
7940  }
7941 
7945  virtual T visit_instruction(Instruction &node) {
7946  return visit_annotated(node);
7947  }
7948 
7952  virtual T visit_int_divide(IntDivide &node) {
7953  return visit_arith_op(node);
7954  }
7955 
7960  return visit_expression(node);
7961  }
7962 
7966  virtual T visit_json_literal(JsonLiteral &node) {
7967  return visit_expression(node);
7968  }
7969 
7973  virtual T visit_logical_and(LogicalAnd &node) {
7974  return visit_logical_op(node);
7975  }
7976 
7980  virtual T visit_logical_not(LogicalNot &node) {
7981  return visit_unary_op(node);
7982  }
7983 
7987  virtual T visit_logical_op(LogicalOp &node) {
7988  return visit_binary_op(node);
7989  }
7990 
7994  virtual T visit_logical_or(LogicalOr &node) {
7995  return visit_logical_op(node);
7996  }
7997 
8001  virtual T visit_logical_xor(LogicalXor &node) {
8002  return visit_logical_op(node);
8003  }
8004 
8008  virtual T visit_mapping(Mapping &node) {
8009  return visit_statement(node);
8010  }
8011 
8016  return visit_expression(node);
8017  }
8018 
8022  virtual T visit_modulo(Modulo &node) {
8023  return visit_arith_op(node);
8024  }
8025 
8029  virtual T visit_multiply(Multiply &node) {
8030  return visit_arith_op(node);
8031  }
8032 
8036  virtual T visit_negate(Negate &node) {
8037  return visit_unary_op(node);
8038  }
8039 
8043  virtual T visit_power(Power &node) {
8044  return visit_arith_op(node);
8045  }
8046 
8050  virtual T visit_program(Program &node) {
8051  return visit_root(node);
8052  }
8053 
8058  return visit_structured(node);
8059  }
8060 
8064  virtual T visit_root(Root &node) {
8065  return visit_node(node);
8066  }
8067 
8071  virtual T visit_shift_left(ShiftLeft &node) {
8072  return visit_shift_op(node);
8073  }
8074 
8078  virtual T visit_shift_op(ShiftOp &node) {
8079  return visit_binary_op(node);
8080  }
8081 
8086  return visit_shift_op(node);
8087  }
8088 
8093  return visit_shift_op(node);
8094  }
8095 
8099  virtual T visit_statement(Statement &node) {
8100  return visit_annotated(node);
8101  }
8102 
8107  return visit_node(node);
8108  }
8109 
8114  return visit_expression(node);
8115  }
8116 
8120  virtual T visit_structured(Structured &node) {
8121  return visit_statement(node);
8122  }
8123 
8127  virtual T visit_subcircuit(Subcircuit &node) {
8128  return visit_statement(node);
8129  }
8130 
8134  virtual T visit_subtract(Subtract &node) {
8135  return visit_arith_op(node);
8136  }
8137 
8141  virtual T visit_ternary_cond(TernaryCond &node) {
8142  return visit_expression(node);
8143  }
8144 
8148  virtual T visit_unary_op(UnaryOp &node) {
8149  return visit_expression(node);
8150  }
8151 
8155  virtual T visit_variables(Variables &node) {
8156  return visit_statement(node);
8157  }
8158 
8162  virtual T visit_version(Version &node) {
8163  return visit_node(node);
8164  }
8165 
8169  virtual T visit_while_loop(WhileLoop &node) {
8170  return visit_structured(node);
8171  }
8172 
8173 };
8174 
8178  template <typename T>
8179  void Visitor<T>::raw_visit_node(Node &node, void *retval) {
8180  if (retval == nullptr) {
8181  this->visit_node(node);
8182  } else {
8183  *((T*)retval) = this->visit_node(node);
8184  };
8185  }
8186 
8190  template <>
8191  void Visitor<void>::raw_visit_node(Node &node, void *retval);
8192 
8196  template <typename T>
8197  void Visitor<T>::raw_visit_add(Add &node, void *retval) {
8198  if (retval == nullptr) {
8199  this->visit_add(node);
8200  } else {
8201  *((T*)retval) = this->visit_add(node);
8202  };
8203  }
8204 
8208  template <>
8209  void Visitor<void>::raw_visit_add(Add &node, void *retval);
8210 
8214  template <typename T>
8215  void Visitor<T>::raw_visit_annotated(Annotated &node, void *retval) {
8216  if (retval == nullptr) {
8217  this->visit_annotated(node);
8218  } else {
8219  *((T*)retval) = this->visit_annotated(node);
8220  };
8221  }
8222 
8226  template <>
8227  void Visitor<void>::raw_visit_annotated(Annotated &node, void *retval);
8228 
8232  template <typename T>
8234  if (retval == nullptr) {
8235  this->visit_annotation_data(node);
8236  } else {
8237  *((T*)retval) = this->visit_annotation_data(node);
8238  };
8239  }
8240 
8244  template <>
8245  void Visitor<void>::raw_visit_annotation_data(AnnotationData &node, void *retval);
8246 
8250  template <typename T>
8251  void Visitor<T>::raw_visit_arith_op(ArithOp &node, void *retval) {
8252  if (retval == nullptr) {
8253  this->visit_arith_op(node);
8254  } else {
8255  *((T*)retval) = this->visit_arith_op(node);
8256  };
8257  }
8258 
8262  template <>
8263  void Visitor<void>::raw_visit_arith_op(ArithOp &node, void *retval);
8264 
8268  template <typename T>
8269  void Visitor<T>::raw_visit_assignment(Assignment &node, void *retval) {
8270  if (retval == nullptr) {
8271  this->visit_assignment(node);
8272  } else {
8273  *((T*)retval) = this->visit_assignment(node);
8274  };
8275  }
8276 
8280  template <>
8281  void Visitor<void>::raw_visit_assignment(Assignment &node, void *retval);
8282 
8286  template <typename T>
8287  void Visitor<T>::raw_visit_binary_op(BinaryOp &node, void *retval) {
8288  if (retval == nullptr) {
8289  this->visit_binary_op(node);
8290  } else {
8291  *((T*)retval) = this->visit_binary_op(node);
8292  };
8293  }
8294 
8298  template <>
8299  void Visitor<void>::raw_visit_binary_op(BinaryOp &node, void *retval);
8300 
8304  template <typename T>
8305  void Visitor<T>::raw_visit_bitwise_and(BitwiseAnd &node, void *retval) {
8306  if (retval == nullptr) {
8307  this->visit_bitwise_and(node);
8308  } else {
8309  *((T*)retval) = this->visit_bitwise_and(node);
8310  };
8311  }
8312 
8316  template <>
8317  void Visitor<void>::raw_visit_bitwise_and(BitwiseAnd &node, void *retval);
8318 
8322  template <typename T>
8323  void Visitor<T>::raw_visit_bitwise_not(BitwiseNot &node, void *retval) {
8324  if (retval == nullptr) {
8325  this->visit_bitwise_not(node);
8326  } else {
8327  *((T*)retval) = this->visit_bitwise_not(node);
8328  };
8329  }
8330 
8334  template <>
8335  void Visitor<void>::raw_visit_bitwise_not(BitwiseNot &node, void *retval);
8336 
8340  template <typename T>
8341  void Visitor<T>::raw_visit_bitwise_op(BitwiseOp &node, void *retval) {
8342  if (retval == nullptr) {
8343  this->visit_bitwise_op(node);
8344  } else {
8345  *((T*)retval) = this->visit_bitwise_op(node);
8346  };
8347  }
8348 
8352  template <>
8353  void Visitor<void>::raw_visit_bitwise_op(BitwiseOp &node, void *retval);
8354 
8358  template <typename T>
8359  void Visitor<T>::raw_visit_bitwise_or(BitwiseOr &node, void *retval) {
8360  if (retval == nullptr) {
8361  this->visit_bitwise_or(node);
8362  } else {
8363  *((T*)retval) = this->visit_bitwise_or(node);
8364  };
8365  }
8366 
8370  template <>
8371  void Visitor<void>::raw_visit_bitwise_or(BitwiseOr &node, void *retval);
8372 
8376  template <typename T>
8377  void Visitor<T>::raw_visit_bitwise_xor(BitwiseXor &node, void *retval) {
8378  if (retval == nullptr) {
8379  this->visit_bitwise_xor(node);
8380  } else {
8381  *((T*)retval) = this->visit_bitwise_xor(node);
8382  };
8383  }
8384 
8388  template <>
8389  void Visitor<void>::raw_visit_bitwise_xor(BitwiseXor &node, void *retval);
8390 
8394  template <typename T>
8396  if (retval == nullptr) {
8397  this->visit_break_statement(node);
8398  } else {
8399  *((T*)retval) = this->visit_break_statement(node);
8400  };
8401  }
8402 
8406  template <>
8407  void Visitor<void>::raw_visit_break_statement(BreakStatement &node, void *retval);
8408 
8412  template <typename T>
8413  void Visitor<T>::raw_visit_bundle(Bundle &node, void *retval) {
8414  if (retval == nullptr) {
8415  this->visit_bundle(node);
8416  } else {
8417  *((T*)retval) = this->visit_bundle(node);
8418  };
8419  }
8420 
8424  template <>
8425  void Visitor<void>::raw_visit_bundle(Bundle &node, void *retval);
8426 
8430  template <typename T>
8431  void Visitor<T>::raw_visit_cmp_eq(CmpEq &node, void *retval) {
8432  if (retval == nullptr) {
8433  this->visit_cmp_eq(node);
8434  } else {
8435  *((T*)retval) = this->visit_cmp_eq(node);
8436  };
8437  }
8438 
8442  template <>
8443  void Visitor<void>::raw_visit_cmp_eq(CmpEq &node, void *retval);
8444 
8448  template <typename T>
8449  void Visitor<T>::raw_visit_cmp_ge(CmpGe &node, void *retval) {
8450  if (retval == nullptr) {
8451  this->visit_cmp_ge(node);
8452  } else {
8453  *((T*)retval) = this->visit_cmp_ge(node);
8454  };
8455  }
8456 
8460  template <>
8461  void Visitor<void>::raw_visit_cmp_ge(CmpGe &node, void *retval);
8462 
8466  template <typename T>
8467  void Visitor<T>::raw_visit_cmp_gt(CmpGt &node, void *retval) {
8468  if (retval == nullptr) {
8469  this->visit_cmp_gt(node);
8470  } else {
8471  *((T*)retval) = this->visit_cmp_gt(node);
8472  };
8473  }
8474 
8478  template <>
8479  void Visitor<void>::raw_visit_cmp_gt(CmpGt &node, void *retval);
8480 
8484  template <typename T>
8485  void Visitor<T>::raw_visit_cmp_le(CmpLe &node, void *retval) {
8486  if (retval == nullptr) {
8487  this->visit_cmp_le(node);
8488  } else {
8489  *((T*)retval) = this->visit_cmp_le(node);
8490  };
8491  }
8492 
8496  template <>
8497  void Visitor<void>::raw_visit_cmp_le(CmpLe &node, void *retval);
8498 
8502  template <typename T>
8503  void Visitor<T>::raw_visit_cmp_lt(CmpLt &node, void *retval) {
8504  if (retval == nullptr) {
8505  this->visit_cmp_lt(node);
8506  } else {
8507  *((T*)retval) = this->visit_cmp_lt(node);
8508  };
8509  }
8510 
8514  template <>
8515  void Visitor<void>::raw_visit_cmp_lt(CmpLt &node, void *retval);
8516 
8520  template <typename T>
8521  void Visitor<T>::raw_visit_cmp_ne(CmpNe &node, void *retval) {
8522  if (retval == nullptr) {
8523  this->visit_cmp_ne(node);
8524  } else {
8525  *((T*)retval) = this->visit_cmp_ne(node);
8526  };
8527  }
8528 
8532  template <>
8533  void Visitor<void>::raw_visit_cmp_ne(CmpNe &node, void *retval);
8534 
8538  template <typename T>
8539  void Visitor<T>::raw_visit_cmp_op(CmpOp &node, void *retval) {
8540  if (retval == nullptr) {
8541  this->visit_cmp_op(node);
8542  } else {
8543  *((T*)retval) = this->visit_cmp_op(node);
8544  };
8545  }
8546 
8550  template <>
8551  void Visitor<void>::raw_visit_cmp_op(CmpOp &node, void *retval);
8552 
8556  template <typename T>
8558  if (retval == nullptr) {
8559  this->visit_continue_statement(node);
8560  } else {
8561  *((T*)retval) = this->visit_continue_statement(node);
8562  };
8563  }
8564 
8568  template <>
8570 
8574  template <typename T>
8575  void Visitor<T>::raw_visit_divide(Divide &node, void *retval) {
8576  if (retval == nullptr) {
8577  this->visit_divide(node);
8578  } else {
8579  *((T*)retval) = this->visit_divide(node);
8580  };
8581  }
8582 
8586  template <>
8587  void Visitor<void>::raw_visit_divide(Divide &node, void *retval);
8588 
8592  template <typename T>
8594  if (retval == nullptr) {
8595  this->visit_erroneous_expression(node);
8596  } else {
8597  *((T*)retval) = this->visit_erroneous_expression(node);
8598  };
8599  }
8600 
8604  template <>
8606 
8610  template <typename T>
8612  if (retval == nullptr) {
8613  this->visit_erroneous_program(node);
8614  } else {
8615  *((T*)retval) = this->visit_erroneous_program(node);
8616  };
8617  }
8618 
8622  template <>
8624 
8628  template <typename T>
8630  if (retval == nullptr) {
8631  this->visit_erroneous_statement(node);
8632  } else {
8633  *((T*)retval) = this->visit_erroneous_statement(node);
8634  };
8635  }
8636 
8640  template <>
8642 
8646  template <typename T>
8647  void Visitor<T>::raw_visit_expression(Expression &node, void *retval) {
8648  if (retval == nullptr) {
8649  this->visit_expression(node);
8650  } else {
8651  *((T*)retval) = this->visit_expression(node);
8652  };
8653  }
8654 
8658  template <>
8659  void Visitor<void>::raw_visit_expression(Expression &node, void *retval);
8660 
8664  template <typename T>
8666  if (retval == nullptr) {
8667  this->visit_expression_list(node);
8668  } else {
8669  *((T*)retval) = this->visit_expression_list(node);
8670  };
8671  }
8672 
8676  template <>
8677  void Visitor<void>::raw_visit_expression_list(ExpressionList &node, void *retval);
8678 
8682  template <typename T>
8684  if (retval == nullptr) {
8685  this->visit_float_literal(node);
8686  } else {
8687  *((T*)retval) = this->visit_float_literal(node);
8688  };
8689  }
8690 
8694  template <>
8695  void Visitor<void>::raw_visit_float_literal(FloatLiteral &node, void *retval);
8696 
8700  template <typename T>
8701  void Visitor<T>::raw_visit_for_loop(ForLoop &node, void *retval) {
8702  if (retval == nullptr) {
8703  this->visit_for_loop(node);
8704  } else {
8705  *((T*)retval) = this->visit_for_loop(node);
8706  };
8707  }
8708 
8712  template <>
8713  void Visitor<void>::raw_visit_for_loop(ForLoop &node, void *retval);
8714 
8718  template <typename T>
8720  if (retval == nullptr) {
8721  this->visit_foreach_loop(node);
8722  } else {
8723  *((T*)retval) = this->visit_foreach_loop(node);
8724  };
8725  }
8726 
8730  template <>
8731  void Visitor<void>::raw_visit_foreach_loop(ForeachLoop &node, void *retval);
8732 
8736  template <typename T>
8738  if (retval == nullptr) {
8739  this->visit_function_call(node);
8740  } else {
8741  *((T*)retval) = this->visit_function_call(node);
8742  };
8743  }
8744 
8748  template <>
8749  void Visitor<void>::raw_visit_function_call(FunctionCall &node, void *retval);
8750 
8754  template <typename T>
8755  void Visitor<T>::raw_visit_identifier(Identifier &node, void *retval) {
8756  if (retval == nullptr) {
8757  this->visit_identifier(node);
8758  } else {
8759  *((T*)retval) = this->visit_identifier(node);
8760  };
8761  }
8762 
8766  template <>
8767  void Visitor<void>::raw_visit_identifier(Identifier &node, void *retval);
8768 
8772  template <typename T>
8773  void Visitor<T>::raw_visit_if_else(IfElse &node, void *retval) {
8774  if (retval == nullptr) {
8775  this->visit_if_else(node);
8776  } else {
8777  *((T*)retval) = this->visit_if_else(node);
8778  };
8779  }
8780 
8784  template <>
8785  void Visitor<void>::raw_visit_if_else(IfElse &node, void *retval);
8786 
8790  template <typename T>
8792  if (retval == nullptr) {
8793  this->visit_if_else_branch(node);
8794  } else {
8795  *((T*)retval) = this->visit_if_else_branch(node);
8796  };
8797  }
8798 
8802  template <>
8803  void Visitor<void>::raw_visit_if_else_branch(IfElseBranch &node, void *retval);
8804 
8808  template <typename T>
8809  void Visitor<T>::raw_visit_index(Index &node, void *retval) {
8810  if (retval == nullptr) {
8811  this->visit_index(node);
8812  } else {
8813  *((T*)retval) = this->visit_index(node);
8814  };
8815  }
8816 
8820  template <>
8821  void Visitor<void>::raw_visit_index(Index &node, void *retval);
8822 
8826  template <typename T>
8827  void Visitor<T>::raw_visit_index_entry(IndexEntry &node, void *retval) {
8828  if (retval == nullptr) {
8829  this->visit_index_entry(node);
8830  } else {
8831  *((T*)retval) = this->visit_index_entry(node);
8832  };
8833  }
8834 
8838  template <>
8839  void Visitor<void>::raw_visit_index_entry(IndexEntry &node, void *retval);
8840 
8844  template <typename T>
8845  void Visitor<T>::raw_visit_index_item(IndexItem &node, void *retval) {
8846  if (retval == nullptr) {
8847  this->visit_index_item(node);
8848  } else {
8849  *((T*)retval) = this->visit_index_item(node);
8850  };
8851  }
8852 
8856  template <>
8857  void Visitor<void>::raw_visit_index_item(IndexItem &node, void *retval);
8858 
8862  template <typename T>
8863  void Visitor<T>::raw_visit_index_list(IndexList &node, void *retval) {
8864  if (retval == nullptr) {
8865  this->visit_index_list(node);
8866  } else {
8867  *((T*)retval) = this->visit_index_list(node);
8868  };
8869  }
8870 
8874  template <>
8875  void Visitor<void>::raw_visit_index_list(IndexList &node, void *retval);
8876 
8880  template <typename T>
8881  void Visitor<T>::raw_visit_index_range(IndexRange &node, void *retval) {
8882  if (retval == nullptr) {
8883  this->visit_index_range(node);
8884  } else {
8885  *((T*)retval) = this->visit_index_range(node);
8886  };
8887  }
8888 
8892  template <>
8893  void Visitor<void>::raw_visit_index_range(IndexRange &node, void *retval);
8894 
8898  template <typename T>
8900  if (retval == nullptr) {
8901  this->visit_instruction(node);
8902  } else {
8903  *((T*)retval) = this->visit_instruction(node);
8904  };
8905  }
8906 
8910  template <>
8911  void Visitor<void>::raw_visit_instruction(Instruction &node, void *retval);
8912 
8916  template <typename T>
8917  void Visitor<T>::raw_visit_int_divide(IntDivide &node, void *retval) {
8918  if (retval == nullptr) {
8919  this->visit_int_divide(node);
8920  } else {
8921  *((T*)retval) = this->visit_int_divide(node);
8922  };
8923  }
8924 
8928  template <>
8929  void Visitor<void>::raw_visit_int_divide(IntDivide &node, void *retval);
8930 
8934  template <typename T>
8936  if (retval == nullptr) {
8937  this->visit_integer_literal(node);
8938  } else {
8939  *((T*)retval) = this->visit_integer_literal(node);
8940  };
8941  }
8942 
8946  template <>
8947  void Visitor<void>::raw_visit_integer_literal(IntegerLiteral &node, void *retval);
8948 
8952  template <typename T>
8954  if (retval == nullptr) {
8955  this->visit_json_literal(node);
8956  } else {
8957  *((T*)retval) = this->visit_json_literal(node);
8958  };
8959  }
8960 
8964  template <>
8965  void Visitor<void>::raw_visit_json_literal(JsonLiteral &node, void *retval);
8966 
8970  template <typename T>
8971  void Visitor<T>::raw_visit_logical_and(LogicalAnd &node, void *retval) {
8972  if (retval == nullptr) {
8973  this->visit_logical_and(node);
8974  } else {
8975  *((T*)retval) = this->visit_logical_and(node);
8976  };
8977  }
8978 
8982  template <>
8983  void Visitor<void>::raw_visit_logical_and(LogicalAnd &node, void *retval);
8984 
8988  template <typename T>
8989  void Visitor<T>::raw_visit_logical_not(LogicalNot &node, void *retval) {
8990  if (retval == nullptr) {
8991  this->visit_logical_not(node);
8992  } else {
8993  *((T*)retval) = this->visit_logical_not(node);
8994  };
8995  }
8996 
9000  template <>
9001  void Visitor<void>::raw_visit_logical_not(LogicalNot &node, void *retval);
9002 
9006  template <typename T>
9007  void Visitor<T>::raw_visit_logical_op(LogicalOp &node, void *retval) {
9008  if (retval == nullptr) {
9009  this->visit_logical_op(node);
9010  } else {
9011  *((T*)retval) = this->visit_logical_op(node);
9012  };
9013  }
9014 
9018  template <>
9019  void Visitor<void>::raw_visit_logical_op(LogicalOp &node, void *retval);
9020 
9024  template <typename T>
9025  void Visitor<T>::raw_visit_logical_or(LogicalOr &node, void *retval) {
9026  if (retval == nullptr) {
9027  this->visit_logical_or(node);
9028  } else {
9029  *((T*)retval) = this->visit_logical_or(node);
9030  };
9031  }
9032 
9036  template <>
9037  void Visitor<void>::raw_visit_logical_or(LogicalOr &node, void *retval);
9038 
9042  template <typename T>
9043  void Visitor<T>::raw_visit_logical_xor(LogicalXor &node, void *retval) {
9044  if (retval == nullptr) {
9045  this->visit_logical_xor(node);
9046  } else {
9047  *((T*)retval) = this->visit_logical_xor(node);
9048  };
9049  }
9050 
9054  template <>
9055  void Visitor<void>::raw_visit_logical_xor(LogicalXor &node, void *retval);
9056 
9060  template <typename T>
9061  void Visitor<T>::raw_visit_mapping(Mapping &node, void *retval) {
9062  if (retval == nullptr) {
9063  this->visit_mapping(node);
9064  } else {
9065  *((T*)retval) = this->visit_mapping(node);
9066  };
9067  }
9068 
9072  template <>
9073  void Visitor<void>::raw_visit_mapping(Mapping &node, void *retval);
9074 
9078  template <typename T>
9080  if (retval == nullptr) {
9081  this->visit_matrix_literal(node);
9082  } else {
9083  *((T*)retval) = this->visit_matrix_literal(node);
9084  };
9085  }
9086 
9090  template <>
9091  void Visitor<void>::raw_visit_matrix_literal(MatrixLiteral &node, void *retval);
9092 
9096  template <typename T>
9097  void Visitor<T>::raw_visit_modulo(Modulo &node, void *retval) {
9098  if (retval == nullptr) {
9099  this->visit_modulo(node);
9100  } else {
9101  *((T*)retval) = this->visit_modulo(node);
9102  };
9103  }
9104 
9108  template <>
9109  void Visitor<void>::raw_visit_modulo(Modulo &node, void *retval);
9110 
9114  template <typename T>
9115  void Visitor<T>::raw_visit_multiply(Multiply &node, void *retval) {
9116  if (retval == nullptr) {
9117  this->visit_multiply(node);
9118  } else {
9119  *((T*)retval) = this->visit_multiply(node);
9120  };
9121  }
9122 
9126  template <>
9127  void Visitor<void>::raw_visit_multiply(Multiply &node, void *retval);
9128 
9132  template <typename T>
9133  void Visitor<T>::raw_visit_negate(Negate &node, void *retval) {
9134  if (retval == nullptr) {
9135  this->visit_negate(node);
9136  } else {
9137  *((T*)retval) = this->visit_negate(node);
9138  };
9139  }
9140 
9144  template <>
9145  void Visitor<void>::raw_visit_negate(Negate &node, void *retval);
9146 
9150  template <typename T>
9151  void Visitor<T>::raw_visit_power(Power &node, void *retval) {
9152  if (retval == nullptr) {
9153  this->visit_power(node);
9154  } else {
9155  *((T*)retval) = this->visit_power(node);
9156  };
9157  }
9158 
9162  template <>
9163  void Visitor<void>::raw_visit_power(Power &node, void *retval);
9164 
9168  template <typename T>
9169  void Visitor<T>::raw_visit_program(Program &node, void *retval) {
9170  if (retval == nullptr) {
9171  this->visit_program(node);
9172  } else {
9173  *((T*)retval) = this->visit_program(node);
9174  };
9175  }
9176 
9180  template <>
9181  void Visitor<void>::raw_visit_program(Program &node, void *retval);
9182 
9186  template <typename T>
9188  if (retval == nullptr) {
9189  this->visit_repeat_until_loop(node);
9190  } else {
9191  *((T*)retval) = this->visit_repeat_until_loop(node);
9192  };
9193  }
9194 
9198  template <>
9200 
9204  template <typename T>
9205  void Visitor<T>::raw_visit_root(Root &node, void *retval) {
9206  if (retval == nullptr) {
9207  this->visit_root(node);
9208  } else {
9209  *((T*)retval) = this->visit_root(node);
9210  };
9211  }
9212 
9216  template <>
9217  void Visitor<void>::raw_visit_root(Root &node, void *retval);
9218 
9222  template <typename T>
9223  void Visitor<T>::raw_visit_shift_left(ShiftLeft &node, void *retval) {
9224  if (retval == nullptr) {
9225  this->visit_shift_left(node);
9226  } else {
9227  *((T*)retval) = this->visit_shift_left(node);
9228  };
9229  }
9230 
9234  template <>
9235  void Visitor<void>::raw_visit_shift_left(ShiftLeft &node, void *retval);
9236 
9240  template <typename T>
9241  void Visitor<T>::raw_visit_shift_op(ShiftOp &node, void *retval) {
9242  if (retval == nullptr) {
9243  this->visit_shift_op(node);
9244  } else {
9245  *((T*)retval) = this->visit_shift_op(node);
9246  };
9247  }
9248 
9252  template <>
9253  void Visitor<void>::raw_visit_shift_op(ShiftOp &node, void *retval);
9254 
9258  template <typename T>
9260  if (retval == nullptr) {
9261  this->visit_shift_right_arith(node);
9262  } else {
9263  *((T*)retval) = this->visit_shift_right_arith(node);
9264  };
9265  }
9266 
9270  template <>
9272 
9276  template <typename T>
9278  if (retval == nullptr) {
9279  this->visit_shift_right_logic(node);
9280  } else {
9281  *((T*)retval) = this->visit_shift_right_logic(node);
9282  };
9283  }
9284 
9288  template <>
9290 
9294  template <typename T>
9295  void Visitor<T>::raw_visit_statement(Statement &node, void *retval) {
9296  if (retval == nullptr) {
9297  this->visit_statement(node);
9298  } else {
9299  *((T*)retval) = this->visit_statement(node);
9300  };
9301  }
9302 
9306  template <>
9307  void Visitor<void>::raw_visit_statement(Statement &node, void *retval);
9308 
9312  template <typename T>
9314  if (retval == nullptr) {
9315  this->visit_statement_list(node);
9316  } else {
9317  *((T*)retval) = this->visit_statement_list(node);
9318  };
9319  }
9320 
9324  template <>
9325  void Visitor<void>::raw_visit_statement_list(StatementList &node, void *retval);
9326 
9330  template <typename T>
9332  if (retval == nullptr) {
9333  this->visit_string_literal(node);
9334  } else {
9335  *((T*)retval) = this->visit_string_literal(node);
9336  };
9337  }
9338 
9342  template <>
9343  void Visitor<void>::raw_visit_string_literal(StringLiteral &node, void *retval);
9344 
9348  template <typename T>
9349  void Visitor<T>::raw_visit_structured(Structured &node, void *retval) {
9350  if (retval == nullptr) {
9351  this->visit_structured(node);
9352  } else {
9353  *((T*)retval) = this->visit_structured(node);
9354  };
9355  }
9356 
9360  template <>
9361  void Visitor<void>::raw_visit_structured(Structured &node, void *retval);
9362 
9366  template <typename T>
9367  void Visitor<T>::raw_visit_subcircuit(Subcircuit &node, void *retval) {
9368  if (retval == nullptr) {
9369  this->visit_subcircuit(node);
9370  } else {
9371  *((T*)retval) = this->visit_subcircuit(node);
9372  };
9373  }
9374 
9378  template <>
9379  void Visitor<void>::raw_visit_subcircuit(Subcircuit &node, void *retval);
9380 
9384  template <typename T>
9385  void Visitor<T>::raw_visit_subtract(Subtract &node, void *retval) {
9386  if (retval == nullptr) {
9387  this->visit_subtract(node);
9388  } else {
9389  *((T*)retval) = this->visit_subtract(node);
9390  };
9391  }
9392 
9396  template <>
9397  void Visitor<void>::raw_visit_subtract(Subtract &node, void *retval);
9398 
9402  template <typename T>
9404  if (retval == nullptr) {
9405  this->visit_ternary_cond(node);
9406  } else {
9407  *((T*)retval) = this->visit_ternary_cond(node);
9408  };
9409  }
9410 
9414  template <>
9415  void Visitor<void>::raw_visit_ternary_cond(TernaryCond &node, void *retval);
9416 
9420  template <typename T>
9421  void Visitor<T>::raw_visit_unary_op(UnaryOp &node, void *retval) {
9422  if (retval == nullptr) {
9423  this->visit_unary_op(node);
9424  } else {
9425  *((T*)retval) = this->visit_unary_op(node);
9426  };
9427  }
9428 
9432  template <>
9433  void Visitor<void>::raw_visit_unary_op(UnaryOp &node, void *retval);
9434 
9438  template <typename T>
9439  void Visitor<T>::raw_visit_variables(Variables &node, void *retval) {
9440  if (retval == nullptr) {
9441  this->visit_variables(node);
9442  } else {
9443  *((T*)retval) = this->visit_variables(node);
9444  };
9445  }
9446 
9450  template <>
9451  void Visitor<void>::raw_visit_variables(Variables &node, void *retval);
9452 
9456  template <typename T>
9457  void Visitor<T>::raw_visit_version(Version &node, void *retval) {
9458  if (retval == nullptr) {
9459  this->visit_version(node);
9460  } else {
9461  *((T*)retval) = this->visit_version(node);
9462  };
9463  }
9464 
9468  template <>
9469  void Visitor<void>::raw_visit_version(Version &node, void *retval);
9470 
9474  template <typename T>
9475  void Visitor<T>::raw_visit_while_loop(WhileLoop &node, void *retval) {
9476  if (retval == nullptr) {
9477  this->visit_while_loop(node);
9478  } else {
9479  *((T*)retval) = this->visit_while_loop(node);
9480  };
9481  }
9482 
9486  template <>
9487  void Visitor<void>::raw_visit_while_loop(WhileLoop &node, void *retval);
9488 
9496 class RecursiveVisitor : public Visitor<void> {
9497 public:
9498 
9502  void visit_add(Add &node) override;
9503 
9507  void visit_annotated(Annotated &node) override;
9508 
9512  void visit_annotation_data(AnnotationData &node) override;
9513 
9517  void visit_arith_op(ArithOp &node) override;
9518 
9522  void visit_assignment(Assignment &node) override;
9523 
9527  void visit_binary_op(BinaryOp &node) override;
9528 
9532  void visit_bitwise_and(BitwiseAnd &node) override;
9533 
9537  void visit_bitwise_not(BitwiseNot &node) override;
9538 
9542  void visit_bitwise_op(BitwiseOp &node) override;
9543 
9547  void visit_bitwise_or(BitwiseOr &node) override;
9548 
9552  void visit_bitwise_xor(BitwiseXor &node) override;
9553 
9557  void visit_break_statement(BreakStatement &node) override;
9558 
9562  void visit_bundle(Bundle &node) override;
9563 
9567  void visit_cmp_eq(CmpEq &node) override;
9568 
9572  void visit_cmp_ge(CmpGe &node) override;
9573 
9577  void visit_cmp_gt(CmpGt &node) override;
9578 
9582  void visit_cmp_le(CmpLe &node) override;
9583 
9587  void visit_cmp_lt(CmpLt &node) override;
9588 
9592  void visit_cmp_ne(CmpNe &node) override;
9593 
9597  void visit_cmp_op(CmpOp &node) override;
9598 
9602  void visit_continue_statement(ContinueStatement &node) override;
9603 
9607  void visit_divide(Divide &node) override;
9608 
9612  void visit_erroneous_expression(ErroneousExpression &node) override;
9613 
9617  void visit_erroneous_program(ErroneousProgram &node) override;
9618 
9622  void visit_erroneous_statement(ErroneousStatement &node) override;
9623 
9627  void visit_expression(Expression &node) override;
9628 
9632  void visit_expression_list(ExpressionList &node) override;
9633 
9637  void visit_float_literal(FloatLiteral &node) override;
9638 
9642  void visit_for_loop(ForLoop &node) override;
9643 
9647  void visit_foreach_loop(ForeachLoop &node) override;
9648 
9652  void visit_function_call(FunctionCall &node) override;
9653 
9657  void visit_identifier(Identifier &node) override;
9658 
9662  void visit_if_else(IfElse &node) override;
9663 
9667  void visit_if_else_branch(IfElseBranch &node) override;
9668 
9672  void visit_index(Index &node) override;
9673 
9677  void visit_index_entry(IndexEntry &node) override;
9678 
9682  void visit_index_item(IndexItem &node) override;
9683 
9687  void visit_index_list(IndexList &node) override;
9688 
9692  void visit_index_range(IndexRange &node) override;
9693 
9697  void visit_instruction(Instruction &node) override;
9698 
9702  void visit_int_divide(IntDivide &node) override;
9703 
9707  void visit_integer_literal(IntegerLiteral &node) override;
9708 
9712  void visit_json_literal(JsonLiteral &node) override;
9713 
9717  void visit_logical_and(LogicalAnd &node) override;
9718 
9722  void visit_logical_not(LogicalNot &node) override;
9723 
9727  void visit_logical_op(LogicalOp &node) override;
9728 
9732  void visit_logical_or(LogicalOr &node) override;
9733 
9737  void visit_logical_xor(LogicalXor &node) override;
9738 
9742  void visit_mapping(Mapping &node) override;
9743 
9747  void visit_matrix_literal(MatrixLiteral &node) override;
9748 
9752  void visit_modulo(Modulo &node) override;
9753 
9757  void visit_multiply(Multiply &node) override;
9758 
9762  void visit_negate(Negate &node) override;
9763 
9767  void visit_power(Power &node) override;
9768 
9772  void visit_program(Program &node) override;
9773 
9777  void visit_repeat_until_loop(RepeatUntilLoop &node) override;
9778 
9782  void visit_root(Root &node) override;
9783 
9787  void visit_shift_left(ShiftLeft &node) override;
9788 
9792  void visit_shift_op(ShiftOp &node) override;
9793 
9797  void visit_shift_right_arith(ShiftRightArith &node) override;
9798 
9802  void visit_shift_right_logic(ShiftRightLogic &node) override;
9803 
9807  void visit_statement(Statement &node) override;
9808 
9812  void visit_statement_list(StatementList &node) override;
9813 
9817  void visit_string_literal(StringLiteral &node) override;
9818 
9822  void visit_structured(Structured &node) override;
9823 
9827  void visit_subcircuit(Subcircuit &node) override;
9828 
9832  void visit_subtract(Subtract &node) override;
9833 
9837  void visit_ternary_cond(TernaryCond &node) override;
9838 
9842  void visit_unary_op(UnaryOp &node) override;
9843 
9847  void visit_variables(Variables &node) override;
9848 
9852  void visit_version(Version &node) override;
9853 
9857  void visit_while_loop(WhileLoop &node) override;
9858 
9859 };
9860 
9864 class Dumper : public RecursiveVisitor {
9865 protected:
9866 
9870  std::ostream &out;
9871 
9875  int indent = 0;
9876 
9880  ::tree::base::PointerMap *ids;
9884  bool in_link = false;
9885 
9889  void write_indent();
9890 
9891 public:
9892 
9896  Dumper(std::ostream &out, int indent=0, ::tree::base::PointerMap *ids = nullptr) : out(out), indent(indent), ids(ids) {};
9897 
9901  void visit_node(Node &node) override;
9905  void visit_add(Add &node) override;
9906 
9910  void visit_annotated(Annotated &node) override;
9911 
9915  void visit_annotation_data(AnnotationData &node) override;
9916 
9920  void visit_arith_op(ArithOp &node) override;
9921 
9925  void visit_assignment(Assignment &node) override;
9926 
9930  void visit_binary_op(BinaryOp &node) override;
9931 
9935  void visit_bitwise_and(BitwiseAnd &node) override;
9936 
9940  void visit_bitwise_not(BitwiseNot &node) override;
9941 
9945  void visit_bitwise_op(BitwiseOp &node) override;
9946 
9950  void visit_bitwise_or(BitwiseOr &node) override;
9951 
9955  void visit_bitwise_xor(BitwiseXor &node) override;
9956 
9960  void visit_break_statement(BreakStatement &node) override;
9961 
9965  void visit_bundle(Bundle &node) override;
9966 
9970  void visit_cmp_eq(CmpEq &node) override;
9971 
9975  void visit_cmp_ge(CmpGe &node) override;
9976 
9980  void visit_cmp_gt(CmpGt &node) override;
9981 
9985  void visit_cmp_le(CmpLe &node) override;
9986 
9990  void visit_cmp_lt(CmpLt &node) override;
9991 
9995  void visit_cmp_ne(CmpNe &node) override;
9996 
10000  void visit_cmp_op(CmpOp &node) override;
10001 
10005  void visit_continue_statement(ContinueStatement &node) override;
10006 
10010  void visit_divide(Divide &node) override;
10011 
10015  void visit_erroneous_expression(ErroneousExpression &node) override;
10016 
10020  void visit_erroneous_program(ErroneousProgram &node) override;
10021 
10025  void visit_erroneous_statement(ErroneousStatement &node) override;
10026 
10030  void visit_expression(Expression &node) override;
10031 
10035  void visit_expression_list(ExpressionList &node) override;
10036 
10040  void visit_float_literal(FloatLiteral &node) override;
10041 
10045  void visit_for_loop(ForLoop &node) override;
10046 
10050  void visit_foreach_loop(ForeachLoop &node) override;
10051 
10055  void visit_function_call(FunctionCall &node) override;
10056 
10060  void visit_identifier(Identifier &node) override;
10061 
10065  void visit_if_else(IfElse &node) override;
10066 
10070  void visit_if_else_branch(IfElseBranch &node) override;
10071 
10075  void visit_index(Index &node) override;
10076 
10080  void visit_index_entry(IndexEntry &node) override;
10081 
10085  void visit_index_item(IndexItem &node) override;
10086 
10090  void visit_index_list(IndexList &node) override;
10091 
10095  void visit_index_range(IndexRange &node) override;
10096 
10100  void visit_instruction(Instruction &node) override;
10101 
10105  void visit_int_divide(IntDivide &node) override;
10106 
10110  void visit_integer_literal(IntegerLiteral &node) override;
10111 
10115  void visit_json_literal(JsonLiteral &node) override;
10116 
10120  void visit_logical_and(LogicalAnd &node) override;
10121 
10125  void visit_logical_not(LogicalNot &node) override;
10126 
10130  void visit_logical_op(LogicalOp &node) override;
10131 
10135  void visit_logical_or(LogicalOr &node) override;
10136 
10140  void visit_logical_xor(LogicalXor &node) override;
10141 
10145  void visit_mapping(Mapping &node) override;
10146 
10150  void visit_matrix_literal(MatrixLiteral &node) override;
10151 
10155  void visit_modulo(Modulo &node) override;
10156 
10160  void visit_multiply(Multiply &node) override;
10161 
10165  void visit_negate(Negate &node) override;
10166 
10170  void visit_power(Power &node) override;
10171 
10175  void visit_program(Program &node) override;
10176 
10180  void visit_repeat_until_loop(RepeatUntilLoop &node) override;
10181 
10185  void visit_root(Root &node) override;
10186 
10190  void visit_shift_left(ShiftLeft &node) override;
10191 
10195  void visit_shift_op(ShiftOp &node) override;
10196 
10200  void visit_shift_right_arith(ShiftRightArith &node) override;
10201 
10205  void visit_shift_right_logic(ShiftRightLogic &node) override;
10206 
10210  void visit_statement(Statement &node) override;
10211 
10215  void visit_statement_list(StatementList &node) override;
10216 
10220  void visit_string_literal(StringLiteral &node) override;
10221 
10225  void visit_structured(Structured &node) override;
10226 
10230  void visit_subcircuit(Subcircuit &node) override;
10231 
10235  void visit_subtract(Subtract &node) override;
10236 
10240  void visit_ternary_cond(TernaryCond &node) override;
10241 
10245  void visit_unary_op(UnaryOp &node) override;
10246 
10250  void visit_variables(Variables &node) override;
10251 
10255  void visit_version(Version &node) override;
10256 
10260  void visit_while_loop(WhileLoop &node) override;
10261 
10262 };
10263 
10267 template <typename T>
10269  T retval;
10270  this->visit_internal(visitor, &retval);
10271  return retval;
10272 }
10273 
10277 template <>
10278 void Node::visit(Visitor<void> &visitor);
10279 
10283 std::ostream &operator<<(std::ostream &os, const Node &object);
10284 
10285 } // namespace ast
10286 } // namespace v1
10287 } // namespace cqasm
10288 
The file version identifier.
void raw_visit_index_list(IndexList &node, void *retval) override
Internal visitor function for IndexList nodes.
Many< ExpressionList > rows
The list of rows in the matrix.
cqasm::v1::primitives::Version items
The list of version components, ordered major to minor.
virtual T visit_cmp_eq(CmpEq &node)
Visitor function for CmpEq nodes.
void raw_visit_arith_op(ArithOp &node, void *retval) override
Internal visitor function for ArithOp nodes.
One< Expression > lhs
Reference to the variable used for looping.
A floating point literal.
Integer division operator.
Many< Identifier > names
Name of the variables.
One< Expression > if_false
The result if cond is false.
void raw_visit_assignment(Assignment &node, void *retval) override
Internal visitor function for Assignment nodes.
void raw_visit_while_loop(WhileLoop &node, void *retval) override
Internal visitor function for WhileLoop nodes.
Many< IndexEntry > items
The list of indices.
One< Version > version
File version.
Bitwise AND operator.
Subtraction operator.
Base class for the visitor pattern for the tree.
Placeholder for an expression with a parse error.
void raw_visit_shift_op(ShiftOp &node, void *retval) override
Internal visitor function for ShiftOp nodes.
virtual T visit_index_entry(IndexEntry &node)
Fallback function for IndexEntry nodes.
Internal class for implementing the visitor pattern.
::tree::base::Base Base
Definition: cqasm-tree.hpp:20
void raw_visit_cmp_gt(CmpGt &node, void *retval) override
Internal visitor function for CmpGt nodes.
void raw_visit_root(Root &node, void *retval) override
Internal visitor function for Root nodes.
Represents a node that carries annotation data.
A C-style for loop.
Placeholder for a program with a parse error.
void raw_visit_logical_op(LogicalOp &node, void *retval) override
Internal visitor function for LogicalOp nodes.
Visitor base class defaulting to DFS pre-order traversal.
::tree::base::Maybe< T > Maybe
Definition: cqasm-tree.hpp:23
void raw_visit_node(Node &node, void *retval) override
Internal visitor function for nodes of any type.
void raw_visit_annotation_data(AnnotationData &node, void *retval) override
Internal visitor function for AnnotationData nodes.
virtual T visit_break_statement(BreakStatement &node)
Visitor function for BreakStatement nodes.
virtual T visit_function_call(FunctionCall &node)
Visitor function for FunctionCall nodes.
void raw_visit_structured(Structured &node, void *retval) override
Internal visitor function for Structured nodes.
One< Identifier > operation
The operation within the interface that this annotation is intended for.
Less-than operator.
void raw_visit_expression(Expression &node, void *retval) override
Internal visitor function for Expression nodes.
One< Expression > lhs
The left-hand side of the expression.
void raw_visit_erroneous_expression(ErroneousExpression &node, void *retval) override
Internal visitor function for ErroneousExpression nodes.
::tree::base::Link< T > Link
Definition: cqasm-tree.hpp:35
NodeType
Enumeration of all node types.
One< ExpressionList > operands
Any operands attached to the annotation.
virtual T visit_divide(Divide &node)
Visitor function for Divide nodes.
One< Expression > lhs
Name of the variable being assigned.
virtual T visit_cmp_lt(CmpLt &node)
Visitor function for CmpLt nodes.
::tree::base::OptLink< T > OptLink
Definition: cqasm-tree.hpp:38
Maybe< Expression > iterations
An optional integer expression representing the number of iterations for this subcircuit.
One< Identifier > name
The name of the subcircuit.
virtual T visit_program(Program &node)
Visitor function for Program nodes.
virtual T visit_erroneous_program(ErroneousProgram &node)
Visitor function for ErroneousProgram nodes.
::tree::base::PointerMap * ids
When non-null, the print node IDs from here instead of link contents.
A list of parallel instructions.
void raw_visit_shift_right_arith(ShiftRightArith &node, void *retval) override
Internal visitor function for ShiftRightArith nodes.
virtual T visit_arith_op(ArithOp &node)
Fallback function for ArithOp nodes.
Placeholder for a statement with a parse error.
virtual T visit_continue_statement(ContinueStatement &node)
Visitor function for ContinueStatement nodes.
Represents a JSON literal.
virtual T visit_instruction(Instruction &node)
Visitor function for Instruction nodes.
void raw_visit_annotated(Annotated &node, void *retval) override
Internal visitor function for Annotated nodes.
Many< IfElseBranch > branches
The if-else branches.
error_model::ErrorModelRef deserialize(const ::tree::cbor::MapReader &map)
Deserializes the given primitive object from CBOR.
Logical AND operator.
void raw_visit_bundle(Bundle &node, void *retval) override
Internal visitor function for Bundle nodes.
Toplevel namespace with entry points for the new API.
void raw_visit_if_else_branch(IfElseBranch &node, void *retval) override
Internal visitor function for IfElseBranch nodes.
void raw_visit_cmp_le(CmpLe &node, void *retval) override
Internal visitor function for CmpLe nodes.
virtual T visit_power(Power &node)
Visitor function for Power nodes.
virtual T visit_unary_op(UnaryOp &node)
Fallback function for UnaryOp nodes.
virtual T visit_matrix_literal(MatrixLiteral &node)
Visitor function for MatrixLiteral nodes.
Maybe< Assignment > initialize
The optional initializing assignment, run before the loop starts.
void raw_visit_string_literal(StringLiteral &node, void *retval) override
Internal visitor function for StringLiteral nodes.
virtual T visit_shift_right_logic(ShiftRightLogic &node)
Visitor function for ShiftRightLogic nodes.
One< Expression > to
The last value.
Any kind of instruction.
virtual T visit_statement_list(StatementList &node)
Visitor function for StatementList nodes.
void raw_visit_subtract(Subtract &node, void *retval) override
Internal visitor function for Subtract nodes.
virtual T visit_structured(Structured &node)
Fallback function for Structured nodes.
void raw_visit_version(Version &node, void *retval) override
Internal visitor function for Version nodes.
virtual T visit_logical_not(LogicalNot &node)
Visitor function for LogicalNot nodes.
void raw_visit_bitwise_not(BitwiseNot &node, void *retval) override
Internal visitor function for BitwiseNot nodes.
Bitwise XOR operator.
void raw_visit_program(Program &node, void *retval) override
Internal visitor function for Program nodes.
Logical/unsigned shift-right operator (shifts in zero).
virtual T visit_subtract(Subtract &node)
Visitor function for Subtract nodes.
A mapping (alias) for an expression.
void raw_visit_continue_statement(ContinueStatement &node, void *retval) override
Internal visitor function for ContinueStatement nodes.
One< Expression > condition
The condition.
void raw_visit_index_entry(IndexEntry &node, void *retval) override
Internal visitor function for IndexEntry nodes.
void raw_visit_subcircuit(Subcircuit &node, void *retval) override
Internal visitor function for Subcircuit nodes.
Addition operator.
A single condition + block for use in an if-else chain.
void raw_visit_shift_right_logic(ShiftRightLogic &node, void *retval) override
Internal visitor function for ShiftRightLogic nodes.
virtual T visit_while_loop(WhileLoop &node)
Visitor function for WhileLoop nodes.
virtual T visit_negate(Negate &node)
Visitor function for Negate nodes.
void raw_visit_modulo(Modulo &node, void *retval) override
Internal visitor function for Modulo nodes.
virtual T visit_bitwise_op(BitwiseOp &node)
Fallback function for BitwiseOp nodes.
double Real
Real number primitive used within the AST and semantic trees.
virtual T visit_assignment(Assignment &node)
Visitor function for Assignment nodes.
An assignment statement within a loop definition.
void raw_visit_binary_op(BinaryOp &node, void *retval) override
Internal visitor function for BinaryOp nodes.
One< Expression > first
An integer expression representing the first index.
One< StatementList > body
The loop body.
One< Expression > expr
The expression being indexed.
cqasm::tree::Any< T > Any
void raw_visit_logical_or(LogicalOr &node, void *retval) override
Internal visitor function for LogicalOr nodes.
virtual T visit_if_else_branch(IfElseBranch &node)
Visitor function for IfElseBranch nodes.
virtual T visit_erroneous_expression(ErroneousExpression &node)
Visitor function for ErroneousExpression nodes.
std::int64_t Int
Integer primitive used within the AST and semantic trees.
cqasm::tree::Many< T > Many
One< Identifier > name
Name identifying the instruction.
void raw_visit_power(Power &node, void *retval) override
Internal visitor function for Power nodes.
One< Expression > last
An integer expression representing the last index.
cqasm::v1::primitives::Str value
The string literal.
Main class for all nodes.
A list of one or more indices.
virtual T visit_index_range(IndexRange &node)
Visitor function for IndexRange nodes.
void raw_visit_unary_op(UnaryOp &node, void *retval) override
Internal visitor function for UnaryOp nodes.
Version number primitive used within the AST and semantic trees.
void raw_visit_erroneous_statement(ErroneousStatement &node, void *retval) override
Internal visitor function for ErroneousStatement nodes.
virtual T visit_logical_and(LogicalAnd &node)
Visitor function for LogicalAnd nodes.
Any unary operator.
virtual T visit_bitwise_or(BitwiseOr &node)
Visitor function for BitwiseOr nodes.
Maybe< StatementList > otherwise
The final else block, if any.
virtual T visit_logical_op(LogicalOp &node)
Fallback function for LogicalOp nodes.
void serialize(const error_model::ErrorModelRef &obj, ::tree::cbor::MapWriter &map)
std::ostream & operator<<(std::ostream &os, const Node &object)
Stream << overload for tree nodes (writes debug dump).
virtual T visit_cmp_ne(CmpNe &node)
Visitor function for CmpNe nodes.
One< StatementList > statements
The statement list.
One< Expression > frm
The first value.
virtual T visit_subcircuit(Subcircuit &node)
Visitor function for Subcircuit nodes.
virtual T visit_index_list(IndexList &node)
Visitor function for IndexList nodes.
virtual T visit_shift_left(ShiftLeft &node)
Visitor function for ShiftLeft nodes.
One< Expression > condition
The condition for starting another iteration.
virtual T visit_string_literal(StringLiteral &node)
Visitor function for StringLiteral nodes.
One or more variable declaration for some type.
virtual T visit_bitwise_xor(BitwiseXor &node)
Visitor function for BitwiseXor nodes.
Represents a matrix literal.
virtual T visit_index_item(IndexItem &node)
Visitor function for IndexItem nodes.
Visitor class that debug-dumps a tree to a stream.
void raw_visit_integer_literal(IntegerLiteral &node, void *retval) override
Internal visitor function for IntegerLiteral nodes.
void raw_visit_statement(Statement &node, void *retval) override
Internal visitor function for Statement nodes.
A single index in an index list.
Any kind of statement.
cqasm::v1::primitives::Int value
The integer.
void raw_visit_bitwise_op(BitwiseOp &node, void *retval) override
Internal visitor function for BitwiseOp nodes.
One< IndexList > indices
The list of indices.
cqasm::tree::One< T > One
Any version 1.2+ structured control-flow statement.
virtual T visit_multiply(Multiply &node)
Visitor function for Multiply nodes.
virtual T visit_root(Root &node)
Fallback function for Root nodes.
virtual T visit_integer_literal(IntegerLiteral &node)
Visitor function for IntegerLiteral nodes.
void raw_visit_mapping(Mapping &node, void *retval) override
Internal visitor function for Mapping nodes.
virtual T visit_mapping(Mapping &node)
Visitor function for Mapping nodes.
virtual T visit_json_literal(JsonLiteral &node)
Visitor function for JsonLiteral nodes.
cqasm::v1::primitives::Str name
The identifier.
Represents an annotation.
Inequality operator.
virtual T visit_version(Version &node)
Visitor function for Version nodes.
void raw_visit_shift_left(ShiftLeft &node, void *retval) override
Internal visitor function for ShiftLeft nodes.
One< ExpressionList > operands
Operands for the instruction.
virtual T visit_binary_op(BinaryOp &node)
Fallback function for BinaryOp nodes.
virtual T visit_if_else(IfElse &node)
Visitor function for IfElse nodes.
virtual T visit_add(Add &node)
Visitor function for Add nodes.
cqasm::tree::Link< T > Link
Maybe< Expression > num_qubits
Integer expression indicating the number of qubits.
Arithmetic/signed shift-right operator (shifts in sign).
void raw_visit_statement_list(StatementList &node, void *retval) override
Internal visitor function for StatementList nodes.
One< StatementList > body
The body.
void raw_visit_ternary_cond(TernaryCond &node, void *retval) override
Internal visitor function for TernaryCond nodes.
Defines primitive types for use in trees generated by tree-gen.
virtual T visit_repeat_until_loop(RepeatUntilLoop &node)
Visitor function for RepeatUntilLoop nodes.
virtual T visit_logical_xor(LogicalXor &node)
Visitor function for LogicalXor nodes.
virtual T visit_statement(Statement &node)
Fallback function for Statement nodes.
One< StatementList > body
The loop body.
void raw_visit_repeat_until_loop(RepeatUntilLoop &node, void *retval) override
Internal visitor function for RepeatUntilLoop nodes.
One< Identifier > interface
The interface this annotation is intended for.
Logical XOR operator.
Namespace for the "new" cQASM 1.x API.
virtual T visit_int_divide(IntDivide &node)
Visitor function for IntDivide nodes.
virtual T visit_ternary_cond(TernaryCond &node)
Visitor function for TernaryCond nodes.
virtual T visit_cmp_op(CmpOp &node)
Fallback function for CmpOp nodes.
void raw_visit_cmp_eq(CmpEq &node, void *retval) override
Internal visitor function for CmpEq nodes.
An inclusive range of indices in an index list.
An entry in an index list.
bool operator!=(const Node &rhs) const
Pointer-based inequality operator.
One< Identifier > name
The name of the function.
Negation operator (two&#39;s complement).
virtual T visit_annotation_data(AnnotationData &node)
Visitor function for AnnotationData nodes.
Wrapper for pulling parts of tree-gen&#39;s support library into libqasm.
One< ExpressionList > arguments
The function arguments.
cqasm::tree::Maybe< T > Maybe
void raw_visit_logical_and(LogicalAnd &node, void *retval) override
Internal visitor function for LogicalAnd nodes.
virtual T visit_expression(Expression &node)
Fallback function for Expression nodes.
Any binary operator.
void raw_visit_bitwise_or(BitwiseOr &node, void *retval) override
Internal visitor function for BitwiseOr nodes.
void raw_visit_index(Index &node, void *retval) override
Internal visitor function for Index nodes.
void raw_visit_add(Add &node, void *retval) override
Internal visitor function for Add nodes.
void raw_visit_foreach_loop(ForeachLoop &node, void *retval) override
Internal visitor function for ForeachLoop nodes.
One< Expression > rhs
The right-hand side of the expression.
Greater-than-or-equal operator.
One< Identifier > alias
The identifier used to refer to the expression.
One< Expression > cond
The boolean condition for selection.
void raw_visit_multiply(Multiply &node, void *retval) override
Internal visitor function for Multiply nodes.
::tree::base::Any< T > Any
Definition: cqasm-tree.hpp:29
Dumper(std::ostream &out, int indent=0, ::tree::base::PointerMap *ids=nullptr)
Construct a dumping visitor.
virtual T visit_shift_right_arith(ShiftRightArith &node)
Visitor function for ShiftRightArith nodes.
std::string Str
String primitive used within the AST and semantic trees.
cqasm::v1::primitives::Str value
The JSON literal.
virtual T visit_cmp_le(CmpLe &node)
Visitor function for CmpLe nodes.
void raw_visit_erroneous_program(ErroneousProgram &node, void *retval) override
Internal visitor function for ErroneousProgram nodes.
void raw_visit_logical_xor(LogicalXor &node, void *retval) override
Internal visitor function for LogicalXor nodes.
void raw_visit_negate(Negate &node, void *retval) override
Internal visitor function for Negate nodes.
::tree::base::Many< T > Many
Definition: cqasm-tree.hpp:32
virtual T visit_erroneous_statement(ErroneousStatement &node)
Visitor function for ErroneousStatement nodes.
Many< Instruction > items
The list of parallel instructions.
Equality operator.
virtual T visit_bitwise_not(BitwiseNot &node)
Visitor function for BitwiseNot nodes.
void raw_visit_divide(Divide &node, void *retval) override
Internal visitor function for Divide nodes.
virtual T visit_float_literal(FloatLiteral &node)
Visitor function for FloatLiteral nodes.
cqasm::v1::primitives::Real value
The floating point number.
void raw_visit_index_item(IndexItem &node, void *retval) override
Internal visitor function for IndexItem nodes.
std::ostream & out
Output stream to dump to.
void raw_visit_logical_not(LogicalNot &node, void *retval) override
Internal visitor function for LogicalNot nodes.
One< Expression > expr
The expression being operated on.
void raw_visit_bitwise_xor(BitwiseXor &node, void *retval) override
Internal visitor function for BitwiseXor nodes.
void raw_visit_matrix_literal(MatrixLiteral &node, void *retval) override
Internal visitor function for MatrixLiteral nodes.
void raw_visit_json_literal(JsonLiteral &node, void *retval) override
Internal visitor function for JsonLiteral nodes.
True division operator.
virtual T visit_cmp_gt(CmpGt &node)
Visitor function for CmpGt nodes.
One< Expression > rhs
Value being assigned to the variable.
virtual T visit_modulo(Modulo &node)
Visitor function for Modulo nodes.
virtual T visit_annotated(Annotated &node)
Fallback function for Annotated nodes.
Represents a string literal.
void raw_visit_variables(Variables &node, void *retval) override
Internal visitor function for Variables nodes.
virtual T visit_logical_or(LogicalOr &node)
Visitor function for LogicalOr nodes.
Any< Statement > items
The list of statements.
One< Identifier > typ
Name of the type.
Less-than-or-equal operator.
A complete program.
T visit(Visitor< T > &visitor)
Visit this object.
void raw_visit_cmp_lt(CmpLt &node, void *retval) override
Internal visitor function for CmpLt nodes.
virtual T visit_bundle(Bundle &node)
Visitor function for Bundle nodes.
Any< Expression > items
The list of expressions.
void raw_visit_float_literal(FloatLiteral &node, void *retval) override
Internal visitor function for FloatLiteral nodes.
virtual T visit_shift_op(ShiftOp &node)
Fallback function for ShiftOp nodes.
One< StatementList > body
The loop body.
Exponentiation operator.
One< Expression > expr
The aliased expression.
Maybe< Assignment > update
The updating assignment, done at the end of the loop body and upon continue.
void raw_visit_break_statement(BreakStatement &node, void *retval) override
Internal visitor function for BreakStatement nodes.
One< Expression > condition
The condition for starting another iteration.
void raw_visit_index_range(IndexRange &node, void *retval) override
Internal visitor function for IndexRange nodes.
virtual T visit_bitwise_and(BitwiseAnd &node)
Visitor function for BitwiseAnd nodes.
Maybe< Expression > condition
Optional conditional expression.
virtual T visit_index(Index &node)
Visitor function for Index nodes.
cqasm::tree::OptLink< T > OptLink
void raw_visit_bitwise_and(BitwiseAnd &node, void *retval) override
Internal visitor function for BitwiseAnd nodes.
void raw_visit_cmp_op(CmpOp &node, void *retval) override
Internal visitor function for CmpOp nodes.
One< Expression > index
An integer expression representing the index.
Any root node for the AST.
void raw_visit_identifier(Identifier &node, void *retval) override
Internal visitor function for Identifier nodes.
virtual T visit_for_loop(ForLoop &node)
Visitor function for ForLoop nodes.
void raw_visit_function_call(FunctionCall &node, void *retval) override
Internal visitor function for FunctionCall nodes.
::tree::base::One< T > One
Definition: cqasm-tree.hpp:26
void raw_visit_int_divide(IntDivide &node, void *retval) override
Internal visitor function for IntDivide nodes.
void raw_visit_cmp_ge(CmpGe &node, void *retval) override
Internal visitor function for CmpGe nodes.
One< StatementList > body
The loop body.
One< Expression > if_true
The result if cond is true.
Indexation operator.
void raw_visit_if_else(IfElse &node, void *retval) override
Internal visitor function for IfElse nodes.
void raw_visit_instruction(Instruction &node, void *retval) override
Internal visitor function for Instruction nodes.
void raw_visit_expression_list(ExpressionList &node, void *retval) override
Internal visitor function for ExpressionList nodes.
Arithmetic operators.
cqasm::tree::Base Base
virtual T visit_expression_list(ExpressionList &node)
Visitor function for ExpressionList nodes.
void raw_visit_for_loop(ForLoop &node, void *retval) override
Internal visitor function for ForLoop nodes.
virtual T visit_foreach_loop(ForeachLoop &node)
Visitor function for ForeachLoop nodes.
Represents a comma-separated list of expressions.
virtual T visit_variables(Variables &node)
Visitor function for Variables nodes.
Comparison operators.
Multiplication operator.
Any kind of expression.
virtual T visit_cmp_ge(CmpGe &node)
Visitor function for CmpGe nodes.
One< Expression > condition
The condition for stopping iteration.
Bitwise NOT (one&#39;s complement).
Ternary conditional operator.
virtual T visit_identifier(Identifier &node)
Visitor function for Identifier nodes.
Greater-than operator.
Any< AnnotationData > annotations
Zero or more annotations attached to this object.
void raw_visit_cmp_ne(CmpNe &node, void *retval) override
Internal visitor function for CmpNe nodes.