|
From: <bl...@us...> - 2003-05-01 21:06:48
|
Update of /cvsroot/cpptool/rfta/src/rftaparser
In directory sc8-pr-cvs1:/tmp/cvs-serv15003/src/rftaparser
Modified Files:
DeclarationDetailsParser.cpp DeclarationDetailsParser.h
Log Message:
* refactored some
* added support for class forward declaration 'class X;'
* fixed class body range (was before } unlike namespace, which caused a bug since the mutator do --end).
Index: DeclarationDetailsParser.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationDetailsParser.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DeclarationDetailsParser.cpp 29 Apr 2003 10:29:56 -0000 1.2
--- DeclarationDetailsParser.cpp 1 May 2003 20:54:10 -0000 1.3
***************
*** 227,231 ****
specifierList->addChild(specifier);
! readClassOrEnumSpecifier(specifier, specifierIdent, secondIdent);
// set real length after completed parsing
--- 227,235 ----
specifierList->addChild(specifier);
! if ( !tryNextIs(';') ) // this is not a forward declaration
! {
! // read the complete specifier:
! readClassOrEnumSpecifier( specifier, specifierIdent );
! }
// set real length after completed parsing
***************
*** 237,241 ****
// 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(':'))
{
// yes it's - so parse the class specifier
--- 241,245 ----
// 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(':') )
{
// yes it's - so parse the class specifier
***************
*** 254,258 ****
// read the complete specifier:
! readClassOrEnumSpecifier(specifier, specifierIdent, secondIdent);
// set real length after completed parsing
--- 258,262 ----
// read the complete specifier:
! readClassOrEnumSpecifier( specifier, specifierIdent );
// set real length after completed parsing
***************
*** 262,266 ****
// FINISH HERE (the class specifier ends here !)
}
! throwFailure( "Expected a double colon => '::'." );
}
--- 266,270 ----
// FINISH HERE (the class specifier ends here !)
}
! throwFailure( "unknown specifier type: " + specifierIdent );
}
***************
*** 400,437 ****
void
! DeclarationDetailsParser::readClassOrEnumSpecifier(ASTNodePtr& specifier, std::string keyword, std::string name)
{
ASTNodePtr body;
- int startIndex;
! if (keyword == "class" || keyword == "struct" || keyword == "union")
! {
! // read over possible inheritance information
! readUntilNextOf("{");
! current_++;
!
! body = createASTNode(
! ASTNodeTypes::unparsedDeclarationList,
! specifier,
! startIndex = getCurrentIndex(),
! getCurrentLength()
! );
! specifier->setPropertyNode( ASTNodeProperties::classBodyProperty , body );
! } else
! {
! specifier->mutateType( ASTNodeTypes::enumSpecifier );
! expect('{');
- body = createASTNode(
- ASTNodeTypes::unparsedDeclarationList,
- specifier,
- startIndex = getCurrentIndex(),
- getCurrentLength()
- );
- specifier->setPropertyNode( ASTNodeProperties::enumBodyProperty , body );
- }
findNextBalanced('{','}');
! body->setLength(getCurrentIndex() - startIndex - 1 ); // do not count the last '}'
}
bool
--- 404,452 ----
void
! DeclarationDetailsParser::readClassOrEnumSpecifier( const ASTNodePtr& specifier,
! std::string keyword )
{
ASTNodePtr body;
! if ( keyword == "class" || keyword == "struct" || keyword == "union" )
! body = readClassSpecifierBodySkippingInheritance( specifier );
! else
! body = readEnumSpecifierBody( specifier );
findNextBalanced('{','}');
!
! body->setEndIndex( getCurrentIndex() ); // do not count the last '}'
}
+
+
+ ASTNodePtr
+ DeclarationDetailsParser::readClassSpecifierBodySkippingInheritance( const ASTNodePtr &specifier )
+ {
+ readUntilNextOf("{");
+ current_++;
+
+ ASTNodePtr body = createASTNode( ASTNodeTypes::unparsedDeclarationList,
+ specifier,
+ getCurrentIndex(),
+ 0 );
+ specifier->setPropertyNode( ASTNodeProperties::classBodyProperty , body );
+ return body;
+ }
+
+
+ ASTNodePtr
+ DeclarationDetailsParser::readEnumSpecifierBody( const ASTNodePtr& specifier )
+ {
+ specifier->mutateType( ASTNodeTypes::enumSpecifier );
+ expect('{');
+
+ ASTNodePtr body = createASTNode( ASTNodeTypes::unparsedDeclarationList,
+ specifier,
+ getCurrentIndex(),
+ 0 );
+ specifier->setPropertyNode( ASTNodeProperties::enumBodyProperty , body );
+ return body;
+ }
+
bool
Index: DeclarationDetailsParser.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationDetailsParser.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DeclarationDetailsParser.h 29 Apr 2003 09:55:39 -0000 1.1
--- DeclarationDetailsParser.h 1 May 2003 20:54:10 -0000 1.2
***************
*** 51,55 ****
void readNestedName(std::string& nestedname);
! void readClassOrEnumSpecifier(ASTNodePtr& specifier, std::string keyword, std::string name);
//
--- 51,58 ----
void readNestedName(std::string& nestedname);
! void readClassOrEnumSpecifier( const ASTNodePtr& specifier,
! std::string keyword );
! ASTNodePtr readClassSpecifierBodySkippingInheritance( const ASTNodePtr &specifier );
! ASTNodePtr readEnumSpecifierBody( const ASTNodePtr &specifier );
//
|