Implement toggling comment parsing feature on and off

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13182 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dmitry Kabak 2012-06-18 18:30:18 +00:00
commit b0f8e594c9
3 changed files with 16 additions and 11 deletions

View file

@ -26,6 +26,7 @@ extern "C" {
extern int cparse_line;
extern int cparse_cplusplus;
extern int cparse_start_line;
extern int scan_doxygen_comments;
extern void Swig_cparse_cplusplus(int);
extern void scanner_file(File *);

View file

@ -46,6 +46,9 @@ static int last_brace = 0;
static int last_id = 0;
static int rename_active = 0;
/* Doxygen comments scanning */
int scan_doxygen_comments = 1;
/* -----------------------------------------------------------------------------
* Swig_cparse_cplusplus()
* ----------------------------------------------------------------------------- */
@ -337,15 +340,17 @@ static int yylook(void) {
if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) {
Scanner_locator(scan, cmt);
}
if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) {
/* printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */
yylval.str = NewString(loc);
return DOXYGENPOSTSTRING;
}
if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) {
/* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */
yylval.str = NewString(loc);
return DOXYGENSTRING;
if (scan_doxygen_comments) { /* else just skip this node, to avoid crashes in parser module*/
if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) {
/* printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */
yylval.str = NewString(loc);
return DOXYGENPOSTSTRING;
}
if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) {
/* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */
yylval.str = NewString(loc);
return DOXYGENSTRING;
}
}
}
break;

View file

@ -63,7 +63,6 @@ static Node **class_decl = NULL;
/* -----------------------------------------------------------------------------
* Doxygen Comment Globals and Assist Functions
* ----------------------------------------------------------------------------- */
int parseComments = 1; /* set this to activate Doxygen uptake into the parse tree */
String *currentComment; /* Location of the stored Doxygen Comment */
String *currentPostComment; /* Location of the stored Doxygen Post-Comment */
String *currentCComment; /* Location of the stored C Comment */
@ -107,7 +106,7 @@ static Node *new_node(const_String_or_char_ptr tag) {
set_nodeType(n,tag);
Setfile(n,cparse_file);
Setline(n,cparse_line);
if(parseComments){
if(scan_doxygen_comments){
/* Sets any post comments to the previous node */
if(previousNode != NULL && currentPostComment != 0){
String *copyPostComment = Copy(currentPostComment);