aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-10-14 00:08:50 +0000
committerMike Buland <eichlan@xagasoft.com>2010-10-14 00:08:50 +0000
commit8d0b7a6cd835b1a8d8dae020b8ad50ab5451b1da (patch)
treede1c1d34e0c99b92317693de53a88772e1210f94 /src
parentfc16fc104a038146c8ab6c2e9fad38e18663a09f (diff)
downloadlibbu++-8d0b7a6cd835b1a8d8dae020b8ad50ab5451b1da.tar.gz
libbu++-8d0b7a6cd835b1a8d8dae020b8ad50ab5451b1da.tar.bz2
libbu++-8d0b7a6cd835b1a8d8dae020b8ad50ab5451b1da.tar.xz
libbu++-8d0b7a6cd835b1a8d8dae020b8ad50ab5451b1da.zip
Minor tweaks to myriad.
Diffstat (limited to '')
-rw-r--r--src/lexer.h5
-rw-r--r--src/myriad.cpp12
-rw-r--r--src/myriad.h3
-rw-r--r--src/parser.cpp14
4 files changed, 27 insertions, 7 deletions
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
29 29
30 template<class t> 30 template<class t>
31 Token( TokenType iToken, const t &v ) : 31 Token( TokenType iToken, const t &v ) :
32 iToken( iToken ), 32 iToken( iToken )//,
33 vExtra( v ) 33// vExtra( v )
34 { 34 {
35 vExtra = v;
35 } 36 }
36 TokenType iToken; 37 TokenType iToken;
37 Bu::Variant vExtra; 38 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 )
472 return findStream( iId )->iSize; 472 return findStream( iId )->iSize;
473} 473}
474 474
475bool Bu::Myriad::hasStream( int iId )
476{
477 try
478 {
479 findStream( iId );
480 return true;
481 }catch(...)
482 {
483 return false;
484 }
485}
486
475Bu::MyriadStream Bu::Myriad::openStream( int iId ) 487Bu::MyriadStream Bu::Myriad::openStream( int iId )
476{ 488{
477 //sio << "Myriad: Request to open stream: " << iId << sio.nl; 489 //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
31 invalidStreamId, 31 invalidStreamId,
32 protectedStream 32 protectedStream
33 }; 33 };
34 subExceptionDeclEnd() 34 subExceptionDeclEnd();
35 35
36 /** 36 /**
37 * Myriad block-allocated stream multiplexing system. This is a system for 37 * Myriad block-allocated stream multiplexing system. This is a system for
@@ -132,6 +132,7 @@ namespace Bu
132 132
133 Bu::Array<int> getStreamIds(); 133 Bu::Array<int> getStreamIds();
134 int getStreamSize( int iId ); 134 int getStreamSize( int iId );
135 bool hasStream( int iId );
135 136
136 int getNumStreams(); 137 int getNumStreams();
137 int getBlockSize(); 138 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()
26{ 26{
27 int iCurNt = iRootNonTerminal; 27 int iCurNt = iRootNonTerminal;
28 Lexer::Token *ptCur = sLexer.peek()->nextToken(); 28 Lexer::Token *ptCur = sLexer.peek()->nextToken();
29 //Lexer::Token *ptNext = sLexer.peek()->nextToken(); 29 sio << "Token: " << sLexer.peek()->tokenToString( *ptCur ) << sio.nl;
30 selectProduction( iCurNt, ptCur ); 30 selectProduction( iCurNt, ptCur );
31 sio << "Token: " << *ptCur << sio.nl;
32 31
33 while( !sState.isEmpty() ) 32 while( !sState.isEmpty() )
34 { 33 {
@@ -43,7 +42,7 @@ void Bu::Parser::parse()
43 advanceState(); 42 advanceState();
44 delete ptCur; 43 delete ptCur;
45 ptCur = sLexer.peek()->nextToken(); 44 ptCur = sLexer.peek()->nextToken();
46 sio << "Token: " << *ptCur << sio.nl; 45 sio << "Token: " << sLexer.peek()->tokenToString( *ptCur ) << sio.nl;
47 } 46 }
48 else 47 else
49 { 48 {
@@ -60,7 +59,7 @@ void Bu::Parser::parse()
60 sToken.push( ptCur ); 59 sToken.push( ptCur );
61 60
62 ptCur = sLexer.peek()->nextToken(); 61 ptCur = sLexer.peek()->nextToken();
63 sio << "Token: " << *ptCur << sio.nl; 62 sio << "Token: " << sLexer.peek()->tokenToString( *ptCur ) << sio.nl;
64 } 63 }
65 else 64 else
66 { 65 {
@@ -99,12 +98,15 @@ bool Bu::Parser::selectProduction( int iNt, Lexer::Token *ptCur )
99 { 98 {
100 if( (*i).isEmpty() ) 99 if( (*i).isEmpty() )
101 continue; 100 continue;
101 sio << "-->(Attempting production " << iNt << ":" << j << ": "
102 << (*i).first() << ")" << sio.nl;
102 if( (*i).first().eType == State::typeTerminal || 103 if( (*i).first().eType == State::typeTerminal ||
103 (*i).first().eType == State::typeTerminalPush ) 104 (*i).first().eType == State::typeTerminalPush )
104 { 105 {
105 if( (*i).first().iIndex == ptCur->iToken ) 106 if( (*i).first().iIndex == ptCur->iToken )
106 { 107 {
107 sState.push( (*i).begin() ); 108 sState.push( (*i).begin() );
109 sio.incIndent();
108 sio << "Pushing production " << j << " from nt " << iNt 110 sio << "Pushing production " << j << " from nt " << iNt
109 << sio.nl; 111 << sio.nl;
110 return true; 112 return true;
@@ -113,10 +115,12 @@ bool Bu::Parser::selectProduction( int iNt, Lexer::Token *ptCur )
113 else if( (*i).first().eType == State::typeNonTerminal ) 115 else if( (*i).first().eType == State::typeNonTerminal )
114 { 116 {
115 sState.push( (*i).begin() ); 117 sState.push( (*i).begin() );
118 sio.incIndent();
116 sio << "Pushing production " << j << " from nt " << iNt 119 sio << "Pushing production " << j << " from nt " << iNt
117 << " as test." << sio.nl; 120 << " as test." << sio.nl;
118 if( !selectProduction( (*i).first().iIndex, ptCur ) ) 121 if( !selectProduction( (*i).first().iIndex, ptCur ) )
119 { 122 {
123 sio.decIndent();
120 sState.pop(); 124 sState.pop();
121 sio << "Production " << j << " from nt " << iNt 125 sio << "Production " << j << " from nt " << iNt
122 << " didn't work out." << sio.nl; 126 << " didn't work out." << sio.nl;
@@ -129,6 +133,7 @@ bool Bu::Parser::selectProduction( int iNt, Lexer::Token *ptCur )
129 } 133 }
130 if( nt.bCanSkip ) 134 if( nt.bCanSkip )
131 return true; 135 return true;
136 sio << "-->(Found nothing)" << sio.nl;
132 return false; 137 return false;
133} 138}
134 139
@@ -140,6 +145,7 @@ void Bu::Parser::advanceState()
140 sState.peek()++; 145 sState.peek()++;
141 if( !sState.peek() ) 146 if( !sState.peek() )
142 { 147 {
148 sio.decIndent();
143 sState.pop(); 149 sState.pop();
144 sio << "State advanced, End of production." << sio.nl; 150 sio << "State advanced, End of production." << sio.nl;
145 return; 151 return;