#include "dealparse.tab.h"
extern int yydebug;
+extern string doctext;
+extern string cvs_id;
%}
%x INSTRING
%x INFUNCTION
%x BASEINIT
+%x DOCCOMMENT
NAME [_a-zA-Z][_a-zA-Z0-9]*
INT [+-]?[0-9]+
WHITE [ \t\n\f\v]
CLASS (class)|(struct)|(union)
ACCESS (public)|(protected)|(private)
-OP \+|\-|\/|\||\^|(==)|(!=)|(<<)|(>>)|(->)
+OP \+|\-|\/|\||\^|(==)|(!=)|(<<)|(>>)|(->)|(\+\+)|(\-\-)
%%
"//<" { return COMTEMP; }
- /* End of declaration section */
+"/**" { yy_push_state(DOCCOMMENT); }
+<DOCCOMMENT>\*\/ { yy_pop_state(); }
+<DOCCOMMENT>.|\n { doctext += string(yytext); }
-\n?"/*"[-* ]*[Ii]nline.* { return ENDOFDECL; }
-
-
-\n?"/*" { yy_push_state(COMMENT); }
+"/*" { yy_push_state(COMMENT); }
<COMMENT>.
<COMMENT>\n
<COMMENT>"*/" { yy_pop_state(); }
-DeclException[0-9] { return(DECLEXCEPTION); }
+DeclException[0-9] { yylval = string("@") + string(yytext); return(DECLEXCEPTION); }
<EXC_IGNORE>.
<EXC_IGNORE>\n
<EXC_IGNORE>");" { yy_pop_state(); }
<LINECOMMENT>.
<LINECOMMENT>\n { yy_pop_state(); }
+ /* scan CVS id in file preamble */
+
+"$Id$" { cvs_id = string(yytext); }
+<LINECOMMENT>"$Id$" { cvs_id = string(yytext); }
+<COMMENT>"$Id$" { cvs_id = string(yytext); }
+
+
/* Ignore function bodies */
<INFUNCTION>"{" { yy_push_state(INFUNCTION); }
/*** keywords ***/
-const { return CONST; }
-virtual { return VIRTUAL; }
-operator { return OPERATOR; }
-unsigned { return UNSIGNED; }
-static { return STATIC; }
-mutable { return MUTABLE; }
-template { return TEMPLATE; }
-enum { return ENUM; }
-friend { return FRIEND; }
-typedef { return TYPEDEF; }
+const { return CONST; }
+virtual { return VIRTUAL; }
+operator { return OPERATOR; }
+unsigned { return UNSIGNED; }
+static { return STATIC; }
+extern { return EXTERN; }
+mutable { return MUTABLE; }
+template { return TEMPLATE; }
+enum { return ENUM; }
+friend { return FRIEND; }
+typedef { return TYPEDEF; }
namespace { return NAMESPACE; }
+using { return USING; }
typename {}
{CLASS} { yylval = string(yytext); return CLASS; }
void enterfunction();
void enterbaseinitializers();
+string doctext;
+string cvs_id;
+
+void printdoc(ostream& s)
+ {
+ s << doctext << endl;
+ doctext = string("");
+ }
+
+
void yyerror(const char* s)
{
cerr << s << endl;
%}
%token NAMESPACE
+%token USING
%token CLASS
%token TYPEDEF
%token ACCESS
%token FARG
%token CONST
%token STATIC
+%token EXTERN
%token MUTABLE
%token VIRTUAL
%token ENUM
declaration_list: declaration
| declaration_list { cout << "@@@" << endl; } declaration
- | NAMESPACE '{' declaration_list '}' ';'
+ | declaration_list NAMESPACE identifier '{' declaration_list '}' ';'
| declaration_list ';'
;
| variable_declaration ';'
| enum_declaration ';'
| typedef_declaration ';'
- | template_declaration class_declaration ';'
- { cout << setw(OUTW) << "@Template-Description:" << $1 << endl; }
+ | template_declaration
+ { cout << setw(OUTW) << "@Template-Description:" << $1 << endl; } class_declaration ';'
| template_declaration function_declaration ';'
{ cout << setw(OUTW) << "@Template-Description:" << $1 << endl; }
| template_declaration function_declaration '{' { enterfunction();
cout << setw(OUTW) << "@Template-Description:" << $1 << endl; }
| template_declaration function_declaration ':' { enterbaseinitializers();
cout << setw(OUTW) << "@Template-Description:" << $1 << endl; }
+ | using_declaration ';';
| deal_exception_declaration ';'
| ';'
;
+using_declaration:
+ USING NAMESPACE identifier
+;
+
variable_declaration:
vartype identifier
{ cout << setw(OUTW) << "@Variable-Declaration:" << $2 << endl
+ << cvs_id << endl
<< setw(OUTW) << "@Type:" << $1 << endl
<< setw(OUTW) << "@In-Class:" << class_stack.top() << endl
- << setw(OUTW) << "@Access:" << access_stack.top() << endl; }
+ << setw(OUTW) << "@Access:" << access_stack.top() << endl;
+ printdoc(cout); }
| vartype identifier array_dimensions
{ cout << setw(OUTW) << "@Variable-Declaration:" << $2 << endl
+ << cvs_id << endl
<< setw(OUTW) << "@Type:" << $1 << endl
<< setw(OUTW) << "@In-Class:" << class_stack.top() << endl
<< setw(OUTW) << "@Access:" << access_stack.top() << endl
- << setw(OUTW) << "@Array-Dimension:" << $3 << endl; }
+ << setw(OUTW) << "@Array-Dimension:" << $3 << endl;
+ printdoc(cout); }
| variable_declaration '=' expression
/* | enum_declaration identifier*/
;
typedef_declaration:
TYPEDEF vartype identifier
{ cout << setw(OUTW) << "@Typedef:" << $3 << endl
+ << cvs_id << endl
<< setw(OUTW) << "@Type:" << $2 << endl
- << setw(OUTW) << "@Access:" << access_stack.top() << endl; }
+ << setw(OUTW) << "@Access:" << access_stack.top() << endl;
+ printdoc(cout); }
+ | TYPEDEF vartype '(' '*' identifier ')' argument_declaration
+ { cout << setw(OUTW) << "@Typedef-Functionpointer:" << $4 << endl
+ << setw(OUTW) << "@Type:" << $2<< endl
+ << setw(OUTW) << "@Access:" << access_stack.top() << endl;
+ printdoc(cout); }
+ | TYPEDEF vartype '(' identifier ':' ':' '*' identifier ')' argument_declaration
+ { cout << setw(OUTW) << "@Typedef-Functionpointer:" << $8 << endl
+ << setw(OUTW) << "@Type:" << $2<< endl
+ << setw(OUTW) << "@Access:" << access_stack.top() << endl;
+ printdoc(cout); }
+ | TYPEDEF vartype '(' '*' identifier ')' argument_declaration CONST
+ { cout << setw(OUTW) << "@Typedef-Functionpointer:" << $4 << endl
+ << setw(OUTW) << "@Type:" << $2<< endl
+ << setw(OUTW) << "@Access:" << access_stack.top() << endl;
+ printdoc(cout); }
+ | TYPEDEF vartype '(' identifier ':' ':' '*' identifier ')' argument_declaration CONST
+ { cout << setw(OUTW) << "@Typedef-Functionpointer:" << $8 << endl
+ << setw(OUTW) << "@Type:" << $2<< endl
+ << setw(OUTW) << "@Access:" << access_stack.top() << endl;
+ printdoc(cout); }
| TYPEDEF vartype identifier array_dimensions
{ cout << setw(OUTW) << "@Typedef:" << $3 << endl
+ << cvs_id << endl
<< setw(OUTW) << "@Type:" << $2 << endl
<< setw(OUTW) << "@Access:" << access_stack.top() << endl
- << setw(OUTW) << "@Array-Dimension:" << $4 << endl; }
+ << setw(OUTW) << "@Array-Dimension:" << $4 << endl;
+ printdoc(cout); }
;
array_dimensions:
function_name argument_declaration
{
cout << setw(OUTW) << "@Function-Definition:" << $1 << endl
+ << cvs_id << endl
<< setw(OUTW) << "@Function-Parameters:" << $2 << endl
<< setw(OUTW) << "@In-Class:" << class_stack.top() << endl
<< setw(OUTW) << "@Access:" << access_stack.top() << endl;
+ printdoc(cout);
}
| function_name argument_declaration CONST
{
cout << setw(OUTW) << "@Function-Definition:" << $1 << endl
+ << cvs_id << endl
<< setw(OUTW) << "@Function-Parameters:" << $2 << endl
<< setw(OUTW) << "@Const:" << "const" << endl
<< setw(OUTW) << "@In-Class:" << class_stack.top() << endl
<< setw(OUTW) << "@Access:" << access_stack.top() << endl;
+ printdoc(cout);
}
| vartype function_declaration
{
| vartype identifier { $$ = $1 + SPC + $2; }
| vartype identifier '=' default_arg
{ $$ = $1 + SPC + $2 + string(" = ") + $4; }
+ | vartype '=' default_arg
+ { $$ = $1 + SPC + string(" = ") + $3; }
| CLASS IDENTIFIER { $$ = $1 + SPC + $2; }
| vartype '(' identifier ')' argument_declaration
{ $$ = $1 + $2 + $3 + $4 + string(" (") + $5 + string(")"); }
;
enumerator: IDENTIFIER
- | IDENTIFIER '=' literal
+ | IDENTIFIER '=' expression
;
class_declaration: class_head
| class_head
{
- cout << "@@@" << endl << setw(OUTW) << "@Class-Definition:" << $1 << endl
+ cout << setw(OUTW) << "@Class-Definition:" << $1 << endl
+ << cvs_id << endl
<< setw(OUTW) << "@In-Class:" << class_stack.top() << endl;
+ printdoc(cout);
class_name = class_stack.top() + string("::") + class_name;
class_stack.push(class_name);
access_stack.push(string("private"));
;
friend_declaration:
- FRIEND /* declaration { cout << setw(OUTW) << "Friend:" << endl; } */
- | TEMPLATE '<' '>' FRIEND /*declaration { cout << setw(OUTW) << "Friend:" << endl; } */
+ FRIEND /* declaration { cout << setw(OUTW) << "Friend:" << endl; } */
+ | template_declaration FRIEND /* declaration { cout << setw(OUTW) << "Friend:" << endl; } */
;
vartype:
| vartype '*' { $$ = $1 + string("*"); }
| STATIC vartype { $$ = string("static ") + $2; }
| MUTABLE vartype { $$ = string("mutable ") + $2; }
+ | EXTERN vartype { $$ = $2; }
+
;
virtualopt: VIRTUAL { $$ = string("virtual"); }
| identifier
| OP expression { $$ = $1 + $2; }
| expression OP expression { $$ = $1 + $2 + $3; }
+ | expression '*' expression { $$ = $1 + $2 + $3; }
| expression INT { $$ = $1 + $2; }
| identifier argument_declaration { $$ = $1 + $2; }
| '(' expression ')' { $$ = $1 + $2 + $3; }
;
template_args:
- '<' template_arglist '>' { $$ = string("<") + $2 + string(">"); }
+ '<' '>' { $$ = string("<>"); }
+ | '<' template_arglist '>' { $$ = string("<") + $2 + string(">"); }
;
template_arglist:
template_arg:
vartype
| expression
- | CLASS IDENTIFIER { $$ = $1 + SPC + $2; }
+ | CLASS identifier { $$ = $1 + SPC + $2; }
;
template_statement:
TEMPLATE '<' arguments '>' { $$ = $3; }
+ | TEMPLATE '<' '>' { $$ = SPC; }
;
template_declaration:
deal_exception_declaration:
DECLEXCEPTION '(' IDENTIFIER deal_exception_arglist ')'
+ { cout << setw(OUTW) << $1 << ':' << $3 << endl
+ << setw(OUTW) << "@In-Class:" << class_stack.top() << endl
+ << setw(OUTW) << "@Access:" << access_stack.top() << endl;
+ printdoc(cout); }
;
deal_exception_arglist: /* empty */
| deal_exception_arglist ',' deal_exception_arg
;
-deal_exception_arg: identifier
+deal_exception_arg:
+ vartype
| deal_exception_output_declaration
| literal
;