You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(37) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(15) |
Feb
(26) |
Mar
(97) |
Apr
(224) |
May
(226) |
Jun
|
Jul
(3) |
Aug
(22) |
Sep
(48) |
Oct
|
Nov
|
Dec
(38) |
2004 |
Jan
(28) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(37) |
Jul
|
Aug
(73) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <net...@us...> - 2003-04-29 10:30:00
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv23272/src/rftaparser Modified Files: DeclarationDetailsParser.cpp Log Message: -- bugfix class body length Index: DeclarationDetailsParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationDetailsParser.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DeclarationDetailsParser.cpp 29 Apr 2003 09:55:39 -0000 1.1 --- DeclarationDetailsParser.cpp 29 Apr 2003 10:29:56 -0000 1.2 *************** *** 432,436 **** } findNextBalanced('{','}'); ! body->setLength(getCurrentLength() - startIndex - 1 ); // do not count the last '}' } --- 432,436 ---- } findNextBalanced('{','}'); ! body->setLength(getCurrentIndex() - startIndex - 1 ); // do not count the last '}' } |
From: <net...@us...> - 2003-04-29 10:29:20
|
Update of /cvsroot/cpptool/rfta/include/rfta/parser In directory sc8-pr-cvs1:/tmp/cvs-serv22786/include/rfta/parser Modified Files: ASTNodes.h Log Message: -- added special ASTNodeType for unparsable declarations. Index: ASTNodes.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/parser/ASTNodes.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ASTNodes.h 28 Apr 2003 20:41:35 -0000 1.18 --- ASTNodes.h 29 Apr 2003 10:29:16 -0000 1.19 *************** *** 17,20 **** --- 17,23 ---- { public: + // node for unknown constructs: + static const ASTNodeType unknownConstruct; + // A source file (.cpp or .h) static const ASTNodeType source; |
From: <net...@us...> - 2003-04-29 10:29:19
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv22786/src/rftaparser Modified Files: UnparsedDeclarationListMutator.cpp ASTNodes.cpp Log Message: -- added special ASTNodeType for unparsable declarations. Index: UnparsedDeclarationListMutator.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationListMutator.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UnparsedDeclarationListMutator.cpp 15 Apr 2003 19:04:20 -0000 1.1 --- UnparsedDeclarationListMutator.cpp 29 Apr 2003 10:29:16 -0000 1.2 *************** *** 47,50 **** --- 47,52 ---- node->mutateType( ASTNodeTypes::declarationList ); } + else + node->mutateType( ASTNodeTypes::unknownConstruct ); } Index: ASTNodes.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ASTNodes.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ASTNodes.cpp 28 Apr 2003 20:41:35 -0000 1.20 --- ASTNodes.cpp 29 Apr 2003 10:29:16 -0000 1.21 *************** *** 13,35 **** const ASTNodeType ASTNodeTypes::source( "source-file", isCompositeStatement ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::templateDeclaration ( "template-declaration" , mayHaveLocalScopeIdentifierChildren ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::linkageDeclaration ( "linkage-declaration", 0 ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::usingNamespace ( "using-namespace" , 0 ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::namespaceAlias ( "namespace-alias" , mayHaveLocalScopeIdentifierChildren ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::namespaceDeclaration ( "namespace-declaration" , mayHaveLocalScopeIdentifierChildren ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::declarationList ( "declaration-list" , mayHaveLocalScopeIdentifierChildren ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::functionImplementation ( "function-implementation" , mayHaveLocalScopeIdentifierChildren ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedDeclarationList ( "unparsed-declaration-list", mayHaveLocalScopeIdentifierChildren ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedDeclaration ( "unparsed-declaration", mayHaveLocalScopeIdentifierChildren ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedFunctionHeader ( "unparsed-function-header", mayHaveLocalScopeIdentifierChildren ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedTemplateHeader ( "unparsed-template-header", mayHaveLocalScopeIdentifierChildren ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::declaration ( "declaration" , 0 ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::declarationSpecifierList ( "declaration-specifier-list" , 0 ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::simpleTypeSpecifier ( "simple-type-specifier" , 0 ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::classSpecifier ( "class-specifier" , 0 ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::enumSpecifier ( "enum-specifier" , 0 ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::elaboratedTypeSpecifier ( "elaborated-type-specifier" , 0 ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedDeclarator ( "unparsed-declarator" , 0 ); const ASTNodeType ASTNodeTypes::unparsedCompoundStatement( "unparsed-compound-statement", isCompositeStatement | needMutation ); --- 13,37 ---- const ASTNodeType ASTNodeTypes::source( "source-file", isCompositeStatement ); ! const ASTNodeType ASTNodeTypes::unknownConstruct ( "unknown-construct" , 0 ); ! const ASTNodeType ASTNodeTypes::templateDeclaration ( "template-declaration" , mayHaveLocalScopeIdentifierChildren ); ! const ASTNodeType ASTNodeTypes::linkageDeclaration ( "linkage-declaration", 0 ); ! const ASTNodeType ASTNodeTypes::usingNamespace ( "using-namespace" , 0 ); ! const ASTNodeType ASTNodeTypes::namespaceAlias ( "namespace-alias" , mayHaveLocalScopeIdentifierChildren ); ! const ASTNodeType ASTNodeTypes::namespaceDeclaration ( "namespace-declaration" , mayHaveLocalScopeIdentifierChildren ); ! const ASTNodeType ASTNodeTypes::declarationList ( "declaration-list" , mayHaveLocalScopeIdentifierChildren ); ! const ASTNodeType ASTNodeTypes::functionImplementation ( "function-implementation" , mayHaveLocalScopeIdentifierChildren ); ! const ASTNodeType ASTNodeTypes::unparsedDeclarationList ( "unparsed-declaration-list", mayHaveLocalScopeIdentifierChildren ); ! const ASTNodeType ASTNodeTypes::unparsedDeclaration ( "unparsed-declaration", mayHaveLocalScopeIdentifierChildren ); ! const ASTNodeType ASTNodeTypes::unparsedFunctionHeader ( "unparsed-function-header", mayHaveLocalScopeIdentifierChildren ); ! const ASTNodeType ASTNodeTypes::unparsedTemplateHeader ( "unparsed-template-header", mayHaveLocalScopeIdentifierChildren ); ! ! const ASTNodeType ASTNodeTypes::declaration ( "declaration" , 0 ); ! const ASTNodeType ASTNodeTypes::declarationSpecifierList ( "declaration-specifier-list" , 0 ); ! const ASTNodeType ASTNodeTypes::simpleTypeSpecifier ( "simple-type-specifier" , 0 ); ! const ASTNodeType ASTNodeTypes::classSpecifier ( "class-specifier" , 0 ); ! const ASTNodeType ASTNodeTypes::enumSpecifier ( "enum-specifier" , 0 ); ! const ASTNodeType ASTNodeTypes::elaboratedTypeSpecifier ( "elaborated-type-specifier" , 0 ); ! const ASTNodeType ASTNodeTypes::unparsedDeclarator ( "unparsed-declarator" , 0 ); const ASTNodeType ASTNodeTypes::unparsedCompoundStatement( "unparsed-compound-statement", isCompositeStatement | needMutation ); *************** *** 104,118 **** /* properties for declarations */ ! /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::templateBodyProperty( "template-body-property" ); ! /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::templateHeaderProperty( "template-header-property" ); ! /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::linkageBodyProperty( "linkage-body-property" ); ! /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::namespaceBodyProperty( "namespace-body-property" ); ! /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::namespaceAliasProperty( "namespace-alias-property" ); ! /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::functionBodyProperty( "function-body-property" ); ! /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::functionHeaderProperty( "function-header-property" ); ! /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::declarationSpecifiersProperty( "declaration-specifiers-property" ); ! /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::enumBodyProperty ( "enumeration-body-property" ); ! /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::classBodyProperty( "class-body-property" ); } // namespace Refactoring --- 106,120 ---- /* properties for declarations */ ! const ASTNodeProperty ASTNodeProperties::templateBodyProperty( "template-body-property" ); ! const ASTNodeProperty ASTNodeProperties::templateHeaderProperty( "template-header-property" ); ! const ASTNodeProperty ASTNodeProperties::linkageBodyProperty( "linkage-body-property" ); ! const ASTNodeProperty ASTNodeProperties::namespaceBodyProperty( "namespace-body-property" ); ! const ASTNodeProperty ASTNodeProperties::namespaceAliasProperty( "namespace-alias-property" ); ! const ASTNodeProperty ASTNodeProperties::functionBodyProperty( "function-body-property" ); ! const ASTNodeProperty ASTNodeProperties::functionHeaderProperty( "function-header-property" ); ! const ASTNodeProperty ASTNodeProperties::declarationSpecifiersProperty( "declaration-specifiers-property" ); ! const ASTNodeProperty ASTNodeProperties::enumBodyProperty ( "enumeration-body-property" ); ! const ASTNodeProperty ASTNodeProperties::classBodyProperty( "class-body-property" ); } // namespace Refactoring |
From: <net...@us...> - 2003-04-29 10:11:45
|
Update of /cvsroot/cpptool/rfta/src/pyrfta In directory sc8-pr-cvs1:/tmp/cvs-serv8492/src/pyrfta Added Files: .cvsignore Log Message: -- hide 'plg' files generated by VC6 --- NEW FILE: .cvsignore --- *.WW *.plg |
From: <net...@us...> - 2003-04-29 10:11:44
|
Update of /cvsroot/cpptool/rfta/deplib/cppunit/src/DllPlugInTester In directory sc8-pr-cvs1:/tmp/cvs-serv8492/deplib/cppunit/src/DllPlugInTester Modified Files: .cvsignore Log Message: -- hide 'plg' files generated by VC6 Index: .cvsignore =================================================================== RCS file: /cvsroot/cpptool/rfta/deplib/cppunit/src/DllPlugInTester/.cvsignore,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** .cvsignore 14 Apr 2003 19:47:23 -0000 1.2 --- .cvsignore 29 Apr 2003 10:11:41 -0000 1.3 *************** *** 1,3 **** --- 1,4 ---- *.WW + *.plg DebugDll ReleaseDll |
From: <net...@us...> - 2003-04-29 10:11:43
|
Update of /cvsroot/cpptool/rfta/deplib/cppunit/src/cppunit In directory sc8-pr-cvs1:/tmp/cvs-serv8492/deplib/cppunit/src/cppunit Modified Files: .cvsignore Log Message: -- hide 'plg' files generated by VC6 Index: .cvsignore =================================================================== RCS file: /cvsroot/cpptool/rfta/deplib/cppunit/src/cppunit/.cvsignore,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** .cvsignore 14 Apr 2003 19:47:08 -0000 1.2 --- .cvsignore 29 Apr 2003 10:11:40 -0000 1.3 *************** *** 1,3 **** --- 1,4 ---- *.WW + *.plg DebugDll ReleaseDll |
From: <net...@us...> - 2003-04-29 10:11:43
|
Update of /cvsroot/cpptool/rfta/deplib/cppunit/src In directory sc8-pr-cvs1:/tmp/cvs-serv8492/deplib/cppunit/src Added Files: .cvsignore Log Message: -- hide 'plg' files generated by VC6 --- NEW FILE: .cvsignore --- *.WW *.plg DebugDll ReleaseDll |
From: <net...@us...> - 2003-04-29 10:06:15
|
Update of /cvsroot/cpptool/rfta/bin In directory sc8-pr-cvs1:/tmp/cvs-serv4433/bin Modified Files: test.bat Log Message: -- enabled astdump test for "keyedstring" source Index: test.bat =================================================================== RCS file: /cvsroot/cpptool/rfta/bin/test.bat,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test.bat 28 Apr 2003 21:03:39 -0000 1.8 --- test.bat 29 Apr 2003 10:06:11 -0000 1.9 *************** *** 1,4 **** del ast\dump*.html ! rem astdump 8 138 KeyedString.h astdump 1 203 ASTDumper.cpp ast astdump 1 524 VariableDeclMutator.cpp ast --- 1,4 ---- del ast\dump*.html ! astdump 1 143 KeyedString.h ast astdump 1 203 ASTDumper.cpp ast astdump 1 524 VariableDeclMutator.cpp ast |
From: <net...@us...> - 2003-04-29 10:03:34
|
Update of /cvsroot/cpptool/rfta/include/rfta/parser In directory sc8-pr-cvs1:/tmp/cvs-serv2595/include/rfta/parser Modified Files: DeclarationParser.h Log Message: -- bugfix function declaration detect Index: DeclarationParser.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/parser/DeclarationParser.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DeclarationParser.h 14 Apr 2003 19:27:04 -0000 1.1 --- DeclarationParser.h 29 Apr 2003 10:03:30 -0000 1.2 *************** *** 32,35 **** --- 32,37 ---- bool parseCommonDeclaration(); + + void backtrackSkippingKeywordsAndSpace(); }; |
From: <net...@us...> - 2003-04-29 10:03:34
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv2595/src/rftaparser Modified Files: DeclarationParser.cpp Log Message: -- bugfix function declaration detect Index: DeclarationParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationParser.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DeclarationParser.cpp 28 Apr 2003 20:40:13 -0000 1.5 --- DeclarationParser.cpp 29 Apr 2003 10:03:30 -0000 1.6 *************** *** 6,10 **** #include "stdafx.h" - #include <rfta/parser/DeclarationParser.h> #include "NamespaceParser.h" #include "UsingNamespaceParser.h" --- 6,9 ---- *************** *** 13,16 **** --- 12,17 ---- #include "TemplateDeclarationParser.h" + #include <rfta/parser/DeclarationParser.h> + #include <rfta/parser/ParserTools.h> #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> *************** *** 81,98 **** backtrackSkippingSpaces(); current_--; ! if (*current_=='y') // special case 'try-function-body' ! { ! if (hasPrevious() && current_[-1]=='r') ! { ! current_--; ! if (hasPrevious() && current_[-1]=='t') ! { ! // TODO: Handle the case of a try-catch-function-body ! throwFailure( "Handling of try-catch-function-body's not yet implemented."); ! } ! } ! // restore position: ! current_ = start_of_curl; ! } if (*current_==')') // check for parameter declaration of a function { --- 82,86 ---- backtrackSkippingSpaces(); current_--; ! backtrackSkippingKeywordsAndSpace(); if (*current_==')') // check for parameter declaration of a function { *************** *** 201,204 **** --- 189,240 ---- return parseCommonDeclaration(); + } + + /** + * function does backtrack skipping over keywords "const", "try" and white spaces + */ + void + DeclarationParser::backtrackSkippingKeywordsAndSpace() + { + Xtl::CStringView cv(start_, current_+1); + Xtl::CStringBackEnumerator backEnumerator = cv.backEnumerate() - cv.getLength(); + + do + { + if (*backEnumerator==' ') + { + backEnumerator++; + current_ = backEnumerator.getCurrentPos()-1; + continue; + } + + Xtl::CStringBackEnumerator saveEnumerator = backEnumerator; + if (!ParserTools::backtrackSkippingOverIdentifier(backEnumerator)) + break; + + Xtl::CStringView help(backEnumerator.getCurrentPos(),saveEnumerator.getCurrentPos()); + std::string ident = help.str(); + if (ident == "const" || ident == "try" ) + current_ = backEnumerator.getCurrentPos()-1; + else + break; + + } while (1); + /* + if (*current_=='y') // special case 'try-function-body' + { + if (hasPrevious() && current_[-1]=='r') + { + current_--; + if (hasPrevious() && current_[-1]=='t') + { + // TODO: Handle the case of a try-catch-function-body + throwFailure( "Handling of try-catch-function-body's not yet implemented."); + } + } + // restore position: + current_ = start_of_curl; + } + */ } |
From: <net...@us...> - 2003-04-29 10:01:28
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv1040/src/rftaparser Modified Files: DeclarationParserTest.h DeclarationParserTest.cpp Log Message: -- additional test for 'operator' keyword Index: DeclarationParserTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationParserTest.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DeclarationParserTest.h 26 Apr 2003 10:50:16 -0000 1.2 --- DeclarationParserTest.h 29 Apr 2003 10:01:25 -0000 1.3 *************** *** 30,33 **** --- 30,34 ---- CPPUNIT_TEST( testTemplateFuntion ); CPPUNIT_TEST( testNestedTemplateClass ); + CPPUNIT_TEST( testOperatorMember ); CPPUNIT_TEST_SUITE_END(); *************** *** 55,58 **** --- 56,60 ---- void testTemplateFuntion(); void testNestedTemplateClass(); + void testOperatorMember(); private: Index: DeclarationParserTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationParserTest.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DeclarationParserTest.cpp 26 Apr 2003 10:50:17 -0000 1.4 --- DeclarationParserTest.cpp 29 Apr 2003 10:01:25 -0000 1.5 *************** *** 7,10 **** --- 7,11 ---- #include "stdafx.h" #include "DeclarationParserTest.h" + #include "KeyedString.h" #include <rfta/parser/ASTNodes.h> #include <rfta/parser/DeclarationParser.h> *************** *** 278,281 **** --- 279,309 ---- startIndex, endIndex-startIndex ); + } + + void + DeclarationParserTest::testOperatorMember() + { + Testing::KeyedString source; + source.setKeyStart("FUNCTION"); + source << "inline "; + source.addKeyed("DECLARATOR" , "KeyedString::operator std::string() const" ) << " "; + source.addKeyed("FUNCTIONBODY","{ return sequence_; }"); + source.setKeyEnd("FUNCTION"); + source << " "; + + SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, + source, + source.length()-2 ); + + RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), + ASTNodeTypes::functionImplementation, + source.getKeyedIndex("FUNCTION",0), + source.getKeyedLen("FUNCTION",0) ); + + // check AST: + //RFTA_ASSERT_DECLARATION( source, sourceAST ); + + // check declarator types: + //RFTA_ASSERT_NODE_TYPE( node->getChildAt(0), ASTNodeTypes::unparsedDeclarator); } |
From: <net...@us...> - 2003-04-29 09:57:05
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv30133/src/rftaparser Modified Files: UnparsedDeclarationMutatorTest.h UnparsedDeclarationMutatorTest.cpp Log Message: -- corrected "UnparsedDeclarationMutator" to be a real Mutator that can be used by MaxLODMutator Index: UnparsedDeclarationMutatorTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UnparsedDeclarationMutatorTest.h 28 Apr 2003 20:36:46 -0000 1.2 --- UnparsedDeclarationMutatorTest.h 29 Apr 2003 09:57:01 -0000 1.3 *************** *** 42,45 **** --- 42,46 ---- CPPUNIT_TEST( testStructTypedef ); CPPUNIT_TEST( testTypedefDeclaration ); + CPPUNIT_TEST( testOperatorMember ); /* class member extensions */ CPPUNIT_TEST( testMemberPure ); *************** *** 86,89 **** --- 87,91 ---- void testMemberConstInit(); void testStructBitfield(); + void testOperatorMember(); private: Index: UnparsedDeclarationMutatorTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** UnparsedDeclarationMutatorTest.cpp 28 Apr 2003 20:36:47 -0000 1.5 --- UnparsedDeclarationMutatorTest.cpp 29 Apr 2003 09:57:01 -0000 1.6 *************** *** 15,19 **** #include <boost/format.hpp> - namespace Refactoring { --- 15,18 ---- *************** *** 24,27 **** --- 23,27 ---- const std::string DECLARATOR = "DECLARATOR"; const std::string SPECIFIERLIST = "SPECIFIERLIST"; + const std::string FUNCTIONBODY = "FUNCTIONBODY"; namespace Testing *************** *** 31,38 **** { SourceASTNodePtr sourceNode = SourceASTNode::create( source, source ); ! ParseContext context( sourceNode ); ! ! // simulate statement level parsing ! ASTNodePtr statement = ASTNode::create( ASTNodeTypes::declarationOrExpression, sourceNode, --- 31,37 ---- { SourceASTNodePtr sourceNode = SourceASTNode::create( source, source ); ! ParseContext context( sourceNode ); ! ! ASTNodePtr decl = ASTNode::create( ASTNodeTypes::declarationOrExpression, sourceNode, *************** *** 40,53 **** source.length(), sourceNode ); ! context.addNode( statement ); // do variable declaration parsing ! UnparsedDeclarationMutator mutator( context, ! statement, ! sourceNode ); ! ! CppUnit::Message message( "mutator failed", ! "Source:\n" + source ); ! CppUnit::Asserter::failIf( !mutator.tryMutate(), message, sourceLine ); return sourceNode; --- 39,47 ---- source.length(), sourceNode ); ! context.addNode( decl ); // do variable declaration parsing ! UnparsedDeclarationMutator mutator; ! mutator.mutate(decl,sourceNode); return sourceNode; *************** *** 198,202 **** Testing::KeyedString source; source.addKeyed(SPECIFIER , "int" ) << " "; ! source.addKeyed(DECLARATOR, "fct(int p1, unsigned int p2, typename tp<int> p3)" ) << ";"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source.asString() ); --- 192,196 ---- Testing::KeyedString source; source.addKeyed(SPECIFIER , "int" ) << " "; ! source.addKeyed(DECLARATOR, "fct(int p1, unsigned int p2, typename tp<int> p3) const" ) << ";"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source.asString() ); *************** *** 218,221 **** --- 212,216 ---- { Testing::KeyedString source; + source.addKeyed(SPECIFIER,"const") << " "; source.setKeyStart(SPECIFIER) << "class x {"; source.addKeyed("CLASS-BODY" , " public: int x() { } " ) << "}" ; *************** *** 231,235 **** // check specifier types: ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty ); ! ASTNodePtr specifier = specifierList->getChildAt(0); RFTA_ASSERT_NODE_TYPE( specifier, ASTNodeTypes::classSpecifier ); --- 226,230 ---- // check specifier types: ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty ); ! ASTNodePtr specifier = specifierList->getChildAt(1); RFTA_ASSERT_NODE_TYPE( specifier, ASTNodeTypes::classSpecifier ); *************** *** 707,710 **** --- 702,723 ---- source.addKeyed(DECLARATOR, "bit0: 1 + 2" ) << ","; source.addKeyed(DECLARATOR, "bit1: 25" ) << ";"; + + 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::testOperatorMember() + { + Testing::KeyedString source; + source.addKeyed(SPECIFIER , "inline" ) << " "; + source.addKeyed(DECLARATOR, "KeyedString::operator std::string() const" ) << " "; + source.addKeyed(FUNCTIONBODY,"{ return sequence_; }"); SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); |
From: <net...@us...> - 2003-04-29 09:56:26
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv29650/src/rftaparser Modified Files: UnparsedDeclarationMutator.h UnparsedDeclarationMutator.cpp UnparsedDeclarationListMutatorTest.cpp Log Message: -- corrected "UnparsedDeclarationMutator" to be a real Mutator that can be used by MaxLODMutator Index: UnparsedDeclarationMutator.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutator.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UnparsedDeclarationMutator.h 26 Apr 2003 11:06:25 -0000 1.1 --- UnparsedDeclarationMutator.h 29 Apr 2003 09:56:21 -0000 1.2 *************** *** 7,12 **** #define RFTA_UnparsedDeclarationMutator_H ! #include <rfta/parser/Parser.h> ! #include <set> namespace Refactoring --- 7,11 ---- #define RFTA_UnparsedDeclarationMutator_H ! #include <rfta/parser/Mutator.h> namespace Refactoring *************** *** 15,19 **** /// Mutate an unparsed-declaration-list into a parsed declaration-list ! class UnparsedDeclarationMutator : public Parser { public: --- 14,19 ---- /// Mutate an unparsed-declaration-list into a parsed declaration-list ! class UnparsedDeclarationMutator : public Mutator ! , public boost::noncopyable { public: *************** *** 22,88 **** * source range must not start with white spaces. */ ! UnparsedDeclarationMutator( ! ParseContext &context, ! const ASTNodePtr &node, ! const SourceASTNodePtr &sourceNode); /// Destructor. virtual ~UnparsedDeclarationMutator(); ! bool tryMutate(); ! ! private: ! ! // ! // private methods for type specifier parsing: ! // ! // ENTRY-Point: ! void parseDeclarationSpecifierList(ASTNodePtr &specifierList); ! ! // parsing of composed specifiers (e.g. "class x { ... }" ! void parseComposedSpecifier(const char * specifierStart, std::string& specifierIdent, ASTNodePtr &specifierList); ! ! /** ! * function does try to read a user defined type (it checks for a variable ! * declaration) ! * returns false in case of the end of specifier list ! */ ! bool tryParseUserDefinedType(std::string& typename_); ! ! void readNestedName(std::string& nestedname); ! void readClassOrEnumSpecifier(ASTNodePtr& specifier, std::string keyword, std::string name); ! ! // ! // private methods for declarator parsing: ! // ! // ENTRY-Point: ! void parseDeclarators(); ! void parseOperator(); ! ! bool tryReadToken(std::string& token); ! ! bool doesKeywordFollow( std::string keyword ); ! static bool tryFindNextBalanced( const char *¤t, ! const char *end, ! char opening = '<', ! char closing = '>' ); ! ! ! bool skipOverAssignmentInitializer(); ! ! void createAndAddInitializerNode( const ASTNodePtr &variableDeclNode ); ! ! void addValueNode( const ASTNodePtr& variableDeclNode, ! int start, ! int end ) const; ! void addInitializerNode( const ASTNodePtr& variableDeclNode, ! const ASTNodeType initializerType, ! int initializerStartIndex ) const; - private: - ASTNodePtr node_; - typedef std::set<std::string> KeywordSet; - KeywordSet declarationSpecifiers; - KeywordSet elaboratedSpecifiers; }; --- 22,33 ---- * source range must not start with white spaces. */ ! UnparsedDeclarationMutator(); /// Destructor. virtual ~UnparsedDeclarationMutator(); ! void mutate( const ASTNodePtr &node, ! const SourceASTNodePtr &sourceNode) const; }; Index: UnparsedDeclarationMutator.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutator.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UnparsedDeclarationMutator.cpp 28 Apr 2003 20:37:54 -0000 1.3 --- UnparsedDeclarationMutator.cpp 29 Apr 2003 09:56:21 -0000 1.4 *************** *** 10,13 **** --- 10,14 ---- #include <rfta/parser/ParseContext.h> #include <rfta/parser/DeclarationListParser.h> + #include "DeclarationDetailsParser.h" *************** *** 16,64 **** ! UnparsedDeclarationMutator::UnparsedDeclarationMutator( ! ParseContext &context, ! const ASTNodePtr &node, ! const SourceASTNodePtr &sourceNode) ! : Parser( context, ! sourceNode->getBlankedSourceStart() + node->getRange().getStartIndex(), ! sourceNode->getBlankedSourceStart() + node->getRange().getEndIndex() ) ! , node_( node ) { - // build lookup table for specifiers: - // generel specifier: - declarationSpecifiers.insert("typedef"); - declarationSpecifiers.insert("friend"); - // storage class - declarationSpecifiers.insert("auto"); - declarationSpecifiers.insert("register"); - declarationSpecifiers.insert("static"); - declarationSpecifiers.insert("extern"); - declarationSpecifiers.insert("mutable"); - // function specifiers - declarationSpecifiers.insert("inline"); - declarationSpecifiers.insert("virtual"); - declarationSpecifiers.insert("explicit"); - // simple type specifiers - declarationSpecifiers.insert("char"); - declarationSpecifiers.insert("wchar_t"); - declarationSpecifiers.insert("bool"); - declarationSpecifiers.insert("short"); - declarationSpecifiers.insert("int"); - declarationSpecifiers.insert("long"); - declarationSpecifiers.insert("signed"); - declarationSpecifiers.insert("unsigned"); - declarationSpecifiers.insert("float"); - declarationSpecifiers.insert("double"); - declarationSpecifiers.insert("void"); - // cv-qualifier - declarationSpecifiers.insert("const"); - declarationSpecifiers.insert("volatile"); - - // build lookup table for elaborated specifiers: - elaboratedSpecifiers.insert("class"); - elaboratedSpecifiers.insert("struct"); - elaboratedSpecifiers.insert("enum"); - elaboratedSpecifiers.insert("union"); - elaboratedSpecifiers.insert("typename"); } --- 17,22 ---- ! UnparsedDeclarationMutator::UnparsedDeclarationMutator() { } *************** *** 69,909 **** - bool - UnparsedDeclarationMutator::tryMutate() - { - ASTNodePtr declarationNode = node_; - node_->mutateType( ASTNodeTypes::declaration ); - - ASTNodePtr specifierList = - createASTNode( - ASTNodeTypes::declarationSpecifierList, - declarationNode, - getCurrentIndex(), - getCurrentLength() - ); - declarationNode->setPropertyNode( - ASTNodeProperties::declarationSpecifiersProperty, - specifierList - ); - - // read the declaration specifier list and add childs to property: - parseDeclarationSpecifierList(specifierList); - - backtrackSkippingSpaces(); - specifierList->setLength(getCurrentLength()); - - skipSpaces(); - - // check if declaration has also a declarator: - if (!tryNextIs(';')) - { - // read all declarators and add childs to property: - parseDeclarators(); - } - - // return with no parsing error: - return true; - } - - /** - * function parses all declaration specifiers until the first declarator is found. - * the decision about the end of the specifier list is done in "tryParseUserDefinedType" - */ - void - UnparsedDeclarationMutator::parseDeclarationSpecifierList(ASTNodePtr &specifierList) - { - std::string identifier; - - const char * save_pointer = getCurrent(); - - while ( save_pointer = getCurrent(), tryReadNextIdentifier(identifier) ) - { - if (declarationSpecifiers.find(identifier) != declarationSpecifiers.end()) - { - // add the specifier node - ASTNodePtr specifier = - createASTNode( - ASTNodeTypes::simpleTypeSpecifier, - specifierList, - save_pointer-getStart(), - getCurrent()-save_pointer - ); - specifierList->addChild(specifier); - - skipSpaces(); - continue; - } - // check elaborated-specifiers: - else if (elaboratedSpecifiers.find(identifier) != elaboratedSpecifiers.end()) - { - skipSpaces(); - parseComposedSpecifier(save_pointer, identifier, specifierList); - skipSpaces(); - continue; - } - else - // check characters after symbol to find out if it's a userdefined type... - if (tryParseUserDefinedType(identifier)) - { - backtrackSkippingSpaces(); - // add the specifier node - ASTNodePtr specifier = - createASTNode( - ASTNodeTypes::simpleTypeSpecifier, - specifierList, - save_pointer-getStart(), - getCurrent()-save_pointer - ); - specifierList->addChild(specifier); - skipSpaces(); - continue; - } - else - { - current_ = save_pointer; - break; - } - } - } - - /** - * function tries to parse elaborated and class/enum/struct/union specifiers - * a decision about the type is found during parsing. - */ - void - UnparsedDeclarationMutator::parseComposedSpecifier(const char * specifierStart, - std::string& specifierIdent, - ASTNodePtr &specifierList) - { - // CASE 1: - // check if identifier starts with a '::') - // (definitions can not start with nested names -> this declaration is an elaborated type - // which ends after the name) - if (tryNextIs(':')) - { - if (!tryNextIs(':')) - { - throwFailure( "Expected a double colon => '::'." ); - } - skipSpaces(); - // read the full name: - std::string name("::"); - readNestedName(name); - - // add the specifier node - ASTNodePtr specifier = - createASTNode( - ASTNodeTypes::elaboratedTypeSpecifier, - specifierList, - specifierStart-getStart(), - getCurrent()-specifierStart - ); - specifierList->addChild(specifier); - - return; - // FINISH HERE - } - - // try to read the identifier that can be specifier after an elaborated type specifier - // if no identifier follows, an unnamed type is specifier (e.g. "struct { } x;") - std::string secondIdent; - if (tryReadNextIdentifier(secondIdent)) - { - skipSpaces(); - } - - // check if no identifier or the identifier is not followed by a ':' (e.g. "class x {" - if (secondIdent.empty() || !tryNextIs(':')) - { - // add the specifier node - ASTNodePtr specifier = - createASTNode( - ASTNodeTypes::classSpecifier, - specifierList, - specifierStart-getStart(), - getCurrent()-specifierStart - ); - specifierList->addChild(specifier); - - readClassOrEnumSpecifier(specifier, specifierIdent, secondIdent); - - // set real length after completed parsing - specifier->setLength(getCurrent()-specifierStart); - - return; - } - - // 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 - if (specifierIdent == "class" || specifierIdent == "struct" || specifierIdent == "union") - { - - // add the specifier node - ASTNodePtr specifier = - createASTNode( - ASTNodeTypes::classSpecifier, - specifierList, - specifierStart-getStart(), - getCurrent()-specifierStart - ); - specifierList->addChild(specifier); - - // read the complete specifier: - readClassOrEnumSpecifier(specifier, specifierIdent, secondIdent); - - // set real length after completed parsing - specifier->setLength(getCurrent()-specifierStart); - - return; - // FINISH HERE (the class specifier ends here !) - } - throwFailure( "Expected a double colon => '::'." ); - } - - // HERE we come only in case of a double colon after the identifier which means: - // an elaborated type is specified: e.g. "class x::y" - skipSpaces(); - - // read the full name: - secondIdent.append("::"); - readNestedName(secondIdent); - - // add the specifier node - ASTNodePtr specifier = - createASTNode( - ASTNodeTypes::elaboratedTypeSpecifier, - specifierList, - specifierStart-getStart(), - getCurrent()-specifierStart - ); - specifierList->addChild(specifier); - // set real length after completed parsing - specifier->setLength(getCurrent()-specifierStart); - } - - bool - UnparsedDeclarationMutator::tryParseUserDefinedType(std::string& typename_) - { - // the 'typename_' might be a userdefined type or a declarator - // here we try to find out: - if (typename_ == "operator") - return false; - - // first read the fully qualified name: - skipSpaces(); - // maybe a full qualified typename (e.g. "std::string") - if (tryNextIs(':')) - { - if (!tryNextIs(':')) - { - --current_; - return false; // it's not "::" - might be the bitfield operator (e.g. "int myvar:0") - } - typename_.append("::"); - readNestedName(typename_); - skipSpaces(); - } - - // do some look ahead for the decision (store rollback position - const char * rollback = current_; - - // now check for template declaration: - if (tryNextIs('<')) // the use of a template type - { - // skip template usage: - findNextBalanced('<','>'); - skipSpaces(); - // check if it has parameter: - if (tryNextIs('(')) - if (!this->tryReadUntilNext(')')) - throwFailure("Expect a closed parameter list for this template."); - - return true; // yes, it's a user defined type ! - } - - // DO SOME LOOK AHEAD TO FIND OUT - // a possible declarator that follows: - // check existence of a next identifier, this is a sign for a userdefined type... - std::string identifier; - if (tryReadNextIdentifier(identifier)) - { - current_ = rollback; - return true; - } - - // check for a special case where the declarator starts with a '(' - // example: "int (*(*f))(int); - - if (tryNextIs('(')) // might be the declarator (e.g. "usertype (*f);" or a parameter (e.g. "int userfct()"; - { - findNextBalanced('(',')'); - } - skipSpaces(); - std::string seperators=",;=["; - bool ret = seperators.find(*current_) == std::string::npos; - - current_ = rollback; - return ret; - } - - void - UnparsedDeclarationMutator::readNestedName(std::string& nestedname) - { - std::string fullName = nestedname; - std::string nameSpecifier; - bool oneMoreLevel; - do { - oneMoreLevel = false; - if (!tryReadNextIdentifier(nameSpecifier)) - throwFailure( "Expected an identifier for elaborated type." ); - - fullName.append(nameSpecifier); - - skipSpaces(); - // check if identifier is followed by a '::' (additional level - if (tryNextIs(':')) - { - if (!tryNextIs(':')) - { - --current_; - return; // // it's not a "::" - might be the bitfield operator (e.g. "int myvar::sub :0") - } - - fullName.append("::"); - - skipSpaces(); - oneMoreLevel = true; - } - } while (oneMoreLevel); - backtrackSkippingSpaces(); - } - - void - UnparsedDeclarationMutator::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(getCurrentLength() - startIndex - 1 ); // do not count the last '}' - } - - bool - UnparsedDeclarationMutator::tryFindNextBalanced( const char *¤t, - const char *end, - char opening, - char closing ) - { - int balance = 1; - while ( ++current != end ) - { - char c = *current; - if ( c == closing ) - { - --balance; - if ( balance == 0 ) - { - ++current; - return true; - } - } - else if ( c == opening ) - ++balance; - } - - return false; - } - - - bool - UnparsedDeclarationMutator::skipOverAssignmentInitializer() - { - const char *start = current_; - while ( current_ != end_ ) - { - char c = *current_; - if ( c == ';' || c == ',' ) - return current_ != (start+1); - else if ( c == '(' ) - { - if ( !tryFindNextBalanced( current_, end_, '(', ')' ) ) - return false; - } - else if ( c == '[' ) - { - if ( !tryFindNextBalanced( current_, end_, '[', ']' ) ) - return false; - } - else if ( c == '{' ) - { - if ( !tryFindNextBalanced( current_, end_, '{', '}' ) ) - return false; - } - else - ++current_; - } - - return true; - } - - void - UnparsedDeclarationMutator::parseDeclarators() - { - Tracker tracker( "UnparsedDeclarationMutator::parseDeclarators", *this ); - - int declaratorNumber = 1; - int prefixEndIndex = getCurrentIndex(); - - while ( current_ != end_ ) - { - skipSpaces(); - int declaratorStartIndex = getCurrentIndex(); - - if (doesKeywordFollow( "operator" )) - { - parseOperator(); - return; - } - - // find end of the init-declarator - bool declaratorEndReached = false; - bool functionDeclarator = false; - bool identifierFound = false; - do { - skipSpaces(); - if (tryNextIs('*')) continue; - if (tryNextIs('&')) continue; - if (tryNextIs('(')) - { - // check if this is a direct declaration of a function: - if (identifierFound) - { - functionDeclarator = true; - findNextBalanced('(',')'); - } else - { - findNextBalanced('(',')'); - readUntilNextOf(";,=("); - if (tryNextIs('(')) - { - functionDeclarator = true; - findNextBalanced('(',')'); - } - } - declaratorEndReached = true; - break; - } - if (tryNextIs('[')) - { - findNextBalanced('[',']'); - continue; - } - if (tryNextIs(';') || tryNextIs(',') || tryNextIs('=') || tryNextIs('{')) - { - declaratorEndReached = true; - --current_; - break; - } - - std::string nestedName; - if (tryNextIs(':')) - { - if (!tryNextIs(':')) - throwFailure("Did not expect a single colon at this stage."); - - nestedName = "::"; - } - - 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(identifier); - } - - // check for bitfield expression - if (tryNextIs(':')) - { - if (!skipOverAssignmentInitializer()) - throwFailure("Constant expression is not well formed."); - // @todo: store bit field expression - } - continue; - } - } while (hasNext() && !declaratorEndReached); - - if (!declaratorEndReached) - { - boost::format frmt( "failed to find expected declarator separator " - "for declaration %1%: ',;=({'. "); - throwFailure( frmt % declaratorNumber ); - } - - if (functionDeclarator) - { - // read the possible identifiers after function declarator: - bool found; - do { - skipSpaces(); - found=false; - if (doesKeywordFollow("const") ) { found=true; } - if (doesKeywordFollow("volatile") ) { found=true; } - } while (found); - - if (doesKeywordFollow("throw")) - { - skipSpaces(); - expect('('); - readUntilNextOf(")"); - if (*current_==')') ++current_; - } - } - ASTNodePtr - declaratorNode = createASTNode( ASTNodeTypes::unparsedDeclarator, - node_, - declaratorStartIndex, - getCurrentIndex() - declaratorStartIndex ); - // the correct length is set when the initializer is added. - node_->addChild(declaratorNode); - - // now go through initializers: - createAndAddInitializerNode(declaratorNode); - declaratorNumber++; - } - } - - - void - UnparsedDeclarationMutator::createAndAddInitializerNode( const ASTNodePtr &declaratorNode ) - { - if ( !hasNext() ) - return; - - Tracker tracker( "UnparsedDeclarationMutator::createAndAddInitializerNode", *this ); - - int initializerStartIndex = getCurrentIndex(); - int initializerValueStartIndex; - int initializerValueEndIndex; - int declaratorEndIndex; - ASTNodeType initializerType; - switch( *current_++ ) - { - case '=': - initializerType = ASTNodeTypes::assignVariableInitializerExpression; - skipSpaces(); - initializerValueStartIndex = getCurrentIndex(); - skipOverAssignmentInitializer(); /// @todo should check return value - declaratorEndIndex = getCurrentIndex(); - initializerValueEndIndex = getCurrentIndex(); - break; - case '(': - initializerType = ASTNodeTypes::constructorVariableInitializerExpression; - initializerValueStartIndex = getCurrentIndex(); - findNextBalanced( '(', ')' ); - declaratorEndIndex = getCurrentIndex(); - initializerValueEndIndex = getCurrentIndex() -1; - break; - case ';': case ',': case '{': - return; - default: - -- current_; - throwFailure( boost::format("unexpected character: '%1%'.") % *current_ ); - } - - declaratorNode->setLength( declaratorEndIndex - - declaratorNode->getStartIndex() ); - addInitializerNode( declaratorNode, - initializerType, - initializerStartIndex ); - addValueNode( declaratorNode, - initializerValueStartIndex, - initializerValueEndIndex ); - - skipSpaces(); - if ( !hasNext() ) - return; - - if ( *current_ == ';' || *current_ == ',' ) - ++current_; - else - throwFailure( boost::format("unexpected character: '%1%'.") % *current_ ); - } - void ! UnparsedDeclarationMutator::addValueNode( const ASTNodePtr& declaratorNode, ! int start, ! int end) const ! { ! ASTNodePtr initializerNode = ! declaratorNode->getProperty( ASTNodeProperties::variableInitializerProperty ); ! ASTNodePtr valueNode = ! createASTNode( ASTNodeTypes::valueExpression, ! initializerNode, ! start, ! end-start); ! initializerNode->setPropertyNode( ASTNodeProperties::valueProperty, ! valueNode ); ! } ! ! ! void ! UnparsedDeclarationMutator::addInitializerNode( const ASTNodePtr& declaratorNode, ! const ASTNodeType initializerType, ! int initializerStartIndex) const ! { ! int initializerLength = getCurrentIndex() - initializerStartIndex; ! ! ASTNodePtr initializerNode = createASTNode( initializerType, ! declaratorNode, ! initializerStartIndex, ! initializerLength ); ! declaratorNode->setPropertyNode( ASTNodeProperties::variableInitializerProperty, ! initializerNode ); ! } ! ! bool ! UnparsedDeclarationMutator::doesKeywordFollow( std::string keyword) ! { ! int idx = 0; ! const char * save = getCurrent(); ! ! std::string id; ! bool retval = tryReadNextIdentifier(id) & id == keyword; ! if (!retval) current_ = save; ! ! return retval; ! } ! ! bool ! UnparsedDeclarationMutator::tryReadToken(std::string& token) ! { ! std::string collect; ! switch(*current_++) ! { ! case '+': ! if (*current_== '=' ) ! { current_++; collect="+="; } ! else ! if (*current_== '+' ) ! { current_++; collect="++"; } ! else ! collect="+"; ! break; ! ! case '-': ! if (*current_== '=' ) ! { current_++; collect="-="; } ! else ! if (*current_== '-' ) ! { current_++; collect="--"; } ! else ! if (*current_== '>' ) ! { ! current_++; ! if (*current_== '*' ) ! { current_++; collect="->*"; } ! else ! collect="->"; ! } ! else ! collect="-"; ! break; ! ! case '*': ! if (*current_== '=' ) ! { current_++; collect="*="; } ! else ! collect="*"; ! break; ! ! case '/': ! if (*current_== '=' ) ! { current_++; collect="/="; } ! else ! collect="/"; ! break; ! ! case '^': ! if (*current_== '=' ) ! { current_++; collect="^="; } ! else ! collect="^"; ! break; ! ! case '&': ! if (*current_== '=' ) ! { current_++; collect="&="; } ! else ! if (*current_== '&' ) ! { current_++; collect="&&"; } ! else ! collect="&"; ! break; ! ! case '|': ! if (*current_== '=' ) ! { current_++; collect="|="; } ! else ! if (*current_== '|' ) ! { current_++; collect="||"; } ! else ! collect="|"; ! break; ! ! case '~': ! collect="~"; ! break; ! ! case '!': ! if (*current_== '=' ) ! { current_++; collect="!="; } ! else ! collect="!"; ! break; ! ! case '=': ! if (*current_== '=' ) ! { current_++; collect="=="; } ! else ! collect="="; ! break; ! ! case '<': ! if (*current_== '=' ) ! { current_++; collect="<="; } ! else ! if (*current_== '<' ) ! { ! current_++; ! if (*current_== '=' ) ! { ! current_++; collect="<<="; ! } ! else ! collect="<<"; ! } ! else ! collect="<"; ! break; ! ! case '>': ! if (*current_== '=' ) ! { current_++; collect=">="; } ! else ! if (*current_== '>' ) ! { ! current_++; ! if (*current_== '=' ) ! { ! current_++; collect=">>="; ! } ! else ! collect=">>"; ! } ! else ! collect=">"; ! break; ! ! case ',': ! collect=","; ! break; ! case '(': ! expect(')'); ! collect="()"; ! break; ! case '[': ! expect(']'); ! collect="[]"; ! break; ! ! default: ! --current_; ! break; ! } ! token = collect; ! return !token.empty(); ! } ! ! void ! UnparsedDeclarationMutator::parseOperator() ! { ! int declaratorStartIndex = getCurrentIndex() - strlen("operator"); ! skipSpaces(); ! ! std::string token; ! ! if (!tryReadToken(token)) ! { ! const char * begin = getCurrent(); ! if ( doesKeywordFollow("new") ) token += "new"; ! if ( doesKeywordFollow("delete") ) token += "delete"; ! if (!token.empty()) ! { ! if ( tryReadNext("[]") ) token+="[]"; ! } ! } ! // check if operator overloading has been parsed ! if (token.empty()) ! { ! // this is not the case. ! // this is 'conversion function declarator': ! ! // skip over the type-specifier and ptr-operator elements ! readUntilNextOf("("); ! } ! ! // now read parameters: (for both operator and conversion function) ! skipSpaces(); ! expect('('); ! findNextBalanced('(',')'); ! ASTNodePtr declaratorNode = createASTNode( ASTNodeTypes::unparsedDeclarator, ! node_, ! declaratorStartIndex, ! getCurrentIndex() - declaratorStartIndex ); ! node_->addChild(declaratorNode); ! skipSpaces(); } - } // namespace Refactoring --- 27,40 ---- void ! UnparsedDeclarationMutator::mutate(const ASTNodePtr &node, ! const SourceASTNodePtr &sourceNode) const ! { ! ParseContext context( sourceNode ); ! DeclarationDetailsParser detailsparser( context, ! node, ! sourceNode ); ! detailsparser.tryParse(); } } // namespace Refactoring Index: UnparsedDeclarationListMutatorTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationListMutatorTest.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UnparsedDeclarationListMutatorTest.cpp 28 Apr 2003 20:38:28 -0000 1.2 --- UnparsedDeclarationListMutatorTest.cpp 29 Apr 2003 09:56:21 -0000 1.3 *************** *** 7,11 **** #include "stdafx.h" #include "UnparsedDeclarationListMutator.h" ! #include "UnparsedDeclarationMutator.h" #include "NamespaceParser.h" #include "KeyedString.h" --- 7,11 ---- #include "stdafx.h" #include "UnparsedDeclarationListMutator.h" ! #include "DeclarationDetailsParser.h" #include "NamespaceParser.h" #include "KeyedString.h" *************** *** 112,122 **** // do variable declaration parsing ! UnparsedDeclarationMutator mutator( context, ! classNode, ! sourceNode ); ! CppUnit::Message message( "mutator failed", "Source:\n" + source.asString() ); ! CppUnit::Asserter::failIf( !mutator.tryMutate(), message, CPPUNIT_SOURCELINE() ); --- 112,122 ---- // do variable declaration parsing ! DeclarationDetailsParser detailsparser( context, ! classNode, ! sourceNode ); ! CppUnit::Message message( "Parser failed", "Source:\n" + source.asString() ); ! CppUnit::Asserter::failIf( !detailsparser.tryParse(), message, CPPUNIT_SOURCELINE() ); |
From: <net...@us...> - 2003-04-29 09:55:42
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv29065/src/rftaparser Added Files: DeclarationDetailsParser.h DeclarationDetailsParser.cpp Log Message: -- corrected "UnparsedDeclarationMutator" to be a real Mutator that can be used by MaxLODMutator --- NEW FILE: DeclarationDetailsParser.h --- // ////////////////////////////////////////////////////////////////////////// // Header file DeclarationDetailsParser.h for class DeclarationDetailsParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/18 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_DeclarationDetailsParser_H #define RFTA_DeclarationDetailsParser_H #include <rfta/parser/Parser.h> #include <set> namespace Refactoring { /// Mutate an unparsed-declaration-list into a parsed declaration-list class DeclarationDetailsParser : public Parser { public: /*! Constructs a DeclarationDetailsParser object. * * source range must not start with white spaces. */ DeclarationDetailsParser( ParseContext &context, const ASTNodePtr &node, const SourceASTNodePtr &sourceNode); /// Destructor. virtual ~DeclarationDetailsParser(); bool tryParse(); private: // // private methods for type specifier parsing: // // ENTRY-Point: void parseDeclarationSpecifierList(ASTNodePtr &specifierList); // parsing of composed specifiers (e.g. "class x { ... }" void parseComposedSpecifier(int specifierStart, std::string& specifierIdent, ASTNodePtr &specifierList); /** * function does try to read a user defined type (it checks for a variable * declaration) * returns false in case of the end of specifier list */ bool tryParseUserDefinedType(std::string& typename_); void readNestedName(std::string& nestedname); void readClassOrEnumSpecifier(ASTNodePtr& specifier, std::string keyword, std::string name); // // private methods for declarator parsing: // // ENTRY-Point: void parseDeclarators(); // parser has to stay at the character after the operator keyword... void parseOperator(int declaratorStartIndex); bool tryReadToken(std::string& token); bool doesKeywordFollow( std::string keyword ); static bool tryFindNextBalanced( const char *¤t, const char *end, char opening = '<', char closing = '>' ); bool skipOverAssignmentInitializer(); void createAndAddInitializerNode( const ASTNodePtr &variableDeclNode ); void addValueNode( const ASTNodePtr& variableDeclNode, int start, int end ) const; void addInitializerNode( const ASTNodePtr& variableDeclNode, const ASTNodeType initializerType, int initializerStartIndex ) const; static bool isOperatorIdentifier(std::string name); private: ASTNodePtr node_; typedef std::set<std::string> KeywordSet; KeywordSet declarationSpecifiers; KeywordSet elaboratedSpecifiers; }; // Inlines methods for DeclarationDetailsParser: // -------------------------------------------- } // namespace Refactoring #endif // RFTA_DeclarationDetailsParser_H --- NEW FILE: DeclarationDetailsParser.cpp --- // ////////////////////////////////////////////////////////////////////////// // Implementation file DeclarationDetailsParser.cpp for class DeclarationDetailsParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/18 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "DeclarationDetailsParser.h" #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> #include <rfta/parser/DeclarationListParser.h> namespace Refactoring { DeclarationDetailsParser::DeclarationDetailsParser( ParseContext &context, const ASTNodePtr &node, const SourceASTNodePtr &sourceNode) : Parser( context, sourceNode->getBlankedSourceStart() + node->getRange().getStartIndex(), sourceNode->getBlankedSourceStart() + node->getRange().getEndIndex() ) , node_( node ) { // build lookup table for specifiers: // generel specifier: declarationSpecifiers.insert("typedef"); declarationSpecifiers.insert("friend"); // storage class declarationSpecifiers.insert("auto"); declarationSpecifiers.insert("register"); declarationSpecifiers.insert("static"); declarationSpecifiers.insert("extern"); declarationSpecifiers.insert("mutable"); // function specifiers declarationSpecifiers.insert("inline"); declarationSpecifiers.insert("virtual"); declarationSpecifiers.insert("explicit"); // simple type specifiers declarationSpecifiers.insert("char"); declarationSpecifiers.insert("wchar_t"); declarationSpecifiers.insert("bool"); declarationSpecifiers.insert("short"); declarationSpecifiers.insert("int"); declarationSpecifiers.insert("long"); declarationSpecifiers.insert("signed"); declarationSpecifiers.insert("unsigned"); declarationSpecifiers.insert("float"); declarationSpecifiers.insert("double"); declarationSpecifiers.insert("void"); // cv-qualifier declarationSpecifiers.insert("const"); declarationSpecifiers.insert("volatile"); // build lookup table for elaborated specifiers: elaboratedSpecifiers.insert("class"); elaboratedSpecifiers.insert("struct"); elaboratedSpecifiers.insert("enum"); elaboratedSpecifiers.insert("union"); elaboratedSpecifiers.insert("typename"); } DeclarationDetailsParser::~DeclarationDetailsParser() { } bool DeclarationDetailsParser::tryParse() { ASTNodePtr declarationNode = node_; node_->mutateType( ASTNodeTypes::declaration ); ASTNodePtr specifierList = createASTNode( ASTNodeTypes::declarationSpecifierList, declarationNode, getCurrentIndex(), getCurrentLength() ); declarationNode->setPropertyNode( ASTNodeProperties::declarationSpecifiersProperty, specifierList ); // read the declaration specifier list and add childs to property: parseDeclarationSpecifierList(specifierList); backtrackSkippingSpaces(); specifierList->setLength(getCurrentLength()); skipSpaces(); // check if declaration has also a declarator: if (!tryNextIs(';')) { // read all declarators and add childs to property: parseDeclarators(); } // return with no parsing error: return true; } /** * function parses all declaration specifiers until the first declarator is found. * the decision about the end of the specifier list is done in "tryParseUserDefinedType" */ void DeclarationDetailsParser::parseDeclarationSpecifierList(ASTNodePtr &specifierList) { std::string identifier; const char * save_pointer = getCurrent(); int lastIndex; while ( save_pointer = getCurrent(),lastIndex=getCurrentIndex(), tryReadNextIdentifier(identifier) ) { if (declarationSpecifiers.find(identifier) != declarationSpecifiers.end()) { // add the specifier node ASTNodePtr specifier = createASTNode( ASTNodeTypes::simpleTypeSpecifier, specifierList, lastIndex, getCurrentIndex()-lastIndex ); specifierList->addChild(specifier); skipSpaces(); continue; } // check elaborated-specifiers: else if (elaboratedSpecifiers.find(identifier) != elaboratedSpecifiers.end()) { skipSpaces(); parseComposedSpecifier(lastIndex, identifier, specifierList); skipSpaces(); continue; } else // check characters after symbol to find out if it's a userdefined type... if (tryParseUserDefinedType(identifier)) { backtrackSkippingSpaces(); // add the specifier node ASTNodePtr specifier = createASTNode( ASTNodeTypes::simpleTypeSpecifier, specifierList, lastIndex, getCurrentIndex()-lastIndex ); specifierList->addChild(specifier); skipSpaces(); continue; } else { current_ = save_pointer; break; } } } /** * function tries to parse elaborated and class/enum/struct/union specifiers * a decision about the type is found during parsing. */ void DeclarationDetailsParser::parseComposedSpecifier( int specifierStart, std::string& specifierIdent, ASTNodePtr &specifierList) { // CASE 1: // check if identifier starts with a '::') // (definitions can not start with nested names -> this declaration is an elaborated type // which ends after the name) if (tryNextIs(':')) { if (!tryNextIs(':')) { throwFailure( "Expected a double colon => '::'." ); } skipSpaces(); // read the full name: std::string name("::"); readNestedName(name); // add the specifier node ASTNodePtr specifier = createASTNode( ASTNodeTypes::elaboratedTypeSpecifier, specifierList, specifierStart, getCurrentIndex()-specifierStart ); specifierList->addChild(specifier); return; // FINISH HERE } // try to read the identifier that can be specifier after an elaborated type specifier // if no identifier follows, an unnamed type is specifier (e.g. "struct { } x;") std::string secondIdent; if (tryReadNextIdentifier(secondIdent)) { skipSpaces(); } // check if no identifier or the identifier is not followed by a ':' (e.g. "class x {" if (secondIdent.empty() || !tryNextIs(':')) { // add the specifier node ASTNodePtr specifier = createASTNode( ASTNodeTypes::classSpecifier, specifierList, specifierStart, getCurrentIndex()-specifierStart ); specifierList->addChild(specifier); readClassOrEnumSpecifier(specifier, specifierIdent, secondIdent); // set real length after completed parsing specifier->setLength(getCurrentIndex()-specifierStart); return; } // 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 if (specifierIdent == "class" || specifierIdent == "struct" || specifierIdent == "union") { // add the specifier node ASTNodePtr specifier = createASTNode( ASTNodeTypes::classSpecifier, specifierList, specifierStart, getCurrentIndex()-specifierStart ); specifierList->addChild(specifier); // read the complete specifier: readClassOrEnumSpecifier(specifier, specifierIdent, secondIdent); // set real length after completed parsing specifier->setLength(getCurrentIndex()-specifierStart); return; // FINISH HERE (the class specifier ends here !) } throwFailure( "Expected a double colon => '::'." ); } // HERE we come only in case of a double colon after the identifier which means: // an elaborated type is specified: e.g. "class x::y" skipSpaces(); // read the full name: secondIdent.append("::"); readNestedName(secondIdent); // add the specifier node ASTNodePtr specifier = createASTNode( ASTNodeTypes::elaboratedTypeSpecifier, specifierList, specifierStart, getCurrentIndex()-specifierStart ); specifierList->addChild(specifier); // set real length after completed parsing specifier->setLength(getCurrentIndex()-specifierStart); } bool DeclarationDetailsParser::tryParseUserDefinedType(std::string& typename_) { // the 'typename_' might be a userdefined type or a declarator // here we try to find out: if (typename_ == "operator") return false; // first read the fully qualified name: skipSpaces(); // maybe a full qualified typename (e.g. "std::string") if (tryNextIs(':')) { if (!tryNextIs(':')) { --current_; return false; // it's not "::" - might be the bitfield operator (e.g. "int myvar:0") } typename_.append("::"); readNestedName(typename_); skipSpaces(); // check for member operator: e.g. "x::operator" if (isOperatorIdentifier(typename_)) { return false; } } // do some look ahead for the decision (store rollback position const char * rollback = current_; // now check for template declaration: if (tryNextIs('<')) // the use of a template type { // skip template usage: findNextBalanced('<','>'); skipSpaces(); // check if it has parameter: if (tryNextIs('(')) if (!this->tryReadUntilNext(')')) throwFailure("Expect a closed parameter list for this template."); return true; // yes, it's a user defined type ! } // DO SOME LOOK AHEAD TO FIND OUT // a possible declarator that follows: // check existence of a next identifier, this is a sign for a userdefined type... std::string identifier; if (tryReadNextIdentifier(identifier)) { current_ = rollback; return true; } // check for a special case where the declarator starts with a '(' // example: "int (*(*f))(int) const;" if (tryNextIs('(')) // might be the declarator (e.g. "usertype (*f);" or a parameter (e.g. "int userfct()"; { findNextBalanced('(',')'); } // check the characters follow the braces: skipSpaces(); if (tryReadNextIdentifier(identifier)) { // the "const" keyword is allowed for function declarations if (identifier!="const") { // but it's not the 'const' current_ = rollback; return false; // this was not a function-declarator, } } std::string seperators=",;=["; bool ret = seperators.find(*current_) == std::string::npos; current_ = rollback; return ret; } void DeclarationDetailsParser::readNestedName(std::string& nestedname) { std::string nameSpecifier; bool oneMoreLevel; do { oneMoreLevel = false; if (!tryReadNextIdentifier(nameSpecifier)) throwFailure( "Expected an identifier for elaborated type." ); nestedname.append(nameSpecifier); skipSpaces(); // check if identifier is followed by a '::' (additional level if (tryNextIs(':')) { if (!tryNextIs(':')) { --current_; return; // // it's not a "::" - might be the bitfield operator (e.g. "int myvar::sub :0") } nestedname.append("::"); skipSpaces(); oneMoreLevel = true; } } while (oneMoreLevel); backtrackSkippingSpaces(); } 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(getCurrentLength() - startIndex - 1 ); // do not count the last '}' } bool DeclarationDetailsParser::tryFindNextBalanced( const char *¤t, const char *end, char opening, char closing ) { int balance = 1; while ( ++current != end ) { char c = *current; if ( c == closing ) { --balance; if ( balance == 0 ) { ++current; return true; } } else if ( c == opening ) ++balance; } return false; } bool DeclarationDetailsParser::skipOverAssignmentInitializer() { const char *start = current_; while ( current_ != end_ ) { char c = *current_; if ( c == ';' || c == ',' ) return current_ != (start+1); else if ( c == '(' ) { if ( !tryFindNextBalanced( current_, end_, '(', ')' ) ) return false; } else if ( c == '[' ) { if ( !tryFindNextBalanced( current_, end_, '[', ']' ) ) return false; } else if ( c == '{' ) { if ( !tryFindNextBalanced( current_, end_, '{', '}' ) ) return false; } else ++current_; } return true; } void DeclarationDetailsParser::parseDeclarators() { Tracker tracker( "DeclarationDetailsParser::parseDeclarators", *this ); int declaratorNumber = 1; while ( current_ != end_ ) { skipSpaces(); int declaratorStartIndex = getCurrentIndex(); // find end of the init-declarator bool declaratorEndReached = false; bool functionDeclarator = false; bool identifierFound = false; do { skipSpaces(); if (tryNextIs('*')) continue; if (tryNextIs('&')) continue; if (tryNextIs('(')) { // check if this is a direct declaration of a function: if (identifierFound) { functionDeclarator = true; findNextBalanced('(',')'); } else { findNextBalanced('(',')'); readUntilNextOf(";,=("); if (tryNextIs('(')) { functionDeclarator = true; findNextBalanced('(',')'); } } declaratorEndReached = true; break; } if (tryNextIs('[')) { findNextBalanced('[',']'); continue; } if (tryNextIs(';') || tryNextIs(',') || tryNextIs('=') || tryNextIs('{')) { declaratorEndReached = true; --current_; break; } std::string nestedName; if (tryNextIs(':')) { if (!tryNextIs(':')) throwFailure("Did not expect a single colon at this stage."); nestedName = "::"; } 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); if (!declaratorEndReached) { boost::format frmt( "failed to find expected declarator separator " "for declaration %1%: ',;=({'. "); throwFailure( frmt % declaratorNumber ); } if (functionDeclarator) { // read the possible identifiers after function declarator: bool found; do { skipSpaces(); found=false; if (doesKeywordFollow("const") ) { found=true; } if (doesKeywordFollow("volatile") ) { found=true; } } while (found); if (doesKeywordFollow("throw")) { skipSpaces(); expect('('); readUntilNextOf(")"); if (*current_==')') ++current_; } } ASTNodePtr declaratorNode = createASTNode( ASTNodeTypes::unparsedDeclarator, node_, declaratorStartIndex, getCurrentIndex() - declaratorStartIndex ); // the correct length is set when the initializer is added. node_->addChild(declaratorNode); // now go through initializers: createAndAddInitializerNode(declaratorNode); declaratorNumber++; } } void DeclarationDetailsParser::createAndAddInitializerNode( const ASTNodePtr &declaratorNode ) { if ( !hasNext() ) return; Tracker tracker( "DeclarationDetailsParser::createAndAddInitializerNode", *this ); int initializerStartIndex = getCurrentIndex(); int initializerValueStartIndex; int initializerValueEndIndex; int declaratorEndIndex; ASTNodeType initializerType; switch( *current_++ ) { case '=': initializerType = ASTNodeTypes::assignVariableInitializerExpression; skipSpaces(); initializerValueStartIndex = getCurrentIndex(); skipOverAssignmentInitializer(); /// @todo should check return value declaratorEndIndex = getCurrentIndex(); initializerValueEndIndex = getCurrentIndex(); break; case '(': initializerType = ASTNodeTypes::constructorVariableInitializerExpression; initializerValueStartIndex = getCurrentIndex(); findNextBalanced( '(', ')' ); declaratorEndIndex = getCurrentIndex(); initializerValueEndIndex = getCurrentIndex() -1; break; case ';': case ',': case '{': return; default: -- current_; throwFailure( boost::format("unexpected character: '%1%'.") % *current_ ); } declaratorNode->setLength( declaratorEndIndex - declaratorNode->getStartIndex() ); addInitializerNode( declaratorNode, initializerType, initializerStartIndex ); addValueNode( declaratorNode, initializerValueStartIndex, initializerValueEndIndex ); skipSpaces(); if ( !hasNext() ) return; if ( *current_ == ';' || *current_ == ',' ) ++current_; else throwFailure( boost::format("unexpected character: '%1%'.") % *current_ ); } void DeclarationDetailsParser::addValueNode( const ASTNodePtr& declaratorNode, int start, int end) const { ASTNodePtr initializerNode = declaratorNode->getProperty( ASTNodeProperties::variableInitializerProperty ); ASTNodePtr valueNode = createASTNode( ASTNodeTypes::valueExpression, initializerNode, start, end-start); initializerNode->setPropertyNode( ASTNodeProperties::valueProperty, valueNode ); } void DeclarationDetailsParser::addInitializerNode( const ASTNodePtr& declaratorNode, const ASTNodeType initializerType, int initializerStartIndex) const { int initializerLength = getCurrentIndex() - initializerStartIndex; ASTNodePtr initializerNode = createASTNode( initializerType, declaratorNode, initializerStartIndex, initializerLength ); declaratorNode->setPropertyNode( ASTNodeProperties::variableInitializerProperty, initializerNode ); } bool DeclarationDetailsParser::doesKeywordFollow( std::string keyword) { int idx = 0; const char * save = getCurrent(); std::string id; bool retval = tryReadNextIdentifier(id) & id == keyword; if (!retval) current_ = save; return retval; } bool DeclarationDetailsParser::tryReadToken(std::string& token) { std::string collect; switch(*current_++) { case '+': if (*current_== '=' ) { current_++; collect="+="; } else if (*current_== '+' ) { current_++; collect="++"; } else collect="+"; break; case '-': if (*current_== '=' ) { current_++; collect="-="; } else if (*current_== '-' ) { current_++; collect="--"; } else if (*current_== '>' ) { current_++; if (*current_== '*' ) { current_++; collect="->*"; } else collect="->"; } else collect="-"; break; case '*': if (*current_== '=' ) { current_++; collect="*="; } else collect="*"; break; case '/': if (*current_== '=' ) { current_++; collect="/="; } else collect="/"; break; case '^': if (*current_== '=' ) { current_++; collect="^="; } else collect="^"; break; case '&': if (*current_== '=' ) { current_++; collect="&="; } else if (*current_== '&' ) { current_++; collect="&&"; } else collect="&"; break; case '|': if (*current_== '=' ) { current_++; collect="|="; } else if (*current_== '|' ) { current_++; collect="||"; } else collect="|"; break; case '~': collect="~"; break; case '!': if (*current_== '=' ) { current_++; collect="!="; } else collect="!"; break; case '=': if (*current_== '=' ) { current_++; collect="=="; } else collect="="; break; case '<': if (*current_== '=' ) { current_++; collect="<="; } else if (*current_== '<' ) { current_++; if (*current_== '=' ) { current_++; collect="<<="; } else collect="<<"; } else collect="<"; break; case '>': if (*current_== '=' ) { current_++; collect=">="; } else if (*current_== '>' ) { current_++; if (*current_== '=' ) { current_++; collect=">>="; } else collect=">>"; } else collect=">"; break; case ',': collect=","; break; case '(': expect(')'); collect="()"; break; case '[': expect(']'); collect="[]"; break; default: --current_; break; } token = collect; return !token.empty(); } void DeclarationDetailsParser::parseOperator(int declaratorStartIndex) { skipSpaces(); std::string token; if (!tryReadToken(token)) { const char * begin = getCurrent(); if ( doesKeywordFollow("new") ) token += "new"; if ( doesKeywordFollow("delete") ) token += "delete"; if (!token.empty()) { if ( tryReadNext("[]") ) token+="[]"; } } // check if operator overloading has been parsed if (token.empty()) { // this is not the case. // this is 'conversion function declarator': // skip over the type-specifier and ptr-operator elements readUntilNextOf("("); } // now read parameters: (for both operator and conversion function) skipSpaces(); expect('('); findNextBalanced('(',')'); readUntilNextOf("{;=,"); backtrackSkippingSpaces(); ASTNodePtr declaratorNode = createASTNode( ASTNodeTypes::unparsedDeclarator, node_, declaratorStartIndex, getCurrentIndex() - declaratorStartIndex ); node_->addChild(declaratorNode); skipSpaces(); } bool DeclarationDetailsParser::isOperatorIdentifier(std::string name) { unsigned int pos = name.find_last_of(":"); if (pos == std::string::npos) return name=="operator"; return name.substr(pos+1) == "operator"; } } // namespace Refactoring |
From: <net...@us...> - 2003-04-29 09:48:02
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv23254/src/rftaparser Modified Files: MaxLODMutator.cpp Log Message: -- added new Mutator for deeper parsing Index: MaxLODMutator.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/MaxLODMutator.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** MaxLODMutator.cpp 15 Apr 2003 19:05:18 -0000 1.10 --- MaxLODMutator.cpp 29 Apr 2003 09:47:59 -0000 1.11 *************** *** 10,13 **** --- 10,14 ---- #include "UnparsedCompoundMutator.h" #include "UnparsedDeclarationListMutator.h" + #include "UnparsedDeclarationMutator.h" #include <rfta/parser/ASTNodes.h> #include <rfta/parser/MaxLODMutator.h> *************** *** 77,80 **** --- 78,83 ---- add( ASTNodeTypes::unparsedDeclarationList, *new UnparsedDeclarationListMutator() ); + add( ASTNodeTypes::unparsedDeclaration, + *new UnparsedDeclarationMutator() ); } |
From: <net...@us...> - 2003-04-29 09:47:08
|
Update of /cvsroot/cpptool/rfta/bin In directory sc8-pr-cvs1:/tmp/cvs-serv22533/bin Added Files: KeyedString.h Log Message: -- additional test file for ASTDump --- NEW FILE: KeyedString.h --- // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2003, Andre Baresel // Created: 2003/04/28 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_KEYEDSTRING_H #define RFTA_KEYEDSTRING_H #include <vector> #include <map> #include <string> namespace Refactoring { namespace Testing { class KeyedString { public: KeyedString& operator<< (std::string characters); operator std::string () const; KeyedString& addKeyed (std::string key , std::string word ); std::string asString() const; std::vector<int> getKeyedIndex(std::string key) const; std::vector<int> getKeyedLen(std::string key) const; int getKeyedIndex(std::string key,int index) const; int getKeyedLen(std::string key,int index) const; std::string getWord(std::string key, int index) const; int length() const; KeyedString& setKeyStart(std::string key); KeyedString& setKeyEnd(std::string key); protected: std::string sequence_; std::map<std::string,std::vector<int> > wordIndex_; std::map<std::string,std::vector<int> > wordLen_; std::map<std::string,std::vector<std::string> > word_; }; // INLINED MEMBERS: inline KeyedString& KeyedString::operator<<(std::string characters) { sequence_.append(characters); return *this; } inline KeyedString::operator std::string() const { return sequence_; } inline std::string KeyedString::asString() const { return sequence_; } inline std::vector<int> KeyedString::getKeyedIndex(std::string key) const { std::map<std::string,std::vector<int> >::const_iterator it; it = wordIndex_.find(key); if (it == wordIndex_.end()) return std::vector<int>(); return (*it).second; } inline std::vector<int> KeyedString::getKeyedLen(std::string key) const { std::map<std::string,std::vector<int> >::const_iterator it; it = wordLen_.find(key); if (it == wordLen_.end()) return std::vector<int>(); return (*it).second; } inline int KeyedString::getKeyedIndex(std::string key, int index) const { std::map<std::string,std::vector<int> >::const_iterator it; it = wordIndex_.find(key); if (it == wordIndex_.end()) throw std::logic_error("No string registered for this key."); if ((*it).second.size()<index) throw std::logic_error("Index out of range."); return (*it).second[index]; } inline int KeyedString::getKeyedLen(std::string key, int index) const { std::map<std::string,std::vector<int> >::const_iterator it; it = wordLen_.find(key); if (it == wordLen_.end()) throw std::logic_error("No string registered for this key."); if ((*it).second.size()<index) throw std::logic_error("Index out of range."); return (*it).second[index]; } inline std::string KeyedString::getWord(std::string key, int index) const { std::map<std::string,std::vector<std::string> >::const_iterator it; it = word_.find(key); if (it == word_.end()) throw std::logic_error("No string registered for this key."); if ((*it).second.size() < index) throw std::logic_error("Index out of range."); return ((*it).second)[index]; } inline KeyedString& KeyedString::addKeyed(std::string key,std::string word) { wordIndex_[key].push_back(sequence_.length()); wordLen_[key].push_back(word.length()); word_[key].push_back(word); sequence_.append(word); return *this; } inline int KeyedString::length() const { return sequence_.length(); } inline KeyedString& KeyedString::setKeyStart(std::string key) { wordIndex_[key].push_back(sequence_.length()); wordLen_[key].push_back(0); word_[key].push_back(""); return *this; } inline KeyedString& KeyedString::setKeyEnd(std::string key) { std::vector<int>& v1_ref = wordIndex_[key]; std::vector<int>& v2_ref = wordLen_[key]; if ( v1_ref.empty() || v2_ref.empty() || v2_ref.size() != v1_ref.size() ) throw std::logic_error("Key was not initialized correctly."); int idx = v1_ref.size()-1; v2_ref[idx] = sequence_.length() - v1_ref[idx]; return *this; } } // namespace Testing } // namespace Refactoring #endif // RFTA_KEYEDSTRING_H |
From: <net...@us...> - 2003-04-29 09:46:42
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv21691/src/rftaparser Modified Files: ParserToolsTest.h ParserToolsTest.cpp Log Message: -- function + test for backward skipping over identifiers Index: ParserToolsTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ParserToolsTest.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ParserToolsTest.h 28 Apr 2003 11:08:41 -0000 1.1 --- ParserToolsTest.h 29 Apr 2003 09:46:07 -0000 1.2 *************** *** 20,23 **** --- 20,24 ---- CPPUNIT_TEST( testTryReadIdentifier ); CPPUNIT_TEST( testTryReadKeyword ); + CPPUNIT_TEST( testBacktrackSkippingOverIdentifier ); CPPUNIT_TEST_SUITE_END(); *************** *** 36,39 **** --- 37,41 ---- void testTryReadIdentifier(); void testTryReadKeyword(); + void testBacktrackSkippingOverIdentifier(); private: Index: ParserToolsTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ParserToolsTest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ParserToolsTest.cpp 28 Apr 2003 11:08:41 -0000 1.1 --- ParserToolsTest.cpp 29 Apr 2003 09:46:08 -0000 1.2 *************** *** 77,88 **** // check non an identifier ! en = Xtl::CStringEnumerator( Xtl::CStringView( en.getCurrentPos(), textend ).enumerate() ); ident = ParserTools::tryReadKeyword( en, keywords ); CPPUNIT_ASSERT( ident.empty() ); // check not registered ! en = Xtl::CStringEnumerator( Xtl::CStringView( en.getCurrentPos()+3, textend ).enumerate() ); ident = ParserTools::tryReadKeyword( en, keywords ); CPPUNIT_ASSERT( ident.empty() ); } --- 77,117 ---- // check non an identifier ! en = Xtl::CStringView( en.getCurrentPos(), textend ).enumerate(); ident = ParserTools::tryReadKeyword( en, keywords ); CPPUNIT_ASSERT( ident.empty() ); // check not registered ! en = Xtl::CStringView( en.getCurrentPos()+3, textend ).enumerate(); ident = ParserTools::tryReadKeyword( en, keywords ); CPPUNIT_ASSERT( ident.empty() ); + } + + void + ParserToolsTest::testBacktrackSkippingOverIdentifier() + { + const char * textbeg = "a * test "; + const char * textend = textbeg + strlen(textbeg); + Xtl::CStringView cv ( textbeg, textend ); + Xtl::CStringBackEnumerator enu( cv.enumerate()+=strlen(textbeg)-1 ); + Xtl::CStringBackEnumerator end = enu; + + CPPUNIT_ASSERT( ParserTools::backtrackSkippingOverIdentifier(enu) ); + + // the back enumerator returns a current position which is one + // character beyond the character lookup by 'operator*' + std::string ident = Xtl::CStringView(enu.getCurrentPos(),end.getCurrentPos() ).str(); + CPPUNIT_ASSERT( ident == "test" ); + + cv = Xtl::CStringView( textbeg , enu.getCurrentPos()-1); // skip ' ' + enu = cv.enumerate()+cv.getLength(); + CPPUNIT_ASSERT( !ParserTools::backtrackSkippingOverIdentifier(enu) ); + + cv = Xtl::CStringView( textbeg , enu.getCurrentPos()-2); // skip ' *' + enu = cv.enumerate()+cv.getLength(); + end = enu; + CPPUNIT_ASSERT( ParserTools::backtrackSkippingOverIdentifier(enu) ); + + ident = Xtl::CStringView(enu.getCurrentPos(),end.getCurrentPos()).str(); + CPPUNIT_ASSERT( ident == "a" ); } |
From: <net...@us...> - 2003-04-29 09:46:15
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv21691/src/rfta Modified Files: ParserTools.cpp Log Message: -- function + test for backward skipping over identifiers Index: ParserTools.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/ParserTools.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ParserTools.cpp 28 Apr 2003 11:03:57 -0000 1.4 --- ParserTools.cpp 29 Apr 2003 09:46:10 -0000 1.5 *************** *** 101,104 **** --- 101,127 ---- } + bool RFTAPARSER_API + backtrackSkippingOverIdentifier(Xtl::CStringBackEnumerator &enumerator) + { + Xtl::CStringBackEnumerator origin = enumerator; + + while ( enumerator.hasNext() && isIdentifierLetter( *enumerator ) ) + enumerator++; + + if ( enumerator == origin ) + { + return false; + } + + enumerator--; + + bool ret = isValidIdentifierFirstLetter( *enumerator ); + if (!ret) + enumerator = origin; + enumerator++; + return ret; + } + + } // namespace ParserTools |
From: <net...@us...> - 2003-04-29 09:46:14
|
Update of /cvsroot/cpptool/rfta/include/rfta/parser In directory sc8-pr-cvs1:/tmp/cvs-serv21691/include/rfta/parser Modified Files: ParserTools.h Log Message: -- function + test for backward skipping over identifiers Index: ParserTools.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/parser/ParserTools.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ParserTools.h 28 Apr 2003 11:03:56 -0000 1.5 --- ParserTools.h 29 Apr 2003 09:46:09 -0000 1.6 *************** *** 168,171 **** --- 168,173 ---- std::string RFTAPARSER_API tryReadKeyword( Xtl::CStringEnumerator &enumerator, std::set< std::string > keywords ); + bool RFTAPARSER_API backtrackSkippingOverIdentifier(Xtl::CStringBackEnumerator &enumerator); + } // namespace ParserTools |
From: <bl...@us...> - 2003-04-29 07:02:43
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv24415/src/rfta Modified Files: CodeModelStatements.cpp Log Message: * added enumerator to compound statement Index: CodeModelStatements.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelStatements.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** CodeModelStatements.cpp 10 Apr 2003 08:37:50 -0000 1.18 --- CodeModelStatements.cpp 29 Apr 2003 07:02:39 -0000 1.19 *************** *** 8,11 **** --- 8,12 ---- #include <rfta/refactoring/CodeModelStatements.h> #include <rfta/refactoring/CodeModelVisitor.h> + #include <xtl/GetAtEnumerator.h> #include <stdexcept> *************** *** 69,72 **** --- 70,81 ---- return statementsTracker_.getAt( index ); } + + + Xtl::Enumerator<StatementPtr> + CompoundStatement::getStatements() const + { + return Xtl::enumGetAt( *this, &CompoundStatement::getStatementAt, 0, getStatementCount() ); + } + void |
From: <bl...@us...> - 2003-04-29 07:02:43
|
Update of /cvsroot/cpptool/rfta/include/rfta/refactoring In directory sc8-pr-cvs1:/tmp/cvs-serv24415/include/rfta/refactoring Modified Files: CodeModelStatements.h Log Message: * added enumerator to compound statement Index: CodeModelStatements.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelStatements.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** CodeModelStatements.h 10 Apr 2003 08:37:47 -0000 1.20 --- CodeModelStatements.h 29 Apr 2003 07:02:38 -0000 1.21 *************** *** 9,12 **** --- 9,13 ---- #include <rfta/refactoring/CodeModelForward.h> #include <rfta/refactoring/CodeModelElement.h> + #include <xtl/Enumerator.h> #include <string> #include <vector> *************** *** 43,46 **** --- 44,49 ---- StatementPtr getStatementAt( int index ) const; + + Xtl::Enumerator<StatementPtr> getStatements() const; int getChangeCount() const; |
From: <bl...@us...> - 2003-04-29 07:01:49
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv23547/src/rfta Modified Files: CodeRewriter.cpp Log Message: * fixed indentation Index: CodeRewriter.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** CodeRewriter.cpp 25 Apr 2003 07:49:15 -0000 1.44 --- CodeRewriter.cpp 29 Apr 2003 07:01:43 -0000 1.45 *************** *** 296,300 **** deleteTextIfNecessary( change ); if ( change.wasRemoved() ) ! continue; currentInsertionPos_ = nextStatementInsertionPos; --- 296,300 ---- deleteTextIfNecessary( change ); if ( change.wasRemoved() ) ! continue; currentInsertionPos_ = nextStatementInsertionPos; *************** *** 648,652 **** deleteTextIfNecessary( change ); if (change.wasRemoved()) ! continue; if ( needsToInsertComma( change, index, firstWasAdded ) ) insertText( ", " ); --- 648,652 ---- deleteTextIfNecessary( change ); if (change.wasRemoved()) ! continue; if ( needsToInsertComma( change, index, firstWasAdded ) ) insertText( ", " ); |
From: <bl...@us...> - 2003-04-28 22:18:10
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv17089/src/rftaparser Modified Files: EnumeratorTest.cpp EnumeratorTest.h rftaparser.dsp Log Message: * added test for GetAtEnumerator Index: EnumeratorTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/EnumeratorTest.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EnumeratorTest.cpp 28 Apr 2003 08:45:09 -0000 1.2 --- EnumeratorTest.cpp 28 Apr 2003 22:18:02 -0000 1.3 *************** *** 198,200 **** --- 198,239 ---- + namespace { + template<typename ValueType> + struct SimpleContainer + { + ValueType getAt( int index ) const + { + return values_.at( index ); + } + + std::deque<ValueType> values_; + }; + } + + + void + EnumeratorTest::testGetAtEnumerator() + { + SimpleContainer<std::string> container; + fillStringSequence( container.values_ ); + + StringEnum e = Xtl::enumGetAt( container, &SimpleContainer<std::string>::getAt, 0, 3 ); + RFTA_ASSERT_EQUAL( "abc", e.getNext() ); + RFTA_ASSERT_EQUAL( "def", e.getNext() ); + RFTA_ASSERT_EQUAL( "ghi", e.getNext() ); + checkHasNoMoreElements( e ); + + SimpleContainer<const char *> container2; + fillStringSequence( container2.values_ ); + + StringEnum e2 = Xtl::enumGetAt( container2, &SimpleContainer<const char *>::getAt, + 0, 3, Xtl::Type<std::string>() ); + RFTA_ASSERT_EQUAL( "abc", e2.getNext() ); + RFTA_ASSERT_EQUAL( "def", e2.getNext() ); + RFTA_ASSERT_EQUAL( "ghi", e2.getNext() ); + checkHasNoMoreElements( e2 ); + } + + + } // namespace Refactoring Index: EnumeratorTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/EnumeratorTest.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EnumeratorTest.h 28 Apr 2003 08:45:11 -0000 1.2 --- EnumeratorTest.h 28 Apr 2003 22:18:05 -0000 1.3 *************** *** 10,13 **** --- 10,14 ---- #include <xtl/Enumerator.h> #include <xtl/StlEnumerator.h> + #include <xtl/GetAtEnumerator.h> #include <deque> #include <map> *************** *** 30,33 **** --- 31,35 ---- CPPUNIT_TEST( testStlMapKeysEnumerator ); CPPUNIT_TEST( testStlMapValuesEnumerator ); + CPPUNIT_TEST( testGetAtEnumerator ); CPPUNIT_TEST_SUITE_END(); *************** *** 53,56 **** --- 55,60 ---- void testStlMapValuesEnumerator(); + void testGetAtEnumerator(); + private: typedef Xtl::Enumerator<int> IntEnum; *************** *** 83,86 **** --- 87,98 ---- RFTA_ASSERT_EQUAL( 34, e2.getNext() ); checkHasNoMoreElements( e2 ); + } + + template<typename SequenceContainer> + void fillStringSequence( SequenceContainer &sequence ) + { + sequence.push_back( "abc" ); + sequence.push_back( "def" ); + sequence.push_back( "ghi" ); } Index: rftaparser.dsp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/rftaparser.dsp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** rftaparser.dsp 28 Apr 2003 11:13:16 -0000 1.44 --- rftaparser.dsp 28 Apr 2003 22:18:06 -0000 1.45 *************** *** 56,61 **** # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\build\rftaparser\Release/rftaparser_mdr.ext" /libpath:"../../deplib/cppunit/lib" # Begin Special Build Tool ! TargetDir=\Projects\Cpptool\rfta\build\rftaparser\Release ! TargetPath=\Projects\Cpptool\rfta\build\rftaparser\Release\rftaparser_mdr.ext TargetName=rftaparser_mdr SOURCE="$(InputPath)" --- 56,61 ---- # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\build\rftaparser\Release/rftaparser_mdr.ext" /libpath:"../../deplib/cppunit/lib" # Begin Special Build Tool ! TargetDir=\prg\vc\Rfta\build\rftaparser\Release ! TargetPath=\prg\vc\Rfta\build\rftaparser\Release\rftaparser_mdr.ext TargetName=rftaparser_mdr SOURCE="$(InputPath)" *************** *** 90,95 **** # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd_dll.lib /nologo /dll /debug /machine:I386 /out:"..\..\build\rftaparser\Debug/rftaparser_mdd.ext" /pdbtype:sept /libpath:"../../deplib/cppunit/lib" # Begin Special Build Tool ! TargetDir=\Projects\Cpptool\rfta\build\rftaparser\Debug ! TargetPath=\Projects\Cpptool\rfta\build\rftaparser\Debug\rftaparser_mdd.ext TargetName=rftaparser_mdd SOURCE="$(InputPath)" --- 90,95 ---- # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd_dll.lib /nologo /dll /debug /machine:I386 /out:"..\..\build\rftaparser\Debug/rftaparser_mdd.ext" /pdbtype:sept /libpath:"../../deplib/cppunit/lib" # Begin Special Build Tool ! TargetDir=\prg\vc\Rfta\build\rftaparser\Debug ! TargetPath=\prg\vc\Rfta\build\rftaparser\Debug\rftaparser_mdd.ext TargetName=rftaparser_mdd SOURCE="$(InputPath)" *************** *** 1211,1214 **** --- 1211,1227 ---- SOURCE=.\KeyedString.h # End Source File + # Begin Source File + + SOURCE=.\UnitTesting.h + + !IF "$(CFG)" == "rftaparser - Win32 Release" + + # PROP Exclude_From_Build 1 + + !ELSEIF "$(CFG)" == "rftaparser - Win32 Debug" + + !ENDIF + + # End Source File # End Group # Begin Source File *************** *** 1288,1304 **** SOURCE=.\SourceRangeTest.h - - !IF "$(CFG)" == "rftaparser - Win32 Release" - - # PROP Exclude_From_Build 1 - - !ELSEIF "$(CFG)" == "rftaparser - Win32 Debug" - - !ENDIF - - # End Source File - # Begin Source File - - SOURCE=.\UnitTesting.h !IF "$(CFG)" == "rftaparser - Win32 Release" --- 1301,1304 ---- |
From: <bl...@us...> - 2003-04-28 22:18:09
|
Update of /cvsroot/cpptool/rfta/include/xtl In directory sc8-pr-cvs1:/tmp/cvs-serv17089/include/xtl Modified Files: GetAtEnumerator.h Log Message: * added test for GetAtEnumerator Index: GetAtEnumerator.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/xtl/GetAtEnumerator.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GetAtEnumerator.h 28 Apr 2003 08:53:20 -0000 1.1 --- GetAtEnumerator.h 28 Apr 2003 22:17:59 -0000 1.2 *************** *** 4,10 **** #include <xtl/Enumerator.h> #include <xtl/EnumAdaptor.h> - #include <xtl/Int2Type.h> #include <xtl/Type.h> - #include <boost/type_traits.hpp> namespace Xtl { --- 4,8 ---- *************** *** 18,33 **** { public: ! typedef GetAtEnumeratorImpl<ObjectType,EnumeratedType,Adaptor> ThisType; ! typedef ReturnType (ObjectType::*GetAtMethod)(int index) const ! ! enum { ! isIdentityAdaptor = ::boost::is_convertible<IdendityEnumAdpator<EnumeratedType> ! ,Adaptor>::value ! }; ! StlEnumeratorImpl( const ObjectType &object, ! GetAtMethod getAtMethod, ! int currentIndex, ! int elementCount ) : object_( object ) , getAtMethod_( getAtMethod ) --- 16,26 ---- { public: ! typedef GetAtEnumeratorImpl<ObjectType,EnumeratedType,ReturnType,Adaptor> ThisType; ! typedef ReturnType (ObjectType::*GetAtMethod)(int index) const; ! GetAtEnumeratorImpl( const ObjectType &object, ! GetAtMethod getAtMethod, ! int currentIndex, ! int elementCount ) : object_( object ) , getAtMethod_( getAtMethod ) *************** *** 36,44 **** { } ! StlEnumeratorImpl( const ObjectType &object, ! GetAtMethod getAtMethod, ! int currentIndex, ! int elementCount, ! Adaptor adaptor ) : object_( object ) , getAtMethod_( getAtMethod ) --- 29,37 ---- { } ! GetAtEnumeratorImpl( const ObjectType &object, ! GetAtMethod getAtMethod, ! int currentIndex, ! int elementCount, ! Adaptor adaptor ) : object_( object ) , getAtMethod_( getAtMethod ) *************** *** 52,59 **** EnumeratedType getNext() { ! if ( currentIndex >= count_ ) throw EnumeratorError(); ! return doGetNext( Int2Type<isIdentityAdaptor>() ); } --- 45,52 ---- EnumeratedType getNext() { ! if ( current_ >= count_ ) throw EnumeratorError(); ! return adaptor_( (object_.*getAtMethod_)( current_++ ) ); } *************** *** 65,80 **** Ptr clone() const { ! return Ptr( new ThisType( object_, getAtMethod_, currentIndex, elementCount, adaptor_ ) ); ! } ! ! private: ! inline EnumeratedType doGetNext( Int2Type<true> ) ! { ! return (object_->*getAtMethod)( current_++ ); ! } ! ! inline EnumeratedType doGetNext( Int2Type<false> ) ! { ! return adaptor_( (object_->*getAtMethod)( current_++ ) ); } --- 58,62 ---- Ptr clone() const { ! return Ptr( new ThisType( object_, getAtMethod_, current_, count_, adaptor_ ) ); } *************** *** 92,96 **** Enumerator<EnumeratedType> enumGetAt( const ObjectType &object, ! EnumeratedType (ObjectType::getAtMethod)(int index) const, int startIndex, int elementCount ) --- 74,78 ---- Enumerator<EnumeratedType> enumGetAt( const ObjectType &object, ! EnumeratedType (ObjectType::*getAtMethod)(int index) const, int startIndex, int elementCount ) *************** *** 98,102 **** return Enumerator<EnumeratedType>( new GetAtEnumeratorImpl<ObjectType, EnumeratedType>( ! object, getAtMethod, startIndex, count ) ); } --- 80,84 ---- return Enumerator<EnumeratedType>( new GetAtEnumeratorImpl<ObjectType, EnumeratedType>( ! object, getAtMethod, startIndex, elementCount ) ); } *************** *** 107,111 **** Enumerator<BOOST_DEDUCED_TYPENAME Adaptor::EnumeratedType> enumGetAtAdapt( const ObjectType &object, ! ReturnType (ObjectType::getAtMethod)(int index) const, int startIndex, int elementCount, --- 89,93 ---- Enumerator<BOOST_DEDUCED_TYPENAME Adaptor::EnumeratedType> enumGetAtAdapt( const ObjectType &object, ! ReturnType (ObjectType::*getAtMethod)(int index) const, int startIndex, int elementCount, *************** *** 115,119 **** return Enumerator<EnumeratedType>( new GetAtEnumeratorImpl<ObjectType, EnumeratedType, ReturnType, Adaptor>( ! object, getAtMethod, startIndex, count, adaptor ) ); } --- 97,101 ---- return Enumerator<EnumeratedType>( new GetAtEnumeratorImpl<ObjectType, EnumeratedType, ReturnType, Adaptor>( ! object, getAtMethod, startIndex, elementCount, adaptor ) ); } *************** *** 124,128 **** Enumerator<EnumeratedType> enumGetAt( const ObjectType &object, ! ReturnType (ObjectType::getAtMethod)(int index) const, int startIndex, int elementCount, --- 106,110 ---- Enumerator<EnumeratedType> enumGetAt( const ObjectType &object, ! ReturnType (ObjectType::*getAtMethod)(int index) const, int startIndex, int elementCount, |
From: <net...@us...> - 2003-04-28 21:03:43
|
Update of /cvsroot/cpptool/rfta/bin In directory sc8-pr-cvs1:/tmp/cvs-serv6899/bin Modified Files: test.bat Log Message: -- ast dumper for File-Level-Parsing Index: test.bat =================================================================== RCS file: /cvsroot/cpptool/rfta/bin/test.bat,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test.bat 25 Apr 2003 08:19:29 -0000 1.7 --- test.bat 28 Apr 2003 21:03:39 -0000 1.8 *************** *** 1,16 **** del ast\dump*.html ! astdump 53 73 ASTDumper.cpp ast ! astdump 78 118 ASTDumper.cpp ast ! astdump 137 150 ASTDumper.cpp ast ! astdump 155 166 ASTDumper.cpp ast ! astdump 172 200 ASTDumper.cpp ast ! astdump 56 106 VariableDeclMutator.cpp ast ! astdump 116 163 VariableDeclMutator.cpp ast ! astdump 168 184 VariableDeclMutator.cpp ast ! astdump 385 456 VariableDeclMutator.cpp ast ! astdump 461 521 VariableDeclMutator.cpp ast ! astdump 26 79 Main.cpp ast ! astdump 89 108 HTMLWriter.cpp ast ! astdump 0 15 DeclarativeCondition.cpp ast ! astdump 0 4 ForDeclaration.cpp ast --- 1,9 ---- del ast\dump*.html ! rem astdump 8 138 KeyedString.h ! astdump 1 203 ASTDumper.cpp ast ! astdump 1 524 VariableDeclMutator.cpp ast ! astdump 1 79 Main.cpp ast ! astdump 1 157 HTMLWriter.cpp ast ! rem astdump 0 15 DeclarativeCondition.cpp ast ! rem astdump 0 4 ForDeclaration.cpp ast |