[Uml-devel] kdesdk/umbrello/umbrello/classparser
Oliver Kellogg
okellogg at users.sourceforge.net
Tue Jul 6 00:16:03 UTC 2004
CVS commit by okellogg:
Partial fix for bug 82977 (Cannot import class ending in comment)
M +24 -5 parser.cpp 1.4
M +4 -3 parser.h 1.2
--- kdesdk/umbrello/umbrello/classparser/parser.cpp #1.3:1.4
@@ -550,5 +550,5 @@ bool Parser::parseDeclaration( Declarati
lex->setIndex( start );
- success = parseDeclarationInternal( node );
+ success = parseDeclarationInternal( node, comment );
}
@@ -1899,4 +1899,21 @@ bool Parser::parseAccessSpecifier( AST::
}
+void Parser::advanceAndCheckTrailingComment(QString& comment)
+{
+ Token t = lex->tokenAt( lex->index() );
+ int previousTokenEndLine = 0;
+ t.getEndPosition( &previousTokenEndLine, 0 );
+ lex->nextToken();
+ if( lex->lookAhead(0) != Token_comment )
+ return;
+ t = lex->tokenAt( lex->index() );
+ int commentStartLine = 0;
+ t.getStartPosition( &commentStartLine, 0 );
+ if( commentStartLine != previousTokenEndLine )
+ return;
+ comment += lex->lookAhead(0).text();
+ lex->nextToken();
+}
+
bool Parser::parseMemberSpecification( DeclarationAST::Node& node )
{
@@ -1916,5 +1933,7 @@ bool Parser::parseMemberSpecification( D
if( lex->lookAhead(0) == ';' ){
- lex->nextToken();
+ advanceAndCheckTrailingComment( comment );
+ if ( !comment.isEmpty() )
+ node->setComment( comment );
return true;
} else if( lex->lookAhead(0) == Token_Q_OBJECT || lex->lookAhead(0) == Token_K_DCOP ){
@@ -1990,5 +2009,5 @@ bool Parser::parseMemberSpecification( D
lex->setIndex( start );
- bool success = parseDeclarationInternal(node);
+ bool success = parseDeclarationInternal(node, comment);
if( success && !comment.isEmpty() ) {
node->setComment( comment );
@@ -2911,5 +2930,5 @@ bool Parser::parseDeclarationStatement(
}
-bool Parser::parseDeclarationInternal( DeclarationAST::Node& node )
+bool Parser::parseDeclarationInternal( DeclarationAST::Node& node, QString& comment )
{
//kdDebug(9007)<< "--- tok = " << lex->lookAhead(0).text() << " -- " << "Parser::parseDeclarationInternal()" << endl;
@@ -3071,5 +3090,5 @@ start_decl:
case ';':
{
- lex->nextToken();
+ advanceAndCheckTrailingComment( comment );
SimpleDeclarationAST::Node ast = CreateNode<SimpleDeclarationAST>();
ast->setStorageSpecifier( storageSpec );
--- kdesdk/umbrello/umbrello/classparser/parser.h #1.1:1.2
@@ -61,5 +61,5 @@ public /*rules*/ :
bool parseAsmDefinition( DeclarationAST::Node& node );
bool parseTemplateDeclaration( DeclarationAST::Node& node );
- bool parseDeclarationInternal( DeclarationAST::Node& node );
+ bool parseDeclarationInternal( DeclarationAST::Node& node, QString& comment );
bool parseUnqualifiedName( ClassOrNamespaceNameAST::Node& node );
@@ -197,4 +197,5 @@ public /*rules*/ :
bool parseObjcCloseBracket( AST::Node& node );
+ void advanceAndCheckTrailingComment(QString& comment);
bool skipUntil( int token );
More information about the umbrello-devel
mailing list