aboutsummaryrefslogtreecommitdiff
path: root/src/astnode.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/astnode.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/astnode.h b/src/astnode.h
new file mode 100644
index 0000000..6ade25b
--- /dev/null
+++ b/src/astnode.h
@@ -0,0 +1,108 @@
1#ifndef AST_NODE_H
2#define AST_NODE_H
3
4#include "bu/formatter.h"
5
6class AstNode
7{
8public:
9 enum Type
10 {
11 // Branching types
12 typeFunction = 0x100001,
13 typeSet = 0x100002,
14 typeUnset = 0x100003,
15 typeIf = 0x100004,
16 typeInclude = 0x100005,
17 typeTarget = 0x100006,
18 typeRule = 0x100007,
19 typeConfig = 0x100008,
20 typeList = 0x100009,
21 typeInlineFunc = 0x10000A,
22 typeRequires = 0x10000B,
23 typeFor = 0x10000C,
24 typeFunctionDef = 0x10000D,
25 typeReturn = 0x10000E,
26 typeProfile = 0x10000F,
27 typeInput = 0x100010,
28 typeRuleDef = 0x100011,
29 typeOutput = 0x100012,
30 typeAutoConfig = 0x100013,
31 typeGlobalConfig = 0x100014,
32 typeType = 0x100015,
33 typeValue = 0x100016,
34 typeAllow = 0x100017,
35 typeDefault = 0x100018,
36 typeExport = 0x100019,
37 typeExpr = 0x10001A, /***< Stack based compound expression.*/
38 typeActionDef = 0x10001B,
39 typeProcessTarget = 0x10001C,
40 typeTag = 0x10001D,
41
42 // Leaf types
43 typeVariable = 0x210001,
44 typeString = 0x210002,
45 typeInt = 0x220003,
46 typeFloat = 0x230004,
47 typeBool = 0x240005,
48 typeVersion = 0x250006,
49 typeOpEq = 0x200007,
50 typeOpPlusEq = 0x200008,
51 typeOpPlusEqRaw = 0x200009,
52 typeError = 0x21000A,
53 typeWarning = 0x21000B,
54 typeNotice = 0x21000C,
55 typeTypeString = 0x20000D,
56 typeTypeInt = 0x20000E,
57 typeTypeFloat = 0x20000F,
58 typeTypeBool = 0x200010,
59 typeTypeVersion = 0x200011,
60 typeCmpEq = 0x200012,
61 typeCmpLt = 0x200013,
62 typeCmpGt = 0x200014,
63 typeCmpNe = 0x200015,
64 typeCmpLtEq = 0x200016,
65 typeCmpGtEq = 0x200017,
66 typeCondition = 0x210018,
67 typeDisplay = 0x210019,
68 typeCache = 0x24001A,
69 typePushPrefix = 0x21001B,
70 typePopPrefix = 0x20001C,
71 typeNull = 0x20001D,
72 typeVariableRef = 0x21001E,
73 typeOpPlus = 0x20001F,
74 typeOpMinus = 0x200020,
75 typeOpMultiply = 0x200021,
76 typeOpDivide = 0x200022,
77 typeOpNegate = 0x200023,
78 typeOpNot = 0x200024,
79
80 typeBranch = 0x100000,
81 typeLeaf = 0x200000,
82 typeClassMask = 0x300000,
83
84 typeDataNone = 0x000000,
85 typeDataString = 0x010000,
86 typeDataInt = 0x020000,
87 typeDataFloat = 0x030000,
88 typeDataBool = 0x040000,
89 typeDataVersion = 0x050000,
90
91 typeDataMask = 0x0F0000
92 };
93public:
94 AstNode( Type eType );
95 virtual ~AstNode();
96
97 Type getType() const { return eType; }
98 Type getClass() const { return (Type)(eType&typeClassMask); }
99 Type getDataType() const { return (Type)(eType&typeDataMask); }
100
101private:
102 Type eType;
103};
104
105Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode &n );
106Bu::Formatter &operator<<( Bu::Formatter &f, const AstNode::Type &t );
107
108#endif