|
From: <net...@us...> - 2003-04-15 19:05:32
|
Update of /cvsroot/cpptool/rfta/src/rftaparser
In directory sc8-pr-cvs1:/tmp/cvs-serv21347/src/rftaparser
Modified Files:
ASTNodes.cpp DeclarationListParserTest.cpp
DeclarationParser.cpp DeclarationParserTest.cpp
LinkageParser.cpp MaxLODMutator.cpp NamespaceParser.cpp
TemplateDeclarationParser.cpp
Log Message:
-- rearrangement of some node types/names and properties
Index: ASTNodes.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ASTNodes.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** ASTNodes.cpp 14 Apr 2003 19:33:12 -0000 1.17
--- ASTNodes.cpp 15 Apr 2003 19:05:14 -0000 1.18
***************
*** 13,25 ****
const ASTNodeType ASTNodeTypes::source( "source-file", isCompositeStatement );
! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedSourcePart ( "unparsed-source-part", mayHaveLocalScopeIdentifierChildren );
! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedTemplate ( "unparsed-template" , mayHaveLocalScopeIdentifierChildren );
! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedNamespace ( "unparsed-namespace" , mayHaveLocalScopeIdentifierChildren );
! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedLinkage ( "unparsed-linkage" , 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::unparsedfunctionImplementation ( "unparsed-function-implementation" , mayHaveLocalScopeIdentifierChildren );
const ASTNodeType ASTNodeTypes::unparsedCompoundStatement( "unparsed-compound-statement", isCompositeStatement | needMutation );
--- 13,27 ----
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 );
const ASTNodeType ASTNodeTypes::unparsedCompoundStatement( "unparsed-compound-statement", isCompositeStatement | needMutation );
***************
*** 94,100 ****
--- 96,105 ----
/* 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" );
} // namespace Refactoring
Index: DeclarationListParserTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationListParserTest.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DeclarationListParserTest.cpp 14 Apr 2003 19:32:54 -0000 1.2
--- DeclarationListParserTest.cpp 15 Apr 2003 19:05:16 -0000 1.3
***************
*** 8,12 ****
#include "DeclarationListParserTest.h"
#include <rfta/parser/ASTNodes.h>
! #include "DeclarationListParser.h"
--- 8,12 ----
#include "DeclarationListParserTest.h"
#include <rfta/parser/ASTNodes.h>
! #include <rfta/parser/DeclarationListParser.h>
***************
*** 58,67 ****
source.length() );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::unparsedTemplate,
startIndex,
endIndex-startIndex );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(1),
! ASTNodeTypes::unparsedSourcePart,
endIndex+1,
6 );
--- 58,67 ----
source.length() );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::templateDeclaration,
startIndex,
endIndex-startIndex );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(1),
! ASTNodeTypes::unparsedDeclaration,
endIndex+1,
6 );
Index: DeclarationParser.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationParser.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DeclarationParser.cpp 14 Apr 2003 19:30:32 -0000 1.2
--- DeclarationParser.cpp 15 Apr 2003 19:05:17 -0000 1.3
***************
*** 45,49 ****
ASTNodePtr declarationNode =
! createASTNode( ASTNodeTypes::unparsedSourcePart,
getParentNode(),
getCurrentIndex(),
--- 45,49 ----
ASTNodePtr declarationNode =
! createASTNode( ASTNodeTypes::unparsedDeclaration,
getParentNode(),
getCurrentIndex(),
***************
*** 95,102 ****
{
current_ = start_of_curl+1;
// read until the end of the function body
findNextBalanced('{','}');
declarationNode->setLength( getCurrentLength() - start_difference );
! declarationNode->mutateType(ASTNodeTypes::unparsedfunctionImplementation);
return true;
}
--- 95,122 ----
{
current_ = start_of_curl+1;
+ int bodystartIdx = getCurrentIndex()-1;
// read until the end of the function body
findNextBalanced('{','}');
+
+ // store function header in function-header-property
+ context_.bindNextNodeToProperty(declarationNode,ASTNodeProperties::functionHeaderProperty );
+
+ ASTNodePtr function_head =
+ createASTNode( ASTNodeTypes::unparsedFunctionHeader,
+ declarationNode,
+ getStartIndex(), bodystartIdx - getStartIndex() );
+ context_.addNode(function_head);
+
+ // store function body in function-body-property
+ context_.bindNextNodeToProperty(declarationNode,ASTNodeProperties::functionBodyProperty );
+
+ ASTNodePtr function_body =
+ createASTNode( ASTNodeTypes::unparsedCompoundStatement,
+ declarationNode,
+ bodystartIdx, getCurrentIndex() - bodystartIdx );
+ context_.addNode(function_body);
+
declarationNode->setLength( getCurrentLength() - start_difference );
! declarationNode->mutateType(ASTNodeTypes::functionImplementation);
return true;
}
Index: DeclarationParserTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationParserTest.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DeclarationParserTest.cpp 14 Apr 2003 19:31:28 -0000 1.2
--- DeclarationParserTest.cpp 15 Apr 2003 19:05:18 -0000 1.3
***************
*** 51,61 ****
ASTNodePtr namespaceDecl = sourceAST->getChildAt(0);
RFTA_ASSERT_NODE_HAS( namespaceDecl,
! ASTNodeTypes::unparsedNamespace,
startIndex,
endIndex-startIndex );
! RFTA_ASSERT_NODE_HAS( namespaceDecl->getProperty(ASTNodeProperties::namespaceBodyProperty),
! ASTNodeTypes::unparsedSourcePart,
! 14,
! 3 );
}
--- 51,63 ----
ASTNodePtr namespaceDecl = sourceAST->getChildAt(0);
RFTA_ASSERT_NODE_HAS( namespaceDecl,
! ASTNodeTypes::namespaceDeclaration,
startIndex,
endIndex-startIndex );
! RFTA_ASSERT_NODE_PROPERTY_HAS(
! namespaceDecl,
! ASTNodeProperties::namespaceBodyProperty,
! ASTNodeTypes::unparsedDeclarationList,
! 14,
! 3);
}
***************
*** 73,76 ****
--- 75,84 ----
startIndex,
endIndex-startIndex );
+ RFTA_ASSERT_NODE_PROPERTY_HAS(
+ sourceAST->getChildAt(0),
+ ASTNodeProperties::namespaceAliasProperty,
+ ASTNodeTypes::localScopeIdentifier,
+ 16,
+ 1);
}
***************
*** 132,138 ****
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::unparsedLinkage,
startIndex,
endIndex-startIndex );
}
--- 140,152 ----
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::linkageDeclaration,
startIndex,
endIndex-startIndex );
+ RFTA_ASSERT_NODE_PROPERTY_HAS(
+ sourceAST->getChildAt(0),
+ ASTNodeProperties::linkageBodyProperty,
+ ASTNodeTypes::unparsedDeclarationList,
+ 16,
+ 10);
}
***************
*** 147,151 ****
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::unparsedLinkage,
startIndex,
endIndex-startIndex );
--- 161,165 ----
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::linkageDeclaration,
startIndex,
endIndex-startIndex );
***************
*** 162,166 ****
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::unparsedSourcePart,
startIndex,
endIndex-startIndex );
--- 176,180 ----
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::unparsedDeclaration,
startIndex,
endIndex-startIndex );
***************
*** 176,183 ****
source,
source.length()-1 );
! RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::unparsedfunctionImplementation,
startIndex,
endIndex-startIndex );
}
--- 190,210 ----
source,
source.length()-1 );
! ASTNodePtr fct = sourceAST->getChildAt(0);
! RFTA_ASSERT_NODE_HAS( fct,
! ASTNodeTypes::functionImplementation,
startIndex,
endIndex-startIndex );
+ RFTA_ASSERT_NODE_PROPERTY_HAS(
+ fct,
+ ASTNodeProperties::functionBodyProperty,
+ ASTNodeTypes::unparsedCompoundStatement,
+ 28,
+ 7);
+ RFTA_ASSERT_NODE_PROPERTY_HAS(
+ fct,
+ ASTNodeProperties::functionHeaderProperty,
+ ASTNodeTypes::unparsedFunctionHeader,
+ 0,
+ 28);
}
***************
*** 192,196 ****
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::unparsedSourcePart,
startIndex,
endIndex-startIndex );
--- 219,223 ----
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::unparsedDeclaration,
startIndex,
endIndex-startIndex );
***************
*** 200,204 ****
DeclarationParserTest::testTemplateClass()
{
! const std::string source( " template x< T > class v { T x; }; " );
int startIndex = 1;
int endIndex = source.length()-1;
--- 227,231 ----
DeclarationParserTest::testTemplateClass()
{
! const std::string source( " template < T > class v { T x; }; " );
int startIndex = 1;
int endIndex = source.length()-1;
***************
*** 207,213 ****
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::unparsedTemplate,
startIndex,
endIndex-startIndex );
}
--- 234,250 ----
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::templateDeclaration,
startIndex,
endIndex-startIndex );
+ RFTA_ASSERT_NODE_PROPERTY_HAS( sourceAST->getChildAt(0),
+ ASTNodeProperties::templateHeaderProperty,
+ ASTNodeTypes::unparsedTemplateHeader,
+ startIndex,
+ 14 );
+ RFTA_ASSERT_NODE_PROPERTY_HAS( sourceAST->getChildAt(0),
+ ASTNodeProperties::templateBodyProperty,
+ ASTNodeTypes::unparsedDeclaration,
+ 16,
+ endIndex-16 );
}
***************
*** 228,234 ****
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::unparsedTemplate,
startIndex,
! endIndex-startIndex );
}
--- 265,281 ----
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::templateDeclaration,
startIndex,
! endIndex-startIndex );
! RFTA_ASSERT_NODE_PROPERTY_HAS( sourceAST->getChildAt(0),
! ASTNodeProperties::templateHeaderProperty,
! ASTNodeTypes::unparsedTemplateHeader,
! startIndex,
! 33 );
! RFTA_ASSERT_NODE_PROPERTY_HAS( sourceAST->getChildAt(0),
! ASTNodeProperties::templateBodyProperty,
! ASTNodeTypes::functionImplementation,
! 35,
! source.length()-36 );
}
***************
*** 243,247 ****
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::unparsedTemplate,
startIndex,
endIndex-startIndex );
--- 290,294 ----
source.length()-1 );
RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0),
! ASTNodeTypes::templateDeclaration,
startIndex,
endIndex-startIndex );
Index: LinkageParser.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/LinkageParser.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** LinkageParser.cpp 14 Apr 2003 19:29:27 -0000 1.2
--- LinkageParser.cpp 15 Apr 2003 19:05:18 -0000 1.3
***************
*** 36,40 ****
ASTNodePtr linkageNode =
! createASTNode( ASTNodeTypes::unparsedLinkage,
getParentNode(),
getStartIndex(),
--- 36,40 ----
ASTNodePtr linkageNode =
! createASTNode( ASTNodeTypes::linkageDeclaration,
getParentNode(),
getStartIndex(),
***************
*** 51,54 ****
--- 51,60 ----
skipSpaces();
+
+ // setup the context to bind next node to templatebody-property
+ context_.bindNextNodeToProperty( linkageNode,
+ ASTNodeProperties::linkageBodyProperty );
+
+ int bodystartIdx = getCurrentIndex();
// check for surrounding linkage:
if (tryNextIs('{'))
***************
*** 56,67 ****
// is surrounding linkage like: "extern "C" { ... }"
findNextBalanced('{','}');
} else
{
// is single linkage like: extern "C" ...
-
- // setup the context to bind next node to templatebody-property
- context_.bindNextNodeToProperty( linkageNode,
- ASTNodeProperties::linkageBodyProperty );
-
DeclarationParser parser( context_, current_, end_ );
parser.tryParse();
--- 62,75 ----
// is surrounding linkage like: "extern "C" { ... }"
findNextBalanced('{','}');
+
+ ASTNodePtr linkageBody =
+ createASTNode( ASTNodeTypes::unparsedDeclarationList,
+ getParentNode(),
+ bodystartIdx+1,
+ getCurrentIndex()-bodystartIdx-2 );
+ context_.addNode( linkageBody );
} else
{
// is single linkage like: extern "C" ...
DeclarationParser parser( context_, current_, end_ );
parser.tryParse();
Index: MaxLODMutator.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/MaxLODMutator.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** MaxLODMutator.cpp 14 Apr 2003 19:46:29 -0000 1.9
--- MaxLODMutator.cpp 15 Apr 2003 19:05:18 -0000 1.10
***************
*** 9,13 ****
#include "ExpressionIdentifierMutator.h"
#include "UnparsedCompoundMutator.h"
! #include "UnparsedNamespaceMutator.h"
#include <rfta/parser/ASTNodes.h>
#include <rfta/parser/MaxLODMutator.h>
--- 9,13 ----
#include "ExpressionIdentifierMutator.h"
#include "UnparsedCompoundMutator.h"
! #include "UnparsedDeclarationListMutator.h"
#include <rfta/parser/ASTNodes.h>
#include <rfta/parser/MaxLODMutator.h>
***************
*** 75,80 ****
add( ASTNodeTypes::constantExpression,
*new ExpressionIdentifierMutator() );
! add( ASTNodeTypes::unparsedNamespace,
! *new UnparsedNamespaceMutator() );
}
--- 75,80 ----
add( ASTNodeTypes::constantExpression,
*new ExpressionIdentifierMutator() );
! add( ASTNodeTypes::unparsedDeclarationList,
! *new UnparsedDeclarationListMutator() );
}
Index: NamespaceParser.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/NamespaceParser.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** NamespaceParser.cpp 14 Apr 2003 19:28:54 -0000 1.2
--- NamespaceParser.cpp 15 Apr 2003 19:05:19 -0000 1.3
***************
*** 35,39 ****
ASTNodePtr namespaceNode =
! createASTNode( ASTNodeTypes::unparsedNamespace,
getParentNode(),
getStartIndex(),
--- 35,39 ----
ASTNodePtr namespaceNode =
! createASTNode( ASTNodeTypes::namespaceDeclaration,
getParentNode(),
getStartIndex(),
***************
*** 79,83 ****
createASTNode( ASTNodeTypes::localScopeIdentifier,
namespaceNode,
! alias_startIdx, getCurrentIndex() - alias_startIdx + 1 );
context_.addNode(namespace_identifier);
--- 79,83 ----
createASTNode( ASTNodeTypes::localScopeIdentifier,
namespaceNode,
! alias_startIdx, getCurrentIndex() - alias_startIdx );
context_.addNode(namespace_identifier);
***************
*** 96,100 ****
ASTNodePtr namespace_body =
! createASTNode( ASTNodeTypes::unparsedSourcePart,
namespaceNode,
body_startIdx, getCurrentIndex() - body_startIdx );
--- 96,100 ----
ASTNodePtr namespace_body =
! createASTNode( ASTNodeTypes::unparsedDeclarationList,
namespaceNode,
body_startIdx, getCurrentIndex() - body_startIdx );
Index: TemplateDeclarationParser.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/TemplateDeclarationParser.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TemplateDeclarationParser.cpp 14 Apr 2003 19:28:00 -0000 1.2
--- TemplateDeclarationParser.cpp 15 Apr 2003 19:05:19 -0000 1.3
***************
*** 36,40 ****
ASTNodePtr templateNode =
! createASTNode( ASTNodeTypes::unparsedTemplate,
getParentNode(),
getStartIndex(),
--- 36,40 ----
ASTNodePtr templateNode =
! createASTNode( ASTNodeTypes::templateDeclaration,
getParentNode(),
getStartIndex(),
***************
*** 47,53 ****
// read the template parameter
if (tryNextIs('<'))
! {
// skipping all the parameters until next '>'
! findNextBalanced('<','>');
}
skipSpaces();
--- 47,62 ----
// read the template parameter
if (tryNextIs('<'))
! {
// skipping all the parameters until next '>'
! findNextBalanced('<','>');
! // setup the context to bind next node to template-header-property
! context_.bindNextNodeToProperty( templateNode,
! ASTNodeProperties::templateHeaderProperty );
! ASTNodePtr templateHeader =
! createASTNode( ASTNodeTypes::unparsedTemplateHeader,
! getParentNode(),
! getStartIndex(),
! getCurrentLength() );
! context_.addNode( templateHeader );
}
skipSpaces();
|