+++ /dev/null
-
-%option stack
-
-%{
-#define YYSTYPE string
-#include <string>
-#include <iostream>
-
-#include "dealparse.tab.h"
-
-extern int yydebug;
-extern string doctext;
-extern string cvs_id;
-
-%}
-
-%x COMMENT
-%x LINECOMMENT
-%x EXC_IGNORE
-%x INSTRING
-%x INFUNCTION
-%x BASEINIT
-%x DOCCOMMENT
-
-NAME [_a-zA-Z][_a-zA-Z0-9]*
-INT [+-]?[0-9]+
-WHITE [ \t\n\f\v]
-ID "$"Id[^\$]*
-CLASS (class)|(struct)|(union)
-ACCESS (public)|(protected)|(private)
-OP \+|\-|\/|\||\^|(==)|(!=)|(<<)|(>>)|(->)|(\+\+)|(\-\-)
-
-%%
-
- /* Commentary template arguments for the parser */
-
-"//<" { return COMTEMP; }
-
-"/**" { yy_push_state(DOCCOMMENT); }
-<DOCCOMMENT>\*\/ { yy_pop_state(); }
-<DOCCOMMENT>.|\n { doctext += string(yytext); }
-
-"/*" { yy_push_state(COMMENT); }
-<COMMENT>.
-<COMMENT>\n
-<COMMENT>"*/" { yy_pop_state(); }
-
-DeclException[0-9] { yylval = string("@") + string(yytext); return(DECLEXCEPTION); }
-<EXC_IGNORE>"(" { yy_push_state(EXC_IGNORE); }
-<EXC_IGNORE>")" { yy_pop_state(); }
-<EXC_IGNORE>.
-<EXC_IGNORE>\n
-
-"//" { yy_push_state(LINECOMMENT); }
-<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); }
-<INFUNCTION>"}" { yy_pop_state(); }
-<INFUNCTION>.
-<INFUNCTION>\n
-
- /* Ignore base initializers */
-<BASEINIT>"{" { yy_pop_state(); yy_push_state(INFUNCTION); }
-<BASEINIT>.
-<BASEINIT>\n
-
- /* Ignore preprocessor commands */
-
-^#.*(\\\n.*)*\n
-
- /* Ignore friend declarations so far */
-
-friend[^;]+; { return FRIEND; }
-
- /*** keywords ***/
-
-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; }
-long { return LONG; }
-typename {}
-
-{CLASS} { yylval = string(yytext); return CLASS; }
-{ACCESS} { yylval = string(yytext); return ACCESS; }
-
-{WHITE} {}
-{OP} { yylval = string(yytext); if (yydebug)
- cerr << "[" << yylval << "]"; return OP; }
-
- /*** literals ***/
-
- /* Parse strings: does not account for embedded \" */
-
-\"[^\"]*\" { yylval = string(yytext); return STRING; }
-
-{INT} { yylval = string(yytext); return INT; }
-0[xX][0-9a-fA-F]+ { yylval = string(yytext); return INT; }
-{INT}\.({INT})?(E[+-]?{INT})? { yylval = string(yytext); return FLOAT; }
-\.{INT}(E[+-]?{INT})? { yylval = string(yytext); return FLOAT; }
-{NAME} { yylval = string(yytext); if (yydebug)
- cerr << "[" << yylval << "]"; return IDENTIFIER; }
-. { yylval = string(yytext); return yytext[0]; }
-
-"..." { yylval = string(yytext); return THREEDOTS; }
-%%
-
-void enterfunction()
-{
- yy_push_state(INFUNCTION);
-}
-
-void enterexc()
-{
- yy_push_state(EXC_IGNORE);
-}
-
-void enterbaseinitializers()
-{
- yy_push_state(BASEINIT);
-}
+++ /dev/null
-%{
-#define YYSTYPE string
-#define OUTW 25
-
-#include <string>
-#include <iomanip>
-#include <stack>
-
-string SPC(" ");
-string class_name; // Contains the last classname parsed
-stack<string> class_stack;
-stack<string> access_stack;
-
-int yylex();
-void enterfunction();
-void enterexc();
-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 IDENTIFIER
-%token CONST
-%token STATIC
-%token EXTERN
-%token MUTABLE
-%token VIRTUAL
-%token ENUM
-%token FRIEND
-%token OPERATOR
-%token OP
-%token TEMPLATE
-%token UNSIGNED
-%token LONG
-%token INT
-%token FLOAT
-%token CHAR
-%token STRING
-%token COMTEMP
-%token DECLEXCEPTION
-%token INLINE
-%token THREEDOTS
-%token ENDOFDECL
-%%
-
-all: declaration_list
- | declaration_list INLINE { return 0; }
- | declaration_list ENDOFDECL { return 0; }
-;
-
-declaration_list: declaration
- | declaration_list { cout << "@@@" << endl; } declaration
- | declaration_list NAMESPACE identifier '{' declaration_list '}' ';'
- | declaration_list ';'
-;
-
-declaration:
- class_declaration ';'
- | function_declaration '{' { enterfunction(); }
- | function_declaration ':' { enterbaseinitializers(); }
- | function_declaration ';'
- | variable_declaration ';'
- | enum_declaration ';'
- | typedef_declaration ';'
- | 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;
- 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;
- 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) << "@In-Class:" << class_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) << "@In-Class:" << class_stack.top() << 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) << "@In-Class:" << class_stack.top() << 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) << "@In-Class:" << class_stack.top() << 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) << "@In-Class:" << class_stack.top() << 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) << "@In-Class:" << class_stack.top() << endl
- << setw(OUTW) << "@Access:" << access_stack.top() << endl
- << setw(OUTW) << "@Array-Dimension:" << $4 << endl;
- printdoc(cout); }
-;
-
-array_dimensions:
- '[' ']' { $$ = string("[]"); }
- | '[' expression ']' { $$ = string("[") + $2 + string("]"); }
- | '[' INT ']' { $$ = string("[") + $2 + string("]"); }
- | array_dimensions array_dimensions { $$ = $1 + $2; }
-;
-
-function_declaration:
- 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
- {
- cout << setw(OUTW) << "@Return-Type:" << $1 << endl;
- }
-;
-
-function_name:
- identifier
- | '~' identifier { $$ = string("~") + $2; }
- | OPERATOR operator { $$ = string("operator") + $2; }
- | OPERATOR vartype { $$ = string("operator") + $2; }
- | identifier ':' ':' function_name { $$ = $1 + string("::") + $4; }
-;
-
-operator: OP
- | operator '=' { $$ = $1 + string("="); }
- | '='
- | '&'
- | '*'
- | '<'
- | '>'
- | '(' ')' { $$ = string("()"); }
- | '[' ']' { $$ = string("[]"); }
-;
-
-argument_declaration:
- '(' ')' { $$ = string(""); }
- | '(' THREEDOTS ')' { $$ = $2; }
- | '(' arguments ')'
- { $$ = $2; }
-;
-
-arguments:
- argument
- | arguments ',' argument { $$ = $1 + string("@") + $3; }
-;
-
-argument:
- vartype
- | 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(")"); }
-;
-
-default_arg:
- expression
-;
-
-enum_declaration:
- ENUM IDENTIFIER '{' enum_list '}'
-;
-
-enum_list: /* empty */
- | enumerator
- | enum_list ',' enumerator { $$ = $1 + string("@") + $3; }
-;
-
-enumerator: IDENTIFIER
- | IDENTIFIER '=' expression
-;
-
-class_declaration: class_head
- | class_head
- {
- 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"));
- cout << "@@@" << endl;
- } '{' class_body '}'
- {
- class_stack.pop();
- access_stack.pop();
- }
-;
-
-class_head:
- CLASS identifier { $$ = $1 + SPC + $2; class_name = $2;}
- | CLASS identifier inheritance
- { $$ = $1 + SPC + $2 + $3; class_name = $2;}
-;
-
-inheritance:
- ':' inheritance_list { $$ = $2; }
-;
-
-inheritance_list:
- ancestor
- | inheritance_list ',' ancestor { $$ = $1 + $3; }
-;
-
-ancestor:
- virtualopt ACCESS virtualopt identifier
- { $$ = string("@") + $1 + SPC + $2 + SPC + $3 + SPC + $4; }
-;
-
-class_body: /* empty */
- | member_declaration_list
-;
-
-member_declaration_list: member_declaration
- | member_declaration_list { cout << "@@@" << endl; } member_declaration
- | member_declaration_list ';'
-;
-
-member_declaration:
- declaration
- | VIRTUAL declaration
- {
- cout << setw(OUTW) << "@Virtual:" << "virtual" << endl;
- }
- | VIRTUAL function_declaration '=' INT
- {
- cout << setw(OUTW) << "@Virtual:" << "pure" << endl;
- }
- | ACCESS ':' { access_stack.top() = $1; }
- | friend_declaration
-;
-
-friend_declaration:
- FRIEND /* declaration { cout << setw(OUTW) << "Friend:" << endl; } */
- | template_declaration FRIEND /* declaration { cout << setw(OUTW) << "Friend:" << endl; } */
-;
-
-vartype:
- identifier { $$ = $1; }
- | LONG IDENTIFIER { $$ = string("long ") + $2; }
- | UNSIGNED IDENTIFIER { $$ = string("unsigned ") + $2; }
- | CONST vartype { $$ = string("const ") + $2; }
- | vartype '*' CONST { $$ = $1 + string("* const"); }
- | vartype '&' { $$ = $1 + string("&"); }
- | vartype '*' { $$ = $1 + string("*"); }
- | STATIC vartype { $$ = string("static ") + $2; }
- | MUTABLE vartype { $$ = string("mutable ") + $2; }
- | EXTERN vartype { $$ = $2; }
-
-;
-
-virtualopt: VIRTUAL { $$ = string("virtual"); }
- | /* empty */ { $$ = string(""); }
-;
-
-identifier:
- IDENTIFIER
- | identifier ':' ':' identifier { $$ = $1 + string("::") + $4; }
- | identifier template_args { $$ = $1 + $2; }
- | IDENTIFIER COMTEMP template_arglist '>'
- { $$ = $1 + string("<") + $3 + string(">"); }
-;
-
-expression:
- literal
- | identifier
- | '&' expression { $$ = string("&") + $2; }
- | OP expression { $$ = $1 + $2; }
- | expression OP expression { $$ = $1 + $2 + $3; }
- | expression '?' expression ':' expression { $$ = string("Conditional"); }
- | expression '*' expression { $$ = $1 + $2 + $3; }
- | expression INT { $$ = $1 + $2; }
- | identifier argument_declaration { $$ = $1 + $2; }
- | '(' expression ')' { $$ = $1 + $2 + $3; }
-;
-
-literal:
- INT
- | FLOAT
- | CHAR
- | STRING
-;
-
-template_args:
- '<' '>' { $$ = string("<>"); }
- | '<' template_arglist '>' { $$ = string("<") + $2 + string(">"); }
-;
-
-template_arglist:
- template_arg
- | template_arglist ',' template_arg { $$ = $1 + string(",") + $3; }
-;
-
-template_arg:
- vartype
- | expression
- | CLASS identifier { $$ = $1 + SPC + $2; }
-;
-
-template_statement:
- TEMPLATE '<' arguments '>' { $$ = $3; }
- | TEMPLATE '<' '>' { $$ = SPC; }
-;
-
-template_declaration:
- template_statement
- | template_declaration template_statement { $$ = $1 + $2; }
-;
-
-deal_exception_declaration:
- DECLEXCEPTION '(' IDENTIFIER
- { cout << setw(OUTW) << $1 << ':' << $3 << endl
- << setw(OUTW) << "@In-Class:" << class_stack.top() << endl
- << setw(OUTW) << "@Access:" << access_stack.top() << endl;
- printdoc(cout);
- enterexc();
- }
-;
-
-
-%%
-
-main(int argc, const char** argv)
-{
- string toplevel("");
- class_stack.push(toplevel);
- access_stack.push(toplevel);
- if (argc>1)
- yydebug=atoi(argv[1]);
- else
- yydebug=0;
- yyparse();
-}
+++ /dev/null
-#!/usr/local/bin/perl
-#
-# $Id$
-#
-# Enter all names into the postgres database
-#
-# Variables and Typedefs are missing
-
-use DBI;
-
-$docindex = 0;
-
-open DOCFILE,">tmpdoc" || die "Could not open docfile";
-
-$db = DBI->connect('DBI:Pg:dbname=deal;host=gaia','deal','DEAL!!') ||
- die $DBI::errstr;
-
-#$db->trace(2);
-
-$db->do('delete from classes;');
-$db->do('delete from inheritance;');
-$db->do('delete from roots;');
-$db->do('delete from exceptions;');
-$db->do('delete from functions;');
-
-$enterclass = $db->prepare('insert into classes (type, name, templates, fullname, scope, access, file, version, documentation) values (?, ?, ?, ?, ?, ?, ?, ?, ?);');
-
-$enterinheritance = $db->prepare('insert into inheritance (inheritor, inherits, access) values (?, ?, ?);');
-
-$enterroot = $db->prepare('insert into roots (name) values (?);');
-
-$enterexception = $db->prepare('insert into exceptions (name, scope, access, arguments, documentation) values (?, ?, ?, ?, ?);');
-
-$enterfunction = $db->prepare('insert into functions (type, name, templates, scope, access, file, version, parameters, virtual, const, documentation) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
-
-#$enterclass->trace(2);
-
-sub output;
-
-while(<>)
-{
- if(/^\@\@\@/)
- {
- # Output depending on defined entity
- output();
- # Delete all variables
- $template_description = "";
- $classname = "";
- $functionname = "";
- $variablename = "";
- $typedef = "";
- $exception = "";
- @inheritance = ();
- $inclass = "";
- $function_parameters = "";
- $access = "";
- $array = "";
- $type = "";
- $const = 0;
- $virtual = "";
- $file = "";
- $doc = "";
- }
- elsif (/\@Template-Description:(.*)/)
- {
- $template_description = $1;
- }
- elsif (/\@Class-Definition:(.*)/)
- {
- ($temp, @inheritance) = split /\@/, $1;
- ($type, $classname) = split / /, $temp, 2;
- }
- elsif (/\@In-Class:(.*)/)
- {
- $inclass = $1;
- $inclass =~ s/^:://;
- }
- elsif (/\@Function-Definition:(.*)/)
- {
- $functionname = $1;
- }
- elsif (/\@Variable-Declaration:(.*)/)
- {
- $variablename = $1;
- }
- elsif (/\@DeclException(.):(.*)/)
- {
- $exception = $2;
- $exceptionargs = $1;
- }
- elsif (/\@Typedef(-Functionpointer)?:(.*)/)
- {
- $typedef = $2;
- }
- elsif (/\@Function-Parameters:(.*)/)
- {
- $function_parameters = $1;
- }
- elsif (/\@Access:(.*)/)
- {
- $access = $1;
- }
- elsif (/\@Array-Dimension:(.*)/)
- {
- $array = $1;
- }
- elsif (/\@(Return-)?Type:(.*)/)
- {
- $type = $2;
- }
- elsif (/\@Const:(.*)/)
- {
- $const = 1;
- }
- elsif (/\@Virtual:(.*)/)
- {
- $virtual = $1;
- }
- elsif (/^\s*\@/)
- {
-# print;
- }
- elsif (/^\s*\$(Id:)\s*(\S+)\s+(\S+)/)
- {
- $file = $2;
- $version = $3;
- $file =~ s/,v//;
- }
- elsif (/\s*\*/)
- {
- s/\s*\* ?//;
- $doc .= $_;
- }
-}
-
-$enterclass->finish;
-$enterinheritance->finish;
-$db->disconnect;
-
-sub output
-{
- if ($classname)
- {
- print STDERR '.';
-# print $type, ' ';
-# print $inclass, '::' if ($inclass);
-# print $classname, " $file $version\n";
- $fullname = "";
- $fullname = $inclass . '::' if ($inclass);
- $fullname .= $classname;
- $enterclass->execute($type, $classname, $template_description, $fullname, $inclass,
- $access, $file, $version, $docindex);
-
- print DOCFILE "\@\@\@$docindex\n$doc\n";
- $docindex++;
-
- foreach (@inheritance)
- {
- m/\s*(\w+)\s+(.*)/;
- $enterinheritance->execute($fullname, $2, $1);
- }
- $enterroot->execute($fullname) unless (@inheritance);
- }
- elsif($exception)
- {
- $enterexception->execute($exception, $inclass, $access,
- $exceptionargs, $docindex);
-
- print DOCFILE "\@\@\@$docindex\n$doc\n";
- $docindex++;
- }
- elsif ($functionname)
- {
- $enterfunction->execute($type, $functionname, $template_description,
- $inclass, $access, $file, $version,
- $function_parameters,
- $virtual, ($const) ? 't' : 'f', $docindex);
-
- print DOCFILE "\@\@\@$docindex\n$doc\n";
- $docindex++;
- }
-}
-