[gobject-introspection] giscanner: only parse GTK-Doc comment blocks, ignore the rest



commit c0e748e1cdf8cf0803266f94c3c5ad154df504a8
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Fri Apr 5 08:44:11 2013 +0200

    giscanner: only parse GTK-Doc comment blocks, ignore the rest
    
    For example, GTK+ has over 15.000 comment blocks (/* ... */)
    of which only about 5.000 are GTK-Doc comment blocks (/** ... */).
    
    No need to store and parse those +-10.000 comment blocks
    just to find out we don't care about them anyway.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=697625

 giscanner/scannerlexer.l |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l
index a783ec0..65fa3c2 100644
--- a/giscanner/scannerlexer.l
+++ b/giscanner/scannerlexer.l
@@ -46,6 +46,7 @@ char linebuf[2000];
 extern int yylex (GISourceScanner *scanner);
 #define YY_DECL int yylex (GISourceScanner *scanner)
 static int yywrap (void);
+static void parse_gtk_doc_comment (GISourceScanner *scanner);
 static void parse_comment (GISourceScanner *scanner);
 static void parse_trigraph (GISourceScanner *scanner);
 static void process_linemarks (GISourceScanner *scanner);
@@ -71,8 +72,10 @@ stringtext                           ([^\\\"])|(\\.)
                                                ++lineno;
                                        }
 "\\\n"                                 { ++lineno; }
+
 [\t\f\v\r ]+                           { /* Ignore whitespace. */ }
 
+"/**"                                  { parse_gtk_doc_comment(scanner); }
 "/*"                                   { parse_comment(scanner); }
 "/*"[\t ]?<[\t ,=A-Za-z0-9_]+>[\t ]?"*/" { parse_trigraph(scanner); }
 "//".*                                 { /* Ignore C++ style comments. */ }
@@ -212,9 +215,8 @@ yywrap (void)
   return 1;
 }
 
-
 static void
-parse_comment (GISourceScanner *scanner)
+parse_gtk_doc_comment (GISourceScanner *scanner)
 {
   GString *string = NULL;
   int c1, c2;
@@ -227,7 +229,7 @@ parse_comment (GISourceScanner *scanner)
                            (GCompareFunc)g_strcmp0)) {
       skip = TRUE;
   } else {
-      string = g_string_new ("/*");
+      string = g_string_new (yytext);
   }
 
   c1 = input();
@@ -262,6 +264,26 @@ parse_comment (GISourceScanner *scanner)
                                        comment);
 }
 
+static void
+parse_comment (GISourceScanner *scanner)
+{
+  int c1, c2;
+
+  c1 = input();
+  c2 = input();
+
+  while (c2 != EOF && !(c1 == '*' && c2 == '/'))
+    {
+      if (c1 == '\n')
+        lineno++;
+
+      c1 = c2;
+      c2 = input();
+    }
+
+  return;
+}
+
 static int
 check_identifier (GISourceScanner *scanner,
                  const char  *s)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]