diff options
Diffstat (limited to 'src/ast.cpp')
-rw-r--r-- | src/ast.cpp | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/src/ast.cpp b/src/ast.cpp index 03ed4b6..6b213ea 100644 --- a/src/ast.cpp +++ b/src/ast.cpp | |||
@@ -3,6 +3,8 @@ | |||
3 | #include "astleaf.h" | 3 | #include "astleaf.h" |
4 | #include "astbranch.h" | 4 | #include "astbranch.h" |
5 | 5 | ||
6 | #include "build.tab.h" | ||
7 | |||
6 | Ast::Ast() | 8 | Ast::Ast() |
7 | { | 9 | { |
8 | } | 10 | } |
@@ -11,13 +13,13 @@ Ast::~Ast() | |||
11 | { | 13 | { |
12 | } | 14 | } |
13 | 15 | ||
14 | void Ast::addNode( AstNode::Type eType ) | 16 | void Ast::addNode( YYLTYPE &loc, AstNode::Type eType ) |
15 | { | 17 | { |
16 | switch( eType&AstNode::typeClassMask ) | 18 | switch( eType&AstNode::typeClassMask ) |
17 | { | 19 | { |
18 | case AstNode::typeBranch: | 20 | case AstNode::typeBranch: |
19 | { | 21 | { |
20 | AstBranch *pNode = new AstBranch( eType ); | 22 | AstBranch *pNode = new AstBranch( loc, eType ); |
21 | addNode( pNode ); | 23 | addNode( pNode ); |
22 | sBranch.push( pNode ); | 24 | sBranch.push( pNode ); |
23 | } | 25 | } |
@@ -25,7 +27,7 @@ void Ast::addNode( AstNode::Type eType ) | |||
25 | 27 | ||
26 | case AstNode::typeLeaf: | 28 | case AstNode::typeLeaf: |
27 | { | 29 | { |
28 | AstLeaf *pNode = new AstLeaf( eType ); | 30 | AstLeaf *pNode = new AstLeaf( loc, eType ); |
29 | addNode( pNode ); | 31 | addNode( pNode ); |
30 | } | 32 | } |
31 | break; | 33 | break; |
@@ -36,29 +38,65 @@ void Ast::addNode( AstNode::Type eType ) | |||
36 | } | 38 | } |
37 | } | 39 | } |
38 | 40 | ||
41 | void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, int iVal ) | ||
42 | { | ||
43 | addNode( new AstLeaf( loc, eType, iVal ) ); | ||
44 | } | ||
45 | |||
46 | void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, float fVal ) | ||
47 | { | ||
48 | addNode( new AstLeaf( loc, eType, fVal ) ); | ||
49 | } | ||
50 | |||
51 | void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, bool bVal ) | ||
52 | { | ||
53 | addNode( new AstLeaf( loc, eType, bVal ) ); | ||
54 | } | ||
55 | |||
56 | void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, const Bu::FString &sVal ) | ||
57 | { | ||
58 | addNode( new AstLeaf( loc, eType, sVal ) ); | ||
59 | } | ||
60 | |||
61 | void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, const char *sVal ) | ||
62 | { | ||
63 | addNode( new AstLeaf( loc, eType, sVal ) ); | ||
64 | } | ||
65 | |||
66 | void Ast::addNode( AstNode::Type eType ) | ||
67 | { | ||
68 | YYLTYPE none = {-1, -1, -1, -1}; | ||
69 | addNode( none, eType ); | ||
70 | } | ||
71 | |||
39 | void Ast::addNode( AstNode::Type eType, int iVal ) | 72 | void Ast::addNode( AstNode::Type eType, int iVal ) |
40 | { | 73 | { |
41 | addNode( new AstLeaf( eType, iVal ) ); | 74 | YYLTYPE none = {-1, -1, -1, -1}; |
75 | addNode( none, eType, iVal ); | ||
42 | } | 76 | } |
43 | 77 | ||
44 | void Ast::addNode( AstNode::Type eType, float fVal ) | 78 | void Ast::addNode( AstNode::Type eType, float fVal ) |
45 | { | 79 | { |
46 | addNode( new AstLeaf( eType, fVal ) ); | 80 | YYLTYPE none = {-1, -1, -1, -1}; |
81 | addNode( none, eType, fVal ); | ||
47 | } | 82 | } |
48 | 83 | ||
49 | void Ast::addNode( AstNode::Type eType, bool bVal ) | 84 | void Ast::addNode( AstNode::Type eType, bool bVal ) |
50 | { | 85 | { |
51 | addNode( new AstLeaf( eType, bVal ) ); | 86 | YYLTYPE none = {-1, -1, -1, -1}; |
87 | addNode( none, eType, bVal ); | ||
52 | } | 88 | } |
53 | 89 | ||
54 | void Ast::addNode( AstNode::Type eType, const Bu::FString &sVal ) | 90 | void Ast::addNode( AstNode::Type eType, const Bu::FString &sVal ) |
55 | { | 91 | { |
56 | addNode( new AstLeaf( eType, sVal ) ); | 92 | YYLTYPE none = {-1, -1, -1, -1}; |
93 | addNode( none, eType, sVal ); | ||
57 | } | 94 | } |
58 | 95 | ||
59 | void Ast::addNode( AstNode::Type eType, const char *sVal ) | 96 | void Ast::addNode( AstNode::Type eType, const char *sVal ) |
60 | { | 97 | { |
61 | addNode( new AstLeaf( eType, sVal ) ); | 98 | YYLTYPE none = {-1, -1, -1, -1}; |
99 | addNode( none, eType, sVal ); | ||
62 | } | 100 | } |
63 | 101 | ||
64 | void Ast::addNode( AstNode *pNode ) | 102 | void Ast::addNode( AstNode *pNode ) |