aboutsummaryrefslogtreecommitdiff
path: root/src/builder.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/builder.cpp45
1 files changed, 37 insertions, 8 deletions
diff --git a/src/builder.cpp b/src/builder.cpp
index 8c72fef..2de6f5c 100644
--- a/src/builder.cpp
+++ b/src/builder.cpp
@@ -1,9 +1,15 @@
1#include <iostream> 1#include <iostream>
2 2
3#include "builder.h" 3#include "builder.h"
4#include "action.h"
5#include "command.h"
4#include "build.tab.h" 6#include "build.tab.h"
5 7
6Builder::Builder() 8subExceptionDef( BuildException )
9
10Builder::Builder() :
11 pDefaultAction( NULL ),
12 pLastAddedAction( NULL )
7{ 13{
8} 14}
9 15
@@ -11,24 +17,47 @@ Builder::~Builder()
11{ 17{
12} 18}
13 19
20void yyparse( Builder &bld );
21
14void Builder::load( const char *sFN ) 22void Builder::load( const char *sFN )
15{ 23{
16 file = sFN; 24 file = sFN;
17 25
18 scanBegin(); 26 scanBegin();
19 yy::BuildParser parser( *this ); 27 yyparse( *this );
20 parser.set_debug_level( false );
21 parser.parse();
22 scanEnd(); 28 scanEnd();
23} 29}
24 30
25void Builder::error( const yy::location &l, const std::string &m ) 31void Builder::add( Action *pAct )
32{
33 if( pAct->isDefault() )
34 {
35 if( pDefaultAction )
36 throw BuildException("There's already a default exception");
37 pDefaultAction = pAct;
38 }
39 else
40 {
41 mAction[pAct->getName()] = pAct;
42 }
43 pLastAddedAction = pAct;
44}
45
46void Builder::add( Command *pCmd )
26{ 47{
27 std::cerr << l << ": " << m << std::endl; 48 if( pLastAddedAction )
49 {
50 pLastAddedAction->add( pCmd );
51 }
28} 52}
29 53
30void Builder::error( const std::string &m ) 54void Builder::debug()
31{ 55{
32 std::cerr << m << std::endl; 56 pDefaultAction->debug();
57 for( std::map<const char *, Action *, ltstr>::iterator i = mAction.begin();
58 i != mAction.end(); i++ )
59 {
60 (*i).second->debug();
61 }
33} 62}
34 63