From: <net...@us...> - 2003-09-06 21:45:19
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv32595 Modified Files: DeclarationDetailsParser.h DeclarationDetailsParser.cpp Log Message: -- fixed class parsing Index: DeclarationDetailsParser.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationDetailsParser.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** DeclarationDetailsParser.h 16 May 2003 10:00:43 -0000 1.7 --- DeclarationDetailsParser.h 6 Sep 2003 21:43:43 -0000 1.8 *************** *** 58,61 **** --- 58,62 ---- void addNamedClassNodeAndReadBody( int specifierStart, + int nameIdentStart, const ASTNodePtr &specifierList, const std::string &specifierIdent ); Index: DeclarationDetailsParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationDetailsParser.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DeclarationDetailsParser.cpp 16 May 2003 10:00:44 -0000 1.12 --- DeclarationDetailsParser.cpp 6 Sep 2003 21:43:43 -0000 1.13 *************** *** 238,243 **** // if no identifier follows, an unnamed type is specifier (e.g. "struct { } x;") Xtl::CStringView secondIdent; ! if ( tryReadNextIdentifier( secondIdent ) ) ! skipSpaces(); Xtl::CStringView thirdIdent; // in the case of export macro: class RFTA_API SourceRange {}; --- 238,250 ---- // if no identifier follows, an unnamed type is specifier (e.g. "struct { } x;") Xtl::CStringView secondIdent; ! int nameIdentStart = -1; ! { ! int save_pos = getCurrentIndex(); ! if ( tryReadNextIdentifier( secondIdent ) ) ! { ! nameIdentStart = save_pos; ! skipSpaces(); ! } ! } Xtl::CStringView thirdIdent; // in the case of export macro: class RFTA_API SourceRange {}; *************** *** 248,253 **** } ! // check if no identifier or the identifier is not followed by a ':' (e.g. "class x {" ! if ( secondIdent.isEmpty() || !tryNextIs(':') ) { addAnonymousClassNodeAndReadBody( specifierStart, specifierList, specifierIdent ); --- 255,260 ---- } ! // check handle anonymouse classes (e.g. "class {" ) ! if ( secondIdent.isEmpty() ) { addAnonymousClassNodeAndReadBody( specifierStart, specifierList, specifierIdent ); *************** *** 255,263 **** } ! // HERE we come only in case where the type is followed by a colon. "e.g. class x:" ! // check if it is only a single colon (which means inheritance information e.g. "class x: public y ") ! if ( !tryNextIs(':') ) { ! addNamedClassNodeAndReadBody( specifierStart, specifierList, specifierIdent ); return; } --- 262,269 ---- } ! // check only a single colon follows (which means inheritance information e.g. "class x: public y ") ! if (!tryReadNext("::")) { ! addNamedClassNodeAndReadBody( specifierStart, nameIdentStart, specifierList, specifierIdent ); return; } *************** *** 323,327 **** specifierList, specifierStart, ! getCurrentIndex()-specifierStart ); specifierList->addChild(specifier); --- 329,333 ---- specifierList, specifierStart, ! 0 ); // length not yet known... specifierList->addChild(specifier); *************** *** 339,357 **** void DeclarationDetailsParser::addNamedClassNodeAndReadBody( int specifierStart, const ASTNodePtr &specifierList, const std::string &specifierIdent ) { - if ( !isClassTypeSpecifier( specifierIdent ) ) - throwFailure( "unknown specifier type: " + specifierIdent ); - // add the specifier node ASTNodePtr specifier = createASTNode( ASTNodeTypes::classSpecifier, specifierList, specifierStart, ! getCurrentIndex()-specifierStart ); specifierList->addChild(specifier); ! // read the complete specifier: ! readClassOrEnumSpecifier( specifier, specifierIdent ); // set real length after completed parsing --- 345,379 ---- void DeclarationDetailsParser::addNamedClassNodeAndReadBody( int specifierStart, + int secondIdentStart, const ASTNodePtr &specifierList, const std::string &specifierIdent ) { // add the specifier node ASTNodePtr specifier = createASTNode( ASTNodeTypes::classSpecifier, specifierList, specifierStart, ! 0 ); specifierList->addChild(specifier); ! // move back to identifier end. ! backtrackSkippingSpaces(); ! ! // create specifier identifier property: ! ASTNodePtr ident ! = createASTNode( ASTNodeTypes::localScopeIdentifier, ! specifier, ! secondIdentStart, ! getCurrentIndex()-secondIdentStart ! ); ! specifier->setPropertyNode( ASTNodeProperties::classNameProperty , ident ); ! ! skipSpaces(); ! ! // check if this is a forward declaration "class x::y;" ! if ( !tryNextIs(';') ) ! { ! // read the complete specifier: ! readClassOrEnumSpecifier( specifier, specifierIdent ); ! } // set real length after completed parsing *************** *** 642,651 **** { if ( isClassTypeSpecifier( keyword ) ) ! { ! ASTNodePtr body = readClassSpecifierBodySkippingInheritance( specifier ); findNextBalanced('{','}'); ! body->setEndIndex( getCurrentIndex() ); // do not count the last '}' } else --- 664,673 ---- { if ( isClassTypeSpecifier( keyword ) ) ! { ! ASTNodePtr body = readClassSpecifierBodySkippingInheritance( specifier ); findNextBalanced('{','}'); ! body->setEndIndex( getCurrentIndex()-1 ); // do not count the last '}' } else *************** *** 659,664 **** DeclarationDetailsParser::readClassSpecifierBodySkippingInheritance( const ASTNodePtr &specifier ) { ! readUntilNextOf("{"); ! current_++; ASTNodePtr body = createASTNode( ASTNodeTypes::unparsedDeclarationList, --- 681,694 ---- DeclarationDetailsParser::readClassSpecifierBodySkippingInheritance( const ASTNodePtr &specifier ) { ! skipSpaces(); ! ! // check if inheritance information does follow... ! if (!tryNextIs('{')) ! { ! // TODO: create node for inheritance-information ! // and add property to specifier-node ! readUntilNextOf("{"); ! current_++; ! } ASTNodePtr body = createASTNode( ASTNodeTypes::unparsedDeclarationList, *************** *** 812,816 **** if ( tryNextIs( '~' ) ) ! { // handle destructor (buggy, need to ensure not followed by const or volatile) skipSpaces(); } --- 842,846 ---- if ( tryNextIs( '~' ) ) ! { // handle destructor (buggy, need to ensure not followed by volatile) skipSpaces(); } |