aboutsummaryrefslogtreecommitdiff
path: root/src/astnode.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/astnode.cpp113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/astnode.cpp b/src/astnode.cpp
new file mode 100644
index 0000000..5adb3ee
--- /dev/null
+++ b/src/astnode.cpp
@@ -0,0 +1,113 @@
1#include "astnode.h"
2#include "astleaf.h"
3#include "astbranch.h"
4
5AstNode::AstNode( Type eType ) :
6 eType( eType )
7{
8}
9
10AstNode::~AstNode()
11{
12}
13
14Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode &n )
15{
16 f << n.getType();
17 if( n.getClass() == AstNode::typeBranch )
18 {
19 f << *dynamic_cast<const AstBranch *>(&n);
20 }
21 else
22 {
23 f << *dynamic_cast<const AstLeaf *>(&n);
24 }
25 return f;
26}
27
28Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode::Type &t )
29{
30 switch( t )
31 {
32 case AstNode::typeFunction: f << "Function"; break;
33 case AstNode::typeSet: f << "Set"; break;
34 case AstNode::typeUnset: f << "Unset"; break;
35 case AstNode::typeIf: f << "If"; break;
36 case AstNode::typeInclude: f << "Include"; break;
37 case AstNode::typeTarget: f << "Target"; break;
38 case AstNode::typeRule: f << "Rule"; break;
39 case AstNode::typeConfig: f << "Config"; break;
40 case AstNode::typeList: f << "List"; break;
41 case AstNode::typeInlineFunc: f << "InlineFunc"; break;
42 case AstNode::typeRequires: f << "Requires"; break;
43 case AstNode::typeFor: f << "For"; break;
44 case AstNode::typeFunctionDef: f << "FunctionDef"; break;
45 case AstNode::typeReturn: f << "Return"; break;
46 case AstNode::typeProfile: f << "Profile"; break;
47 case AstNode::typeInput: f << "Input"; break;
48 case AstNode::typeRuleDef: f << "RuleDef"; break;
49 case AstNode::typeOutput: f << "Output"; break;
50 case AstNode::typeAutoConfig: f << "AutoConfig"; break;
51 case AstNode::typeGlobalConfig: f << "GlobalConfig"; break;
52 case AstNode::typeType: f << "Type"; break;
53 case AstNode::typeValue: f << "Value"; break;
54 case AstNode::typeAllow: f << "Allow"; break;
55 case AstNode::typeDefault: f << "Default"; break;
56 case AstNode::typeExport: f << "Export"; break;
57 case AstNode::typeExpr: f << "Expr"; break;
58 case AstNode::typeActionDef: f << "ActionDef"; break;
59 case AstNode::typeProcessTarget:f << "ProcessTarget"; break;
60 case AstNode::typeTag: f << "Tag"; break;
61
62 case AstNode::typeVariable: f << "Variable"; break;
63 case AstNode::typeString: f << "String"; break;
64 case AstNode::typeInt: f << "Int"; break;
65 case AstNode::typeFloat: f << "Float"; break;
66 case AstNode::typeBool: f << "Bool"; break;
67 case AstNode::typeVersion: f << "Version"; break;
68 case AstNode::typeOpEq: f << "Operator ="; break;
69 case AstNode::typeOpPlusEq: f << "Operator +="; break;
70 case AstNode::typeOpPlusEqRaw: f << "Operator <<"; break;
71 case AstNode::typeError: f << "Error"; break;
72 case AstNode::typeWarning: f << "Warning"; break;
73 case AstNode::typeNotice: f << "Notice"; break;
74 case AstNode::typeTypeString: f << "Type String"; break;
75 case AstNode::typeTypeInt: f << "Type Int"; break;
76 case AstNode::typeTypeFloat: f << "Type Float"; break;
77 case AstNode::typeTypeBool: f << "Type Bool"; break;
78 case AstNode::typeTypeVersion: f << "Type Version"; break;
79 case AstNode::typeCmpEq: f << "Compare ="; break;
80 case AstNode::typeCmpLt: f << "Compare <"; break;
81 case AstNode::typeCmpGt: f << "Compare >"; break;
82 case AstNode::typeCmpNe: f << "Compare !="; break;
83 case AstNode::typeCmpLtEq: f << "Compare <="; break;
84 case AstNode::typeCmpGtEq: f << "Compare >="; break;
85 case AstNode::typeCondition: f << "Condition"; break;
86 case AstNode::typeDisplay: f << "Display"; break;
87 case AstNode::typeCache: f << "Cache"; break;
88 case AstNode::typePushPrefix: f << "Push Prefix"; break;
89 case AstNode::typePopPrefix: f << "Pop Prefix"; break;
90 case AstNode::typeNull: f << "Null"; break;
91 case AstNode::typeVariableRef: f << "VariableRef"; break;
92 case AstNode::typeOpPlus: f << "Operator +"; break;
93 case AstNode::typeOpMinus: f << "Operator -"; break;
94 case AstNode::typeOpMultiply: f << "Operator *"; break;
95 case AstNode::typeOpDivide: f << "Operator /"; break;
96 case AstNode::typeOpNegate: f << "Operator negate"; break;
97 case AstNode::typeOpNot: f << "Operator not"; break;
98
99 case AstNode::typeBranch: f << "Branch"; break;
100 case AstNode::typeLeaf: f << "Leaf"; break;
101 case AstNode::typeClassMask: f << "ClassMask"; break;
102
103 case AstNode::typeDataNone: f << "<Data None>"; break;
104 case AstNode::typeDataString: f << "<Data String>"; break;
105 case AstNode::typeDataInt: f << "<Data Int>"; break;
106 case AstNode::typeDataFloat: f << "<Data Float>"; break;
107 case AstNode::typeDataBool: f << "<Data Bool>"; break;
108 case AstNode::typeDataVersion: f << "<Data Version>"; break;
109 case AstNode::typeDataMask: f << "<Data Mask>"; break;
110 }
111 return f;
112}
113