27class ASTPrinter :
public AcyclicVisitor,
28 public Visitor<ASTNode>,
29 public Visitor<OperatorPlusNode>,
30 public Visitor<OperatorMinusNode>,
31 public Visitor<OperatorMultiplyNode>,
32 public Visitor<OperatorDivideNode>,
33 public Visitor<NegateNode>,
34 public Visitor<FunctionAbsNode>,
35 public Visitor<FunctionExpNode>,
36 public Visitor<FunctionLogNode>,
37 public Visitor<FunctionSqrtNode>,
38 public Visitor<FunctionNormalCdfNode>,
39 public Visitor<FunctionNormalPdfNode>,
40 public Visitor<FunctionMinNode>,
41 public Visitor<FunctionMaxNode>,
42 public Visitor<FunctionPowNode>,
43 public Visitor<FunctionBlackNode>,
44 public Visitor<FunctionDcfNode>,
45 public Visitor<FunctionDaysNode>,
46 public Visitor<FunctionPayNode>,
47 public Visitor<FunctionLogPayNode>,
48 public Visitor<FunctionNpvNode>,
49 public Visitor<FunctionNpvMemNode>,
50 public Visitor<HistFixingNode>,
51 public Visitor<FunctionDiscountNode>,
52 public Visitor<FunctionFwdCompNode>,
53 public Visitor<FunctionFwdAvgNode>,
54 public Visitor<FunctionAboveProbNode>,
55 public Visitor<FunctionBelowProbNode>,
56 public Visitor<FunctionDateIndexNode>,
57 public Visitor<SortNode>,
58 public Visitor<PermuteNode>,
59 public Visitor<ConstantNumberNode>,
60 public Visitor<VariableNode>,
61 public Visitor<SizeOpNode>,
62 public Visitor<VarEvaluationNode>,
63 public Visitor<AssignmentNode>,
64 public Visitor<RequireNode>,
65 public Visitor<DeclarationNumberNode>,
66 public Visitor<SequenceNode>,
67 public Visitor<ConditionEqNode>,
68 public Visitor<ConditionNeqNode>,
69 public Visitor<ConditionLtNode>,
70 public Visitor<ConditionLeqNode>,
71 public Visitor<ConditionGtNode>,
72 public Visitor<ConditionGeqNode>,
73 public Visitor<ConditionNotNode>,
74 public Visitor<ConditionAndNode>,
75 public Visitor<ConditionOrNode>,
76 public Visitor<IfThenElseNode>,
77 public Visitor<LoopNode> {
80 std::string str()
const {
return out_.str(); }
81 void visit(ASTNode& n)
override {
print(
"Unknown", n); }
82 void visit(OperatorPlusNode& n)
override {
print(
"OperatorPlus", n); }
83 void visit(OperatorMinusNode& n)
override {
print(
"OperatorMinus", n); }
84 void visit(OperatorMultiplyNode& n)
override {
print(
"OperatorMultiply", n); }
85 void visit(OperatorDivideNode& n)
override {
print(
"OperatorDivide", n); }
86 void visit(NegateNode& n)
override {
print(
"Negate", n); }
87 void visit(FunctionAbsNode& n)
override {
print(
"FunctionAbs", n); }
88 void visit(FunctionExpNode& n)
override {
print(
"FunctionExp", n); }
89 void visit(FunctionLogNode& n)
override {
print(
"FunctionLog", n); }
90 void visit(FunctionSqrtNode& n)
override {
print(
"FunctionSqrt", n); }
91 void visit(FunctionNormalCdfNode& n)
override {
print(
"FunctionNormalCdf", n); }
92 void visit(FunctionNormalPdfNode& n)
override {
print(
"FunctionNormalPdf", n); }
93 void visit(FunctionMinNode& n)
override {
print(
"FunctionMin", n); }
94 void visit(FunctionMaxNode& n)
override {
print(
"FunctionMax", n); }
95 void visit(FunctionPowNode& n)
override {
print(
"FunctionPow", n); }
96 void visit(FunctionBlackNode& n)
override {
print(
"FunctionBlack", n); }
97 void visit(FunctionDcfNode& n)
override {
print(
"FunctionDcf", n); }
98 void visit(FunctionDaysNode& n)
override {
print(
"FunctionDays", n); }
99 void visit(FunctionPayNode& n)
override {
print(
"FunctionPay", n); }
100 void visit(FunctionLogPayNode& n)
override {
print(
"FunctionLogPay", n); }
101 void visit(FunctionNpvNode& n)
override {
print(
"FunctionNpv", n); }
102 void visit(FunctionNpvMemNode& n)
override {
print(
"FunctionNpvMem", n); }
103 void visit(HistFixingNode& n)
override {
print(
"HistFixing", n); }
104 void visit(FunctionDiscountNode& n)
override {
print(
"FunctionDiscount", n); }
105 void visit(FunctionFwdCompNode& n)
override {
print(
"FunctionFwdComp", n); }
106 void visit(FunctionFwdAvgNode& n)
override {
print(
"FunctionFwdAvg", n); }
107 void visit(FunctionAboveProbNode& n)
override {
print(
"FunctionAboveProb", n); }
108 void visit(FunctionBelowProbNode& n)
override {
print(
"FunctionBelowProb", n); }
109 void visit(FunctionDateIndexNode& n)
override {
print(
"FunctionDateIndex(" + n.name +
"," + n.op +
")", n); }
110 void visit(SortNode& n)
override {
print(
"Sort", n); }
111 void visit(PermuteNode& n)
override {
print(
"Permute", n); }
112 void visit(ConstantNumberNode& n)
override {
print(
"ConstantNumber(" + std::to_string(n.value) +
")", n); }
113 void visit(VariableNode& n)
override {
print(
"Variable(" + n.name +
")", n); }
114 void visit(SizeOpNode& n)
override {
print(
"Size(" + n.name +
")", n); }
115 void visit(VarEvaluationNode& n)
override {
print(
"VarEvaluation", n); }
116 void visit(AssignmentNode& n)
override {
print(
"Assignment", n); }
117 void visit(RequireNode& n)
override {
print(
"Require", n); }
118 void visit(DeclarationNumberNode& n)
override {
print(
"DeclarationNumber", n); }
119 void visit(SequenceNode& n)
override {
print(
"Sequence", n); }
120 void visit(ConditionEqNode& n)
override {
print(
"ConditionEq", n); }
121 void visit(ConditionNeqNode& n)
override {
print(
"ConditionNeq", n); }
122 void visit(ConditionLtNode& n)
override {
print(
"ConditionLt", n); }
123 void visit(ConditionLeqNode& n)
override {
print(
"ConditionLeq", n); }
124 void visit(ConditionGtNode& n)
override {
print(
"ConditionGt", n); }
125 void visit(ConditionGeqNode& n)
override {
print(
"ConditionGeq", n); }
126 void visit(ConditionNotNode& n)
override {
print(
"ConditionNot", n); }
127 void visit(ConditionAndNode& n)
override {
print(
"ConditionAnd", n); }
128 void visit(ConditionOrNode& n)
override {
print(
"ConditionOr", n); }
129 void visit(IfThenElseNode& n)
override {
print(
"IfThenElse", n); }
130 void visit(LoopNode& n)
override {
print(
"Loop(" + n.name +
")", n); }
133 void print(
const std::string& s,
const ASTNode& n) {
134 out_ << std::string(indent_,
' ') << s;
135 if (printLocationInfo_)
138 for (
auto const& c : n.args) {
141 out_ << std::string(indent_,
' ') <<
"-\n";
158 ASTPrinter p(printLocationInfo);
const bool printLocationInfo_
void print(Distribution &dist, std::string fileName)
std::string to_string(const LocationInfo &l)
QuantLib::ext::shared_ptr< ASTNode > ASTNodePtr
Serializable Credit Default Swap.