aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-12-10 21:08:43 +0000
committerMike Buland <eichlan@xagasoft.com>2008-12-10 21:08:43 +0000
commit87dd1cd2afbc3b0d67236cdc543a25893a01539d (patch)
tree6c93f2ed8b275f8388fa67985b52e0ac469eb3e8 /src
parent0bd8b8cf19687229b53e37468dfe36c4217fbbf1 (diff)
downloadlibbu++-87dd1cd2afbc3b0d67236cdc543a25893a01539d.tar.gz
libbu++-87dd1cd2afbc3b0d67236cdc543a25893a01539d.tar.bz2
libbu++-87dd1cd2afbc3b0d67236cdc543a25893a01539d.tar.xz
libbu++-87dd1cd2afbc3b0d67236cdc543a25893a01539d.zip
Fixed a couple of minor Bu::TafReader bugs. It wasn't parsing the colons, and
it was off two characters on the first line for error reporting.
Diffstat (limited to '')
-rw-r--r--src/tafreader.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/tafreader.cpp b/src/tafreader.cpp
index c5ef8cc..2918454 100644
--- a/src/tafreader.cpp
+++ b/src/tafreader.cpp
@@ -15,7 +15,7 @@ using namespace Bu;
15Bu::TafReader::TafReader( Bu::Stream &sIn ) : 15Bu::TafReader::TafReader( Bu::Stream &sIn ) :
16 c( 0 ), 16 c( 0 ),
17 sIn( sIn ), 17 sIn( sIn ),
18 iLine( 1 ), iCol( 1 ) 18 iLine( 1 ), iCol( -1 )
19{ 19{
20 next(); next(); 20 next(); next();
21} 21}
@@ -29,18 +29,21 @@ Bu::TafGroup *Bu::TafReader::readGroup()
29{ 29{
30 ws(); 30 ws();
31 if( c != '{' ) 31 if( c != '{' )
32 throw TafException("Expected '{' at %d:%d.", iLine, iCol ); 32 throw TafException("%d:%d: Expected '{' got '%c'.", iLine, iCol, c );
33 next(); 33 next();
34 ws(); 34 ws();
35 FString sName = readStr(); 35 FString sName = readStr();
36 TafGroup *pGroup = new TafGroup( sName ); 36 TafGroup *pGroup = new TafGroup( sName );
37 ws();
38 if( c != ':' )
39 throw TafException("%d:%d: Expected ':' got '%c'.", iLine, iCol, c );
37 next(); 40 next();
38 //printf("Node[%s]:\n", sName.getStr() ); 41 //printf("Node[%s]:\n", sName.getStr() );
39 42
40 groupContent( pGroup ); 43 groupContent( pGroup );
41 44
42 if( c != '}' ) 45 if( c != '}' )
43 throw TafException("Expected '}' at %d:%d.", iLine, iCol ); 46 throw TafException("%d:%d: Expected '}' got '%c'.", iLine, iCol, c );
44 47
45 //next(); 48 //next();
46 49
@@ -64,7 +67,8 @@ void Bu::TafReader::groupContent( Bu::TafGroup *pGroup )
64 else if( c == '/' && la == '/' ) 67 else if( c == '/' && la == '/' )
65 pGroup->addChild( readComment( true ) ); 68 pGroup->addChild( readComment( true ) );
66 else if( c == ':' ) 69 else if( c == ':' )
67 throw TafException("Encountered stray ':' in taf stream at %d:%d.", iLine, iCol ); 70 throw TafException("%d:%d: Encountered stray ':' in taf stream.",
71 iLine, iCol );
68 else 72 else
69 pGroup->addChild( readProperty() ); 73 pGroup->addChild( readProperty() );
70 } 74 }
@@ -154,7 +158,8 @@ Bu::FString Bu::TafReader::readStr()
154 else if( c == 't' ) 158 else if( c == 't' )
155 c = '\t'; 159 c = '\t';
156 else 160 else
157 throw TafException("Invalid escape sequence at %d:%d.", iLine, iCol ); 161 throw TafException("%d:%d: Invalid escape sequence '\\%c'.",
162 iLine, iCol, c );
158 } 163 }
159 else if( c == '"' ) 164 else if( c == '"' )
160 break; 165 break;
@@ -195,6 +200,7 @@ bool Bu::TafReader::isws()
195 200
196void Bu::TafReader::next() 201void Bu::TafReader::next()
197{ 202{
203 printf("%d:%d: read '%c' (%d)\n", iLine, iCol, c, c );
198 if( c == '\n' ) 204 if( c == '\n' )
199 { 205 {
200 iLine++; 206 iLine++;