Small modifications to place comments into the parse tree (Fairly inflexible at the moment)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10620 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
bfb5a0989b
commit
d97e486fb4
2 changed files with 42 additions and 1 deletions
|
|
@ -426,6 +426,14 @@ int yylook(void) {
|
||||||
if ((strncmp(loc,"/*@SWIG@",6) == 0) && (loc[Len(cmt)-3] == '@')) {
|
if ((strncmp(loc,"/*@SWIG@",6) == 0) && (loc[Len(cmt)-3] == '@')) {
|
||||||
scanner_locator(cmt);
|
scanner_locator(cmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
break;
|
||||||
case SWIG_TOKEN_ENDLINE:
|
case SWIG_TOKEN_ENDLINE:
|
||||||
|
|
@ -897,6 +905,8 @@ int yylex(void) {
|
||||||
return (ID);
|
return (ID);
|
||||||
case POUND:
|
case POUND:
|
||||||
return yylex();
|
return yylex();
|
||||||
|
case SWIG_TOKEN_COMMENT:
|
||||||
|
return yylex();
|
||||||
default:
|
default:
|
||||||
return (l);
|
return (l);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,14 @@ static int max_class_levels = 0;
|
||||||
static int class_level = 0;
|
static int class_level = 0;
|
||||||
static Node **class_decl = NULL;
|
static Node **class_decl = NULL;
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Doxygen Comment Globals
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int isComment = 0; /* boolean for parsing Doxygen Comments */
|
||||||
|
String *currentComment = 0; /* Location of the stored Doxygen Comment */
|
||||||
|
static String *sideDoxComments = 0;
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Assist Functions
|
* Assist Functions
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
@ -71,6 +79,12 @@ static Node *new_node(const String_or_char *tag) {
|
||||||
set_nodeType(n,tag);
|
set_nodeType(n,tag);
|
||||||
Setfile(n,cparse_file);
|
Setfile(n,cparse_file);
|
||||||
Setline(n,cparse_line);
|
Setline(n,cparse_line);
|
||||||
|
/* Sets Comment if a Comment is Availible */
|
||||||
|
if(isComment){
|
||||||
|
String *copyComment = Copy(currentComment);
|
||||||
|
Setattr(n,"comment",copyComment);
|
||||||
|
isComment = 0;
|
||||||
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1440,6 +1454,7 @@ static void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) {
|
||||||
%token <str> OPERATOR
|
%token <str> OPERATOR
|
||||||
%token <str> COPERATOR
|
%token <str> COPERATOR
|
||||||
%token PARSETYPE PARSEPARM PARSEPARMS
|
%token PARSETYPE PARSEPARM PARSEPARMS
|
||||||
|
%token <str> DOXYGENSTRING
|
||||||
|
|
||||||
%left CAST
|
%left CAST
|
||||||
%left QUESTIONMARK
|
%left QUESTIONMARK
|
||||||
|
|
@ -1511,6 +1526,7 @@ static void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) {
|
||||||
%type <ptype> type_specifier primitive_type_list ;
|
%type <ptype> type_specifier primitive_type_list ;
|
||||||
%type <node> fname stringtype;
|
%type <node> fname stringtype;
|
||||||
%type <node> featattr;
|
%type <node> featattr;
|
||||||
|
%type <str> doxygen_comment;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
|
@ -1568,6 +1584,7 @@ interface : interface declaration {
|
||||||
declaration : swig_directive { $$ = $1; }
|
declaration : swig_directive { $$ = $1; }
|
||||||
| c_declaration { $$ = $1; }
|
| c_declaration { $$ = $1; }
|
||||||
| cpp_declaration { $$ = $1; }
|
| cpp_declaration { $$ = $1; }
|
||||||
|
| doxygen_comment { $$ = $1; }
|
||||||
| SEMI { $$ = 0; }
|
| SEMI { $$ = 0; }
|
||||||
| error {
|
| error {
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
|
|
@ -2811,6 +2828,7 @@ warn_directive : WARN string {
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
/* ======================================================================
|
/* ======================================================================
|
||||||
* C Parsing
|
* C Parsing
|
||||||
* ====================================================================== */
|
* ====================================================================== */
|
||||||
|
|
@ -3132,6 +3150,20 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end {
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------
|
||||||
|
A Doxygen Comment (a string in Doxygen Format)
|
||||||
|
------------------------------------------------------------ */
|
||||||
|
|
||||||
|
doxygen_comment : DOXYGENSTRING
|
||||||
|
{
|
||||||
|
currentComment = NewString($1);
|
||||||
|
isComment = 1;
|
||||||
|
$$ = 0;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ======================================================================
|
/* ======================================================================
|
||||||
* C++ Support
|
* C++ Support
|
||||||
* ====================================================================== */
|
* ====================================================================== */
|
||||||
|
|
@ -5977,4 +6009,3 @@ ParmList *Swig_cparse_parms(String *s) {
|
||||||
/* Printf(stdout,"typeparse: '%s' ---> '%s'\n", s, top); */
|
/* Printf(stdout,"typeparse: '%s' ---> '%s'\n", s, top); */
|
||||||
return top;
|
return top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue