From 2ab64959d83ed2793d71ab3fa03b8ebdd4925902 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 9 Nov 2007 22:38:47 +0000 Subject: Figured I might as well add single-line comments to taf, it now supports // style comments. --- src/tafreader.cpp | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'src/tafreader.cpp') diff --git a/src/tafreader.cpp b/src/tafreader.cpp index 5609f7c..efcb3d9 100644 --- a/src/tafreader.cpp +++ b/src/tafreader.cpp @@ -49,6 +49,8 @@ void Bu::TafReader::groupContent( Bu::TafGroup *pGroup ) return; else if( c == '/' && la == '*' ) pGroup->addChild( readComment() ); + else if( c == '/' && la == '/' ) + pGroup->addChild( readComment( true ) ); else if( c == ':' ) throw TafException("Encountered stray ':' in taf stream."); else @@ -71,22 +73,43 @@ Bu::TafProperty *Bu::TafReader::readProperty() //printf(" %s = %s\n", sName.getStr(), sValue.getStr() ); } -Bu::TafComment *Bu::TafReader::readComment() +Bu::TafComment *Bu::TafReader::readComment( bool bEOL ) { - next(); FString sCmnt; - for(;;) + next(); + if( bEOL ) { - next(); - if( c == '*' && la == '/' ) + for(;;) { - next(); next(); - break; + next(); + if( c == '\n' && la == '\r' ) + { + next(); next(); + break; + } + else if( c == '\n' || c == '\r' ) + { + next(); + break; + } + sCmnt += c; + } + } + else + { + for(;;) + { + next(); + if( c == '*' && la == '/' ) + { + next(); next(); + break; + } + sCmnt += c; } - sCmnt += c; } - return new TafComment( sCmnt ); + return new TafComment( sCmnt, bEOL ); } Bu::FString Bu::TafReader::readStr() -- cgit v1.2.3