From 5c0cd50a43e9bcc85f636fa8d49b1f9947e3640f Mon Sep 17 00:00:00 2001 From: Lutz Kettner Date: Tue, 7 Sep 1999 11:21:10 +0000 Subject: [PATCH] Release before handing over to Susan Hert. --- Packages/Manual_tools/src/INSTALLATION | 4 +- Packages/Manual_tools/src/Makefile | 24 +- Packages/Manual_tools/src/Makefile_depend | 34 +- Packages/Manual_tools/src/README | 3 +- Packages/Manual_tools/src/basic.C | 101 +++++ Packages/Manual_tools/src/basic.h | 53 +++ Packages/Manual_tools/src/buffer.C | 243 +----------- Packages/Manual_tools/src/buffer.h | 354 +++--------------- Packages/Manual_tools/src/cc_build_checker.C | 48 +-- Packages/Manual_tools/src/cc_extract.C | 127 ++++++- Packages/Manual_tools/src/cc_extract_html.C | 43 +-- Packages/Manual_tools/src/config.h | 7 +- Packages/Manual_tools/src/cpp_formatting.C | 92 ++--- Packages/Manual_tools/src/cpp_formatting.h | 1 - Packages/Manual_tools/src/extract_lex.yy | 2 +- Packages/Manual_tools/src/extract_syntax.y | 350 +++++++++-------- Packages/Manual_tools/src/html_config.h | 20 +- Packages/Manual_tools/src/html_lex.yy | 2 +- Packages/Manual_tools/src/html_syntax.y | 44 +-- Packages/Manual_tools/src/internal_macros.C | 26 +- Packages/Manual_tools/src/internal_macros.h | 8 +- .../latex_converter_config/html/cc_manual.sty | 2 - .../src/latex_converter_config/html/latex.sty | 20 - .../ref_pages/Class.tex | 53 +++ .../ref_pages/Concept.tex | 52 +++ .../latex_converter_config/ref_pages/Enum.tex | 42 +++ .../ref_pages/Function.tex | 42 +++ .../ref_pages/Macro.tex | 42 +++ .../ref_pages/Variable.tex | 42 +++ Packages/Manual_tools/src/lex_include.h | 1 - Packages/Manual_tools/src/macro_dictionary.C | 91 +++-- Packages/Manual_tools/src/macro_dictionary.h | 35 +- Packages/Manual_tools/src/mstring.h | 2 + Packages/Manual_tools/src/output.h | 3 +- Packages/Manual_tools/src/string_conversion.C | 4 +- 35 files changed, 1007 insertions(+), 1010 deletions(-) create mode 100644 Packages/Manual_tools/src/basic.C create mode 100644 Packages/Manual_tools/src/basic.h create mode 100644 Packages/Manual_tools/src/latex_converter_config/ref_pages/Class.tex create mode 100644 Packages/Manual_tools/src/latex_converter_config/ref_pages/Concept.tex create mode 100644 Packages/Manual_tools/src/latex_converter_config/ref_pages/Enum.tex create mode 100644 Packages/Manual_tools/src/latex_converter_config/ref_pages/Function.tex create mode 100644 Packages/Manual_tools/src/latex_converter_config/ref_pages/Macro.tex create mode 100644 Packages/Manual_tools/src/latex_converter_config/ref_pages/Variable.tex diff --git a/Packages/Manual_tools/src/INSTALLATION b/Packages/Manual_tools/src/INSTALLATION index 6b908c0d8a9..d5ba4a862e6 100644 --- a/Packages/Manual_tools/src/INSTALLATION +++ b/Packages/Manual_tools/src/INSTALLATION @@ -1,7 +1,7 @@ INSTALLATION for the Specification and Manual Writing Tools for C++ Reference Manuals =========================================================== -03.08.1998 Zurich Lutz Kettner +24.08.1999 Zurich Lutz Kettner Installation of the Supporting Tools: @@ -11,7 +11,7 @@ Installation of the Supporting Tools: (1) System Requirements: - * C++ Compiler (Gnu g++ 2.8.1 and SGI CC 7.2 were tested) + * C++ Compiler (Gnu g++ 2.8.1, 2.95.1, Gnu egcs 1.1.2) * C Compiler (Gnu gcc 2.6.3 or the usual system cc compiler) * flex and bison * perl 5 diff --git a/Packages/Manual_tools/src/Makefile b/Packages/Manual_tools/src/Makefile index c203057dd0d..f6d871fa463 100644 --- a/Packages/Manual_tools/src/Makefile +++ b/Packages/Manual_tools/src/Makefile @@ -94,20 +94,22 @@ all: $(ALL) # modules # -------------------- -database.o : database.C database.h config.h +basic.o : basic.h -extract_lex.o : extract_syntax.tab.h database.h config.h +buffer.o : buffer.C buffer.h config.h basic.h -extract_syntax.o : extract_syntax.tab.h database.h config.h +extract_lex.o : extract_syntax.tab.h buffer.h config.h basic.h -cc_extract.o : database.h config.h +extract_syntax.o : extract_syntax.tab.h buffer.h config.h basic.h -cc_build_checker.o : database.h config.h +cc_extract.o : buffer.h config.h basic.h + +cc_build_checker.o : buffer.h config.h basic.h # program # -------------------- -OBJ = extract_lex.o extract_syntax.o database.o -HEADER = extract_syntax.tab.h database.h config.h +OBJ = extract_lex.o extract_syntax.o buffer.o basic.o +HEADER = extract_syntax.tab.h buffer.h config.h basic.h cc_extract : ${OBJ} ${HEADER} cc_extract.o ${CXX} ${CXXFLAGS} -o $@ $@.o ${OBJ} ${LDFLAGS} @@ -132,7 +134,8 @@ cc_extract_html.o : cc_extract_html.C # -------------------- OBJHTML = html_lex.o \ html_syntax.o \ - database.o \ + basic.o \ + buffer.o \ macro_dictionary.o \ internal_macros.o \ html_error.o \ @@ -202,7 +205,8 @@ install: rminstall pathinstall cpinstall mvinstall refinstall gifinstall DEPENDSRC = html_lex.C \ html_syntax.C \ - database.C \ + basic.C \ + buffer.C \ macro_dictionary.C \ internal_macros.C \ html_error.C \ @@ -216,7 +220,7 @@ DEPENDSRC = html_lex.C \ depend: ${DEPENDSRC} # Works only with SunPro CC - CC -I. ${CPPFLAGS} ${CXXFLAGS} -xM1 ${DEPENDSRC} | grep -v "STL/SUN" | grep -v "ADT" | grep -v "opt/SUNWspro" | sort | uniq > Makefile_depend + CC -I. ${CPPFLAGS} ${CXXFLAGS} -xM1 ${DEPENDSRC} | grep -v "STL/SUN" | grep -v "opt/SUNWspro" | sort | uniq > Makefile_depend # ===================================================================== diff --git a/Packages/Manual_tools/src/Makefile_depend b/Packages/Manual_tools/src/Makefile_depend index 81568091b41..ae9a25358a1 100644 --- a/Packages/Manual_tools/src/Makefile_depend +++ b/Packages/Manual_tools/src/Makefile_depend @@ -1,5 +1,6 @@ cc_extract_html.C: -cc_extract_html.o : ./database.h +cc_extract_html.o : ./basic.h +cc_extract_html.o : ./buffer.h cc_extract_html.o : ./html_config.h cc_extract_html.o : ./html_error.h cc_extract_html.o : ./html_lex.h @@ -13,7 +14,8 @@ cc_extract_html.o : ./string_conversion.h cc_extract_html.o : cc_extract_html.C cpp_formatting.C: cpp_formatting.o : ./cpp_formatting.h -cpp_formatting.o : ./database.h +cpp_formatting.o : ./basic.h +cpp_formatting.o : ./buffer.h cpp_formatting.o : ./html_config.h cpp_formatting.o : ./html_error.h cpp_formatting.o : ./html_lex.h @@ -23,18 +25,21 @@ cpp_formatting.o : ./mstring.h cpp_formatting.o : ./output.h cpp_formatting.o : ./string_conversion.h cpp_formatting.o : cpp_formatting.C -database.C: -database.o : ./database.h -database.o : database.C +buffer.C: +buffer.o : ./basic.h +buffer.o : ./buffer.h +buffer.o : buffer.C html_error.C: -html_error.o : ./database.h +html_error.o : ./basic.h +html_error.o : ./buffer.h html_error.o : ./html_config.h html_error.o : ./html_error.h html_error.o : ./lex_include.h html_error.o : ./mstring.h html_error.o : html_error.C html_lex.C: -html_lex.o : ./database.h +html_lex.o : ./basic.h +html_lex.o : ./buffer.h html_lex.o : ./html_config.h html_lex.o : ./html_error.h html_lex.o : ./html_lex.h @@ -47,8 +52,9 @@ html_lex.o : ./mstring.h html_lex.o : ./string_conversion.h html_lex.o : html_lex.C html_syntax.C: +html_syntax.o : ./basic.h html_syntax.o : ./cpp_formatting.h -html_syntax.o : ./database.h +html_syntax.o : ./buffer.h html_syntax.o : ./html_config.h html_syntax.o : ./html_error.h html_syntax.o : ./html_lex.h @@ -60,8 +66,9 @@ html_syntax.o : ./mstring.h html_syntax.o : ./string_conversion.h html_syntax.o : html_syntax.C internal_macros.C: +internal_macros.o : ./basic.h internal_macros.o : ./cpp_formatting.h -internal_macros.o : ./database.h +internal_macros.o : ./buffer.h internal_macros.o : ./html_config.h internal_macros.o : ./html_error.h internal_macros.o : ./html_lex.h @@ -73,7 +80,8 @@ internal_macros.o : ./output.h internal_macros.o : ./string_conversion.h internal_macros.o : internal_macros.C macro_dictionary.C: -macro_dictionary.o : ./database.h +macro_dictionary.o : ./basic.h +macro_dictionary.o : ./buffer.h macro_dictionary.o : ./html_config.h macro_dictionary.o : ./html_error.h macro_dictionary.o : ./html_lex.h @@ -83,8 +91,9 @@ macro_dictionary.o : ./mstring.h macro_dictionary.o : ./string_conversion.h macro_dictionary.o : macro_dictionary.C output.C: +output.o : ./basic.h output.o : ./cpp_formatting.h -output.o : ./database.h +output.o : ./buffer.h output.o : ./html_config.h output.o : ./html_error.h output.o : ./html_lex.h @@ -94,7 +103,8 @@ output.o : ./output.h output.o : ./string_conversion.h output.o : output.C string_conversion.C: -string_conversion.o : ./database.h +string_conversion.o : ./basic.h +string_conversion.o : ./buffer.h string_conversion.o : ./html_config.h string_conversion.o : ./html_lex.h string_conversion.o : ./mstring.h diff --git a/Packages/Manual_tools/src/README b/Packages/Manual_tools/src/README index 90afd11acc2..80c75c9d703 100644 --- a/Packages/Manual_tools/src/README +++ b/Packages/Manual_tools/src/README @@ -1,7 +1,7 @@ README for the Specification and Manual Writing Tools for C++ Reference Manuals ===================================================== -03.08.1998 Zurich Lutz Kettner kettner@acm.org +24.08.1999 Zurich Lutz Kettner kettner@acm.org This is the directory containing the tools for extracting the C++ declarations from a specification, to check the specification @@ -12,7 +12,6 @@ The directory structure is: INSTALLATION installation instructions. RCS/ revision controlled files. - ADT/ a list and a stack implementation. latex_converter_config/ configuration files for the LaTeX converter. test/ test suit. test_html/ conversion example using multiple directories. diff --git a/Packages/Manual_tools/src/basic.C b/Packages/Manual_tools/src/basic.C new file mode 100644 index 00000000000..1966883adb6 --- /dev/null +++ b/Packages/Manual_tools/src/basic.C @@ -0,0 +1,101 @@ +/************************************************************************** + + basic.C + ============================================================= + Project : CGAL merger tool for the specification task + Function : Assertions, indented output, etc. + System : C++ (g++) + Author : (c) 1995 Lutz Kettner + (c) 1999 Susan Hert + Revision : $Revision$ + Date : $Date$ + +**************************************************************************/ + +#include +#include + +// Own assertion macro +// ================================================ + +void cc_assertion_error( char *cond, char *fname, int line) { + cerr << endl << "fatal error: assertion '" << cond << "' failed in line " + << line << " of file '" << fname << "'." << endl; + abort(); +} + +// Indented output, using global indentation counter +// ==================================================== + +class Output_indentation { + int n; + int step; +public: + Output_indentation( int stepSize = 4) : n(0), step( stepSize) {} + void operator++(){ n += step;} + void operator--(){ n -= step;} + int indentation() { return n; } +}; + +ostream& operator<< (ostream& out, Output_indentation& ind) { + const char* s = " "; // 32 spaces !!! + int n = ind.indentation(); + while ( n > 32) { // 32 !!! + n -= 32; + out << s; + } + if ( n > 0) + out << (s + 32 - n); + return out; +} + +static Output_indentation output_indentation; + +ostream& indent( ostream& out){ + ++ output_indentation; + return out; +} + +ostream& outdent( ostream& out){ + -- output_indentation; + return out; +} + +ostream& ind_newline( ostream& out){ + out << endl << output_indentation; + return out; +} + +ostream& ind_space( ostream& out){ + out << output_indentation; + return out; +} + +int indentation_number() { + return output_indentation.indentation(); +} + +// Substitute old style malloc, realloc, strdup ... +// ================================================ +char* renew( char* old, size_t old_size, size_t new_size) { + CC_Assert( old_size == 0 || old != 0); + CC_Assert( new_size > old_size); + char* cpy = new char[ new_size]; + if ( old && old_size > 0) { + size_t min = ( old_size < new_size ? old_size : new_size); + memcpy( cpy, old, min); + delete[] old; + } + return cpy; +} + +char* newstr( const char* src) { + CC_Assert( src); + if ( ! src) + return 0; + char* s = new char[ strlen( src) + 1]; + strcpy( s, src); + return s; +} + +// EOF // diff --git a/Packages/Manual_tools/src/basic.h b/Packages/Manual_tools/src/basic.h new file mode 100644 index 00000000000..ee3362a1c65 --- /dev/null +++ b/Packages/Manual_tools/src/basic.h @@ -0,0 +1,53 @@ +/************************************************************************** + + basic.h + ============================================================= + Project : CGAL merger tool for the specification task + Function : Assertions, indented output, etc. + System : C++ (g++) + Author : (c) 1995 Lutz Kettner + (c) 1999 Susan Hert + Revision : $Revision$ + Date : $Date$ + +**************************************************************************/ + +#if ! defined( MODULE_BASIC) +#define MODULE_BASIC 1 + +#include +#include + +// Own assertion macro +// ================================================ + +void cc_assertion_error( char *cond, char *fname, int line); + +#if !NDEBUG +#define CC_Assert( cond) {\ + if (!( cond)) \ + cc_assertion_error( #cond, __FILE__, __LINE__); \ + } +#else // NDEBUG +#define CC_Assert( cond) (void)0 +#endif // NDEBUG + + +// Indented output, using global indentation counter +// ==================================================== + +ostream& indent( ostream&); +ostream& outdent( ostream&); +ostream& ind_newline( ostream&); +ostream& ind_space( ostream&); +int indentation_number(); + +// Substitute old style malloc, realloc, strdup ... +// ================================================ + +char* renew( char* old, size_t old_size, size_t new_size); +char* newstr( const char* src); + + + +#endif // MODULE_BASIC // diff --git a/Packages/Manual_tools/src/buffer.C b/Packages/Manual_tools/src/buffer.C index 53a190fb447..ec3f0cb01dd 100644 --- a/Packages/Manual_tools/src/buffer.C +++ b/Packages/Manual_tools/src/buffer.C @@ -1,10 +1,10 @@ /************************************************************************** - database.C + buffer.C ============================================================= Project : CGAL merger tool for the specification task - Function : Datastructures for the database extracted from - the TeX and C++ code mixed files. + Function : List of buffers (similar to strings) keeping the text + parsed from the TeX input files. System : C++ (g++) Author : (c) 1995 Lutz Kettner Revision : $Revision$ @@ -12,239 +12,12 @@ **************************************************************************/ -// Other modules needed: -// ===================== -#include -#include +#include - -// Substitute old style malloc, realloc, strdup ... -// ================================================ -char* renew( char* old, size_t old_size, size_t new_size) { - ADT_Assert( old_size == 0 || old != 0); - ADT_Assert( new_size > old_size); - char* cpy = new char[ new_size]; - if ( old && old_size > 0) { - size_t min = ( old_size < new_size ? old_size : new_size); - memcpy( cpy, old, min); - delete[] old; - } - return cpy; +void delete_list( Buffer_list* l) { + for ( Buffer_iterator i = l->begin(); i != l->end(); ++i) + delete *i; + delete l; } -char* newstr( const char* src) { - ADT_Assert( src); - if ( ! src) - return 0; - char* s = new char[ strlen( src) + 1]; - strcpy( s, src); - return s; -} - - -// Class definitions: -// ============================================== -int printComment( ostream &out, const Text& T, bool leadingLine, bool HTML) { - InListFIter< TextToken> words( (Text&)T); - int width = MaxTextWidth - indentation_number() - 3; - int w = width; - int state = 0; // 0 = start, 1 = after token, 2 = spaces - // 3 = one newline (and spaces), 4 = newlines - ForAll( words) { - switch ( state) { - case 0: - if ( !words->isSpace) { - if ( leadingLine) - out << endl; - out << indNewline << (HTML ? "" : "// ") << words->string; - w -= words->len; - state = 1; - } - break; - case 1: - if ( !words->isSpace || words->len > 0) { - if ( !words->isSpace) { - if ((words->len > w) && (w != width)) { - w = width; - out << indNewline << (HTML ? "" : "// "); - } - out << words->string; - w -= words->len; - } else { - if ( words->string[0] == '\n') - state = 3; - else - state = 2; - } - } - break; - case 2: - if ( !words->isSpace || words->len > 0) { - if ( !words->isSpace) { - if ((words->len >= w) && (w != width)) { - w = width; - out << indNewline << (HTML ? "" : "// "); - } else { - out << ' '; - w--; - } - out << words->string; - w -= words->len; - state = 1; - } else { - if ( words->string[0] == '\n') - state = 3; - } - } - break; - case 3: - if ( !words->isSpace || words->len > 0) { - if ( !words->isSpace) { - if ((words->len >= w) && (w != width)) { - w = width; - out << indNewline << (HTML ? "" : "// "); - } else { - out << ' '; - w--; - } - out << words->string; - w -= words->len; - state = 1; - } else { - if ( words->string[0] == '\n') - state = 4; - } - } - break; - case 4: - if ( !words->isSpace || words->len > 0) { - if ( !words->isSpace) { - if (HTML) - out << indNewline << "

