From 8d0b7a6cd835b1a8d8dae020b8ad50ab5451b1da Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 14 Oct 2010 00:08:50 +0000 Subject: Minor tweaks to myriad. --- src/lexer.h | 5 +++-- src/myriad.cpp | 12 ++++++++++++ src/myriad.h | 3 ++- src/parser.cpp | 14 ++++++++++---- 4 files changed, 27 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/lexer.h b/src/lexer.h index e8a17b5..2cb5f51 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -29,9 +29,10 @@ namespace Bu template Token( TokenType iToken, const t &v ) : - iToken( iToken ), - vExtra( v ) + iToken( iToken )//, +// vExtra( v ) { + vExtra = v; } TokenType iToken; Bu::Variant vExtra; diff --git a/src/myriad.cpp b/src/myriad.cpp index 8650a1c..c3eb97e 100644 --- a/src/myriad.cpp +++ b/src/myriad.cpp @@ -472,6 +472,18 @@ int Bu::Myriad::getStreamSize( int iId ) return findStream( iId )->iSize; } +bool Bu::Myriad::hasStream( int iId ) +{ + try + { + findStream( iId ); + return true; + }catch(...) + { + return false; + } +} + Bu::MyriadStream Bu::Myriad::openStream( int iId ) { //sio << "Myriad: Request to open stream: " << iId << sio.nl; diff --git a/src/myriad.h b/src/myriad.h index 84f273e..79c3cda 100644 --- a/src/myriad.h +++ b/src/myriad.h @@ -31,7 +31,7 @@ namespace Bu invalidStreamId, protectedStream }; - subExceptionDeclEnd() + subExceptionDeclEnd(); /** * Myriad block-allocated stream multiplexing system. This is a system for @@ -132,6 +132,7 @@ namespace Bu Bu::Array getStreamIds(); int getStreamSize( int iId ); + bool hasStream( int iId ); int getNumStreams(); int getBlockSize(); diff --git a/src/parser.cpp b/src/parser.cpp index b563691..e4e8ae5 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -26,9 +26,8 @@ void Bu::Parser::parse() { int iCurNt = iRootNonTerminal; Lexer::Token *ptCur = sLexer.peek()->nextToken(); - //Lexer::Token *ptNext = sLexer.peek()->nextToken(); + sio << "Token: " << sLexer.peek()->tokenToString( *ptCur ) << sio.nl; selectProduction( iCurNt, ptCur ); - sio << "Token: " << *ptCur << sio.nl; while( !sState.isEmpty() ) { @@ -43,7 +42,7 @@ void Bu::Parser::parse() advanceState(); delete ptCur; ptCur = sLexer.peek()->nextToken(); - sio << "Token: " << *ptCur << sio.nl; + sio << "Token: " << sLexer.peek()->tokenToString( *ptCur ) << sio.nl; } else { @@ -60,7 +59,7 @@ void Bu::Parser::parse() sToken.push( ptCur ); ptCur = sLexer.peek()->nextToken(); - sio << "Token: " << *ptCur << sio.nl; + sio << "Token: " << sLexer.peek()->tokenToString( *ptCur ) << sio.nl; } else { @@ -99,12 +98,15 @@ bool Bu::Parser::selectProduction( int iNt, Lexer::Token *ptCur ) { if( (*i).isEmpty() ) continue; + sio << "-->(Attempting production " << iNt << ":" << j << ": " + << (*i).first() << ")" << sio.nl; if( (*i).first().eType == State::typeTerminal || (*i).first().eType == State::typeTerminalPush ) { if( (*i).first().iIndex == ptCur->iToken ) { sState.push( (*i).begin() ); + sio.incIndent(); sio << "Pushing production " << j << " from nt " << iNt << sio.nl; return true; @@ -113,10 +115,12 @@ bool Bu::Parser::selectProduction( int iNt, Lexer::Token *ptCur ) else if( (*i).first().eType == State::typeNonTerminal ) { sState.push( (*i).begin() ); + sio.incIndent(); sio << "Pushing production " << j << " from nt " << iNt << " as test." << sio.nl; if( !selectProduction( (*i).first().iIndex, ptCur ) ) { + sio.decIndent(); sState.pop(); sio << "Production " << j << " from nt " << iNt << " didn't work out." << sio.nl; @@ -129,6 +133,7 @@ bool Bu::Parser::selectProduction( int iNt, Lexer::Token *ptCur ) } if( nt.bCanSkip ) return true; + sio << "-->(Found nothing)" << sio.nl; return false; } @@ -140,6 +145,7 @@ void Bu::Parser::advanceState() sState.peek()++; if( !sState.peek() ) { + sio.decIndent(); sState.pop(); sio << "State advanced, End of production." << sio.nl; return; -- cgit v1.2.3