aboutsummaryrefslogtreecommitdiff
path: root/src/ast.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-12-28 20:55:18 +0000
committerMike Buland <eichlan@xagasoft.com>2009-12-28 20:55:18 +0000
commitc5fcf682195b0b191d19a598844f734ebf5b2583 (patch)
tree9fb24ddc20aaee06ee4990e84725b33a3e213207 /src/ast.cpp
parente27c94b51a2e315ed5f529ba0c8c0d1bf354143c (diff)
downloadbuild-c5fcf682195b0b191d19a598844f734ebf5b2583.tar.gz
build-c5fcf682195b0b191d19a598844f734ebf5b2583.tar.bz2
build-c5fcf682195b0b191d19a598844f734ebf5b2583.tar.xz
build-c5fcf682195b0b191d19a598844f734ebf5b2583.zip
Location data is being tracked (for the most part, filenames...not as much),
but it isn't being used in errors yet, I should add some new exceptions for now.
Diffstat (limited to 'src/ast.cpp')
-rw-r--r--src/ast.cpp54
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
6Ast::Ast() 8Ast::Ast()
7{ 9{
8} 10}
@@ -11,13 +13,13 @@ Ast::~Ast()
11{ 13{
12} 14}
13 15
14void Ast::addNode( AstNode::Type eType ) 16void 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
41void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, int iVal )
42{
43 addNode( new AstLeaf( loc, eType, iVal ) );
44}
45
46void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, float fVal )
47{
48 addNode( new AstLeaf( loc, eType, fVal ) );
49}
50
51void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, bool bVal )
52{
53 addNode( new AstLeaf( loc, eType, bVal ) );
54}
55
56void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, const Bu::FString &sVal )
57{
58 addNode( new AstLeaf( loc, eType, sVal ) );
59}
60
61void Ast::addNode( YYLTYPE &loc, AstNode::Type eType, const char *sVal )
62{
63 addNode( new AstLeaf( loc, eType, sVal ) );
64}
65
66void Ast::addNode( AstNode::Type eType )
67{
68 YYLTYPE none = {-1, -1, -1, -1};
69 addNode( none, eType );
70}
71
39void Ast::addNode( AstNode::Type eType, int iVal ) 72void 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
44void Ast::addNode( AstNode::Type eType, float fVal ) 78void 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
49void Ast::addNode( AstNode::Type eType, bool bVal ) 84void 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
54void Ast::addNode( AstNode::Type eType, const Bu::FString &sVal ) 90void 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
59void Ast::addNode( AstNode::Type eType, const char *sVal ) 96void 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
64void Ast::addNode( AstNode *pNode ) 102void Ast::addNode( AstNode *pNode )