"; - out << indNewline << (HTML ? "" : "// "); - out << indNewline << (HTML ? "" : "// "); - w = width; - out << words->string; - w -= words->len; - state = 1; - } - } - break; - } - } - return state; -} - -int printTrueComment( ostream &out, const Text& T, bool leadingLine) { - InListFIter< TextToken> words( (Text&)T); - int state = 0; // 0 = start, 1 = spaces at start, 2 = at least one token - int spaces = 0; - ForAll( words) { - switch ( state) { - case 0: - if ( !words->isSpace) { - if ( leadingLine) - out << endl; - out << indNewline << "// " << words->string; - state = 1; - } else { - if ( words->string[0] != '\n') { - state = 1; - spaces = 1; - } - } - break; - case 1: - if ( !words->isSpace) { - if ( leadingLine) - out << endl; - out << indNewline << "// "; - while ( spaces--) - out << ' '; - out << words->string; - } else { - if ( words->string[0] == '\n') - state = 0; - else - spaces++; - } - break; - case 2: - if ( words->isSpace && ( words->string[0] == '\n')) - out << indNewline << "// "; - else - out << words->string; - break; - } - } - return state; -} - - -ostream& -operator<< (ostream& out, const TextToken& t) { - out << t.isSpace << ", "; - printString( out, t.string, t.len); - return out; -} - -istream& -operator>> (istream& in, TextToken& t) { - char c; - int e; - in >> e >> c; // c == ',' - t.isSpace = bool( e); - delete[] t.string; - t.len = scanString( in, t.string); - return in; -} - - -// Auxiliary function definitions -// ============================================== -/* ... - char* catString( const char* r, const char* s, int l, int m) { - char *p; - if ( l < 0) - l = strlen( r); - if ( m < 0) - m = strlen( s); - p = (char *)malloc( l + m + 1); - ADT_Assert( p != NULL); - memcpy( p, r, l); - memcpy( p+l, s, m); - p[ l+m] = 0; - return( p); - } -... */ - -void printString( ostream &out, const char *s, int len) { - if ( len < 0) - len = strlen( s); - out << len; - if ( len > 0) - out << ", " << s; -} - -int scanString( istream &in, char*& s) { - int len; - int i; - in >> len; - if ( len > 0) { - s = new char[ len + 1]; - ADT_Assert( s != NULL); - in.get( s[0]); // the comma - in.get( s[0]); // the space - for ( i=0; i -#include -#undef LK_RestrictedOverloading -#define LK_RestrictedOverloading 0 -#include -#include -#include - -// Class declarations: -// ============================================== -class TextToken; - -// Substitute old style malloc, realloc, strdup ... -// ================================================ - -char* renew( char* old, size_t old_size, size_t new_size); -char* newstr( const char* src); +#include +#include +#include // Class specifications: // ============================================== - -// Auxiliary class: -// ------------------------------------ class Buffer { - size_t fibo1; // fibonacci numbers to increase buffer in - size_t fibo2; // the case of an overflow. - size_t len; - char* data; + typedef vector::const_iterator const_iterator; + vector buf; public: - Buffer() { - fibo1 = 610; - fibo2 = 987; - len = 0; - data = new char[ fibo2]; - *data = '\0'; - // Assert( data != NULL); - } - ~Buffer() { - // ADT_Assert( fibo2 > fibo1); // SGI complains in the test_suit - // ADT_Assert( fibo2 > len); // Gnu complains in the test_suit - // ADT_Assert( data[ len] == '\0'); - // ADT_Assert( strlen( data) == len); - delete[] data; - } - Buffer( const Buffer& t) { - ADT_Assert( t.data[ t.len] == '\0'); - fibo1 = t.fibo1; - fibo2 = t.fibo2; - len = t.len; - ADT_Assert( fibo2 > fibo1); - ADT_Assert( fibo2 > len); - data = newstr( t.data); // ============== ?? FALSCH ERROR !!!! - cerr << "Error: Buffer copy constructor called." << endl; - exit( 6); - } - Buffer& operator=( const Buffer& t) { - if( this != &t) { // beware of this=t; see Stroustrup pp.238 - delete[] data; - t.data[ t.len] = '\0'; - fibo1 = t.fibo1; - fibo2 = t.fibo2; - len = t.len; - data = newstr( t.data);// ============== ?? FALSCH ERROR !!!! - } else { - fibo1 = 610; - fibo2 = 987; - len = 0; - data = new char[ fibo2]; - } - ADT_Assert( fibo2 > fibo1); - ADT_Assert( fibo2 > len); - cerr << "Error: Buffer assignment operator called." << endl; - exit( 6); - return *this; + Buffer() : buf( 1, '\0') {} + Buffer( char c) : buf( 2, '\0') { *(buf.begin()) = c; } + Buffer( const char* s, int l = -1) { + if (s) + buf.insert( 0, s, s + 1 + ((l<0) ? strlen(s) : l)); + else + buf.push_back( '\0'); } void add( const char* s, int l = -1) { - ADT_Assert( data[ len] == '\0'); - int tmp; if ( l < 0) l = strlen( s); - // ADT_Assert( l == (int)strlen( s)); // this is definitly wrong! - if ( len + l >= fibo2) { // increase buffer - do { - tmp = fibo2; - fibo2 += fibo1; - fibo1 = tmp; - } while ( len + l >= fibo2); // increase buffer - data = renew( data, fibo1, fibo2); - // Assert( data != NULL); - } - memcpy( data + len, s, l); - len += l; - data[ len] = '\0'; - ADT_Assert( fibo2 > fibo1); - ADT_Assert( fibo2 > len); - } - void add( const Buffer& buf) { - add( buf.string(), buf.length()); - } - void add( const Buffer* buf) { - add( buf->string(), buf->length()); + buf.insert( buf.end() - 1, s, s + l); } + void add( const Buffer& buf) { add( buf.begin(), buf.size() - 1); } void add( char c) { - ADT_Assert( data[ len] == '\0'); - if ( len + 1 >= fibo2) { // increase buffer - int tmp = fibo2; - fibo2 += fibo1; - fibo1 = tmp; - data = renew( data, fibo1, fibo2); - // Assert( data != NULL); - } - data[ len++] = c; - data[ len] = '\0'; - ADT_Assert( fibo2 > fibo1); - ADT_Assert( fibo2 > len); + buf.pop_back(); + buf.push_back(c); + buf.push_back( '\0'); } void prepend( const char* s, int l = -1) { - ADT_Assert( s); - ADT_Assert( data[ len] == '\0'); - int tmp; + if ( l == 0 || s == 0) + return; if ( l < 0) l = strlen( s); - ADT_Assert( l == (int)strlen( s)); - if ( len + l >= fibo2) { // increase buffer - do { - tmp = fibo2; - fibo2 += fibo1; - fibo1 = tmp; - } while ( len + l >= fibo2); // increase buffer - data = renew( data, fibo1, fibo2); - // Assert( data != NULL); - } - // relocate current text - int i; - for ( i = len-1; i >= 0; i--) - data[i+l] = data[ i]; - memcpy( data, s, l); - len += l; - data[ len] = '\0'; - ADT_Assert( fibo2 > fibo1); - ADT_Assert( fibo2 > len); + buf.insert( buf.begin(), s, s + l); } - void prepend( char c) { - ADT_Assert( data[ len] == '\0'); - if ( len + 1 >= fibo2) { // increase buffer - int tmp = fibo2; - fibo2 += fibo1; - fibo1 = tmp; - data = renew( data, fibo1, fibo2); - // Assert( data != NULL); - } - // relocate current text - int i; - for ( i = len; i > 0; i--) - data[i] = data[ i-1]; - data[ 0] = c; - len++; - data[ len] = '\0'; - ADT_Assert( fibo2 > fibo1); - ADT_Assert( fibo2 > len); - } - void cut( int i) { - ADT_Assert( data[ len] == '\0'); - ADT_Assert( i >= 0); - if ( (int)len >= i) { - len -= i; - } - data[ len] = '\0'; - ADT_Assert( fibo2 > fibo1); - ADT_Assert( fibo2 > len); - } - const char* string() const { - ADT_Assert( data[ len] == '\0'); - ADT_Assert( len < fibo2); - return data; - } - void set( int i, char c) { - ADT_Assert( c != 0); - ADT_Assert( i >= 0); - ADT_Assert( size_t(i) < len); - data[i] = c; - } - int length() const { - ADT_Assert( data[ len] == '\0'); - ADT_Assert( len < fibo2); - return (int)len; - } - void flush() { - ADT_Assert( data[ len] == '\0'); - ADT_Assert( len < fibo2); - len = 0; - *data = '\0'; - } - void capitalize() { - for ( size_t i = 0; i < len; i++) - data[i] = toupper( data[i]); + void prepend( const Buffer& t) { prepend( t.begin(), t.size() - 1);} + void prepend( char c) { buf.insert( buf.begin(), c); } + char* begin() { return &*(buf.begin()); } + const char* begin() const { return &*(buf.begin()); } + char* end() { return &*(buf.end()); } + const char* end() const { return &*(buf.end()); } + void set( int i, char c) { buf[i] = c; } + size_t size() const { return buf.size(); } + void flush() { buf.erase( buf.begin(), buf.end()-1); } + bool is_space() const { + CC_Assert( buf.size() > 0); + for ( const_iterator i = buf.begin(); i != buf.end() - 1; ++i) + if ( *i > ' ') + return false; + return true; } }; -class TextToken : public ListLink{ -public: - bool isSpace; - int len; - char* string; - TextToken() { - isSpace = false; - len = 0; - string = newstr( ""); - } - TextToken( const char* s, int l = -1, bool space = false) { - isSpace = space; - if ( s) { - if ( l < 0) - len = strlen( s); - else - len = l; - string = newstr( s); - } else { - string = newstr( ""); - len = 0; - } - } - TextToken( const TextToken& t) { - isSpace = t.isSpace; - len = t.len; - string = newstr( t.string); - } - ~TextToken() { - ADT_Assert( (! string && len == 0) || (int)strlen( string) == len); - ADT_Assert( ! string || string[ len] == '\0'); - delete[] string; - } - TextToken& operator=( const TextToken& t) { - if( this != &t) { // beware of this=t; see Stroustrup pp.238 - delete[] string; - isSpace = t.isSpace; - len = t.len; - string = newstr( t.string); - } - ADT_Assert( (! string && len == 0) || (int)strlen( string) == len); - ADT_Assert( ! string || string[ len] == '\0'); - return *this; - } - TextToken& add( const TextToken& t) { - if ( t.len > 0) { - string = renew( string, len + 1, len + t.len + 1); - memcpy( string + len, t.string, t.len); - len += t.len; - string[len] = '\0'; - isSpace = isSpace && t.isSpace; - } - ADT_Assert( (! string && len == 0) || (int)strlen( string) == len); - ADT_Assert( ! string || string[ len] == '\0'); - return *this; - } - TextToken& add( const char* s, int l = -1) { - if ( s == 0) - l = 0; - if ( l == -1) - l = strlen(s); - if ( l > 0) { - string = renew( string, len + 1, len + l + 1); - memcpy( string + len, s, l); - len += l; - string[len] = '\0'; - isSpace = false; - } - ADT_Assert( (! string && len == 0) || (int)strlen( string) == len); - ADT_Assert( ! string || string[ len] == '\0'); - return *this; - } - TextToken& add( char c) { - string = renew( string, len + 1, len + 2); - string[ len] = c; - len ++; - string[ len] = '\0'; - isSpace = isSpace && (( c == ' ') || ( c == '\t')); - ADT_Assert( (! string && len == 0) || (int)strlen( string) == len); - ADT_Assert( ! string || string[ len] == '\0'); - return *this; - } - TextToken& prepend( const TextToken& t) { - if ( t.len > 0) { - int i; - string = renew( string, len + 1, len + t.len + 1); - for( i=len; i>=0; i--) // 0 will also be copied - string[ i + t.len] = string[ i]; - memcpy( string, t.string, t.len); - len += t.len; - isSpace = isSpace && t.isSpace; - } - ADT_Assert( (! string && len == 0) || (int)strlen( string) == len); - ADT_Assert( ! string || string[ len] == '\0'); - return *this; - } - TextToken& prepend( char c) { - int i; - string = renew( string, len + 1, len + 2); - for( i=len; i>=0; i--) // 0 will also be copied - string[ i + 1] = string[ i]; - *string = c; - len ++; - isSpace = isSpace && (( c == ' ') || ( c == '\t')); - ADT_Assert( (! string && len == 0) || (int)strlen( string) == len); - ADT_Assert( ! string || string[ len] == '\0'); - return *this; - } -}; +typedef list< Buffer*> Buffer_list; +typedef Buffer_list::iterator Buffer_iterator; +typedef Buffer_list::const_iterator Buffer_const_iterator; -ostream& operator<< (ostream& out, const TextToken& t); -istream& operator>> (istream& in, TextToken& t); +void delete_list( Buffer_list* l); -//class InList< TextToken>; - -typedef InList< TextToken> Text; - -int printComment( ostream& out, const Text& T, - bool leadingLine = false, bool HTML = false); -int printTrueComment( ostream& out, const Text& T, bool leadingLine = false); +#endif // MODULE_BUFFER // - -void printString( ostream &out, const char* s, int len = -1); -int scanString( istream &in, char*& s); - - -#endif // MODULE_DATABASE // diff --git a/Packages/Manual_tools/src/cc_build_checker.C b/Packages/Manual_tools/src/cc_build_checker.C index eaa3b4321f2..84ec2cb9cff 100644 --- a/Packages/Manual_tools/src/cc_build_checker.C +++ b/Packages/Manual_tools/src/cc_build_checker.C @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #define MaxParameters 1002 @@ -450,8 +450,8 @@ void printPattern( ostream& out_pattern, return; } int i; - int l = err->length(); - const char *str = err->string(); + int l = err->size() - 1; + const char *str = err->begin(); if ( pat == 0) { pat = pattern; pat->flush(); @@ -460,7 +460,7 @@ void printPattern( ostream& out_pattern, pat->add( patternText( str[i], str[i+1])); pat->add( '"'); } - printReducedPattern( out_pattern, pat->string(), pat->length()); + printReducedPattern( out_pattern, pat->begin(), pat->size() - 1); out_pattern << " {" << endl; out_pattern << " tags[" << n_pattern << "] = -1;" << endl; out_pattern << " count_newlines( yytext);" << endl; @@ -498,8 +498,8 @@ void printFunctionPattern( ostream& out_pattern, bool default_params = false; bool nonzero_param_list = false; int nesting = 0; - int l = err->length(); - const char *str = err->string(); + int l = err->size() - 1; + const char *str = err->begin(); if ( pat == 0) { pat = pattern; pat->flush(); @@ -516,7 +516,7 @@ void printFunctionPattern( ostream& out_pattern, pat->add( "\"{ws}*\""); pat2 = pattern2; pat2->flush(); - pat2->add( pat); + pat2->add( * pat); if ( nonzero_param_list) pat2->add( ','); pat2->add( "\"{ws}*[^ \\n\\r\\t)]"); @@ -534,14 +534,14 @@ void printFunctionPattern( ostream& out_pattern, // if ( default_params) // pat2->add( '"'); } - printReducedPattern( out_pattern, pat->string(), pat->length()); + printReducedPattern( out_pattern, pat->begin(), pat->size() - 1); out_pattern << " {" << endl; out_pattern << " tags[" << n_pattern << "] = -1;" << endl; out_pattern << " count_newlines( yytext);" << endl; out_pattern << " MD;" << endl; out_pattern << " }" << endl; if ( default_params || pat2 != 0) { - printReducedPattern( out_pattern, pat2->string(), pat2->length()); + printReducedPattern( out_pattern, pat2->begin(), pat2->size() - 1); out_pattern << " {" << endl; out_pattern << " if (tags[" << n_pattern << "] == 0) {" << endl; out_pattern << " tags[" << n_pattern << "] = line_number;" @@ -628,11 +628,11 @@ void translateFunctionArgumentLists( const char* decl, Buffer *func) { const char* current = decl; while ( *current != '(') { current++; - ADT_Assert( *current); + CC_Assert( *current); } - ADT_Assert( *current == '('); + CC_Assert( *current == '('); current++; - ADT_Assert( *current); + CC_Assert( *current); func->add( decl, current - decl); /* the parsing starts here. It counts parenthesis. */ @@ -641,7 +641,7 @@ void translateFunctionArgumentLists( const char* decl, Buffer *func) { const char* from = current; const char* last_idfier = current - 1; while ( nesting > 0) { - ADT_Assert( *current); + CC_Assert( *current); if ( nesting == 1 && *current == '=') in_init = true; if ( nesting == 1 @@ -658,7 +658,7 @@ void translateFunctionArgumentLists( const char* decl, Buffer *func) { while( isalnum( *p) || *p == '_') p--; p++; /* points to idfier start */ - ADT_Assert( p - from >= 0); + CC_Assert( p - from >= 0); if ( isTypeInFunctionArgument( from, p)) { func->add( from, p - from); func->add( IDFIER_TAG); @@ -681,7 +681,7 @@ void translateFunctionArgumentLists( const char* decl, Buffer *func) { case ')': case '>': nesting--; - ADT_Assert( nesting >= 1); + CC_Assert( nesting >= 1); break; } } @@ -694,8 +694,8 @@ void translateFunctionArgumentLists( const char* decl, Buffer *func) { // if so, use the INLINE_TAG to add the regular expression for an optional // inline keyword right after the template declaration. void checkTemplateKeyword( Buffer *decl){ - if( 0 == strncmp( "template", decl->string(), 8)) { - const char* p = decl->string() + 8; + if( 0 == strncmp( "template", decl->begin(), 8)) { + const char* p = decl->begin() + 8; int nesting = 0; while( *p != '\0') { switch( *p) { @@ -709,7 +709,7 @@ void checkTemplateKeyword( Buffer *decl){ case '>': nesting --; if ( nesting == 0) { - decl->set( p - decl->string(), INLINE_TAG); + decl->set( p - decl->begin(), INLINE_TAG); return; } break; @@ -723,11 +723,11 @@ void checkTemplateKeyword( Buffer *decl){ /* Taylored semantic functions used in syntax.y */ /* ============================================ */ -void handleMainComment( const Text& ) { +void handleMainComment( const Buffer_list& ) { return; } -void handleComment( const Text& ) { +void handleComment( const Buffer_list& ) { return; } @@ -857,7 +857,7 @@ void handleNestedType( const char* decl) { void handleMethodDeclaration( const char* decl) { translateFunctionArgumentLists( decl, function_decl); checkTemplateKeyword( function_decl); - decl = function_decl->string(); + decl = function_decl->begin(); errmessage->flush(); int l = strlen( decl); while ( l > 0 && decl[ l-1] == ' ') l--; @@ -873,7 +873,7 @@ void handleMethodDeclaration( const char* decl) { void handleFunctionDeclaration( const char* decl) { translateFunctionArgumentLists( decl, function_decl); checkTemplateKeyword( function_decl); - decl = function_decl->string(); + decl = function_decl->begin(); errmessage->flush(); int l = strlen( decl); while ( l > 0 && decl[ l-1] == ' ') l--; @@ -888,7 +888,7 @@ void handleFunctionDeclaration( const char* decl) { void handleFunctionTemplateDeclaration( const char* templ, const char* decl) { translateFunctionArgumentLists( decl, function_decl); - decl = function_decl->string(); + decl = function_decl->begin(); errmessage->flush(); pattern->flush(); pattern2->flush(); @@ -952,7 +952,7 @@ void handleFunctionTemplateDeclaration( const char* templ, const char* decl) { if ( nesting == 0) { default_params = true; pattern->add( "\"{ws}*\""); - pattern2->add( pattern); + pattern2->add( * pattern); pattern2->add( ",\".*\""); } break; diff --git a/Packages/Manual_tools/src/cc_extract.C b/Packages/Manual_tools/src/cc_extract.C index f9c8bece381..18c1c2207f0 100644 --- a/Packages/Manual_tools/src/cc_extract.C +++ b/Packages/Manual_tools/src/cc_extract.C @@ -17,9 +17,12 @@ #include #include #include -#include +#include #include +// Max. width of the formatted output +#define MaxTextWidth 74 + typedef char Switch; #define NO_SWITCH 0 @@ -31,7 +34,97 @@ Switch noc_switch = NO_SWITCH; Switch nomc_switch = NO_SWITCH; Switch nosc_switch = NO_SWITCH; - +// Format comments +// ========================== +int printComment( ostream &out, const Buffer_list& T, bool leadingLine) { + int width = MaxTextWidth - indentation_number() - 3; + int w = width; + int state = 0; // 0 = start, 1 = after token, 2 = spaces + // 3 = one newline (and spaces), 4 = newlines + for ( Buffer_const_iterator words = T.begin(); words != T.end(); ++words) { + bool is_space = (*words)->is_space(); + int len = int((*words)->size()) - 1; + switch ( state) { + case 0: + if ( ! is_space) { + if ( leadingLine) + out << endl; + out << ind_newline << "// " << (*words)->begin(); + w -= len; + state = 1; + } + break; + case 1: + if ( ! is_space || len > 0) { + if ( ! is_space) { + if ((len > w) && (w != width)) { + w = width; + out << ind_newline << "// "; + } + out << (*words)->begin(); + w -= len; + } else { + if ( (*words)->begin()[0] == '\n') + state = 3; + else + state = 2; + } + } + break; + case 2: + if ( ! is_space || len > 0) { + if ( ! is_space) { + if ((len >= w) && (w != width)) { + w = width; + out << ind_newline << "// "; + } else { + out << ' '; + w--; + } + out << (*words)->begin(); + w -= len; + state = 1; + } else { + if ( (*words)->begin()[0] == '\n') + state = 3; + } + } + break; + case 3: + if ( ! is_space || len > 0) { + if ( !is_space) { + if ((len >= w) && (w != width)) { + w = width; + out << ind_newline << "// "; + } else { + out << ' '; + w--; + } + out << (*words)->begin(); + w -= len; + state = 1; + } else { + if ( (*words)->begin()[0] == '\n') + state = 4; + } + } + break; + case 4: + if ( ! is_space || len > 0) { + if ( ! is_space) { + out << ind_newline << "// "; + out << ind_newline << "// "; + w = width; + out << (*words)->begin(); + w -= len; + state = 1; + } + } + break; + } + } + return state; +} /* Declarations from syntax.y */ /* ========================== */ @@ -54,7 +147,7 @@ const char* file_name = ""; /* Taylored semantic functions used in syntax.y */ /* ============================================ */ -void handleMainComment( const Text& T) { +void handleMainComment( const Buffer_list& T) { if ( noc_switch || nomc_switch) return; if ( indentation_number() > 0) { @@ -66,7 +159,7 @@ void handleMainComment( const Text& T) { } } -void handleComment( const Text& T) { +void handleComment( const Buffer_list& T) { if ( noc_switch || nosc_switch) return; cout << indent; @@ -83,13 +176,13 @@ void handleClass( const char* classname) { s++; if ( *s == 0) { - cout << indNewline; + cout << ind_newline; cout << "class " << classname; } else { global_template_params = global_classname; while( *global_template_params && *global_template_params != '<') ++global_template_params; - cout << indNewline; + cout << ind_newline; cout << "template < class "; int nesting = 0; s++; @@ -118,7 +211,7 @@ void handleClass( const char* classname) { } if ( nesting >= 0) printErrorMessage( MalformedTemplateParamError); - cout << " >" << indNewline; + cout << " >" << ind_newline; cout << "class "; s = classname; while ( *s != 0 && *s != '<') { @@ -126,8 +219,8 @@ void handleClass( const char* classname) { s++; } } - cout << " {" << indNewline; - cout << "public:" << indNewline; + cout << " {" << ind_newline; + cout << "public:" << ind_newline; cout << indent; } @@ -137,8 +230,8 @@ void handleClassEnd( void) { free( global_classname); global_classname = NULL; cout << outdent; - cout << indNewline; - cout << "};" << indNewline; + cout << ind_newline; + cout << "};" << ind_newline; } void handleRefPage( const char* token) { @@ -154,27 +247,27 @@ void handleRefPageEnd( void) { } void handleDeclaration( const char* decl) { - cout << endl << indNewline; + cout << endl << ind_newline; cout << decl; } void handleNestedType( const char* decl) { - cout << endl << indNewline; + cout << endl << ind_newline; cout << "Nested type required: " << global_classname << "::" << decl; } void handleMethodDeclaration( const char* decl) { - cout << endl << indNewline; + cout << endl << ind_newline; cout << decl; } void handleFunctionDeclaration( const char* decl) { - cout << endl << indNewline; + cout << endl << ind_newline; cout << decl; } void handleFunctionTemplateDeclaration( const char* templ, const char* decl) { - cout << endl << indNewline; + cout << endl << ind_newline; cout << "template < class "; const char* s = templ; int nesting = 0; @@ -203,7 +296,7 @@ void handleFunctionTemplateDeclaration( const char* templ, const char* decl) { } if ( nesting != 0) printErrorMessage( MalformedTemplateParamError); - cout << " >" << indNewline; + cout << " >" << ind_newline; cout << decl; } diff --git a/Packages/Manual_tools/src/cc_extract_html.C b/Packages/Manual_tools/src/cc_extract_html.C index a5a42c83055..36bde8be191 100644 --- a/Packages/Manual_tools/src/cc_extract_html.C +++ b/Packages/Manual_tools/src/cc_extract_html.C @@ -18,14 +18,13 @@ #include #include #include -#include #include #include #include #include -#include +#include #include #include #include @@ -121,44 +120,40 @@ void init_commandline_args() { -int text_block_length( const Text& T) { +int text_block_length( const Buffer_list& T) { int l = 0; - InListFIter< TextToken> words( (Text&)T); - ForAll( words) { - if ( words->isSpace) + for ( Buffer_const_iterator words = T.begin(); words != T.end(); ++words) { + if ( (*words)->is_space()) ++l; else - l += (*words).len; + l += (*words)->size() - 1; } return l; } -char* text_block_to_string( const Text& T) { - char* string = new char[ text_block_length( T) + 1]; +char* text_block_to_string( const Buffer_list& T) { + char* string = new char[ text_block_length(T) + 1]; string[0] = '\0'; - InListFIter< TextToken> words( (Text&)T); - ForAll( words) { - if ( words->isSpace) + for ( Buffer_const_iterator words = T.begin(); words != T.end(); ++words) { + if ( (*words)->is_space()) strcat( string, " "); else - strcat( string, (*words).string); + strcat( string, (*words)->begin()); } return string; } -bool is_text_block_empty( const Text& T) { - InListFIter< TextToken> words( (Text&)T); - ForAll( words) { - if ( !words->isSpace) +bool is_text_block_empty( const Buffer_list& T) { + for ( Buffer_const_iterator words = T.begin(); words != T.end(); ++words) { + if ( ! (*words)->is_space()) return false; } return true; } -void print_html_text_block( ostream &out, const Text& T) { - InListFIter< TextToken> words( (Text&)T); - ForAll( words) { - const char* s = words->string; +void print_html_text_block( ostream &out, const Buffer_list& T) { + for ( Buffer_const_iterator words = T.begin(); words != T.end(); ++words) { + const char* s = (*words)->begin(); while ( *s) { if ( *s != SEPARATOR) out << *s; @@ -172,15 +167,15 @@ void print_html_text_block( ostream &out, const Text& T) { /* Taylored semantic functions used in syntax.y */ /* ============================================ */ -void handleText( const Text& T) { +void handleText( const Buffer_list& T) { if ( ! current_ostream) return; print_html_text_block( *current_ostream, T); } -void handleTextToken( const TextToken& TT) { +void handleBuffer( const Buffer& TT) { if ( current_ostream) - *current_ostream << TT.string; + *current_ostream << TT.begin(); } void handleString( const char* s) { diff --git a/Packages/Manual_tools/src/config.h b/Packages/Manual_tools/src/config.h index 5264983489b..b8ac33fedad 100644 --- a/Packages/Manual_tools/src/config.h +++ b/Packages/Manual_tools/src/config.h @@ -14,14 +14,15 @@ #if ! defined( MODULE_CONFIG) #define MODULE_CONFIG 1 +#include // Global declarations that are implemented in the main module. // There they can be taylored to the specific application, i.e. // extraction or checker. -void handleComment( const Text& T); -void handleConstructorComment( const Text& T); -void handleMainComment( const Text& T); +void handleComment( const Buffer_list& T); +void handleConstructorComment( const Buffer_list& T); +void handleMainComment( const Buffer_list& T); void handleClass( const char* classname); void handleClassEnd( void); diff --git a/Packages/Manual_tools/src/cpp_formatting.C b/Packages/Manual_tools/src/cpp_formatting.C index ccc505192ec..ce583e98a2e 100644 --- a/Packages/Manual_tools/src/cpp_formatting.C +++ b/Packages/Manual_tools/src/cpp_formatting.C @@ -72,36 +72,36 @@ inline double estimate_html_size( const string& s) { void three_cols_html_begin( ostream& out, bool big_col1) { current_font = it_font; - out << indent << indent << indNewline + out << indent << indent << ind_newline << "" << indNewline + << table_width << ">" << ind_newline << "" << indNewline - << "
" : " NOWRAP>") - << indNewline << "" << outdent << indNewline; + << ind_newline << "" << outdent << ind_newline; } void three_cols_html_premature_end( ostream& out) { - out << indent << indNewline << store_remember_font() << "" - << indNewline << "
" << outdent << outdent << indNewline; + out << indent << ind_newline << store_remember_font() << "" + << ind_newline << "" << ind_newline + << "" << outdent << outdent << ind_newline; } void three_cols_html_second( ostream& out, bool big_col1, bool big_col2) { - out << indent << indNewline << store_remember_font() << "" - << indNewline << ""; + out << indent << ind_newline << store_remember_font() << "" + << ind_newline << ""; if ( big_col1) out << ""; out << "" : ">") - << indNewline << "" << get_remember_font() << outdent - << indNewline; + << ind_newline << "" << get_remember_font() << outdent + << ind_newline; } void three_cols_html_third( ostream& out, bool big_col2, bool empty_col3) { - out << indent << indNewline << store_remember_font() << "" - << indNewline; + out << indent << ind_newline << store_remember_font() << "" + << ind_newline; if ( ! big_col2) out << ""; if ( ! empty_col3) { @@ -111,15 +111,15 @@ void three_cols_html_third( ostream& out, bool big_col2, bool empty_col3) { << "% NOWRAP>"; out << ""; } - out << outdent << indNewline; + out << outdent << ind_newline; } void three_cols_html_end( ostream& out, bool empty_col3) { - out << indent << indNewline; + out << indent << ind_newline; if ( ! empty_col3) out << ""; - out << "" << indNewline - << "" << outdent << outdent << indNewline; + out << "" << ind_newline + << "" << outdent << outdent << ind_newline; } void three_cols_html_new_closing( ostream& out) { @@ -128,40 +128,40 @@ void three_cols_html_new_closing( ostream& out) { void two_cols_html_begin( ostream& out) { current_font = it_font; - out << indent << indent << indNewline + out << indent << indent << ind_newline << "" << indNewline + << table_width << ">" << ind_newline << "" << indNewline - << "
" - << indNewline << "" << outdent << indNewline; + << ind_newline << "" << outdent << ind_newline; } void two_cols_html_premature_end( ostream& out) { - out << indent << indNewline << store_remember_font() <<"" - << indNewline << "
" << outdent << outdent << indNewline; + out << indent << ind_newline << store_remember_font() <<"" + << ind_newline << "" << ind_newline + << "" << outdent << outdent << ind_newline; } void two_cols_html_second( ostream& out, bool empty_col2) { - out << indent << indNewline << store_remember_font() << "" - << indNewline << ""; + out << indent << ind_newline << store_remember_font() << "" + << ind_newline << ""; if ( ! empty_col2) out << ""; - out << outdent << indNewline; + out << outdent << ind_newline; } void two_cols_html_new_closing( ostream& out) { - out << indent << indNewline << store_remember_font() << "" - << indNewline << "" << outdent << outdent; + out << indent << ind_newline << store_remember_font() << "" + << ind_newline << "" << outdent << outdent; } void two_cols_html_end( ostream& out, bool empty_col2) { - out << indent << indNewline; + out << indent << ind_newline; if ( ! empty_col2) - out << "" << indNewline; - out << "" << outdent << outdent << indNewline; + out << "" << ind_newline; + out << "" << outdent << outdent << ind_newline; } @@ -1000,7 +1000,7 @@ void format_function( bool method, const char* signature, ! macroIsTrue( "\\ccAlternateThreeColumn")) *current_ostream << " COLSPAN=2"; *current_ostream << ">" << get_remember_font() - << indNewline; + << ind_newline; } if ( method) { if ( ! definedMacro( "\\ccPureVar")) { @@ -1026,7 +1026,7 @@ void format_function( bool method, const char* signature, << " NOWRAP>"; *current_ostream << ""; - *current_ostream << get_remember_font() << indNewline; + *current_ostream << get_remember_font() << ind_newline; } char* p = parameter_list; while ( n--) { @@ -1035,13 +1035,13 @@ void format_function( bool method, const char* signature, if ( n) { *current_ostream << ", "; if ( exp_size > dd_width) - *current_ostream << "
" << indNewline; + *current_ostream << "
" << ind_newline; } } *current_ostream << ")"; if ( exp_size > dd_width) { *current_ostream << store_remember_font(); - *current_ostream << "
" << indNewline; + *current_ostream << "
" <" << get_remember_font() << indNewline; + *current_ostream << ">" << get_remember_font() << ind_newline; } if ( return_value) { print_ascii_to_html_spc( *current_ostream, return_value); @@ -1346,7 +1346,7 @@ void format_struct( const char* signature) { if ( exp_size > table_width) { *current_ostream << store_remember_font(); *current_ostream << ""; - *current_ostream << get_remember_font() << indNewline; + *current_ostream << get_remember_font() << ind_newline; } char* p = parameter_list; while ( n--) { @@ -1358,13 +1358,13 @@ void format_struct( const char* signature) { if ( n) { *current_ostream << ", "; if ( exp_size > table_width) - *current_ostream << "
" << indNewline; + *current_ostream << "
" << ind_newline; } } *current_ostream << "};"; if ( exp_size > table_width) { *current_ostream << store_remember_font(); - *current_ostream << "" << indNewline; + *current_ostream << "" << ind_newline; } } else *current_ostream << ';'; @@ -1504,7 +1504,7 @@ void format_enum( const char* signature) { "" << get_remember_font() << indNewline; + *current_ostream << ">" << get_remember_font() << ind_newline; } if ( return_value) { print_ascii_to_html_spc( *current_ostream, return_value); @@ -1518,7 +1518,7 @@ void format_enum( const char* signature) { if ( exp_size > table_width) { *current_ostream << store_remember_font(); *current_ostream << ""; - *current_ostream << get_remember_font() << indNewline; + *current_ostream << get_remember_font() << ind_newline; } char* p = parameter_list; while ( n--) { @@ -1580,13 +1580,13 @@ void format_enum( const char* signature) { if ( n) { *current_ostream << ", "; if ( exp_size > table_width) - *current_ostream << "
" << indNewline; + *current_ostream << "
" << ind_newline; } } *current_ostream << "};"; if ( exp_size > table_width) { *current_ostream << store_remember_font(); - *current_ostream << "" << indNewline; + *current_ostream << "" << ind_newline; } } else *current_ostream << ';'; @@ -1645,7 +1645,7 @@ void format_constructor( const char* signature) { if ( macroIsTrue( "\\ccLongParamLayout") || ! macroIsTrue( "\\ccAlternateThreeColumn")) *current_ostream << " COLSPAN=2"; - *current_ostream << ">" << get_remember_font() << indNewline; + *current_ostream << ">" << get_remember_font() << ind_newline; } // Of no use here! // if ( scope) @@ -1666,7 +1666,7 @@ void format_constructor( const char* signature) { << " NOWRAP>"; *current_ostream << ""; - *current_ostream << get_remember_font() << indNewline; + *current_ostream << get_remember_font() << ind_newline; } char* p = parameter_list; while ( n--) { @@ -1675,13 +1675,13 @@ void format_constructor( const char* signature) { if ( n) { *current_ostream << ", "; if ( exp_size > table_width) - *current_ostream << "
" << indNewline; + *current_ostream << "
" << ind_newline; } } *current_ostream << ");"; if ( exp_size > table_width) { *current_ostream << store_remember_font(); - *current_ostream << "
" << indNewline; + *current_ostream << "
" << ind_newline; } } else *current_ostream << ';'; diff --git a/Packages/Manual_tools/src/cpp_formatting.h b/Packages/Manual_tools/src/cpp_formatting.h index 239a09892d8..a264e21fc6e 100644 --- a/Packages/Manual_tools/src/cpp_formatting.h +++ b/Packages/Manual_tools/src/cpp_formatting.h @@ -15,7 +15,6 @@ #define CPP_FORMATTING_H 1 #include -#include extern string class_name; extern string template_class_name; diff --git a/Packages/Manual_tools/src/extract_lex.yy b/Packages/Manual_tools/src/extract_lex.yy index 05a0bbe6759..e30e5524b4b 100644 --- a/Packages/Manual_tools/src/extract_lex.yy +++ b/Packages/Manual_tools/src/extract_lex.yy @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include diff --git a/Packages/Manual_tools/src/extract_syntax.y b/Packages/Manual_tools/src/extract_syntax.y index fe5c766242b..543cf85fe08 100644 --- a/Packages/Manual_tools/src/extract_syntax.y +++ b/Packages/Manual_tools/src/extract_syntax.y @@ -45,7 +45,7 @@ int yyerror( char *s); /* Datastructures for the parser */ /* ============================= */ -#include +#include #include %} @@ -53,11 +53,10 @@ int yyerror( char *s); struct { char* text; /* a (meaningless) chunk of zero terminated text */ int len; /* its length */ - } string; - char character; /* a (meaningless) character */ - Buffer* pBuffer; /* Buffer for collected strings and characters */ - TextToken* pTextToken; - Text* pText; + } string; + char character; /* a (meaningless) character */ + Buffer* pBuffer; /* Buffer for collected strings and characters */ + Buffer_list* pText; } /* Elementary data types */ @@ -112,19 +111,25 @@ int yyerror( char *s); /* -------------------------- */ %token LALRRESTRICTION -%type string -%type declaration classname template_params -%type cc_stmts cc_stmt cc_stmts_skip_space -%type comment_group comment_sequence -%type nested_token_sequence nested_token -%type compound_comment full_comment_sequence -%type non_empty_comment_sequence - -%type whitespaces optional_whitespaces - -%type comment_token non_empty_token whitespace - +%type string +%type whitespace +%type cc_stmts +%type cc_stmt +%type cc_stmts_skip_space +%type comment_token +%type declaration +%type classname +%type template_params +%type whitespaces +%type optional_whitespaces +%type comment_group +%type comment_sequence +%type compound_comment +%type full_comment_sequence +%type non_empty_comment_sequence +%type nested_token_sequence +%type nested_token %% /* Grammar: Top Level */ @@ -138,7 +143,7 @@ stmt: string { delete $1;} | SPACE {} | NEWLINE | BEGINCLASS - classname { handleClass( $2->string()); + classname { handleClass( $2->begin()); delete $2;} decl_sequence ENDCLASS @@ -148,8 +153,8 @@ stmt: string { delete $1;} creationvariable = NULL; } | BEGINREFCLASS - classname { handleClass( $2->string()); - handleRefPage( $2->string()); + classname { handleClass( $2->begin()); + handleRefPage( $2->begin()); delete $2;} decl_sequence ENDREFCLASS @@ -161,9 +166,9 @@ stmt: string { delete $1;} } | BEGINREFCLASS '[' nested_token_sequence ']' - classname { handleClass( $5->string()); - handleRefPage( $5->string()); - delete $3; + classname { handleClass( $5->begin()); + handleRefPage( $5->begin()); + delete_list( $3); delete $5;} decl_sequence ENDREFCLASS @@ -174,21 +179,21 @@ stmt: string { delete $1;} creationvariable = NULL; } | BEGINREFPAGE - classname { handleRefPage( $2->string()); + classname { handleRefPage( $2->begin()); delete $2; } | BEGINREFPAGE '[' nested_token_sequence ']' - classname { handleRefPage( $5->string()); - delete $3; + classname { handleRefPage( $5->begin()); + delete_list( $3); delete $5; } | ENDREFPAGE { handleRefPageEnd(); } | CREATIONVARIABLE {} | CCSTYLE '{' nested_token_sequence '}' { set_INITIAL = 1; - delete $3; + delete_list($3); } - | HEADING '{' comment_sequence '}' { delete $3; } - | INCLUDE '{' comment_sequence '}' { delete $3; } - | COMMENTHEADING '{' comment_sequence '}' { delete $3; } + | HEADING '{' comment_sequence '}' { delete_list($3); } + | INCLUDE '{' comment_sequence '}' { delete_list($3); } + | COMMENTHEADING '{' comment_sequence '}' { delete_list($3); } | gobble_parameters | GOBBLEAFTERONEPARAM reduced_group reduced_group | global_tagged_declarator @@ -221,11 +226,11 @@ reduced_statement: | NEWLINE | CREATIONVARIABLE {} | CCSTYLE '{' nested_token_sequence '}' { set_INITIAL = 1; - delete $3; + delete_list($3); } - | HEADING '{' comment_sequence '}' { delete $3; } - | INCLUDE '{' comment_sequence '}' { delete $3; } - | COMMENTHEADING '{' comment_sequence '}' { delete $3; } + | HEADING '{' comment_sequence '}' { delete_list($3); } + | INCLUDE '{' comment_sequence '}' { delete_list($3); } + | COMMENTHEADING '{' comment_sequence '}' { delete_list($3); } | gobble_parameters | GOBBLEAFTERONEPARAM reduced_group reduced_group | reduced_group @@ -251,36 +256,31 @@ string: STRING { } ; -non_empty_token: string { $$ = new TextToken( - $1->string(), $1->length()); - delete $1; - } -; - -optional_whitespaces: /* empty */ { $$ = new Text( managed); } +optional_whitespaces: /* empty */ { $$ = new Buffer_list(); } | whitespaces { $$ = $1; } ; -whitespaces: whitespace { $$ = new Text( * $1, managed); } +whitespaces: whitespace { $$ = new Buffer_list( 1, $1); } | GOBBLEAFTERONEPARAM comment_group comment_group { $$ = $2; - delete $3; + delete_list( $3); } | whitespaces whitespace { $$ = $1; - $$->append( * $2); + $$->push_back( $2); } - | whitespaces GOBBLEAFTERONEPARAM comment_group comment_group { + | whitespaces GOBBLEAFTERONEPARAM comment_group + comment_group { $$ = $3; - delete $1; - delete $4; + delete_list( $1); + delete_list( $4); } ; -whitespace: SPACE { $$ = new TextToken( $1.text, $1.len, true); } - | NEWLINE { $$ = new TextToken( "\n", 1, true); } +whitespace: SPACE { $$ = new Buffer( $1.text, $1.len); } + | NEWLINE { $$ = new Buffer( "\n", 1); } | gobble_parameters - { $$ = new TextToken( " ", 1, true); } + { $$ = new Buffer( " ", 1); } ; @@ -289,39 +289,39 @@ whitespace: SPACE { $$ = new TextToken( $1.text, $1.len, true); } /* =============================== */ decl_sequence: comment_sequence { handleMainComment( * $1); - delete $1; + delete_list($1); } | decl_sequence tagged_declarator comment_sequence { handleMainComment( * $3); - delete $3; + delete_list($3); } ; tagged_declarator: global_tagged_declarator | CONSTRUCTOR declaration comment_group { - handleFunctionDeclaration( $2->string()); + handleFunctionDeclaration( $2->begin()); delete $2; handleComment( * $3); - delete $3; + delete_list( $3); } | METHOD declaration comment_group { - handleMethodDeclaration( $2->string()); + handleMethodDeclaration( $2->begin()); delete $2; handleComment( * $3); - delete $3; + delete_list( $3); } ; global_tagged_declarator: error {} | FUNCTION declaration comment_group { - handleFunctionDeclaration( $2->string()); + handleFunctionDeclaration( $2->begin()); delete $2; handleComment( * $3); - delete $3; + delete_list( $3); } | FUNCTIONTEMPLATE template_params @@ -329,46 +329,46 @@ global_tagged_declarator: declaration comment_group { handleFunctionTemplateDeclaration( - $2->string(), - $4->string()); + $2->begin(), + $4->begin()); delete $2; - delete $3; + delete_list( $3); delete $4; handleComment( * $5); - delete $5; + delete_list( $5); } | VARIABLE declaration comment_group { - handleDeclaration( $2->string()); + handleDeclaration( $2->begin()); delete $2; handleComment( * $3); - delete $3; + delete_list( $3); } | TYPEDEF declaration comment_group { - handleDeclaration( $2->string()); + handleDeclaration( $2->begin()); delete $2; handleComment( * $3); - delete $3; + delete_list( $3); } | NESTEDTYPE declaration comment_group { - handleNestedType( $2->string()); + handleNestedType( $2->begin()); delete $2; handleComment( * $3); - delete $3; + delete_list( $3); } | ENUM declaration comment_group { - handleDeclaration( $2->string()); + handleDeclaration( $2->begin()); delete $2; handleComment( * $3); - delete $3; + delete_list( $3); } | STRUCT declaration comment_group { - handleDeclaration( $2->string()); + handleDeclaration( $2->begin()); delete $2; handleComment( * $3); - delete $3; + delete_list( $3); } | GLOBALFUNCTION declaration { - handleFunctionDeclaration( $2->string()); + handleFunctionDeclaration( $2->begin()); delete $2; } | GLOBALFUNCTIONTEMPLATE @@ -376,30 +376,30 @@ global_tagged_declarator: optional_whitespaces declaration { handleFunctionTemplateDeclaration( - $2->string(), - $4->string()); + $2->begin(), + $4->begin()); delete $2; - delete $3; + delete_list( $3); delete $4; } | GLOBALVARIABLE declaration { - handleDeclaration( $2->string()); + handleDeclaration( $2->begin()); delete $2; } | GLOBALTYPEDEF declaration { - handleDeclaration( $2->string()); + handleDeclaration( $2->begin()); delete $2; } | GLOBALENUM declaration { - handleDeclaration( $2->string()); + handleDeclaration( $2->begin()); delete $2; } | GLOBALSTRUCT declaration { - handleDeclaration( $2->string()); + handleDeclaration( $2->begin()); delete $2; } | DECLARATION declaration { - handleDeclaration( $2->string()); + handleDeclaration( $2->begin()); delete $2; } ; @@ -408,55 +408,61 @@ global_tagged_declarator: /* ===================================== */ comment_group: optional_whitespaces '{' comment_sequence '}' { $$ = $3; - delete $1; + delete_list( $1); } | optional_whitespaces BLOCKINTRO comment_sequence '}' { $$ = $3; - delete $1; + delete_list( $1); } ; -comment_sequence: optional_whitespaces { $$ = new Text(managed); - delete $1; +comment_sequence: optional_whitespaces { $$ = new Buffer_list(); + delete_list( $1); } | optional_whitespaces non_empty_comment_sequence optional_whitespaces { $$ = $2; - delete $1; - delete $3; + delete_list( $1); + delete_list( $3); } ; -full_comment_sequence: /* empty */ { $$ = new Text(managed); } +full_comment_sequence: /* empty */ { $$ = new Buffer_list(); } | whitespaces { $$ = $1; } | optional_whitespaces non_empty_comment_sequence optional_whitespaces { $$ = $1; - $$->append( * $2); - $$->append( * $3); + $$->insert($$->end(), $2->begin(),$2->end()); + $$->insert($$->end(), $3->begin(),$3->end()); + delete $2; + delete $3; } ; non_empty_comment_sequence: - comment_token { $$ = new Text( * $1, managed); } + comment_token { $$ = new Buffer_list( 1, $1); } | compound_comment { $$ = $1; } - | non_empty_comment_sequence optional_whitespaces comment_token { + | non_empty_comment_sequence optional_whitespaces + comment_token { $$ = $1; - $$->append( * $2); - $$->append( * $3); + $$->insert($$->end(), $2->begin(),$2->end()); + delete $2; + $$->push_back( $3); } | non_empty_comment_sequence optional_whitespaces compound_comment { $$ = $1; - $$->append( * $2); - $$->append( * $3); + $$->insert($$->end(), $2->begin(),$2->end()); + delete $2; + $$->insert($$->end(), $3->begin(),$3->end()); + delete $3; } ; -comment_token: non_empty_token { $$ = $1; } - | comment_token non_empty_token { +comment_token: string { $$ = $1; } + | comment_token string { $$ = $1; $$->add( * $2); delete $2; @@ -465,8 +471,8 @@ comment_token: non_empty_token { $$ = $1; } compound_comment: '{' full_comment_sequence '}' { $$ = $2; - $$->cons( *new TextToken( "{", 1)); - $$->append( *new TextToken( "}", 1)); + $$->push_front( new Buffer( "{", 1)); + $$->push_back( new Buffer( "}", 1)); } | BLOCKINTRO full_comment_sequence '}' { $$ = $2; @@ -474,140 +480,120 @@ compound_comment: '{' full_comment_sequence '}' { | CCSTYLE '{' nested_token_sequence '}' { $$ = $3; set_INITIAL = 1; - if ( $$->head().isSpace) // should not - $$->cons( *new TextToken( "`", 1)); + if ( $$->front()->is_space()) // should not + $$->push_front( new Buffer( "`", 1)); else - $$->head().prepend( "`"); - InListFIter< TextToken> ix( * $$); - ForAll( ix) { - if ( ix.isLast()) - if ( ix->isSpace) - $$->append( *new TextToken( - "'", 1)); - else - ix->add( "'"); - } - } + $$->front()->prepend( "`"); + if ( $$->back()->is_space()) + $$->push_back( new Buffer( "'", 1)); + else + $$->back()->add( "'"); + } | CCSECTION '{' comment_sequence '}' { $$ = $3; - $$->cons( *new TextToken( " ", 1, true)); - $$->cons( *new TextToken( "SECTION:")); - $$->cons( *new TextToken( "\n", 1, true)); - $$->cons( *new TextToken( "\n", 1, true)); - $$->append( *new TextToken( "\n", 1, true)); - $$->append( *new TextToken( + $$->push_front( new Buffer( " ", 1)); + $$->push_front( new Buffer( "SECTION:")); + $$->push_front( new Buffer( "\n", 1)); + $$->push_front( new Buffer( "\n", 1)); + $$->push_back( new Buffer( "\n", 1)); + $$->push_back( new Buffer( "====================================" "====================================")); - $$->append( *new TextToken( "\n", 1, true)); - $$->append( *new TextToken( "\n", 1, true)); + $$->push_back( new Buffer( "\n", 1)); + $$->push_back( new Buffer( "\n", 1)); } | CCSUBSECTION '{' comment_sequence '}' { $$ = $3; - $$->cons( *new TextToken( " ", 1, true)); - $$->cons( *new TextToken( "Subsection:")); - $$->cons( *new TextToken( "\n", 1, true)); - $$->cons( *new TextToken( "\n", 1, true)); - $$->append( *new TextToken( "\n", 1, true)); - $$->append( *new TextToken( + $$->push_front( new Buffer( " ", 1)); + $$->push_front( new Buffer( "Subsection:")); + $$->push_front( new Buffer( "\n", 1)); + $$->push_front( new Buffer( "\n", 1)); + $$->push_back( new Buffer( "\n", 1)); + $$->push_back( new Buffer( "------------------------------------" "------------------------------------")); - $$->append( *new TextToken( "\n", 1, true)); - $$->append( *new TextToken( "\n", 1, true)); + $$->push_back( new Buffer( "\n", 1)); + $$->push_back( new Buffer( "\n", 1)); } | HEADING '{' comment_sequence '}' { $$ = $3; } | INCLUDE '{' comment_sequence '}' { $$ = $3; - $$->cons( *new TextToken( "<")); - $$->cons( *new TextToken( " ", 1, true)); - $$->cons( *new TextToken( "#include")); - $$->append( *new TextToken( ">")); + $$->push_front( new Buffer( "<")); + $$->push_front( new Buffer( " ", 1)); + $$->push_front( new Buffer( "#include")); + $$->push_back( new Buffer( ">")); } | COMMENTHEADING '{' comment_sequence '}' { $$ = $3; } | CREATIONVARIABLE { - $$ = new Text( managed); - $$->append( *new TextToken( "\n", 1, true)); - $$->append( *new TextToken( "\n", 1, true)); - $$->append( *new TextToken( + $$ = new Buffer_list(); + $$->push_back( new Buffer( "\n", 1)); + $$->push_back( new Buffer( "\n", 1)); + $$->push_back( new Buffer( "New creation variable is:")); - $$->append( *new TextToken( " ", 1, true)); - TextToken* t = new TextToken($1.text,$1.len); + $$->push_back( new Buffer( " ", 1)); + Buffer* t = new Buffer( $1.text, $1.len); t->prepend( "`"); t->add( "'"); - $$->append( *t); - $$->append( *new TextToken( "\n", 1, true)); - $$->append( *new TextToken( "\n", 1, true)); + $$->push_back( t); + $$->push_back( new Buffer( "\n", 1)); + $$->push_back( new Buffer( "\n", 1)); } ; /* Parsing of a C++ expression/statement with nested expressions */ /* ============================================================= */ nested_token_sequence: - /* empty */ { - $$ = new Text(managed); - } + /* empty */ { $$ = new Buffer_list(); } | nested_token_sequence nested_token { - $1->append( * $2); + $1->insert($1->end(), $2->begin(),$2->end()); + delete $2; $$ = $1; } ; -nested_token: string { - $$ = new Text(*new TextToken( - $1->string(), - $1->length()), - managed); - delete $1; - } +nested_token: string { $$ = new Buffer_list( 1, $1); } | SPACE { - $$ = new Text(*new TextToken( - $1.text, - $1.len, - true), - managed); + $$ = new Buffer_list( 1, + new Buffer( $1.text, $1.len)); } | NEWLINE { - $$ = new Text(*new TextToken( "\n", 1, true), - managed); + $$ = new Buffer_list( 1, + new Buffer( "\n", 1)); } | '{' nested_token_sequence '}' { - $2->cons( *new TextToken( "{", 1)); - $2->append( *new TextToken( "}", 1)); + $2->push_front( new Buffer( "{", 1)); + $2->push_back( new Buffer( "}", 1)); $$ = $2; } | BLOCKINTRO nested_token_sequence '}' { $$ = $2; } | '[' nested_token_sequence ']' { - $2->cons( *new TextToken( "[", 1)); - $2->append( *new TextToken( "]", 1)); + $2->push_front( new Buffer( "[", 1)); + $2->push_back( new Buffer( "]", 1)); $$ = $2; } | '(' nested_token_sequence ')' { - $2->cons( *new TextToken( "(", 1)); - $2->append( *new TextToken( ")", 1)); + $2->push_front( new Buffer( "(", 1)); + $2->push_back( new Buffer( ")", 1)); $$ = $2; } | CCSTYLE '{' nested_token_sequence '}' { $$ = $3; set_INITIAL = 1; - if ( $$->head().isSpace) // should not - $$->cons( *new TextToken( "`", 1)); + if ( $$->front()->is_space()) // should not + $$->push_front( new Buffer( "`", 1)); else - $$->head().prepend( "`"); - InListFIter< TextToken> ix( * $$); - ForAll( ix) { - if ( ix.isLast()) - if ( ix->isSpace) - $$->append( *new TextToken( - "'", 1)); - else - ix->add( "'"); - } + $$->front()->prepend( "`"); + if ( $$->back()->is_space()) + $$->push_back( new Buffer( "'", 1)); + else + $$->back()->add( "'"); } ; @@ -653,7 +639,7 @@ cc_stmts: /* empty */ { $$ = new Buffer;} | cc_stmts cc_stmt { $$ = $1; - $$->add( $2); + $$->add( * $2); delete $2; } ; @@ -680,7 +666,7 @@ cc_stmts_skip_space: { $$ = new Buffer;} | string cc_stmts { $$ = $1; - $$->add( $2); + $$->add( * $2); delete $2; } | SPACE cc_stmts { $$ = $2;} @@ -692,7 +678,7 @@ cc_stmts_skip_space: $$ = $3; $$->prepend( '{'); $$->add( '}'); - $$->add( $6); + $$->add( * $6); delete $6; } ; diff --git a/Packages/Manual_tools/src/html_config.h b/Packages/Manual_tools/src/html_config.h index 5b13d8f819b..69390a40c55 100644 --- a/Packages/Manual_tools/src/html_config.h +++ b/Packages/Manual_tools/src/html_config.h @@ -14,7 +14,7 @@ #if ! defined( MODULE_CONFIG) #define MODULE_CONFIG 1 -#include +#include #include @@ -49,16 +49,16 @@ extern const string reference_icon; // outdated -int text_block_length( const Text& T); -char* text_block_to_string( const Text& T); -bool is_text_block_empty( const Text& T); -void print_html_text_block( ostream &out, const Text& T); +int text_block_length( const Buffer_list& T); +char* text_block_to_string( const Buffer_list& T); +bool is_text_block_empty( const Buffer_list& T); +void print_html_text_block( ostream &out, const Buffer_list& T); -void handleText( const Text& T); -void handleTextToken( const TextToken& TT); -void handleString( const char* s); -void handleString( const string& s); -void handleChar( char c); +void handleText( const Buffer_list& T); +void handleBuffer( const Buffer& TT); +void handleString( const char* s); +void handleString( const string& s); +void handleChar( char c); #endif // MODULE_CONFIG // diff --git a/Packages/Manual_tools/src/html_lex.yy b/Packages/Manual_tools/src/html_lex.yy index c6cde57f839..2a8485c0a81 100644 --- a/Packages/Manual_tools/src/html_lex.yy +++ b/Packages/Manual_tools/src/html_lex.yy @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Packages/Manual_tools/src/html_syntax.y b/Packages/Manual_tools/src/html_syntax.y index 80a257c0b59..7ee36d71d15 100644 --- a/Packages/Manual_tools/src/html_syntax.y +++ b/Packages/Manual_tools/src/html_syntax.y @@ -28,7 +28,7 @@ #include #include -#include +#include #include @@ -39,11 +39,11 @@ int yyerror( char *s); %} %union { - const char* text; /* a chunk of zero terminated text */ - char character; /* a character */ - int number; /* an integer */ - TextToken* pTextToken; - Text* pText; + const char* text; /* a chunk of zero terminated text */ + char character; /* a character */ + int number; /* an integer */ + Buffer* pBuffer; + Buffer_list* pText; } /* Elementary data types */ @@ -81,8 +81,10 @@ int yyerror( char *s); /* Type declarations for production rules */ /* -------------------------------------------- */ -%type string_token -%type comment_group comment_sequence comment_token +%type string_token +%type comment_group +%type comment_sequence +%type comment_token @@ -98,13 +100,13 @@ stmt: error {} | direct_string {} | CHAPTER '{' comment_sequence '}' { handleChapter( * $3); - delete $3; + delete_list( $3); } | BEGINCLASS { handleClassEnvironment(); } | ENDCLASS { handleClassEnd(); } | HTMLBEGINCLASSFILE comment_group { handleHtmlClassFile( cc_filename,*$2); - delete $2; + delete_list( $2); } | '{' input '}' ; @@ -174,27 +176,27 @@ direct_string: STRING { handleString( $1); } ; -string_token: STRING { $$ = new TextToken( $1); } - | CHAR { $$ = new TextToken(); $$->add( $1); } +string_token: STRING { $$ = new Buffer( $1); } + | CHAR { $$ = new Buffer( $1); } | ASCIITOHTML PARAMETER { char* s = convert_ascii_to_html($2); - $$ = new TextToken( s); + $$ = new Buffer( s); delete[] $2; delete[] s; set_old_state = 1; } | RAWOUTPUT PARAMETER { - $$ = new TextToken( $2); + $$ = new Buffer( $2); delete[] $2; set_old_state = 1; } | RAWOUTPUTN { - $$ = new TextToken( $1); + $$ = new Buffer( $1); delete[] $1; set_old_state = 1; } | DEFWITHARGS PARAMETER { - $$ = new TextToken(); + $$ = new Buffer(); if ( number_of_args < 1 || number_of_args> 9) printErrorMessage( NParamRangeError); @@ -207,7 +209,7 @@ string_token: STRING { $$ = new TextToken( $1); } set_old_state = 1; } | GDEFWITHARGS PARAMETER { - $$ = new TextToken(); + $$ = new Buffer(); if ( number_of_args < 1 || number_of_args > 9) printErrorMessage( NParamRangeError); @@ -222,7 +224,7 @@ string_token: STRING { $$ = new TextToken( $1); } set_old_state = 1; } | DEFWITHUNKNOWNARGS PARAMETER { - $$ = new TextToken(); + $$ = new Buffer(); if ( ! quiet_switch) { cerr << endl << "Unknown macro definition: " @@ -243,15 +245,15 @@ string_token: STRING { $$ = new TextToken( $1); } comment_group: '{' comment_sequence '}' { $$ = $2; } ; -comment_sequence: /* empty */ { $$ = new Text( managed); } +comment_sequence: /* empty */ { $$ = new Buffer_list(); } | comment_sequence comment_token { $$ = $1; - $$->append( * $2); + $$->insert($$->end(), $2->begin(),$2->end()); delete $2; } ; -comment_token: string_token { $$ = new Text( * $1, managed); } +comment_token: string_token { $$ = new Buffer_list( 1, $1); } | comment_group { $$ = $1; } ; diff --git a/Packages/Manual_tools/src/internal_macros.C b/Packages/Manual_tools/src/internal_macros.C index 0a6a8b242f4..796cbaa41bc 100644 --- a/Packages/Manual_tools/src/internal_macros.C +++ b/Packages/Manual_tools/src/internal_macros.C @@ -179,7 +179,7 @@ static int next_class_link_last = 0; string chapter_title; -void handleChapter( const Text& T) { +void handleChapter( const Buffer_list& T) { next_class_link_last = 0; //string new_main_filename = macroX( "\\lciInputPath") // + macroX( "\\lciChapterPrefix") @@ -218,7 +218,7 @@ void handleChapter( const Text& T) { << "\">" << chapter_title << "" << endl; } -void handleBiblio( const Text& T) { +void handleBiblio( const Buffer_list& T) { ostream* out = open_file_for_write( tmp_path + macroX("\\lciBibFilename")); istream* in = open_config_file( macroX( "\\lciBiblioHeader")); filter_config_file( *in, *out); @@ -326,7 +326,7 @@ void handleClassEnd( void) { handleClassFileEnd(); } -void handleHtmlClassFile( const string& filename, const Text& T) { +void handleHtmlClassFile( const string& filename, const Buffer_list& T) { char* s = text_block_to_string( T); string p = string("" + s + ""; handleClassFile( filename, p); @@ -395,18 +395,6 @@ undef( const string&, string param[], size_t n, size_t opt) { return string(); } -string -optional_param_at_end( const string&, string param[], size_t n, size_t opt) { - NParamCheck( 2, 0); - string macroname( param[0]); - crop_string( macroname); - remove_separator( macroname); - string s( param[1]); - crop_string( s); - setMacroOptEnd( macroname, atoi(s.c_str())); - return string(); -} - string begin_scope( const string&, string param[], size_t n, size_t opt) { NParamCheck( 0, 0); @@ -700,8 +688,6 @@ void init_internal_macros() { insertInternalGlobalMacro( "\\def", newcommand, 2); insertInternalGlobalMacro( "\\gdef", global_newcommand, 2); insertInternalGlobalMacro( "\\lciUndef", undef, 1); - insertInternalGlobalMacro( "\\lciOptionalParameterAtEnd", - optional_param_at_end, 2); insertInternalGlobalMacro( "\\lciBeginScope", begin_scope, 0); insertInternalGlobalMacro( "\\lciEndScope", end_scope, 0); insertInternalGlobalMacro( "\\lciIfDefined", if_defined, 1); @@ -719,10 +705,8 @@ void init_internal_macros() { insertInternalGlobalMacro( "\\lciStyle", cc_style, 1); insertInternalGlobalMacro( "\\lciCCParameter", cc_parameter, 0); - insertInternalGlobalMacro( "\\lciTwoColumnLayout", - two_column_layout, 1); - insertInternalGlobalMacro( "\\lciThreeColumnLayout", - three_column_layout, 2); + insertInternalGlobalMacro( "\\lciTwoColumnLayout", two_column_layout, 1); + insertInternalGlobalMacro( "\\lciThreeColumnLayout",three_column_layout,2); insertInternalGlobalMacro( "\\lciHtmlIndex", html_index, 2); insertInternalGlobalMacro( "\\lciHtmlIndexC", html_index_C, 1); diff --git a/Packages/Manual_tools/src/internal_macros.h b/Packages/Manual_tools/src/internal_macros.h index ebba26b8ef7..72f380144bc 100644 --- a/Packages/Manual_tools/src/internal_macros.h +++ b/Packages/Manual_tools/src/internal_macros.h @@ -16,12 +16,12 @@ #include #include -#include +#include void init_internal_macros(); -void handleChapter( const Text& T); -void handleBiblio( const Text& T); +void handleChapter( const Buffer_list& T); +void handleBiblio( const Buffer_list& T); void handleClassEnvironment(); void handleClassEnd(); @@ -29,7 +29,7 @@ void handleClassEnd(); void handleClassNameEnd( void); void handleClassFileEnd( void); -void handleHtmlClassFile( const string& filename, const Text& T); +void handleHtmlClassFile( const string& filename, const Buffer_list& T); string handleHtmlIndexC( const string& category, const string& item); string handleHtmlIndex( const string& category, const string& item); diff --git a/Packages/Manual_tools/src/latex_converter_config/html/cc_manual.sty b/Packages/Manual_tools/src/latex_converter_config/html/cc_manual.sty index a81281d5046..e3281930c97 100644 --- a/Packages/Manual_tools/src/latex_converter_config/html/cc_manual.sty +++ b/Packages/Manual_tools/src/latex_converter_config/html/cc_manual.sty @@ -394,7 +394,6 @@ \gdef{\lciIfHtmlRefLinks}{\lcTrue}% \gdef{\lciIfHtmlRefIndex}{\lcTrue}% } -\lciOptionalParameterAtEnd{\begin@ccRefDeclaration}{1} \newcommand{\begin@ccRefDeclaration@mo}{% \def\ccRefCategory{#C1}% \def\ccPureRefScope{#C2}% @@ -676,7 +675,6 @@ \newcommand{\ccHtmlIndexC}{% \newcommand{\lciLocalIndexCategory}{class}\lciParseCC{\lciIndexCParsed}} -\lciOptionalParameterAtEnd{\ccHtmlIndexC}{1} \newcommand{\ccHtmlIndexC@o}{% \newcommand{\lciLocalIndexCategory}{#C1}\lciParseCC{\lciIndexCParsed}} \newcommand{\lciIndexCParsed}{\lciIndexCParsedX{\lciLocalIndexCategory}} diff --git a/Packages/Manual_tools/src/latex_converter_config/html/latex.sty b/Packages/Manual_tools/src/latex_converter_config/html/latex.sty index 6cd2dd2ee51..dfb0238327c 100644 --- a/Packages/Manual_tools/src/latex_converter_config/html/latex.sty +++ b/Packages/Manual_tools/src/latex_converter_config/html/latex.sty @@ -135,8 +135,6 @@ %% newlines, except for tabbing and tabular environments. \newcommand{\\}{\lcRawHtml{
}} \newcommand{\\*}{\lcRawHtml{
}} -\lciOptionalParameterAtEnd{\\}{1} -\lciOptionalParameterAtEnd{\\*}{1} \newcommand{\\@o}{\lcRawHtml{
}} \newcommand{\\*@o}{\lcRawHtml{
}} @@ -239,7 +237,6 @@ \newcommand{\footnotemark}{% \addtocounter{footnote}{1}% \footnotemark[\thefootnote]} -\lciOptionalParameterAtEnd{\footnotemark}{1} \newcommand{\footnotemark@o}{% \lcRawHtml{#XC1}} \newcommand{\footnotetext}[1]{% @@ -1020,7 +1017,6 @@ \newcommand{\pagenumbering}[1]{} \newcommand{\twocolumn}{} -\lciOptionalParameterAtEnd{\twocolumn}{1} \newcommand{\twocolumn@o}{#1} \newcommand{\onecolumn}{} @@ -1057,7 +1053,6 @@ \newenvironment{enumerate}{\lcRawHtml{

    }}{\lcRawHtml{
}} \newenvironment{description}{\lcRawHtml{
}}{\lcRawHtml{
}} \newcommand{\item}{\lcRawHtml{
  • }} -\lciOptionalParameterAtEnd{\item}{1} \newcommand{\item@o}{\lcRawHtml{
    }#1\lcRawHtml{
    }} \newcommand{\lciLocalVerbatim}[1]{% @@ -1143,14 +1138,12 @@ \newcommand{\newtheorem}[2]{% \gdef{\begin@#C1}{{\bf #2}~~\lcRawHtml{}}% - \lciOptionalParameterAtEnd{\begin@#C1}{1}% \gdef{\begin@#C1@o}{{\bf #2 (##1)}~~\lcRawHtml{}}% \gdef{\end#C1}{\lcRawHtml{}}% } \newcommand{\newcounter}[1]{% \gdef{\the#C1}{0}% \gdef{\lciDependantCounter#C1}{}} -\lciOptionalParameterAtEnd{\newcounter}{1} \newcommand{\newcounter@mo}{ \gdef{\the#C1}{0}% \gdef{\lciDependantCounter#C1}{}% @@ -1177,15 +1170,11 @@ \newenvironment{figure}{\newcommand{\lciLabelTitle}{{\bf Figure:~~}}}{} \newenvironment{figure*}{\begin{figure}}{\end{figure}} -\lciOptionalParameterAtEnd{\begin@figure}{1} -\lciOptionalParameterAtEnd{\begin@figure*}{1} \newenvironment{figure@o}{\begin{figure}}{\end{figure}} \newenvironment{figure*@o}{\begin{figure}}{\end{figure}} \newenvironment{table}{\newcommand{\lciLabelTitle}{{\bf Table:~~}}}{} \newenvironment{table*}{\begin{table}}{\end{table}} -\lciOptionalParameterAtEnd{\begin@table}{1} -\lciOptionalParameterAtEnd{\begin@table*}{1} \newenvironment{table@o}{\begin{table}}{\end{table}} \newenvironment{table*@o}{\begin{table}}{\end{table}} @@ -1193,7 +1182,6 @@ \newcommand{\caption@om}{\lciLabelTitle #1} \newcommand{\suppressfloats}{} -\lciOptionalParameterAtEnd{\suppressfloats}{1} \newcommand{\suppressfloats@o}{} \newcommand{\marginpar}[1]{% @@ -1229,8 +1217,6 @@ \newcommand{\>}{\lciTabbingSkip}% \renewcommand{\\}{\lciTabbingNL}% \renewcommand{\\*}{\lciTabbingNL}% - \lciOptionalParameterAtEnd{\\}{1}% - \lciOptionalParameterAtEnd{\\*}{1}% \renewcommand{\\@o}{\lciTabbingNL}% \renewcommand{\\*@o}{\lciTabbingNL}% } @@ -1270,8 +1256,6 @@ \newcommand{&}{\lciTabularSkip}% \renewcommand{\\}{\lciTabularNL}% \renewcommand{\\*}{\lciTabularNL}% - \lciOptionalParameterAtEnd{\\}{1}% - \lciOptionalParameterAtEnd{\\*}{1}% \renewcommand{\\@o}{\lciTabularNL}% \renewcommand{\\*@o}{\lciTabularNL}% \lciTabularCountColumns #1\*% @@ -1438,10 +1422,8 @@ % ########################################################################### \newcommand{\linebreak}{} -\lciOptionalParameterAtEnd{\linebreak}{1} \newcommand{\linebreak@o}{} \newcommand{\nolinebreak}{} -\lciOptionalParameterAtEnd{\nolinebreak}{1} \newcommand{\nolinebreak@o}{} \newcommand{\newline}{\\} @@ -1453,10 +1435,8 @@ \newenvironment{sloppypar}{}{} \newcommand{\pagebreak}{} -\lciOptionalParameterAtEnd{\pagebreak}{1} \newcommand{\pagebreak@o}{} \newcommand{\nopagebreak}{} -\lciOptionalParameterAtEnd{\nopagebreak}{1} \newcommand{\nopagebreak@o}{} \newcommand{\samepage}{} diff --git a/Packages/Manual_tools/src/latex_converter_config/ref_pages/Class.tex b/Packages/Manual_tools/src/latex_converter_config/ref_pages/Class.tex new file mode 100644 index 00000000000..128771ec7c2 --- /dev/null +++ b/Packages/Manual_tools/src/latex_converter_config/ref_pages/Class.tex @@ -0,0 +1,53 @@ +include(CONFIG_PATH/header.tex) +\begin{ccRefClass}SCOPE{PREFIX`'ITEM} %% add template arg's if necessary + +%% \ccHtmlCrossLink{} %% add further rules for cross referencing links +%% \ccHtmlIndexC[class]{} %% add further `index' entries + +\ccDefinition + +The class \ccRefName\ does this and that. + +\ccInclude{SUBDIR`'ITEM.h} + +\ccIsModel + +\ccc{Concept} + +\ccTypes + +\ccNestedType{TYPE}{some nested types} + +\ccCreation +\ccCreationVariable{a} %% choose variable name + +\ccConstructor{PREFIX`'ITEM`'();}{default constructor.} + +\ccOperations + +\ccMethod{void foo();}{some member functions} + +\ccSeeAlso + +\ccc{Some_other_class}, +\ccc{some_other_function}. + +\ccExample + +A short example program. +Instead of a short program fragment, a full running program can be +included using the +\verb|\ccIncludeExampleCode{examples/PACKAGE/ITEM`'_prog.C}| +macro. The program example would be part of the source code distribution and +also part of the automatic test suite. + +\begin{ccExampleCode} +void your_example_code() { +} +\end{ccExampleCode} + +%% \ccIncludeExampleCode{examples/PACKAGE/ITEM`'_prog.C} + +\end{ccRefClass} + +include(CONFIG_PATH/footer.tex) diff --git a/Packages/Manual_tools/src/latex_converter_config/ref_pages/Concept.tex b/Packages/Manual_tools/src/latex_converter_config/ref_pages/Concept.tex new file mode 100644 index 00000000000..449fe369149 --- /dev/null +++ b/Packages/Manual_tools/src/latex_converter_config/ref_pages/Concept.tex @@ -0,0 +1,52 @@ +include(CONFIG_PATH/header.tex) +\begin{ccRefConcept}{ITEM} + +%% \ccHtmlCrossLink{} %% add further rules for cross referencing links +%% \ccHtmlIndexC[concept]{} %% add further `index' entries + +\ccDefinition + +The concept \ccRefName\ does this and that. + +\ccTypes + +\ccNestedType{TYPE}{some nested types} + +\ccCreation +\ccCreationVariable{a} %% choose variable name + +\ccConstructor{ITEM`'();}{default constructor.} + +\ccOperations + +\ccMethod{void foo();}{some member functions} + +\ccHasModels + +\ccc{Some_class}, +\ccc{Some_other_class}. + +\ccSeeAlso + +\ccc{Some_other_concept}, +\ccc{some_other_function}. + +\ccExample + +A short example program. +Instead of a short program fragment, a full running program can be +included using the +\verb|\ccIncludeExampleCode{examples/PACKAGE/ITEM`'_prog.C}| +macro. The program example would be part of the source code distribution and +also part of the automatic test suite. + +\begin{ccExampleCode} +void your_example_code() { +} +\end{ccExampleCode} + +%% \ccIncludeExampleCode{examples/PACKAGE/ITEM`'_prog.C} + +\end{ccRefConcept} + +include(CONFIG_PATH/footer.tex) diff --git a/Packages/Manual_tools/src/latex_converter_config/ref_pages/Enum.tex b/Packages/Manual_tools/src/latex_converter_config/ref_pages/Enum.tex new file mode 100644 index 00000000000..1ce55597d49 --- /dev/null +++ b/Packages/Manual_tools/src/latex_converter_config/ref_pages/Enum.tex @@ -0,0 +1,42 @@ +include(CONFIG_PATH/header.tex) +\begin{ccRefEnum}SCOPE{PREFIX`'ITEM} %% add template arg's if necessary + +%% \ccHtmlCrossLink{} %% add further rules for cross referencing links +%% \ccHtmlIndexC[enum]{} %% add further `index' entries + +\ccDefinition + +The enum \ccRefName\ does this and that. + +\ccInclude{SUBDIR`'ITEM.h} + +\ccGlobalEnum{enum PREFIX`'ITEM { tag1, tag2 };} + +\ccIsModel + +\ccc{Concept} + +\ccSeeAlso + +\ccc{Some_other_enum}, +\ccc{some_other_function}. + +\ccExample + +A short example program. +Instead of a short program fragment, a full running program can be +included using the +\verb|\ccIncludeExampleCode{examples/PACKAGE/ITEM`'_prog.C}| +macro. The program example would be part of the source code distribution and +also part of the automatic test suite. + +\begin{ccExampleCode} +void your_example_code() { +} +\end{ccExampleCode} + +%% \ccIncludeExampleCode{examples/PACKAGE/ITEM`'_prog.C} + +\end{ccRefEnum} + +include(CONFIG_PATH/footer.tex) diff --git a/Packages/Manual_tools/src/latex_converter_config/ref_pages/Function.tex b/Packages/Manual_tools/src/latex_converter_config/ref_pages/Function.tex new file mode 100644 index 00000000000..189e232f388 --- /dev/null +++ b/Packages/Manual_tools/src/latex_converter_config/ref_pages/Function.tex @@ -0,0 +1,42 @@ +include(CONFIG_PATH/header.tex) +\begin{ccRefFunction}SCOPE{PREFIX`'ITEM} %% add template arg's if necessary + +%% \ccHtmlCrossLink{} %% add further rules for cross referencing links +%% \ccHtmlIndexC[function]{} %% add further `index' entries + +\ccDefinition + +The function \ccRefName\ does this and that. + +\ccInclude{SUBDIR`'ITEM.h} + +\ccGlobalFunction{void PREFIX`'ITEM`'();} + +\ccIsModel + +\ccc{Concept} + +\ccSeeAlso + +\ccc{Some_other_class}, +\ccc{some_other_function}. + +\ccExample + +A short example program. +Instead of a short program fragment, a full running program can be +included using the +\verb|\ccIncludeExampleCode{examples/PACKAGE/ITEM`'_prog.C}| +macro. The program example would be part of the source code distribution and +also part of the automatic test suite. + +\begin{ccExampleCode} +void your_example_code() { +} +\end{ccExampleCode} + +%% \ccIncludeExampleCode{examples/PACKAGE/ITEM`'_prog.C} + +\end{ccRefFunction} + +include(CONFIG_PATH/footer.tex) diff --git a/Packages/Manual_tools/src/latex_converter_config/ref_pages/Macro.tex b/Packages/Manual_tools/src/latex_converter_config/ref_pages/Macro.tex new file mode 100644 index 00000000000..9b801935be9 --- /dev/null +++ b/Packages/Manual_tools/src/latex_converter_config/ref_pages/Macro.tex @@ -0,0 +1,42 @@ +include(CONFIG_PATH/header.tex) +\begin{ccRefMacro}{PREFIX`'ITEM} %% add template arg's if necessary + +%% \ccHtmlCrossLink{} %% add further rules for cross referencing links +%% \ccHtmlIndexC[macro]{} %% add further `index' entries + +\ccDefinition + +The macro \ccRefName\ does this and that. + +\ccInclude{SUBDIR`'ITEM.h} + +\ccc{PREFIX`'ITEM} + +\ccIsModel + +\ccc{Concept} + +\ccSeeAlso + +\ccc{Some_other_macro}, +\ccc{some_other_function}. + +\ccExample + +A short example program. +Instead of a short program fragment, a full running program can be +included using the +\verb|\ccIncludeExampleCode{examples/PACKAGE/ITEM`'_prog.C}| +macro. The program example would be part of the source code distribution and +also part of the automatic test suite. + +\begin{ccExampleCode} +void your_example_code() { +} +\end{ccExampleCode} + +%% \ccIncludeExampleCode{examples/PACKAGE/ITEM`'_prog.C} + +\end{ccRefMacro} + +include(CONFIG_PATH/footer.tex) diff --git a/Packages/Manual_tools/src/latex_converter_config/ref_pages/Variable.tex b/Packages/Manual_tools/src/latex_converter_config/ref_pages/Variable.tex new file mode 100644 index 00000000000..9c672ee8865 --- /dev/null +++ b/Packages/Manual_tools/src/latex_converter_config/ref_pages/Variable.tex @@ -0,0 +1,42 @@ +include(CONFIG_PATH/header.tex) +\begin{ccRefVariable}SCOPE{PREFIX`'ITEM} %% add template arg's if necessary + +%% \ccHtmlCrossLink{} %% add further rules for cross referencing links +%% \ccHtmlIndexC[variable]{} %% add further `index' entries + +\ccDefinition + +The variable \ccRefName\ does this and that. + +\ccInclude{SUBDIR`'ITEM.h} + +\ccGlobalVariable{type PREFIX`'ITEM = init_value;} + +\ccIsModel + +\ccc{Concept} + +\ccSeeAlso + +\ccc{Some_other_variable}, +\ccc{some_other_function}. + +\ccExample + +A short example program. +Instead of a short program fragment, a full running program can be +included using the +\verb|\ccIncludeExampleCode{examples/PACKAGE/ITEM`'_prog.C}| +macro. The program example would be part of the source code distribution and +also part of the automatic test suite. + +\begin{ccExampleCode} +void your_example_code() { +} +\end{ccExampleCode} + +%% \ccIncludeExampleCode{examples/PACKAGE/ITEM`'_prog.C} + +\end{ccRefVariable} + +include(CONFIG_PATH/footer.tex) diff --git a/Packages/Manual_tools/src/lex_include.h b/Packages/Manual_tools/src/lex_include.h index 890be569840..d4cd95dacaf 100644 --- a/Packages/Manual_tools/src/lex_include.h +++ b/Packages/Manual_tools/src/lex_include.h @@ -17,7 +17,6 @@ #include #include -#include #include #include diff --git a/Packages/Manual_tools/src/macro_dictionary.C b/Packages/Manual_tools/src/macro_dictionary.C index f8b80a06eb4..cb14135a330 100644 --- a/Packages/Manual_tools/src/macro_dictionary.C +++ b/Packages/Manual_tools/src/macro_dictionary.C @@ -84,46 +84,46 @@ void insertMacro( const string& macro, const string& filename, size_t line, const string& body, - size_t n_param, - size_t n_opt) { + size_t n_param) { if ( macro_def_switch) { cerr << "Macro definition: macro `" << macro << "' = `" << body << "'." << endl; } - assert( macro_dictionary.size() > 0); + CC_Assert( macro_dictionary.size() > 0); if ( macro[0] != '\0' && macro[1] == '\0') set_active_char( macro[0], true); + checkMacroOptEnd( macro); macro_dictionary.front()[ macro] = - Macro_item( filename, line, body, n_param, n_opt); + Macro_item( filename, line, body, n_param); } void insertInternalMacro( const string& macro, ExpandFunction fct, - size_t n_param, - size_t n_opt) { + size_t n_param) { if ( macro_def_switch) { cerr << "Internal def. : macro `" << macro << "'." << endl; } - assert( macro_dictionary.size() > 0); + CC_Assert( macro_dictionary.size() > 0); if ( macro[0] != '\0' && macro[1] == '\0') set_active_char( macro[0], true); + checkMacroOptEnd( macro); macro_dictionary.front()[ macro] = - Macro_item( "", 0, fct, n_param, n_opt); + Macro_item( "", 0, fct, n_param); } void insertInternalMacro( const string& macro, const string& body, - size_t n_param , - size_t n_opt) { + size_t n_param ) { if ( macro_def_switch) { cerr << "Internal def. : macro `" << macro << "' = `" << body << "'." << endl; } - assert( macro_dictionary.size() > 0); + CC_Assert( macro_dictionary.size() > 0); if ( macro[0] != '\0' && macro[1] == '\0') set_active_char( macro[0], true); + checkMacroOptEnd( macro); macro_dictionary.front()[ macro] = - Macro_item( "", 0, body, n_param, n_opt); + Macro_item( "", 0, body, n_param); } @@ -131,49 +131,49 @@ void insertGlobalMacro( const string& macro, const string& filename, size_t line, const string& body, - size_t n_param, - size_t n_opt) { + size_t n_param) { if ( macro_def_switch) { cerr << "Macro global def: macro `" << macro << "' = `" << body << "'." << endl; } - assert( macro_dictionary.size() > 0); + CC_Assert( macro_dictionary.size() > 0); localEraseMacro( macro); if ( macro[0] != '\0' && macro[1] == '\0') set_all_active_char( macro[0], true); + checkMacroOptEnd( macro); macro_dictionary.back()[ macro] = - Macro_item( filename, line, body, n_param, n_opt); + Macro_item( filename, line, body, n_param); } void insertInternalGlobalMacro( const string& macro, ExpandFunction fct, - size_t n_param, - size_t n_opt) { + size_t n_param) { if ( macro_def_switch) { cerr << "Internal gdef. : macro `" << macro << "'." << endl; } - assert( macro_dictionary.size() > 0); + CC_Assert( macro_dictionary.size() > 0); localEraseMacro( macro); if ( macro[0] != '\0' && macro[1] == '\0') set_all_active_char( macro[0], true); + checkMacroOptEnd( macro); macro_dictionary.back()[ macro] = - Macro_item( "", 0, fct, n_param, n_opt); + Macro_item( "", 0, fct, n_param); } void insertInternalGlobalMacro( const string& macro, const string& body, - size_t n_param, - size_t n_opt) { + size_t n_param) { if ( macro_def_switch) { cerr << "Internal gdef. : macro `" << macro << "' = `" << body << "'." << endl; } - assert( macro_dictionary.size() > 0); + CC_Assert( macro_dictionary.size() > 0); localEraseMacro( macro); if ( macro[0] != '\0' && macro[1] == '\0') set_all_active_char( macro[0], true); + checkMacroOptEnd( macro); macro_dictionary.back()[ macro] = - Macro_item( "", 0, body, n_param, n_opt); + Macro_item( "", 0, body, n_param); } @@ -214,19 +214,6 @@ bool macroIsTrue( const string& macro) { return false; } -void setMacroOptEnd( const string& macro, int n_opt) { - Macro_dictionary_scope::iterator j; - if ( queryMacro( macro, j)) { - (*j).second.n_opt_at_end = n_opt; - } else { - cerr << endl << "Unknown macro " << macro - << " in `" << in_string->name() - << " in line " << in_string->line() << "'."; - if ( stack_trace_switch) - printErrorMessage( MacroUndefinedError); - } -} - void eraseMacro( const string& macro) { if ( macro_def_switch) { cerr << "Macro erasion: macro `" << macro << "'." << endl; @@ -393,5 +380,35 @@ string expandMacro( const string& macro, return s; } +void checkMacroOptEnd( const string& macro) { + if ( macro.size() > 2) { + int cnt = 0; + string::const_iterator i = macro.end(); + -- i; + while ( i != macro.begin() && *i == 'o') { + -- i; + ++ cnt; + } + while ( i != macro.begin() && (*i == 'o' || *i == 'm')) + --i; + if ( *i != '@' || cnt == 0) + return; + string basename( macro.begin(), i); + Macro_dictionary_scope::iterator j; + if ( queryMacro( basename, j)) { + if ( cnt > int((*j).second.n_opt_at_end)) + (*j).second.n_opt_at_end = cnt; + } else { + cerr << endl << "Error: Define macro " << basename + << " before defining optional arguments " << macro + << " in `" << in_string->name() + << " in line " << in_string->line() << "'."; + if ( stack_trace_switch) + printErrorMessage( MacroUndefinedError); + } + } + +} + // EOF // diff --git a/Packages/Manual_tools/src/macro_dictionary.h b/Packages/Manual_tools/src/macro_dictionary.h index 5dcb86c8dd7..cddd460487f 100644 --- a/Packages/Manual_tools/src/macro_dictionary.h +++ b/Packages/Manual_tools/src/macro_dictionary.h @@ -30,22 +30,20 @@ struct Macro_item { size_t n_param; size_t n_opt_at_end; ExpandFunction fct; - Macro_item() : n_param(0), n_opt_at_end(false) {} + + Macro_item() : n_param(0), n_opt_at_end(0) {} Macro_item( const string& file, size_t ln, const string& bdy, - size_t n_par = 0, - size_t n_opt = 0) + size_t n_par = 0) : filename(file), line(ln), body(bdy), n_param(n_par), - n_opt_at_end(n_opt), fct(0) + n_opt_at_end(0), fct(0) {} Macro_item( const string& file, size_t ln, ExpandFunction f, - size_t n_par = 0, - size_t n_opt = 0) - : filename(file), line(ln), n_param(n_par), - n_opt_at_end(n_opt), fct(f) + size_t n_par = 0) + : filename(file), line(ln), n_param(n_par), n_opt_at_end(0), fct(f) {} }; @@ -56,35 +54,29 @@ void insertMacro( const string& macro, const string& filename, size_t line, const string& body, - size_t n_param = 0, - size_t n_opt = 0); + size_t n_param = 0); void insertInternalMacro( const string& macro, ExpandFunction fct, - size_t n_param = 0, - size_t n_opt = 0); + size_t n_param = 0); void insertInternalMacro( const string& macro, const string& body, - size_t n_param = 0, - size_t n_opt = 0); + size_t n_param = 0); void insertGlobalMacro( const string& macro, const string& filename, size_t line, const string& body, - size_t n_param = 0, - size_t n_opt = 0); + size_t n_param = 0); void insertInternalGlobalMacro( const string& macro, ExpandFunction fct, - size_t n_param = 0, - size_t n_opt = 0); + size_t n_param = 0); void insertInternalGlobalMacro( const string& macro, const string& body, - size_t n_param = 0, - size_t n_opt = 0); + size_t n_param = 0); const Macro_item& fetchMacro( const string& macro); @@ -113,8 +105,7 @@ bool definedMacro( const string& macro); bool macroIsTrue( const string& macro); -void setMacroOptEnd( const string& macro, int n_opt); - +void checkMacroOptEnd( const string& macro); #endif // MACRO_DICTIONARY_H // // EOF // diff --git a/Packages/Manual_tools/src/mstring.h b/Packages/Manual_tools/src/mstring.h index 1404413df27..4ec47f91059 100644 --- a/Packages/Manual_tools/src/mstring.h +++ b/Packages/Manual_tools/src/mstring.h @@ -9,6 +9,8 @@ #define MY_STRING_H 1 #include + +// comment this for SGI 7.2 using namespace std; // provide hash function for string class of egcs 1.1.1 diff --git a/Packages/Manual_tools/src/output.h b/Packages/Manual_tools/src/output.h index 6a5fe8c3eb9..402470e3b97 100644 --- a/Packages/Manual_tools/src/output.h +++ b/Packages/Manual_tools/src/output.h @@ -16,6 +16,7 @@ #include #include +#include #define OUT(x) if ( m_out) *m_out << x; return *this @@ -31,7 +32,7 @@ public: Output_file( ostream* out, const string& name) : m_out(out), m_name(name) {} bool is_valid() const { return m_out != 0;} - ostream& stream() const { assert( m_out != 0); return *m_out;} + ostream& stream() const { CC_Assert( m_out != 0); return *m_out;} ostream* stream_ptr() const { return m_out;} const string& name() const { return m_name;} Output_file& operator<<( char c) { OUT(c);} diff --git a/Packages/Manual_tools/src/string_conversion.C b/Packages/Manual_tools/src/string_conversion.C index 7573682307c..e81baa3bbe5 100644 --- a/Packages/Manual_tools/src/string_conversion.C +++ b/Packages/Manual_tools/src/string_conversion.C @@ -527,8 +527,8 @@ const int max_tag_size = 20; char font_tag_buffer[max_tag_size]; const char* font_changing_tags( Font old_font, Font new_font) { - assert( old_font > unknown_font && old_font < end_font_array); - assert( new_font > unknown_font && new_font < end_font_array); + CC_Assert( old_font > unknown_font && old_font < end_font_array); + CC_Assert( new_font > unknown_font && new_font < end_font_array); if ( old_font == new_font) *font_tag_buffer = '\0'; else {