From: <net...@us...> - 2003-04-14 19:28:58
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv25160/rfta/src/rftaparser Modified Files: NamespaceParser.cpp Log Message: -- additional nodes created by the namespace parser Index: NamespaceParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/NamespaceParser.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NamespaceParser.cpp 12 Apr 2003 19:08:40 -0000 1.1 --- NamespaceParser.cpp 14 Apr 2003 19:28:54 -0000 1.2 *************** *** 46,58 **** // named namespace or unnamed namespace: // "namespace x" or "namespace { ... }" std::string namespace_name; if (tryReadNextIdentifier(namespace_name)) { ! // namespace has an identifier ! // TODO: add property for name ! } else ! { ! // unnamed namespace ! // TODO: add property marking this as unnamed namespace } --- 46,59 ---- // named namespace or unnamed namespace: // "namespace x" or "namespace { ... }" + int name_startIdx = getCurrentIndex(); std::string namespace_name; if (tryReadNextIdentifier(namespace_name)) { ! // namespace has an identifier which will be stored as child-node. ! ASTNodePtr namespace_identifier = ! createASTNode( ASTNodeTypes::localScopeIdentifier, ! namespaceNode, ! name_startIdx, getCurrentIndex() - name_startIdx + 1 ); ! namespaceNode->addChild( namespace_identifier ); } *************** *** 65,68 **** --- 66,70 ---- // namespace alias: "namespace x = y;" skipSpaces(); + int alias_startIdx = getCurrentIndex(); std::string alias_name = namespace_name; if (!tryReadNextIdentifier(namespace_name)) *************** *** 70,82 **** throwFailure( std::string("expected identifier for namespace alias." )); } ! // TODO: store alias name in a property skipSpaces(); ! expect(';'); } else { // this is a usual namespace definition: ! // "namespace x { }" expect('{'); findNextBalanced('{','}'); } } --- 72,104 ---- throwFailure( std::string("expected identifier for namespace alias." )); } ! namespaceNode->mutateType(ASTNodeTypes::namespaceAlias); ! // store alias name in property ! context_.bindNextNodeToProperty(namespaceNode,ASTNodeProperties::namespaceAliasProperty ); ! ! ASTNodePtr namespace_identifier = ! createASTNode( ASTNodeTypes::localScopeIdentifier, ! namespaceNode, ! alias_startIdx, getCurrentIndex() - alias_startIdx + 1 ); ! ! context_.addNode(namespace_identifier); ! skipSpaces(); ! expect(';'); } else { // this is a usual namespace definition: ! // "namespace x { }" ! int body_startIdx = getCurrentIndex(); expect('{'); findNextBalanced('{','}'); + // store body in namespace-body-property + context_.bindNextNodeToProperty(namespaceNode,ASTNodeProperties::namespaceBodyProperty ); + + ASTNodePtr namespace_body = + createASTNode( ASTNodeTypes::unparsedSourcePart, + namespaceNode, + body_startIdx, getCurrentIndex() - body_startIdx ); + + context_.addNode(namespace_body); } } |