From 113fc467a7170a8a564049c64d1036dd10e6abac Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 30 Jul 2006 09:07:20 +0000 Subject: It's starting to look pretty good, just trying to figure out how to get through everything that needs to be made modular and general. --- src/builder.cpp | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'src/builder.cpp') 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 @@ #include #include "builder.h" +#include "action.h" +#include "command.h" #include "build.tab.h" -Builder::Builder() +subExceptionDef( BuildException ) + +Builder::Builder() : + pDefaultAction( NULL ), + pLastAddedAction( NULL ) { } @@ -11,24 +17,47 @@ Builder::~Builder() { } +void yyparse( Builder &bld ); + void Builder::load( const char *sFN ) { file = sFN; scanBegin(); - yy::BuildParser parser( *this ); - parser.set_debug_level( false ); - parser.parse(); + yyparse( *this ); scanEnd(); } -void Builder::error( const yy::location &l, const std::string &m ) +void Builder::add( Action *pAct ) +{ + if( pAct->isDefault() ) + { + if( pDefaultAction ) + throw BuildException("There's already a default exception"); + pDefaultAction = pAct; + } + else + { + mAction[pAct->getName()] = pAct; + } + pLastAddedAction = pAct; +} + +void Builder::add( Command *pCmd ) { - std::cerr << l << ": " << m << std::endl; + if( pLastAddedAction ) + { + pLastAddedAction->add( pCmd ); + } } -void Builder::error( const std::string &m ) +void Builder::debug() { - std::cerr << m << std::endl; + pDefaultAction->debug(); + for( std::map::iterator i = mAction.begin(); + i != mAction.end(); i++ ) + { + (*i).second->debug(); + } } -- cgit v1.2.3