diff options
Diffstat (limited to 'giscanner/scannerlexer.l')
-rw-r--r-- | giscanner/scannerlexer.l | 98 |
1 files changed, 48 insertions, 50 deletions
diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l index 554e2da7..bf51d0d5 100644 --- a/giscanner/scannerlexer.l +++ b/giscanner/scannerlexer.l @@ -46,7 +46,6 @@ 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); @@ -75,7 +74,6 @@ stringtext ([^\\\"])|(\\.) [\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. */ } @@ -224,72 +222,72 @@ yywrap (void) } static void -parse_gtk_doc_comment (GISourceScanner *scanner) +parse_comment (GISourceScanner *scanner) { - GString *string = NULL; int c1, c2; + GString *string = NULL; GISourceComment *comment; int comment_lineno; int skip = FALSE; - if (!g_list_find_custom (scanner->filenames, - scanner->current_filename, - (GCompareFunc)g_strcmp0)) { - skip = TRUE; - } else { - string = g_string_new (yytext); - } - c1 = input(); c2 = input(); - comment_lineno = lineno; - - while (c2 != EOF && !(c1 == '*' && c2 == '/')) - { - if (!skip) - g_string_append_c (string, c1); - - if (c1 == '\n') - lineno++; - - c1 = c2; - c2 = input(); + if (c2 != EOF && (c1 == '*' && c2 != '*' && c2 != '/')) { + /* + * Store GTK-Doc comment blocks, + * starts with one '/' followed by exactly two '*' and not followed by a '/' + */ + if (!g_list_find_custom (scanner->filenames, + scanner->current_filename, + (GCompareFunc)g_strcmp0)) { + skip = TRUE; + } else { + string = g_string_new (yytext); } - if (skip) { - return; - } - - g_string_append (string, "*/"); + comment_lineno = lineno; - comment = g_slice_new (GISourceComment); - comment->comment = g_string_free (string, FALSE); - comment->line = comment_lineno; - comment->filename = g_strdup(scanner->current_filename); + while (c2 != EOF && !(c1 == '*' && c2 == '/')) + { + if (!skip) + g_string_append_c (string, c1); - scanner->comments = g_slist_prepend (scanner->comments, - comment); -} + if (c1 == '\n') + lineno++; -static void -parse_comment (GISourceScanner *scanner) -{ - int c1, c2; + c1 = c2; + c2 = input(); + } - c1 = input(); - c2 = input(); + if (skip) { + return; + } - while (c2 != EOF && !(c1 == '*' && c2 == '/')) - { - if (c1 == '\n') - lineno++; + g_string_append (string, "*/"); - c1 = c2; - c2 = input(); - } + comment = g_slice_new (GISourceComment); + comment->comment = g_string_free (string, FALSE); + comment->line = comment_lineno; + comment->filename = g_strdup(scanner->current_filename); - return; + scanner->comments = g_slist_prepend (scanner->comments, + comment); + } else { + /* + * Ignore all other comment blocks + */ + while (c2 != EOF && !(c1 == '*' && c2 == '/')) + { + if (c1 == '\n') + lineno++; + + c1 = c2; + c2 = input(); + } + + return; + } } static int |