|
From: <bl...@us...> - 2003-05-01 21:54:44
|
Update of /cvsroot/cpptool/rfta/src/rftaparser
In directory sc8-pr-cvs1:/tmp/cvs-serv9187/src/rftaparser
Modified Files:
DeclarationDetailsParser.cpp
UnparsedDeclarationMutatorTest.cpp
UnparsedDeclarationMutatorTest.h
Log Message:
* added support for destructor declaration in class (not very clean, it is too tolerant)
Index: DeclarationDetailsParser.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationDetailsParser.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** DeclarationDetailsParser.cpp 1 May 2003 20:54:10 -0000 1.3
--- DeclarationDetailsParser.cpp 1 May 2003 21:54:40 -0000 1.4
***************
*** 526,531 ****
do {
skipSpaces();
! if (tryNextIs('*')) continue;
! if (tryNextIs('&')) continue;
if (tryNextIs('('))
{
--- 526,535 ----
do {
skipSpaces();
! if (tryNextIs('*'))
! continue;
!
! if (tryNextIs('&'))
! continue;
!
if (tryNextIs('('))
{
***************
*** 569,607 ****
}
std::string identifier;
if (!tryReadNextIdentifier(identifier))
- {
throwFailure( boost::format("unexpected character: '%1%'.") % *current_ );
- } else
- {
- if (identifier=="const") continue;
- if (identifier=="volatile") continue;
- identifierFound = true;
! // read fully qualified name:
! nestedName.append(identifier);
! if (tryReadNext("::"))
! {
! nestedName.append("::");
! readNestedName(nestedName);
! }
! // check for operator keyword:
! if (isOperatorIdentifier(nestedName))
! {
! parseOperator(declaratorStartIndex);
! return;
! }
! // check for bitfield expression
! if (tryNextIs(':'))
! {
! if (!skipOverAssignmentInitializer())
! throwFailure("Constant expression is not well formed.");
! // @todo: store bit field expression
! }
! continue;
}
} while (hasNext() && !declaratorEndReached);
--- 573,615 ----
}
+ if ( tryNextIs( '~' ) )
+ { // handle destructor (buggy, need to ensure not followed by const or volatile)
+ }
+
std::string identifier;
if (!tryReadNextIdentifier(identifier))
throwFailure( boost::format("unexpected character: '%1%'.") % *current_ );
! if (identifier=="const")
! continue;
! if (identifier=="volatile")
! continue;
! identifierFound = true;
! // read fully qualified name:
! nestedName.append(identifier);
! if (tryReadNext("::"))
! {
! nestedName.append("::");
! readNestedName(nestedName);
}
+
+ // check for operator keyword:
+ if (isOperatorIdentifier(nestedName))
+ {
+ parseOperator(declaratorStartIndex);
+ return;
+ }
+
+ // check for bitfield expression
+ if (tryNextIs(':'))
+ {
+ if (!skipOverAssignmentInitializer())
+ throwFailure("Constant expression is not well formed.");
+ // @todo: store bit field expression
+ }
+ continue;
} while (hasNext() && !declaratorEndReached);
Index: UnparsedDeclarationMutatorTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** UnparsedDeclarationMutatorTest.cpp 1 May 2003 21:12:15 -0000 1.7
--- UnparsedDeclarationMutatorTest.cpp 1 May 2003 21:54:40 -0000 1.8
***************
*** 258,261 ****
--- 258,273 ----
}
+
+ void
+ UnparsedDeclarationMutatorTest::testClassForwardDeclaration()
+ {
+ const std::string source( "class X;" );
+ SourceASTNodePtr sourceNode = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source );
+
+ ASTNodePtr classNode = sourceNode->getChildAt(0);
+ RFTA_ASSERT_NODE_TYPE( classNode, ASTNodeTypes::declaration );
+ }
+
+
void
UnparsedDeclarationMutatorTest::testEnumDeclaration()
***************
*** 657,660 ****
--- 669,708 ----
}
+
+ void
+ UnparsedDeclarationMutatorTest::testDestructorMember()
+ {
+ Testing::KeyedString source;
+ source.addKeyed(DECLARATOR, "~Destructor()" ) << ";";
+
+ SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source );
+ ASTNodePtr node = sourceAST->getChildAt(0);
+
+ // check AST:
+ RFTA_ASSERT_DECLARATION( source, sourceAST );
+
+ // check declarator types:
+ RFTA_ASSERT_NODE_TYPE( node->getChildAt(0), ASTNodeTypes::unparsedDeclarator);
+ }
+
+
+ void
+ UnparsedDeclarationMutatorTest::testVirtualDestructorMember()
+ {
+ Testing::KeyedString source;
+ source.addKeyed(SPECIFIER , "virtual" ) << " ";
+ source.addKeyed(DECLARATOR, "~Destructor()" ) << ";";
+
+ SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source );
+ ASTNodePtr node = sourceAST->getChildAt(0);
+
+ // check AST:
+ RFTA_ASSERT_DECLARATION( source, sourceAST );
+
+ // check declarator types:
+ RFTA_ASSERT_NODE_TYPE( node->getChildAt(0), ASTNodeTypes::unparsedDeclarator);
+ }
+
+
void
UnparsedDeclarationMutatorTest::testMemberPure()
***************
*** 729,743 ****
// check declarator types:
RFTA_ASSERT_NODE_TYPE( node->getChildAt(0), ASTNodeTypes::unparsedDeclarator);
- }
-
-
- void
- UnparsedDeclarationMutatorTest::testClassForwardDeclaration()
- {
- const std::string source( "class X;" );
- SourceASTNodePtr sourceNode = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source );
-
- ASTNodePtr classNode = sourceNode->getChildAt(0);
- RFTA_ASSERT_NODE_TYPE( classNode, ASTNodeTypes::declaration );
}
--- 777,780 ----
Index: UnparsedDeclarationMutatorTest.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** UnparsedDeclarationMutatorTest.h 1 May 2003 21:12:16 -0000 1.4
--- UnparsedDeclarationMutatorTest.h 1 May 2003 21:54:40 -0000 1.5
***************
*** 45,48 ****
--- 45,50 ----
CPPUNIT_TEST( testOperatorMember );
/* class member extensions */
+ CPPUNIT_TEST( testDestructorMember );
+ CPPUNIT_TEST( testVirtualDestructorMember );
CPPUNIT_TEST( testMemberPure );
CPPUNIT_TEST( testMemberConstInit );
***************
*** 86,89 ****
--- 88,93 ----
void testStructTypedef();
void testTypedefDeclaration();
+ void testDestructorMember();
+ void testVirtualDestructorMember();
void testMemberPure();
void testMemberConstInit();
|