[Synopsis-changes] Synopsis/Synopsis/Synopsis/Parser/C++/syn swalker.cc,1.76,1.77

Stefan Seefeld stefan at synopsis.fresco.org
Wed Oct 15 04:29:01 UTC 2003


Update of /cvs/synopsis/Synopsis/Synopsis/Parser/C++/syn
In directory frida:/tmp/cvs-serv16077/Synopsis/Parser/C++/syn

Modified Files:
	swalker.cc 
Log Message:
* only keep last comment if it is not suspect
* provide an alternative Grouper


Index: swalker.cc
===================================================================
RCS file: /cvs/synopsis/Synopsis/Synopsis/Parser/C++/syn/swalker.cc,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -p -d -r1.76 -r1.77
--- swalker.cc	13 Oct 2003 18:50:20 -0000	1.76
+++ swalker.cc	15 Oct 2003 04:28:58 -0000	1.77
@@ -25,6 +25,10 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.77  2003/10/15 04:28:58  stefan
+// * only keep last comment if it is not suspect
+// * provide an alternative Grouper
+//
 // Revision 1.76  2003/10/13 18:50:20  stefan
 // * provide a clearer definition of 'Comment', i.e.
 //   a single comment as opposed to a list of comments
@@ -302,9 +306,23 @@ SWalker::add_comments(AST::Declaration* 
       next = next->Rest();
     }
 
+    // all comments that are not immediately (i.e. separated
+    // by a single new line) followed by a declaration are
+    // marked as 'suspect'
+    bool suspect = false;
+    char* pos = first->GetPosition() + first->GetLength();
+    while (*pos && strchr(" \t\r", *pos)) ++pos;
+    if (*pos == '\n')
+    {
+      ++pos;
+      // Found only allowed \n
+      while (*pos && strchr(" \t\r", *pos)) ++pos;
+      if (*pos == '\n' || !strncmp(pos, "/*", 2)) suspect = true;
+    }
+
     if (decl)
     {
-      AST::Comment* comment = make_Comment(m_file, 0, first);
+      AST::Comment* comment = make_Comment(m_file, 0, first, suspect);
       comments.push_back(comment);
     }
     if (m_links) m_links->long_span(first, "file-comment");





More information about the Synopsis-changes mailing list