mirror of https://github.com/CGAL/cgal
Release 2.1. Delivered to CGAL.
This commit is contained in:
parent
45fb3d9d76
commit
094a20bd1e
|
|
@ -0,0 +1,187 @@
|
|||
# Makefile
|
||||
# ===================================
|
||||
# V 1.00 17.08.1995 Lutz Kettner
|
||||
# Project: CGAL merger tool for the specification task
|
||||
# V 1.1 22.11.1996 Lutz Kettner
|
||||
# Project: tools around the CGAL manual writing task.
|
||||
# extract, check, HTML conversion.
|
||||
# V 1.2 03.12.1996 Lutz Kettner
|
||||
# Tools renamed from CGAL to CC. Relates to cc_manual.sty R2.1.
|
||||
#
|
||||
# $Release:$, $Date$
|
||||
|
||||
# =======================================================
|
||||
# Installation: chose the appropriate compiler and paths:
|
||||
# =======================================================
|
||||
|
||||
# Installation directory (where to put the executables)
|
||||
# Only necessary if the make target 'install' is used for installation.
|
||||
#INSTALL_DIR = /usr/bin
|
||||
INSTALL_DIR = $(PUBLIC)/$(SYSTEM)/bin # local settings on my machine
|
||||
|
||||
# Include path (needs probably no adaption)
|
||||
INCL = -I.
|
||||
|
||||
# Path for the HTML conversion tools for the default configuration files.
|
||||
# This path will be compiled into the cc_extract_html program and used for
|
||||
# the installation.
|
||||
# The same variable has to be configured in the cc_manual_to_html script.
|
||||
# The path must terminate with a slash.
|
||||
#HTML_DEFAULT_PATH =
|
||||
HTML_DEFAULT_PATH = /pub/local/CGAL/Tools/html_config_files/
|
||||
|
||||
# Three supported C++ compilers:
|
||||
# Gnu g++ 2.6.3 (or above)
|
||||
# Sun Pro CC 4.0.1 (or above)
|
||||
# SGI CC 4.0 (or above)
|
||||
# The compiler call:
|
||||
#CPP = g++
|
||||
CPP = CC
|
||||
|
||||
# The C++ compiler options (optimization, debugging, warnings, includes)
|
||||
#CPPOPT = -O -Wall $(INCL) # Gnu
|
||||
#CPPOPT = -O +w $(INCL) # Sgi
|
||||
CPPOPT = -O +w $(INCL) # Sun
|
||||
|
||||
# A C compiler:
|
||||
# Gnu gcc 2.6.3 (or above)
|
||||
# System cc
|
||||
#CC = gcc
|
||||
CC = cc
|
||||
|
||||
# The C compiler options
|
||||
# CCOPT = $(CPPOPT) # Gnu
|
||||
CCOPT = -O $(INCL) # Sun, SGI
|
||||
|
||||
# flex, bison, compile and link commands
|
||||
FLEX = flex -t -8
|
||||
BISON = bison -d -t -v
|
||||
COMPILE = $(CPP) $(CPPOPT) -c
|
||||
LINK = $(CPP) $(CPPOPT)
|
||||
|
||||
# The flex and bison output might produce a lot of warnings with
|
||||
# the C++ compiler (Sgi). Special options switch these messages off.
|
||||
#XCOMPILE = $(COMPILE) # Gnu
|
||||
#XCOMPILE = $(COMPILE) -woff 3203 # SGI
|
||||
XCOMPILE = $(COMPILE) # Sun
|
||||
|
||||
# Default targets to make:
|
||||
ALL = cc_extract cc_build_checker cc_extract_html cc_index_sort
|
||||
|
||||
# =======================================================
|
||||
# Installation: Nothing else below this line.
|
||||
# =======================================================
|
||||
|
||||
# all the files that have to be copied into a directory in the $PATH
|
||||
PROGRAM_FILES = cc_extract cc_build_checker cc_extract_html cc_index_sort
|
||||
|
||||
# all the files that have to be moved into a directory in the $PATH
|
||||
SCRIPT_FILES = cc_check cc_manual_to_html
|
||||
|
||||
# all the files for the HTML config directory
|
||||
HTML_CONFIG_FILES = html_config_files/*
|
||||
# cc_anchor_footer cc_anchor_header cc_biblio_footer \
|
||||
# cc_biblio_header cc_index_footer cc_index_header \
|
||||
# cc_manual_footer cc_manual_header cc_toc_footer \
|
||||
# cc_toc_header
|
||||
|
||||
# default rule
|
||||
all: $(ALL)
|
||||
|
||||
|
||||
# General Modules
|
||||
# ==========================
|
||||
database.o : database.C database.h config.h
|
||||
$(COMPILE) -o database.o database.C
|
||||
|
||||
# Extraction and Checking
|
||||
# ==========================
|
||||
# parser and scanner
|
||||
# --------------------
|
||||
extract_lex.c : extract_lex.yy
|
||||
$(FLEX) extract_lex.yy >extract_lex.c
|
||||
|
||||
extract_syntax.tab.c extract_syntax.tab.h : extract_syntax.y
|
||||
$(BISON) extract_syntax.y
|
||||
|
||||
# modules
|
||||
# --------------------
|
||||
extract_lex.o : extract_lex.c extract_syntax.tab.h database.h config.h
|
||||
$(XCOMPILE) -o extract_lex.o extract_lex.c
|
||||
|
||||
extract_syntax.o : extract_syntax.tab.c extract_syntax.tab.h \
|
||||
database.h config.h
|
||||
$(XCOMPILE) -o extract_syntax.o extract_syntax.tab.c
|
||||
|
||||
cc_extract.o : cc_extract.C database.h config.h
|
||||
$(COMPILE) -o cc_extract.o cc_extract.C
|
||||
|
||||
cc_build_checker.o : cc_build_checker.C database.h config.h
|
||||
$(COMPILE) -o cc_build_checker.o cc_build_checker.C
|
||||
|
||||
# program
|
||||
# --------------------
|
||||
OBJ = extract_lex.o extract_syntax.o database.o
|
||||
HEADER = extract_syntax.tab.h database.h config.h
|
||||
|
||||
cc_extract : $(OBJ) $(HEADER) cc_extract.o
|
||||
$(LINK) -o cc_extract cc_extract.o $(OBJ)
|
||||
|
||||
cc_build_checker : $(OBJ) $(HEADER) cc_build_checker.o
|
||||
$(LINK) -o cc_build_checker cc_build_checker.o $(OBJ)
|
||||
|
||||
|
||||
# Converting to HTML
|
||||
# ==========================
|
||||
# parser and scanner
|
||||
# --------------------
|
||||
html_lex.c : html_lex.yy
|
||||
$(FLEX) html_lex.yy >html_lex.c
|
||||
|
||||
html_syntax.tab.c html_syntax.tab.h : html_syntax.y
|
||||
$(BISON) html_syntax.y
|
||||
|
||||
# modules
|
||||
# --------------------
|
||||
html_lex.o : html_lex.c html_syntax.tab.h database.h html_config.h
|
||||
$(XCOMPILE) -o html_lex.o html_lex.c
|
||||
|
||||
html_syntax.o : html_syntax.tab.c html_syntax.tab.h database.h html_config.h
|
||||
$(XCOMPILE) -o html_syntax.o html_syntax.tab.c
|
||||
|
||||
cc_extract_html.o : cc_extract_html.C database.h html_config.h
|
||||
$(COMPILE) -DHTML_DEFAULT_PATH=\"$(HTML_DEFAULT_PATH)\" -o cc_extract_html.o cc_extract_html.C
|
||||
|
||||
|
||||
# program
|
||||
# --------------------
|
||||
OBJHTML = html_lex.o html_syntax.o database.o
|
||||
HEADERHTML = html_syntax.tab.h database.h html_config.h
|
||||
|
||||
cc_extract_html : $(OBJHTML) $(HEADERHTML) cc_extract_html.o
|
||||
$(LINK) -o cc_extract_html cc_extract_html.o $(OBJHTML)
|
||||
|
||||
|
||||
# Sort Program to Sort the Index
|
||||
# ==============================
|
||||
cc_index_sort : cc_index_sort.c
|
||||
$(CC) $(CCOPT) -o cc_index_sort cc_index_sort.c
|
||||
|
||||
# Installation Targets
|
||||
# ====================
|
||||
install:
|
||||
mv $(PROGRAM_FILES) $(INSTALL_DIR)
|
||||
cp $(SCRIPT_FILES) $(INSTALL_DIR)
|
||||
cp $(HTML_CONFIG_FILES) $(HTML_DEFAULT_PATH)
|
||||
|
||||
# Auxiliary Targets
|
||||
# =================
|
||||
clean :
|
||||
rm *.o extract_lex.c extract_syntax.output extract_syntax.tab.h \
|
||||
extract_syntax.tab.c html_lex.c html_syntax.output \
|
||||
html_syntax.tab.h html_syntax.tab.c
|
||||
|
||||
cleanall : clean
|
||||
rm cc_build_checker cc_extract cc_extract_html
|
||||
if (-d Templates.DB) rm -r Templates.DB
|
||||
if (-d ii_files) rm -r ii_files
|
||||
|
|
@ -0,0 +1,276 @@
|
|||
/**************************************************************************
|
||||
|
||||
database.C
|
||||
=============================================================
|
||||
Project : CGAL merger tool for the specification task
|
||||
Function : Datastructures for the database extracted from
|
||||
the TeX and C++ code mixed files.
|
||||
System : C++ (g++)
|
||||
Author : (c) 1995 Lutz Kettner
|
||||
Revision : $Revision$
|
||||
Date : $Date$
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
// Other modules needed:
|
||||
// =====================
|
||||
#define ADT_INCLUDE_CC 1
|
||||
#include <database.h>
|
||||
#include <ADT/include_cc.h>
|
||||
|
||||
|
||||
// Substitute old style malloc, realloc, strdup ...
|
||||
// ================================================
|
||||
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 << "<P>";
|
||||
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;
|
||||
}
|
||||
|
||||
ostream&
|
||||
operator<< (ostream& out, const Declaration& d) {
|
||||
out << "Declaration[" << indent << indNewline;
|
||||
out << d.type << indNewline;
|
||||
printString( out, d.returnType);
|
||||
out << indNewline;
|
||||
printString( out, d.name);
|
||||
out << indNewline;
|
||||
printString( out, d.templateParams);
|
||||
out << indNewline;
|
||||
printString( out, d.parameters);
|
||||
out << indNewline;
|
||||
out << d.comment << indNewline;
|
||||
out << d.spec << outdent << indNewline;
|
||||
out << ']';
|
||||
return out;
|
||||
}
|
||||
|
||||
istream&
|
||||
operator>> (istream& in, Declaration& ) {
|
||||
return in;
|
||||
}
|
||||
|
||||
ostream&
|
||||
operator<< (ostream& out, const Specification& s) {
|
||||
out << "Specification[" << indent << indNewline;
|
||||
out << s.type << indNewline;
|
||||
out << s.decl << indNewline;
|
||||
out << s.comment << outdent << indNewline;
|
||||
out << ']';
|
||||
return out;
|
||||
}
|
||||
|
||||
istream&
|
||||
operator>> (istream& in, Specification& ) {
|
||||
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<len; i++)
|
||||
in.get( s[i]);
|
||||
s[i] = 0;
|
||||
} else {
|
||||
s = NULL;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// EOF //
|
||||
|
||||
|
|
@ -0,0 +1,439 @@
|
|||
/**************************************************************************
|
||||
|
||||
database.h
|
||||
=============================================================
|
||||
Project : CGAL merger tool for the specification task
|
||||
Function : Datastructures for the database extracted from
|
||||
the TeX and C++ code mixed files.
|
||||
System : C++ (g++)
|
||||
Author : (c) 1995 Lutz Kettner
|
||||
Revision : $Revision$
|
||||
Date : $Date$
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
#if ! defined( MODULE_DATABASE)
|
||||
#define MODULE_DATABASE 1
|
||||
|
||||
#define MaxTextWidth 74
|
||||
|
||||
// Other modules needed:
|
||||
// ==============================================
|
||||
#include <stdlib.h>
|
||||
#include <ADT/adtbase.h>
|
||||
#undef LK_RestrictedOverloading
|
||||
#define LK_RestrictedOverloading 0
|
||||
#include <ADT/list.h>
|
||||
#include <string.h>
|
||||
|
||||
// Class declarations:
|
||||
// ==============================================
|
||||
// Top Level Structure:
|
||||
// typedef InList<Specification> SpecificationList; // typedef is postponed.
|
||||
struct Specification;
|
||||
|
||||
// Parts of a specification:
|
||||
struct Declaration;
|
||||
class TextToken;
|
||||
// typedef InList< TextToken> Text; // typedef is postponed.
|
||||
|
||||
|
||||
// Substitute old style malloc, realloc, strdup ...
|
||||
// ================================================
|
||||
template < class T, class I>
|
||||
T* renew( const T* old, I old_size, I new_size);
|
||||
|
||||
template < class T, class I>
|
||||
T* renew( const T* old, I old_size, I new_size) {
|
||||
ADT_Assert( old);
|
||||
ADT_Assert( strlen( old) == size_t(old_size - 1));
|
||||
ADT_Assert( new_size > old_size);
|
||||
T* cpy = new T[ size_t(new_size)];
|
||||
if ( old && old_size > 0) {
|
||||
size_t min = ( old_size < new_size ? old_size : new_size);
|
||||
memcpy( cpy, old, min * sizeof( T));
|
||||
// delete[] old;
|
||||
}
|
||||
return cpy;
|
||||
}
|
||||
|
||||
char* newstr( const char* src);
|
||||
|
||||
|
||||
// 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;
|
||||
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( strlen( data) == len);
|
||||
ADT_Assert( data[ len] == '\0');
|
||||
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;
|
||||
}
|
||||
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());
|
||||
}
|
||||
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);
|
||||
}
|
||||
void prepend( const char* s, int l = -1) {
|
||||
ADT_Assert( s);
|
||||
ADT_Assert( data[ len] == '\0');
|
||||
int tmp;
|
||||
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);
|
||||
}
|
||||
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( 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';
|
||||
}
|
||||
};
|
||||
|
||||
class TextToken : public ListLink{
|
||||
public:
|
||||
bool isSpace;
|
||||
int len;
|
||||
char* string;
|
||||
TextToken() {
|
||||
isSpace = false;
|
||||
len = 0;
|
||||
string = 0;
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
string = NULL;
|
||||
len = 0;
|
||||
}
|
||||
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( 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;
|
||||
}
|
||||
friend ostream& operator<< (ostream& out, const TextToken& t);
|
||||
friend istream& operator>> (istream& in, TextToken& t);
|
||||
};
|
||||
|
||||
//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);
|
||||
|
||||
//class InList< Specification>;
|
||||
typedef InList< Specification> SpecificationList;
|
||||
|
||||
|
||||
enum DeclarationType {
|
||||
EmptyDecl,
|
||||
ClassDecl,
|
||||
StructDecl,
|
||||
ConstructorDecl,
|
||||
MethodDecl,
|
||||
FunctionDecl
|
||||
};
|
||||
|
||||
struct Declaration {
|
||||
DeclarationType type;
|
||||
char* returnType;
|
||||
char* name; // name without template parameter
|
||||
char* templateParams; // template parameter list
|
||||
char* parameters; // call parameters
|
||||
Text comment; // written besides the declaration
|
||||
SpecificationList spec; // for classes and structs.
|
||||
Declaration() {
|
||||
type = EmptyDecl;
|
||||
returnType = name = templateParams = parameters = NULL;
|
||||
}
|
||||
Declaration( const Declaration& d) {
|
||||
type = d.type;
|
||||
returnType = newstr( d.returnType);
|
||||
name = newstr( d.name);
|
||||
templateParams = newstr( d.templateParams);
|
||||
parameters = newstr( d.parameters);
|
||||
comment = d.comment;
|
||||
spec = d.spec;
|
||||
}
|
||||
~Declaration() {
|
||||
delete[] returnType;
|
||||
delete[] name;
|
||||
delete[] templateParams;
|
||||
delete[] parameters;
|
||||
}
|
||||
Declaration& operator=( const Declaration& d) {
|
||||
if( this != &d) { // beware of this=d; see Stroustrup pp.238
|
||||
delete[] returnType;
|
||||
delete[] name;
|
||||
delete[] templateParams;
|
||||
delete[] parameters;
|
||||
type = d.type;
|
||||
returnType = newstr( d.returnType);
|
||||
name = newstr( d.name);
|
||||
templateParams = newstr( d.templateParams);
|
||||
parameters = newstr( d.parameters);
|
||||
comment = d.comment;
|
||||
spec = d.spec;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
friend ostream& operator<< (ostream& out, const Declaration& d);
|
||||
friend istream& operator>> (istream& in, Declaration& d);
|
||||
};
|
||||
|
||||
|
||||
enum SpecificationType {
|
||||
SpecNone,
|
||||
SpecDecl,
|
||||
SpecBoth,
|
||||
SpecComment
|
||||
};
|
||||
|
||||
struct Specification : public ListLink{
|
||||
SpecificationType type;
|
||||
Declaration decl;
|
||||
Text comment; // written below of the decl.
|
||||
Specification() {
|
||||
type = SpecNone;
|
||||
}
|
||||
// Specification( const Specification& s); // default
|
||||
// ~Specification(); // default
|
||||
// Specification& operator=( const Specification& s); // default
|
||||
friend ostream& operator<< (ostream& out, const Specification& s);
|
||||
friend istream& operator>> (istream& in, Specification& s);
|
||||
};
|
||||
|
||||
|
||||
// Auxiliary function declarations
|
||||
// ==============================================
|
||||
/* ...
|
||||
char* catString( const char* r, const char* s, int l = -1, int m = -1);
|
||||
... */
|
||||
|
||||
void printString( ostream &out, const char* s, int len = -1);
|
||||
int scanString( istream &in, char*& s);
|
||||
|
||||
|
||||
#endif // MODULE_DATABASE //
|
||||
|
|
@ -94,7 +94,8 @@ ostream* p_out_errmessage;
|
|||
char char_tmp[2] = " ";
|
||||
char char_tricky_tmp[16] = "\"{ws}*\" \"{ws}*\"";
|
||||
|
||||
const char* patternText( char c, char d = 'X') {
|
||||
// const char* patternText( char c, char d = 'X') {
|
||||
const char* patternText( char c, char) {
|
||||
switch ( c) {
|
||||
case IDFIER_TAG:
|
||||
return "\"{idfier}\"";
|
||||
|
|
|
|||
|
|
@ -1,22 +1,37 @@
|
|||
#!/bin/csh -f
|
||||
# **************************************************************************
|
||||
#
|
||||
# cgal_check
|
||||
# ==========
|
||||
#
|
||||
# csh script to check consistency between specification and
|
||||
# implementation of the CGAL library kernel.
|
||||
# cc_check
|
||||
# ===================
|
||||
# A script to check the consistency between a specification written
|
||||
# in a TeX file with the cc_manual.sty and the implementation in
|
||||
# a C++ header file.
|
||||
#
|
||||
# The following programs are necessary to run this script
|
||||
#
|
||||
# o cgal_build_checker
|
||||
# o cc_build_checker
|
||||
# o flex
|
||||
# o cc / gcc
|
||||
#
|
||||
# 1.1 30.10.95 Lutz Kettner, FU Berlin, Germany
|
||||
# Author : (c) 1997 Lutz Kettner
|
||||
# Revision : $Revision$
|
||||
# Date : $Date$
|
||||
#
|
||||
# **************************************************************************
|
||||
|
||||
if ( $?DEBUG) echo "# DEBUG defined; all commands will be echoed."
|
||||
# optionally the gcc compiler can set here
|
||||
# =============================================
|
||||
# Installation: chose the appropriate compiler:
|
||||
# =============================================
|
||||
# A C compiler can be specified here. Normally cc or gcc should work.
|
||||
# Note: cc does not work on SunOS 4.1.3 (BSD), but on SunOS 5...
|
||||
#set CC = gcc
|
||||
set CC = cc
|
||||
|
||||
# =============================================
|
||||
# Installation: Nothing else below this line.
|
||||
# =============================================
|
||||
|
||||
if ( $?DEBUG) echo "# DEBUG defined; all commands will be echoed."
|
||||
|
||||
if ( $#argv < 1) goto usage
|
||||
set spec = ""
|
||||
|
|
@ -27,40 +42,48 @@ while ($#argv > 0)
|
|||
if ( $#argv < 1) goto usage
|
||||
break
|
||||
endif
|
||||
if ( "$1" == "-a") then
|
||||
shift
|
||||
if ( $#argv < 1) goto usage
|
||||
break
|
||||
endif
|
||||
set spec = "$spec $1"
|
||||
shift
|
||||
end
|
||||
|
||||
if ( $?DEBUG) echo "cgal_build_checker cgal_checker.yy cgal_checker.h $spec"
|
||||
cgal_build_checker cgal_checker.yy cgal_checker.h $spec
|
||||
if ( $?DEBUG) echo "flex -t -8 cgal_checker.yy > cgal_checker.c"
|
||||
flex -t -8 cgal_checker.yy > cgal_checker.c
|
||||
if ( $?DEBUG) echo "$CC -o cgal_checker cgal_checker.c"
|
||||
$CC -o cgal_checker cgal_checker.c
|
||||
if ( $?DEBUG) echo "cc_build_checker cc_checker.yy cc_checker.h $spec"
|
||||
cc_build_checker cc_checker.yy cc_checker.h $spec
|
||||
if ( $?DEBUG) echo "flex -t -8 cc_checker.yy > cc_checker.c"
|
||||
flex -t -8 cc_checker.yy > cc_checker.c
|
||||
if ( $?DEBUG) echo "$CC -o cc_checker cc_checker.c"
|
||||
$CC -o cc_checker cc_checker.c
|
||||
if ( $?DEBUG) then
|
||||
echo "# rm cgal_checker.yy cgal_checker.c cgal_checker.h cgal_checker.o"
|
||||
echo "# rm cc_checker.yy cc_checker.c cc_checker.h cc_checker.o"
|
||||
else
|
||||
rm cgal_checker.yy cgal_checker.c cgal_checker.h cgal_checker.o
|
||||
rm cc_checker.yy cc_checker.c cc_checker.h
|
||||
if ( -w cc_checker.o) rm cc_checker.o
|
||||
endif
|
||||
if ( $?DEBUG) echo "cgal_checker $argv"
|
||||
cgal_checker $argv
|
||||
if ( $?DEBUG) echo "cc_checker $argv"
|
||||
cc_checker $argv
|
||||
set returnvalue = $status
|
||||
if ( $returnvalue) then
|
||||
echo '==> NOTE: The program call `cgal_checker '"$argv""' can be used to"
|
||||
echo '==> check the sources again. Otherwise, remove it.'
|
||||
echo '==> NOTE: The program call `cc_checker '"$argv""' can be used to"
|
||||
echo '==> check the sources again. Otherwise, remove `cc_checker'"'."
|
||||
if ( $returnvalue == 3) set returnvalue = 0
|
||||
else
|
||||
if ( $?DEBUG) then
|
||||
echo "# rm cgal_checker"
|
||||
echo "# rm cc_checker"
|
||||
else
|
||||
rm cgal_checker
|
||||
rm cc_checker
|
||||
endif
|
||||
endif
|
||||
exit $returnvalue
|
||||
|
||||
usage:
|
||||
echo "$0 "'$Revision$'" (c) Lutz Kettner"
|
||||
echo "Usage: $0 <spec-files...> [-against [<options>] <impl-files...>]"
|
||||
echo " or: $0 -against [<options>] <impl-files...>"
|
||||
echo " -a short form for -against"
|
||||
echo " -fw recognize FunnelWeb or AnyWeb keywords"
|
||||
echo " -match print all matched text"
|
||||
echo " -unmatch print all unmatched text"
|
||||
|
|
|
|||
|
|
@ -281,6 +281,7 @@ main( int argc, char **argv) {
|
|||
(nParameters > MaxParameters) || (help_switch != NO_SWITCH)) {
|
||||
if (help_switch == NO_SWITCH)
|
||||
cerr << "Error: in parameter list" << endl;
|
||||
cerr << "cc_extract $Revision$ (c) Lutz Kettner" << endl;
|
||||
cerr << "Usage: cc_extract [<options>] [<infile> ...]" << endl;
|
||||
cerr << " -nomc no main comments" << endl;
|
||||
cerr << " -nosc no sub comments" << endl;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,696 @@
|
|||
/**************************************************************************
|
||||
|
||||
cc_index_sort.c
|
||||
=============================================================
|
||||
Project : Tools for the CC manual writing task around cc_manual.sty.
|
||||
Function : Reads an inputfile (or stdin) line by line, sorts them
|
||||
according to the lexicographic order and binary order
|
||||
of the characters (alternativly german character ordering).
|
||||
System : Standard Ansi C
|
||||
Author : (c) 1992 Lutz Kettner
|
||||
History : This program is derived from binsort 1.05. It implements
|
||||
a quicksort algorithm with a pivot chosen as the median
|
||||
of three randomly chosen elements. Dynamic line management,
|
||||
works as a filter, also for empty files.
|
||||
Revision : $Revision$
|
||||
Date : $Date$
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define FatalError( str) {\
|
||||
fprintf( stderr, "\ncc_index_sort: error: %s.\n", str);\
|
||||
exit(1);\
|
||||
}
|
||||
|
||||
#define saveMalloc( text, len, ptr) {\
|
||||
(ptr) = malloc( len); \
|
||||
if ( (ptr) == NULL) { \
|
||||
fprintf( stderr, "\ncc_index_sort: error: cannot malloc space for %s.\n",text); \
|
||||
exit( 1); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define vPrintStr( s) if ( verbose) fputs( s, stderr)
|
||||
#define vPrintInt( s) if ( verbose) fprintf( stderr, "%d", s)
|
||||
#define vPrintLong( s) if ( verbose) fprintf( stderr, "%ld", s)
|
||||
#define vNL if ( verbose) putc( '\n', stderr)
|
||||
#define vDump( l) if ( verbose) writeLines( stderr, (l))
|
||||
|
||||
|
||||
/* Dynamic Line Management */
|
||||
/* ======================= */
|
||||
/* Lines are stored without trailing \n */
|
||||
|
||||
typedef struct sList{
|
||||
char *text;
|
||||
struct sList *next;
|
||||
} tList, *pList;
|
||||
|
||||
typedef char *tIndex;
|
||||
|
||||
typedef struct{
|
||||
long count;
|
||||
pList list;
|
||||
pList *last;
|
||||
tIndex *index;
|
||||
} tLines, *pLines;
|
||||
|
||||
|
||||
pLines initLines( void) {
|
||||
pLines l;
|
||||
saveMalloc( "initLines", sizeof( tLines), l);
|
||||
l->count = 0L;
|
||||
l->list = NULL;
|
||||
l->last = &( l->list);
|
||||
l->index = NULL;
|
||||
return( l);
|
||||
}
|
||||
|
||||
pLines freeLines( pLines l) {
|
||||
pList p1, p2;
|
||||
|
||||
if ( l == NULL)
|
||||
return( l);
|
||||
p1 = l->list;
|
||||
while ( p1 != NULL) {
|
||||
p2 = p1->next;
|
||||
free( p1->text);
|
||||
free( p1);
|
||||
p1 = p2;
|
||||
}
|
||||
free( l->index);
|
||||
free( l);
|
||||
return( NULL);
|
||||
}
|
||||
|
||||
pLines appendLine( pLines l, char *text) {
|
||||
register pList p;
|
||||
long len;
|
||||
|
||||
if ( l == NULL)
|
||||
return( l);
|
||||
len = strlen( text);
|
||||
if ( text[ len - 1] == '\n') {
|
||||
len --;
|
||||
text[ len] = 0;
|
||||
}
|
||||
saveMalloc( "listStruct", sizeof( tList), p);
|
||||
saveMalloc( "textSpace", len + 1, p->text);
|
||||
p->next = NULL;
|
||||
strcpy( p->text, text);
|
||||
*(l->last) = p;
|
||||
l->last = &( p->next);
|
||||
l->count ++;
|
||||
return( l);
|
||||
}
|
||||
|
||||
pLines makeLinesIndex( pLines l) {
|
||||
long i;
|
||||
pList p;
|
||||
|
||||
if ( l == NULL)
|
||||
return( l);
|
||||
|
||||
free( l->index);
|
||||
saveMalloc( "indexSpace", l->count * sizeof( tIndex), l->index);
|
||||
p = l->list;
|
||||
for ( i = 0; i < l->count; i++) {
|
||||
l->index[ i] = p->text;
|
||||
p = p->next;
|
||||
}
|
||||
return( l);
|
||||
}
|
||||
|
||||
pLines reverseLinesIndex( pLines l) {
|
||||
long i;
|
||||
tIndex tmp;
|
||||
|
||||
if ( l == NULL)
|
||||
return( l);
|
||||
if ( l->index == NULL)
|
||||
FatalError( "reverseLinesIndex: no index found");
|
||||
for ( i = 0; i < ( l->count) >> 1; i++) {
|
||||
tmp = l->index[ i];
|
||||
l->index[ i] = l->index[ l->count - i - 1];
|
||||
l->index[ l->count - i - 1] = tmp;
|
||||
}
|
||||
return( l);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Read and Write Dynamic Lines from and to Files */
|
||||
/* ============================================== */
|
||||
|
||||
#define MaxLineLength 32766
|
||||
char lineBuffer[ MaxLineLength + 1];
|
||||
|
||||
pLines readLines( FILE *inFile, pLines l) {
|
||||
char *line;
|
||||
|
||||
while( 1) {
|
||||
line = fgets( lineBuffer, MaxLineLength, inFile);
|
||||
if ( line == NULL)
|
||||
break;
|
||||
if ( strlen( line) >= MaxLineLength)
|
||||
FatalError( "line length too long (>= 32766)");
|
||||
l = appendLine( l, line);
|
||||
}
|
||||
return( l);
|
||||
}
|
||||
|
||||
pLines writeLines( FILE *outFile, pLines l) {
|
||||
long i;
|
||||
pList p;
|
||||
|
||||
if ( l == NULL)
|
||||
return( l);
|
||||
p = l->list;
|
||||
for ( i = 0; i < l->count; i++) {
|
||||
fputs( p->text, outFile);
|
||||
fputc( '\n', outFile);
|
||||
p = p->next;
|
||||
}
|
||||
return( l);
|
||||
}
|
||||
|
||||
pLines writeLinesByIndex( FILE *outFile, pLines l) {
|
||||
long i;
|
||||
|
||||
if ( l == NULL)
|
||||
return( l);
|
||||
if ( l->index == NULL)
|
||||
FatalError( "writeLinesByIndex: no index found");
|
||||
for ( i = 0; i < l->count; i++) {
|
||||
fputs( l->index[ i], outFile);
|
||||
fputc( '\n', outFile);
|
||||
}
|
||||
return( l);
|
||||
}
|
||||
|
||||
|
||||
/* Sort Index of Dynamic Lines */
|
||||
/* ============================================= */
|
||||
/* comparefunction: strcmp( a, b) */
|
||||
/* evaluate to: -1 for a<b, 0 for a=b, 1 for a>b */
|
||||
/* --------------------------------------------- */
|
||||
|
||||
typedef int (*compareFunction)(const char *, const char *);
|
||||
|
||||
|
||||
/* Privat */
|
||||
/* ------ */
|
||||
long iQ, jQ;
|
||||
int verbose;
|
||||
tIndex *lineIndex;
|
||||
compareFunction compare;
|
||||
char *item, *swapTmp;
|
||||
long item1, item2, item3, midItem, nItems;
|
||||
|
||||
|
||||
void quickSort( long l, long r) {
|
||||
do {
|
||||
assert( l - r <= 0);
|
||||
iQ = l;
|
||||
jQ = r;
|
||||
|
||||
/* randomisierter Quicksort mit dreier Stichprobe */
|
||||
nItems = r - l + 1;
|
||||
if ( nItems - 10L > 0L) {
|
||||
item1 = iQ + ( rand() % nItems);
|
||||
item2 = iQ + ( rand() % nItems);
|
||||
item3 = iQ + ( rand() % nItems);
|
||||
if ( compare( lineIndex[ item1], lineIndex[ item2]) > 0) {
|
||||
if ( compare( lineIndex[ item2], lineIndex[ item3]) > 0)
|
||||
midItem = item2;
|
||||
else {
|
||||
if ( compare( lineIndex[ item1], lineIndex[ item3]) > 0)
|
||||
midItem = item3;
|
||||
else
|
||||
midItem = item1;
|
||||
}
|
||||
} else {
|
||||
if ( compare( lineIndex[ item3], lineIndex[ item2]) > 0)
|
||||
midItem = item2;
|
||||
else {
|
||||
if ( compare( lineIndex[ item1], lineIndex[ item3]) > 0)
|
||||
midItem = item1;
|
||||
else
|
||||
midItem = item3;
|
||||
}
|
||||
}
|
||||
assert( iQ - midItem <= 0);
|
||||
assert( midItem - jQ <= 0);
|
||||
swapTmp = lineIndex[ midItem];
|
||||
lineIndex[ midItem] = lineIndex[ iQ];
|
||||
lineIndex[ iQ] = swapTmp;
|
||||
}
|
||||
item = lineIndex[ iQ];
|
||||
do {
|
||||
while (( compare( lineIndex[jQ], item) > -1) && ( iQ - jQ < 0L)) jQ--;
|
||||
lineIndex[iQ] = lineIndex[jQ];
|
||||
while (( compare( lineIndex[iQ], item) < 1) && ( iQ - jQ < 0L)) iQ++;
|
||||
lineIndex[jQ] = lineIndex[iQ];
|
||||
} while( iQ != jQ);
|
||||
lineIndex[iQ] = item;
|
||||
jQ = l;
|
||||
l = iQ + 1;
|
||||
if ( jQ - iQ + 1 < 0L)
|
||||
quickSort( jQ, iQ-1); /* linke Haelfte sortieren */
|
||||
} while ( l - r < 0L); /* rechte Haelfte durch Endrekursion sortieren */
|
||||
}
|
||||
|
||||
pLines sortLines( pLines l, compareFunction f, int verb) {
|
||||
if ( l == NULL)
|
||||
return( l);
|
||||
if ( l->index == NULL)
|
||||
FatalError( "sortLines: no index found");
|
||||
|
||||
/* init privat global variables */
|
||||
compare = f;
|
||||
verbose = verb;
|
||||
lineIndex = l->index;
|
||||
|
||||
vPrintStr( "sortLines()\n");
|
||||
if ( l->count > 0)
|
||||
quickSort( 0L, l->count - 1);
|
||||
return( l);
|
||||
}
|
||||
|
||||
|
||||
/* Other Comparefunctions */
|
||||
/* ====================== */
|
||||
|
||||
int germanTable[ 256];
|
||||
|
||||
void initGermanTable( void) {
|
||||
germanTable[ 0] = 0;
|
||||
germanTable[ 1] = 10;
|
||||
germanTable[ 2] = 20;
|
||||
germanTable[ 3] = 30;
|
||||
germanTable[ 4] = 40;
|
||||
germanTable[ 5] = 50;
|
||||
germanTable[ 6] = 60;
|
||||
germanTable[ 7] = 70;
|
||||
germanTable[ 8] = 80;
|
||||
germanTable[ 9] = 90;
|
||||
germanTable[ 10] = 100;
|
||||
germanTable[ 11] = 110;
|
||||
germanTable[ 12] = 120;
|
||||
germanTable[ 13] = 130;
|
||||
germanTable[ 14] = 140;
|
||||
germanTable[ 15] = 150;
|
||||
germanTable[ 16] = 160;
|
||||
germanTable[ 17] = 170;
|
||||
germanTable[ 18] = 180;
|
||||
germanTable[ 19] = 190;
|
||||
germanTable[ 20] = 200;
|
||||
germanTable[ 21] = 210;
|
||||
germanTable[ 22] = 220;
|
||||
germanTable[ 23] = 230;
|
||||
germanTable[ 24] = 240;
|
||||
germanTable[ 25] = 250;
|
||||
germanTable[ 26] = 260;
|
||||
germanTable[ 27] = 270;
|
||||
germanTable[ 28] = 280;
|
||||
germanTable[ 29] = 290;
|
||||
germanTable[ 30] = 300;
|
||||
germanTable[ 31] = 310;
|
||||
germanTable[ 32] = 320; /* ' ' */
|
||||
germanTable[ 33] = 330; /* '!' */
|
||||
germanTable[ 34] = 340; /* '"' */
|
||||
germanTable[ 35] = 350; /* '#' */
|
||||
germanTable[ 36] = 360; /* '$' */
|
||||
germanTable[ 37] = 370; /* '%' */
|
||||
germanTable[ 38] = 380; /* '&' */
|
||||
germanTable[ 39] = 390; /* ''' */
|
||||
germanTable[ 40] = 400; /* '(' */
|
||||
germanTable[ 41] = 410; /* ')' */
|
||||
germanTable[ 42] = 420; /* '*' */
|
||||
germanTable[ 43] = 430; /* '+' */
|
||||
germanTable[ 44] = 440; /* ',' */
|
||||
germanTable[ 45] = 450; /* '-' */
|
||||
germanTable[ 46] = 460; /* '.' */
|
||||
germanTable[ 47] = 470; /* '/' */
|
||||
germanTable[ 48] = 480; /* '0' */
|
||||
germanTable[ 49] = 490; /* '1' */
|
||||
germanTable[ 50] = 500; /* '2' */
|
||||
germanTable[ 51] = 510; /* '3' */
|
||||
germanTable[ 52] = 520; /* '4' */
|
||||
germanTable[ 53] = 530; /* '5' */
|
||||
germanTable[ 54] = 540; /* '6' */
|
||||
germanTable[ 55] = 550; /* '7' */
|
||||
germanTable[ 56] = 560; /* '8' */
|
||||
germanTable[ 57] = 570; /* '9' */
|
||||
germanTable[ 58] = 580; /* ':' */
|
||||
germanTable[ 59] = 590; /* ';' */
|
||||
germanTable[ 60] = 600; /* '<' */
|
||||
germanTable[ 61] = 610; /* '=' */
|
||||
germanTable[ 62] = 620; /* '>' */
|
||||
germanTable[ 63] = 630; /* '?' */
|
||||
germanTable[ 64] = 640; /* '@' */
|
||||
germanTable[ 65] = 651; /* 'A' */
|
||||
germanTable[ 66] = 666; /* 'B' */
|
||||
germanTable[ 67] = 671; /* 'C' */
|
||||
germanTable[ 68] = 681; /* 'D' */
|
||||
germanTable[ 69] = 691; /* 'E' */
|
||||
germanTable[ 70] = 701; /* 'F' */
|
||||
germanTable[ 71] = 711; /* 'G' */
|
||||
germanTable[ 72] = 721; /* 'H' */
|
||||
germanTable[ 73] = 731; /* 'I' */
|
||||
germanTable[ 74] = 741; /* 'J' */
|
||||
germanTable[ 75] = 751; /* 'K' */
|
||||
germanTable[ 76] = 761; /* 'L' */
|
||||
germanTable[ 77] = 771; /* 'M' */
|
||||
germanTable[ 78] = 781; /* 'N' */
|
||||
germanTable[ 79] = 791; /* 'O' */
|
||||
germanTable[ 80] = 801; /* 'P' */
|
||||
germanTable[ 81] = 811; /* 'Q' */
|
||||
germanTable[ 82] = 821; /* 'R' */
|
||||
germanTable[ 83] = 831; /* 'S' */
|
||||
germanTable[ 84] = 841; /* 'T' */
|
||||
germanTable[ 85] = 851; /* 'U' */
|
||||
germanTable[ 86] = 861; /* 'V' */
|
||||
germanTable[ 87] = 871; /* 'W' */
|
||||
germanTable[ 88] = 881; /* 'X' */
|
||||
germanTable[ 89] = 891; /* 'Y' */
|
||||
germanTable[ 90] = 901; /* 'Z' */
|
||||
germanTable[ 91] = 910; /* '[' */
|
||||
germanTable[ 92] = 920; /* '\' */
|
||||
germanTable[ 93] = 930; /* ']' */
|
||||
germanTable[ 94] = 940; /* '^' */
|
||||
germanTable[ 95] = 950; /* '_' */
|
||||
germanTable[ 96] = 960; /* '`' */
|
||||
germanTable[ 97] = 650; /* 'a' */
|
||||
germanTable[ 98] = 665; /* 'b' */
|
||||
germanTable[ 99] = 670; /* 'c' */
|
||||
germanTable[100] = 680; /* 'd' */
|
||||
germanTable[101] = 690; /* 'e' */
|
||||
germanTable[102] = 700; /* 'f' */
|
||||
germanTable[103] = 710; /* 'g' */
|
||||
germanTable[104] = 720; /* 'h' */
|
||||
germanTable[105] = 730; /* 'i' */
|
||||
germanTable[106] = 740; /* 'j' */
|
||||
germanTable[107] = 750; /* 'k' */
|
||||
germanTable[108] = 760; /* 'l' */
|
||||
germanTable[109] = 770; /* 'm' */
|
||||
germanTable[110] = 780; /* 'n' */
|
||||
germanTable[111] = 790; /* 'o' */
|
||||
germanTable[112] = 800; /* 'p' */
|
||||
germanTable[113] = 810; /* 'q' */
|
||||
germanTable[114] = 820; /* 'r' */
|
||||
germanTable[115] = 830; /* 's' */
|
||||
germanTable[116] = 840; /* 't' */
|
||||
germanTable[117] = 850; /* 'u' */
|
||||
germanTable[118] = 860; /* 'v' */
|
||||
germanTable[119] = 870; /* 'w' */
|
||||
germanTable[120] = 880; /* 'x' */
|
||||
germanTable[121] = 890; /* 'y' */
|
||||
germanTable[122] = 900; /* 'z' */
|
||||
germanTable[123] = 1230; /* '{' */
|
||||
germanTable[124] = 1240; /* '|' */
|
||||
germanTable[125] = 1250; /* '}' */
|
||||
germanTable[126] = 1260; /* '~' */
|
||||
germanTable[127] = 1270; /* '' */
|
||||
germanTable[128] = 673; /* '€' */
|
||||
germanTable[129] = 852; /* '<27>' */
|
||||
germanTable[130] = 691; /* '‚' */
|
||||
germanTable[131] = 654; /* 'ƒ' */
|
||||
germanTable[132] = 652; /* '„' */
|
||||
germanTable[133] = 655; /* '…' */
|
||||
germanTable[134] = 656; /* '†' */
|
||||
germanTable[135] = 672; /* '‡' */
|
||||
germanTable[136] = 692; /* 'ˆ' */
|
||||
germanTable[137] = 693; /* '‰' */
|
||||
germanTable[138] = 694; /* 'Š' */
|
||||
germanTable[139] = 732; /* '‹' */
|
||||
germanTable[140] = 733; /* 'Œ' */
|
||||
germanTable[141] = 734; /* '<27>' */
|
||||
germanTable[142] = 653; /* 'Ž' */
|
||||
germanTable[143] = 657; /* '<27>' */
|
||||
germanTable[144] = 695; /* '<27>' */
|
||||
germanTable[145] = 660; /* '‘' */
|
||||
germanTable[146] = 658; /* '’' */
|
||||
germanTable[147] = 794; /* '“' */
|
||||
germanTable[148] = 792; /* '”' */
|
||||
germanTable[149] = 795; /* '•' */
|
||||
germanTable[150] = 854; /* '–' */
|
||||
germanTable[151] = 855; /* '—' */
|
||||
germanTable[152] = 892; /* '˜' */
|
||||
germanTable[153] = 793; /* '™' */
|
||||
germanTable[154] = 853; /* 'š' */
|
||||
germanTable[155] = 1550; /* '›' */
|
||||
germanTable[156] = 1560; /* 'œ' */
|
||||
germanTable[157] = 1570; /* '<27>' */
|
||||
germanTable[158] = 1580; /* 'ž' */
|
||||
germanTable[159] = 1590; /* 'Ÿ' */
|
||||
germanTable[160] = 659; /* ' ' */
|
||||
germanTable[161] = 735; /* '¡' */
|
||||
germanTable[162] = 796; /* '¢' */
|
||||
germanTable[163] = 856; /* '£' */
|
||||
germanTable[164] = 782; /* '¤' */
|
||||
germanTable[165] = 783; /* '¥' */
|
||||
germanTable[166] = 1660; /* '¦' */
|
||||
germanTable[167] = 1670; /* '§' */
|
||||
germanTable[168] = 1680; /* '¨' */
|
||||
germanTable[169] = 1690; /* '©' */
|
||||
germanTable[170] = 1700; /* 'ª' */
|
||||
germanTable[171] = 1710; /* '«' */
|
||||
germanTable[172] = 1720; /* '¬' */
|
||||
germanTable[173] = 1730; /* '' */
|
||||
germanTable[174] = 1740; /* '®' */
|
||||
germanTable[175] = 1750; /* '¯' */
|
||||
germanTable[176] = 1760; /* '°' */
|
||||
germanTable[177] = 1770; /* '±' */
|
||||
germanTable[178] = 1780; /* '²' */
|
||||
germanTable[179] = 1790; /* '³' */
|
||||
germanTable[180] = 1800; /* '´' */
|
||||
germanTable[181] = 1810; /* 'µ' */
|
||||
germanTable[182] = 1820; /* '¶' */
|
||||
germanTable[183] = 1830; /* '·' */
|
||||
germanTable[184] = 1840; /* '¸' */
|
||||
germanTable[185] = 1850; /* '¹' */
|
||||
germanTable[186] = 1860; /* 'º' */
|
||||
germanTable[187] = 1870; /* '»' */
|
||||
germanTable[188] = 1880; /* '¼' */
|
||||
germanTable[189] = 1890; /* '½' */
|
||||
germanTable[190] = 1900; /* '¾' */
|
||||
germanTable[191] = 1910; /* '¿' */
|
||||
germanTable[192] = 1920; /* 'À' */
|
||||
germanTable[193] = 1930; /* 'Á' */
|
||||
germanTable[194] = 1940; /* 'Â' */
|
||||
germanTable[195] = 1950; /* 'Ã' */
|
||||
germanTable[196] = 1960; /* 'Ä' */
|
||||
germanTable[197] = 1970; /* 'Å' */
|
||||
germanTable[198] = 1980; /* 'Æ' */
|
||||
germanTable[199] = 1990; /* 'Ç' */
|
||||
germanTable[200] = 2000; /* 'È' */
|
||||
germanTable[201] = 2010; /* 'É' */
|
||||
germanTable[202] = 2020; /* 'Ê' */
|
||||
germanTable[203] = 2030; /* 'Ë' */
|
||||
germanTable[204] = 2040; /* 'Ì' */
|
||||
germanTable[205] = 2050; /* 'Í' */
|
||||
germanTable[206] = 2060; /* 'Î' */
|
||||
germanTable[207] = 2070; /* 'Ï' */
|
||||
germanTable[208] = 2080; /* 'Ð' */
|
||||
germanTable[209] = 2090; /* 'Ñ' */
|
||||
germanTable[210] = 2100; /* 'Ò' */
|
||||
germanTable[211] = 2110; /* 'Ó' */
|
||||
germanTable[212] = 2120; /* 'Ô' */
|
||||
germanTable[213] = 2130; /* 'Õ' */
|
||||
germanTable[214] = 2140; /* 'Ö' */
|
||||
germanTable[215] = 2150; /* '×' */
|
||||
germanTable[216] = 2160; /* 'Ø' */
|
||||
germanTable[217] = 2170; /* 'Ù' */
|
||||
germanTable[218] = 2180; /* 'Ú' */
|
||||
germanTable[219] = 2190; /* 'Û' */
|
||||
germanTable[220] = 2200; /* 'Ü' */
|
||||
germanTable[221] = 2210; /* 'Ý' */
|
||||
germanTable[222] = 2220; /* 'Þ' */
|
||||
germanTable[223] = 2230; /* 'ß' */
|
||||
germanTable[224] = 2240; /* 'à' */
|
||||
germanTable[225] = 832; /* 'á' */
|
||||
germanTable[226] = 2260; /* 'â' */
|
||||
germanTable[227] = 2270; /* 'ã' */
|
||||
germanTable[228] = 2280; /* 'ä' */
|
||||
germanTable[229] = 2290; /* 'å' */
|
||||
germanTable[230] = 2300; /* 'æ' */
|
||||
germanTable[231] = 2310; /* 'ç' */
|
||||
germanTable[232] = 2320; /* 'è' */
|
||||
germanTable[233] = 2330; /* 'é' */
|
||||
germanTable[234] = 2340; /* 'ê' */
|
||||
germanTable[235] = 2350; /* 'ë' */
|
||||
germanTable[236] = 2360; /* 'ì' */
|
||||
germanTable[237] = 2370; /* 'í' */
|
||||
germanTable[238] = 2380; /* 'î' */
|
||||
germanTable[239] = 2390; /* 'ï' */
|
||||
germanTable[240] = 2400; /* 'ð' */
|
||||
germanTable[241] = 2410; /* 'ñ' */
|
||||
germanTable[242] = 2420; /* 'ò' */
|
||||
germanTable[243] = 2430; /* 'ó' */
|
||||
germanTable[244] = 2440; /* 'ô' */
|
||||
germanTable[245] = 2450; /* 'õ' */
|
||||
germanTable[246] = 2460; /* 'ö' */
|
||||
germanTable[247] = 2470; /* '÷' */
|
||||
germanTable[248] = 2480; /* 'ø' */
|
||||
germanTable[249] = 2490; /* 'ù' */
|
||||
germanTable[250] = 2500; /* 'ú' */
|
||||
germanTable[251] = 2510; /* 'û' */
|
||||
germanTable[252] = 2520; /* 'ü' */
|
||||
germanTable[253] = 2530; /* 'ý' */
|
||||
germanTable[254] = 2540; /* 'þ' */
|
||||
germanTable[255] = 2550; /* 'ÿ' */
|
||||
}
|
||||
|
||||
int germanCompare( const char *s, const char *t) {
|
||||
while( germanTable[ (int)(*s)] == germanTable[ (int)(*t)]) {
|
||||
if ( *s == 0) {
|
||||
if ( *t == 0)
|
||||
return( 0);
|
||||
else
|
||||
return( -1);
|
||||
} else if ( *t == 0)
|
||||
return( 1);
|
||||
s++;
|
||||
t++;
|
||||
}
|
||||
if ( germanTable[ (int)(*s)] < germanTable[ (int)(*t)])
|
||||
return( -1);
|
||||
return( 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* main */
|
||||
/* ==== */
|
||||
|
||||
#define MaxParameters 2
|
||||
#define MaxOptionalParameters 2
|
||||
#define ErrParameters 10000
|
||||
|
||||
typedef char tSwitch;
|
||||
|
||||
#define NoSwitch 0
|
||||
#define MinusSwitch 1
|
||||
#define PlusSwitch 2
|
||||
|
||||
tSwitch reverseSwitch = NoSwitch;
|
||||
tSwitch germanSwitch = NoSwitch;
|
||||
tSwitch verboseSwitch = NoSwitch;
|
||||
|
||||
|
||||
/* this macro opens a block, in which the switch is detected */
|
||||
/* it must be closed with the macro endDetect() */
|
||||
#define detectSwitch( var, text) \
|
||||
if ( (( argv[i][0] == '/' ) || ( argv[i][0] == '-' ) || \
|
||||
( argv[i][0] == '+' )) && ( strcmp( text, argv[i]+1) == 0)) { \
|
||||
if ( argv[i][0] == '+' ) \
|
||||
var = PlusSwitch; \
|
||||
else \
|
||||
var = MinusSwitch;
|
||||
|
||||
#define endDetect() \
|
||||
if ( nParameters <= MaxParameters ) \
|
||||
continue; \
|
||||
else \
|
||||
break; \
|
||||
}
|
||||
|
||||
|
||||
/* >main: main function with standard unix parameter input */
|
||||
|
||||
int main( int argc, char **argv) {
|
||||
int i;
|
||||
int err = 0;
|
||||
int nParameters = 0;
|
||||
char *parameters[ MaxParameters + 1];
|
||||
|
||||
tSwitch helpSwitch = NoSwitch;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
|
||||
/* check switches */
|
||||
detectSwitch( reverseSwitch, "r");
|
||||
endDetect();
|
||||
detectSwitch( germanSwitch, "ger");
|
||||
endDetect();
|
||||
detectSwitch( verboseSwitch, "v");
|
||||
endDetect();
|
||||
|
||||
|
||||
detectSwitch( helpSwitch, "h");
|
||||
endDetect();
|
||||
detectSwitch( helpSwitch, "H");
|
||||
endDetect();
|
||||
detectSwitch( helpSwitch, "help");
|
||||
endDetect();
|
||||
|
||||
/* else get standard or optional paramters */
|
||||
if ( nParameters < MaxParameters ) {
|
||||
parameters[nParameters ++] = argv[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
nParameters = ErrParameters;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((nParameters < MaxParameters - MaxOptionalParameters) ||
|
||||
(nParameters > MaxParameters) || (helpSwitch != NoSwitch)) {
|
||||
if (helpSwitch == NoSwitch)
|
||||
fputs( "Error: in parameter list\n", stderr);
|
||||
fputs( "cc_index_sort $Revision$ (c) Lutz Kettner\n", stderr);
|
||||
fputs( "Usage: cc_index_sort [-r] [-ger] [-v] [<infile> [<outfile>]]\n", stderr);
|
||||
fputs( " -r reverse order\n", stderr);
|
||||
fputs( " -ger german character ordering\n", stderr);
|
||||
fputs( " -v verbose, print internals\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
{
|
||||
FILE *in,
|
||||
*out;
|
||||
pLines lines;
|
||||
|
||||
in = stdin;
|
||||
out = stdout;
|
||||
lines = initLines();
|
||||
initGermanTable();
|
||||
|
||||
if ( nParameters >= 1)
|
||||
if ( (in = fopen( parameters[0], "r")) == NULL) {
|
||||
fprintf( stderr, "\ncc_index_sort: error: cannot open infile %s.\n",
|
||||
parameters[0]);
|
||||
exit(1);
|
||||
}
|
||||
lines = readLines( in, lines);
|
||||
if ( nParameters >= 1)
|
||||
fclose( in);
|
||||
|
||||
lines = makeLinesIndex( lines);
|
||||
if ( germanSwitch)
|
||||
lines = sortLines( lines, germanCompare, verboseSwitch);
|
||||
else
|
||||
lines = sortLines( lines, strcmp, verboseSwitch);
|
||||
if ( reverseSwitch)
|
||||
lines = reverseLinesIndex( lines);
|
||||
|
||||
if ( nParameters == 2)
|
||||
if ( (out = fopen( parameters[1], "w")) == NULL) {
|
||||
fprintf( stderr, "cc_index_sort: error: cannot open outfile %s.\n",
|
||||
parameters[1]);
|
||||
exit(1);
|
||||
}
|
||||
lines = freeLines( writeLinesByIndex( out, lines));
|
||||
if ( nParameters == 2)
|
||||
fclose( out);
|
||||
}
|
||||
return(err);
|
||||
}
|
||||
|
|
@ -0,0 +1,284 @@
|
|||
#!/bin/csh -f
|
||||
# **************************************************************************
|
||||
#
|
||||
# cc_manual_to_html
|
||||
# ===================
|
||||
# A script to convert a specification written in a TeX file with the
|
||||
# cc_manual.sty into an online manual in HTML.
|
||||
#
|
||||
# It is a two step procedure: First all TeX files are converted into
|
||||
# HTML. Meanwhile the necessary information for the cross links is
|
||||
# collected as set of flex-rules. In the second step are the hyperlinks
|
||||
# generated for all HTML files.
|
||||
#
|
||||
# The following programs are necessary to run this script
|
||||
#
|
||||
# o cc_extract_html
|
||||
# o flex
|
||||
# o cc / gcc
|
||||
# o cc_index_sort
|
||||
#
|
||||
# Author : (c) 1997 Lutz Kettner
|
||||
# Revision : $Revision$
|
||||
# Date : $Date$
|
||||
#
|
||||
# **************************************************************************
|
||||
|
||||
# =======================================================
|
||||
# Installation: chose the appropriate compiler and paths:
|
||||
# =======================================================
|
||||
# A C compiler can be specified here. Normally cc or gcc should work.
|
||||
# Note: cc does not work on SunOS 4.1.3 (BSD), but on SunOS 5...
|
||||
#set CC = gcc
|
||||
set CC = cc
|
||||
|
||||
# Path for the HTML conversion tools for the default configuration files.
|
||||
# This path will be compiled into the cc_extract_html program.
|
||||
# The same variable has to be configured here. (No slash / at the end!)
|
||||
#set HTML_DEFAULT_PATH =
|
||||
set HTML_DEFAULT_PATH = /home/kettner/topics/cgal/Tools/src/html_config_files
|
||||
|
||||
# A couple of default settings that the cc_extract_html program does not know.
|
||||
set DEFAULT_DATE = `date +"%a, %B %e, %Y"`
|
||||
set DEFAULT_AUTHOR = "The <A HREF="http://www.cs.ruu.nl/CGAL/"><TT>CGAL</TT> Project</A>"
|
||||
set DEFAULT_TITLE = "The CGAL Kernel Manual"
|
||||
|
||||
# =======================================================
|
||||
# Installation: Nothing else below this line.
|
||||
# =======================================================
|
||||
|
||||
if ( $?DEBUG) echo "# DEBUG defined; all commands will be echoed."
|
||||
|
||||
# Prepare local variables
|
||||
# -----------------------
|
||||
set tmp_path = "/usr/tmp"
|
||||
if ( ! -d ${tmp_path}) set = tmp_path = "."
|
||||
if ($?TEMP) then
|
||||
if (-d ${TEMP}) set tmp_path = $TEMP
|
||||
endif
|
||||
if ($?TMP) then
|
||||
if (-d ${TMP}) set tmp_path = $TMP
|
||||
endif
|
||||
|
||||
set out_path = "."
|
||||
set config_path = ${HTML_DEFAULT_PATH}
|
||||
|
||||
set DEFAULT_RELEASE =
|
||||
|
||||
set default_switch = 0
|
||||
set show_main_switch = 0
|
||||
|
||||
# Parse command line parameters
|
||||
# -----------------------------
|
||||
|
||||
if ( $?DEBUG) echo "# command line parsing."
|
||||
|
||||
if ( $#argv < 1) goto usage
|
||||
set in_files = ""
|
||||
|
||||
while ($#argv > 0)
|
||||
if ( "$1" == "-h") goto usage
|
||||
if ( "$1" == "-help") goto usage
|
||||
|
||||
if ( "$1" == "-defaults") then
|
||||
set default_switch = 1
|
||||
break
|
||||
endif
|
||||
|
||||
if ( "$1" == "-show_main") then
|
||||
set show_main_switch = 1;
|
||||
shift
|
||||
continue
|
||||
endif
|
||||
if ( "$1" == "-config") then
|
||||
shift
|
||||
if ( $#argv < 1) then
|
||||
echo "error: switch -config needs an additional parameter."
|
||||
goto usage
|
||||
endif
|
||||
if ( ! -d $1) then
|
||||
echo "error: switch -config needs a valid directory as parameter."
|
||||
goto usage
|
||||
endif
|
||||
set config_path = "$1"
|
||||
shift
|
||||
continue
|
||||
endif
|
||||
if ( "$1" == "-tmp") then
|
||||
shift
|
||||
if ( $#argv < 1) then
|
||||
echo "error: switch -tmp needs an additional parameter."
|
||||
goto usage
|
||||
endif
|
||||
if ( ! -d $1) then
|
||||
echo "error: switch -tmp needs a valid directory as parameter."
|
||||
goto usage
|
||||
endif
|
||||
set tmp_path = "$1"
|
||||
shift
|
||||
continue
|
||||
endif
|
||||
if ( "$1" == "-o") then
|
||||
shift
|
||||
if ( $#argv < 1) then
|
||||
echo "error: switch -o needs an additional parameter."
|
||||
goto usage
|
||||
endif
|
||||
if ( ! -d $1) then
|
||||
echo "error: switch -o needs a valid directory as parameter."
|
||||
goto usage
|
||||
endif
|
||||
set out_path = "$1"
|
||||
shift
|
||||
continue
|
||||
endif
|
||||
if ( "$1" == "-date") then
|
||||
shift
|
||||
if ( $#argv < 1) then
|
||||
echo "error: switch -date needs an additional parameter."
|
||||
goto usage
|
||||
endif
|
||||
set DEFAULT_DATE = "$1"
|
||||
shift
|
||||
continue
|
||||
endif
|
||||
if ( "$1" == "-release") then
|
||||
shift
|
||||
if ( $#argv < 1) then
|
||||
echo "error: switch -release needs an additional parameter."
|
||||
goto usage
|
||||
endif
|
||||
set DEFAULT_RELEASE = "$1"
|
||||
shift
|
||||
continue
|
||||
endif
|
||||
if ( "$1" == "-title") then
|
||||
shift
|
||||
if ( $#argv < 1) then
|
||||
echo "error: switch -title needs an additional parameter."
|
||||
goto usage
|
||||
endif
|
||||
set DEFAULT_TITLE = "$1"
|
||||
shift
|
||||
continue
|
||||
endif
|
||||
if ( "$1" == "-author") then
|
||||
shift
|
||||
if ( $#argv < 1) then
|
||||
echo "error: switch -author needs an additional parameter."
|
||||
goto usage
|
||||
endif
|
||||
set DEFAULT_AUTHOR = "$1"
|
||||
shift
|
||||
continue
|
||||
endif
|
||||
|
||||
set in_files = "$in_files $1"
|
||||
shift
|
||||
end
|
||||
|
||||
if ( $?DEBUG || $default_switch == 1) then
|
||||
echo "The variable settings (including commmandline options) are:"
|
||||
echo " HTML_DEFAULT_PATH = ${HTML_DEFAULT_PATH}"
|
||||
echo " DEFAULT_DATE = ${DEFAULT_DATE}"
|
||||
echo " DEFAULT_AUTHOR = ${DEFAULT_AUTHOR}"
|
||||
echo " DEFAULT_TITLE = ${DEFAULT_TITLE}"
|
||||
echo " DEFAULT_RELEASE = ${DEFAULT_RELEASE}"
|
||||
echo " tmp_path = ${tmp_path}"
|
||||
echo " out_path = ${out_path}"
|
||||
echo " config_path = ${config_path}"
|
||||
echo " input_files = ${in_files}"
|
||||
echo ""
|
||||
endif
|
||||
if ( $default_switch) goto end_of_script
|
||||
|
||||
if ( "$in_files" == "") goto usage
|
||||
|
||||
# Make a subdirectory for the temp_path:
|
||||
# --------------------------------------
|
||||
set tmp_name = "extract_html_tmp"
|
||||
if ( $?DEBUG) echo "# Make a subdirectory 'extract_html_tmp' for the tmp_path."
|
||||
|
||||
set new_tmp_path = ${tmp_path}/${tmp_name}
|
||||
if ( -d ${new_tmp_path}) then
|
||||
echo "error: the subdirectory 'extract_html_tmp' for the tmp_path exists already."
|
||||
echo " type 'rm -r ${new_tmp_path}' to remove it."
|
||||
goto usage
|
||||
endif
|
||||
mkdir ${new_tmp_path}
|
||||
|
||||
|
||||
# Step 1: convert each LaTeX file into an HTML file.
|
||||
# --------------------------------------------------
|
||||
if ( $?DEBUG) echo "# Step 1: convert each LaTeX file into an HTML file."
|
||||
if ($show_main_switch) then
|
||||
if ( $?DEBUG) echo "cc_extract_html -date "'"'"${DEFAULT_DATE}"'"'" -release "'"'"${DEFAULT_RELEASE}"'"'" -title "'"'"${DEFAULT_TITLE}"'"'" -author "'"'"${DEFAULT_AUTHOR}"'"'" -config ${config_path}/ -tmp ${new_tmp_path}/ ${in_files}"
|
||||
cc_extract_html -date "${DEFAULT_DATE}" -release "${DEFAULT_RELEASE}" -title "${DEFAULT_TITLE}" -author "${DEFAULT_AUTHOR}" -config ${config_path}/ -tmp ${new_tmp_path}/ ${in_files}
|
||||
else
|
||||
if ( $?DEBUG) echo "cc_extract_html -date "'"'"${DEFAULT_DATE}"'"'" -release "'"'"${DEFAULT_RELEASE}"'"'" -title "'"'"${DEFAULT_TITLE}"'"'" -author "'"'"${DEFAULT_AUTHOR}"'"'" -config ${config_path}/ -tmp ${new_tmp_path}/ ${in_files} >/dev/null"
|
||||
cc_extract_html -date "${DEFAULT_DATE}" -release "${DEFAULT_RELEASE}" -title "${DEFAULT_TITLE}" -author "${DEFAULT_AUTHOR}" -config ${config_path}/ -tmp ${new_tmp_path}/ ${in_files} >/dev/null
|
||||
endif
|
||||
|
||||
# Step 2: generate the hyperlinks. The anchor filter.
|
||||
# ---------------------------------------------------
|
||||
if ( $?DEBUG) echo "# Step 2: generate the hyperlinks. The anchor filter"
|
||||
|
||||
if ( $?DEBUG) echo "cat ${config_path}/cc_anchor_header ${new_tmp_path}/cc_anchor_rules ${config_path}/cc_anchor_footer > ${new_tmp_path}/cc_anchor_filter.yy"
|
||||
cat ${config_path}/cc_anchor_header ${new_tmp_path}/cc_anchor_rules ${config_path}/cc_anchor_footer > ${new_tmp_path}/cc_anchor_filter.yy
|
||||
|
||||
if ( $?DEBUG) echo "flex -t -8 ${new_tmp_path}/cc_anchor_filter.yy > ${new_tmp_path}/cc_anchor_filter.c"
|
||||
flex -t -8 ${new_tmp_path}/cc_anchor_filter.yy > ${new_tmp_path}/cc_anchor_filter.c
|
||||
|
||||
if ( $?DEBUG) echo "cc -o ${new_tmp_path}/cc_anchor_filter ${new_tmp_path}/cc_anchor_filter.c"
|
||||
cc -o ${new_tmp_path}/cc_anchor_filter ${new_tmp_path}/cc_anchor_filter.c
|
||||
if (-r cc_anchor_filter.o) rm cc_anchor_filter.o
|
||||
|
||||
# Filtering all HTML files.
|
||||
# -------------------------
|
||||
if ( $?DEBUG) echo "# Filtering all HTML files."
|
||||
foreach f (${new_tmp_path}/*.html)
|
||||
if ( $?DEBUG) echo "${new_tmp_path}/cc_anchor_filter < $f > ${out_path}/$f:t"
|
||||
${new_tmp_path}/cc_anchor_filter < $f > ${out_path}/$f:t
|
||||
end
|
||||
|
||||
# Converting the index.
|
||||
# ---------------------
|
||||
if ( $?DEBUG) echo "# Converting the index."
|
||||
|
||||
if ( $?DEBUG) echo "cc_index_sort -ger ${new_tmp_path}/cc_index_body | sed 's/[<][\!]sort[^\!]*[\!][>]//' > ${new_tmp_path}/cc_index_sorted"
|
||||
cc_index_sort -ger ${new_tmp_path}/cc_index_body | sed 's/[<][\!]sort[^\!]*[\!][>]//' > ${new_tmp_path}/cc_index_sorted
|
||||
|
||||
if ( $?DEBUG) echo "cat ${new_tmp_path}/cc_index_header ${new_tmp_path}/cc_index_sorted ${new_tmp_path}/cc_index_footer > ${new_tmp_path}/cc_index"
|
||||
cat ${new_tmp_path}/cc_index_header ${new_tmp_path}/cc_index_sorted ${new_tmp_path}/cc_index_footer > ${new_tmp_path}/cc_index
|
||||
|
||||
if ( $?DEBUG) echo "${new_tmp_path}/cc_anchor_filter < ${new_tmp_path}/cc_index > ${out_path}/manual_index.html"
|
||||
${new_tmp_path}/cc_anchor_filter < ${new_tmp_path}/cc_index > ${out_path}/manual_index.html
|
||||
|
||||
|
||||
# Cleanup
|
||||
# -------
|
||||
if ( $?DEBUG) echo "# Cleanup and all done"
|
||||
if ( $?DEBUG) then
|
||||
echo "# rm -r ${new_tmp_path}"
|
||||
else
|
||||
rm -r ${new_tmp_path}
|
||||
endif
|
||||
|
||||
end_of_script:
|
||||
exit
|
||||
|
||||
usage:
|
||||
echo "$0 "'$Revision$'" (c) Lutz Kettner"
|
||||
echo "Usage: $0 [<options>] <tex-files...>"
|
||||
echo " -defaults show the settings of the internal variables."
|
||||
echo " -show_main show the translation result for the main file."
|
||||
echo " -date <text> set a date for the manual."
|
||||
echo " -release <text> set a release number for the manual."
|
||||
echo " -title <text> set a title text for the manual."
|
||||
echo " -author <text> set an author address (email) for the manual."
|
||||
echo " -config <dir> set the path where to find the config files."
|
||||
echo " -tmp <dir> set the path where to put the output files."
|
||||
echo " "
|
||||
echo " -o <dir> output directory for the generated HTML manual"
|
||||
exit (1)
|
||||
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/**************************************************************************
|
||||
|
||||
config.h
|
||||
=============================================================
|
||||
Project : CGAL merger tool for the specification task
|
||||
Function : Configuration constants and variables
|
||||
System : C++ (g++)
|
||||
Author : (c) 1995 Lutz Kettner
|
||||
Revision : $Revision$
|
||||
Date : $Date$
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
#if ! defined( MODULE_CONFIG)
|
||||
#define MODULE_CONFIG 1
|
||||
|
||||
|
||||
// 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 handleClass( const char* classname);
|
||||
void handleClassEnd( void);
|
||||
void handleClassTemplate( const char* classname);
|
||||
void handleClassTemplateEnd( void);
|
||||
|
||||
void handleDeclaration( const char* decl);
|
||||
void handleNestedType( const char* decl);
|
||||
void handleMethodDeclaration( const char* decl);
|
||||
void handleConstructorDeclaration( const char* decl);
|
||||
void handleFunctionDeclaration( const char* decl);
|
||||
void handleFunctionTemplateDeclaration( const char* templ, const char* decl);
|
||||
|
||||
// Error messages and Numbers
|
||||
// ==========================
|
||||
enum ErrorNumber {
|
||||
NoError,
|
||||
ParseError, // must stay at position 1
|
||||
VariableUsedError,
|
||||
ClassnameUsedError,
|
||||
TemplateParamExpectedError,
|
||||
MalformedTemplateParamError,
|
||||
MalformedFunctionDeclaration,
|
||||
SemicolonMissingError
|
||||
};
|
||||
|
||||
|
||||
// Functions belonging to the Error messages
|
||||
// -----------------------------------------
|
||||
// See their implementations in syntax.y
|
||||
|
||||
const char* errorMessage( ErrorNumber n);
|
||||
void printErrorMessage( ErrorNumber n);
|
||||
|
||||
#endif // MODULE_CONFIG //
|
||||
|
|
@ -0,0 +1,611 @@
|
|||
/**************************************************************************
|
||||
|
||||
extract_lex.yy
|
||||
=============================================================
|
||||
Project : CGAL merger tool for the specification task
|
||||
Function : lexical scanner for TeX and C++ code mixed files.
|
||||
System : flex, bison, C++ (g++)
|
||||
Author : (c) 1995 Lutz Kettner
|
||||
Revision : $Revision$
|
||||
Date : $Date$
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
%{
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <database.h>
|
||||
#include <config.h>
|
||||
#include <extract_syntax.tab.h>
|
||||
|
||||
/* Set this flag to 1 to switch immediately to CCMode. */
|
||||
int set_CCMode = 0;
|
||||
/* Set this flag to 1 to switch immediately to NestingMode. */
|
||||
int set_NestingMode = 0;
|
||||
/* Set this flag to 1 to switch back to INITIAL. */
|
||||
int set_INITIAL = 0;
|
||||
|
||||
/* Tag to mark the unchecked keyword */
|
||||
int unchecked_tag = 0;
|
||||
|
||||
/* Count the linenumber for better errormessages. */
|
||||
int line_number = 1;
|
||||
|
||||
/* store the creationvariable */
|
||||
char* creationvariable = NULL;
|
||||
|
||||
/* remember the necessary stop character for \verb"..." */
|
||||
char stop_character;
|
||||
|
||||
/* The classname and other state varaibles */
|
||||
char* global_classname = 0;
|
||||
char* global_template_params = 0;
|
||||
|
||||
/* Hack, to get rid of the yywrap. */
|
||||
#define YY_SKIP_YYWRAP 1
|
||||
#define yywrap() 1
|
||||
|
||||
%}
|
||||
|
||||
/* The normal scanning mode parses TeX conventions. */
|
||||
/* In CCMode, it parses C++ conventions. */
|
||||
/* The NestingMode parses only (){}[] nested expressions */
|
||||
/* The VerbMode parses LaTeX \verb"..." statements as */
|
||||
/* a sequence of characters */
|
||||
%x CCMode
|
||||
%x NestingMode
|
||||
%x VerbMode
|
||||
|
||||
letter [a-zA-Z]
|
||||
digit [0-9]
|
||||
CCletter [a-zA-Z_]
|
||||
idfier {letter}+
|
||||
CCidfier ({CCletter}({CCletter}|{digit})*)
|
||||
space [\t ]
|
||||
w {space}*
|
||||
ws {space}+
|
||||
escchar [\\]
|
||||
sign [+-]
|
||||
exp [eE]
|
||||
number {digit}+
|
||||
signNumber ({sign}?{number})
|
||||
floatNumber ({signNumber}\.|{signNumber}\.{number})
|
||||
expNumber ({floatNumber}|{signNumber}){exp}{signNumber}
|
||||
No ({signNumber}|{floatNumber}|{expNumber})
|
||||
operator [^a-zA-Z_0-9\n\r\t \\]
|
||||
blockintro [\{][\\]((tt)|(em)|(it)|(sc)|(sl))
|
||||
|
||||
%%
|
||||
/* Mode switching can be triggered from the parser */
|
||||
/* ----------------------------------------------- */
|
||||
if (set_CCMode) {
|
||||
BEGIN( CCMode);
|
||||
set_CCMode = 0;
|
||||
}
|
||||
if (set_NestingMode) {
|
||||
BEGIN( NestingMode);
|
||||
set_NestingMode = 0;
|
||||
}
|
||||
if (set_INITIAL) {
|
||||
BEGIN( INITIAL);
|
||||
set_INITIAL = 0;
|
||||
}
|
||||
|
||||
/* Count line numbers in all modes for better error messages */
|
||||
/* --------------------------------------------------------- */
|
||||
<INITIAL,CCMode,NestingMode>[\n] {
|
||||
line_number++;
|
||||
return NEWLINE;
|
||||
}
|
||||
|
||||
/* Rules for TeX conventions */
|
||||
/* ------------------------- */
|
||||
[\\]"%" { /* Avoid the quoted comment symbol */
|
||||
yylval.character = '%';
|
||||
return CHAR;
|
||||
}
|
||||
"%".*[\n]{w} { /* Match one line TeX comments */
|
||||
/* remove spaces in next line */
|
||||
unput( '\n');
|
||||
}
|
||||
"%".* { /* Match one line TeX comments at the last line in file */
|
||||
}
|
||||
[\\]verb[^a-zA-Z] { /* match LaTeX \verb"..." constructs */
|
||||
BEGIN( VerbMode);
|
||||
stop_character = yytext[ yyleng-1];
|
||||
yylval.string.text = " ";
|
||||
yylval.string.len = 0;
|
||||
return SPACE;
|
||||
}
|
||||
<VerbMode>{ws} {
|
||||
yylval.string.text = yytext;
|
||||
yylval.string.len = yyleng;
|
||||
return SPACE;
|
||||
}
|
||||
<VerbMode>. {
|
||||
if ( yytext[0] == stop_character) {
|
||||
BEGIN( INITIAL);
|
||||
yylval.string.text = " ";
|
||||
yylval.string.len = 0;
|
||||
return SPACE;
|
||||
}
|
||||
yylval.character = yytext[0];
|
||||
return CHAR;
|
||||
}
|
||||
|
||||
/* Trigger on different keywords */
|
||||
/* ----------------------------- */
|
||||
[\\]begin{w}[\{]ccClass[\}]{w} {
|
||||
BEGIN( CCMode);
|
||||
return BEGINCLASS;
|
||||
}
|
||||
[\\]end{w}[\{]ccClass[\}] {
|
||||
return ENDCLASS;
|
||||
}
|
||||
[\\]begin{w}[\{]ccClassTemplate[\}]{w} {
|
||||
BEGIN( CCMode);
|
||||
return BEGINCLASSTEMPLATE;
|
||||
}
|
||||
[\\]end{w}[\{]ccClassTemplate[\}] {
|
||||
return ENDCLASSTEMPLATE;
|
||||
}
|
||||
[\\]ccCreationVariable{w}[\{]{w}.*{w}[\}] {
|
||||
char *s = yytext + yyleng - 2;
|
||||
while (( *s == ' ') || ( *s == '\t'))
|
||||
s--;
|
||||
char *r = yytext;
|
||||
while ( *r != '{')
|
||||
r++;
|
||||
r++;
|
||||
while (( *r == ' ') || ( *r == '\t'))
|
||||
r++;
|
||||
r[-1] = '`';
|
||||
s[1] = '\'';
|
||||
s[2] = 0;
|
||||
free( creationvariable);
|
||||
creationvariable = strdup( r - 1);
|
||||
s[1] = 0;
|
||||
yylval.string.text = r;
|
||||
yylval.string.len = s - r + 1;
|
||||
return CREATIONVARIABLE;
|
||||
}
|
||||
[\\]ccConstructor{w} { /* constructor declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return CONSTRUCTOR;
|
||||
}
|
||||
[\\]ccMemberFunction{w} { /* method declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return METHOD;
|
||||
}
|
||||
[\\]ccMethod{w} { /* method declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return METHOD;
|
||||
}
|
||||
[\\]ccFunction{w} { /* function declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return FUNCTION;
|
||||
}
|
||||
[\\]ccFunctionTemplate{w} { /* function template declaration:
|
||||
change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return FUNCTIONTEMPLATE;
|
||||
}
|
||||
[\\]ccVariable{w} { /* variable declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return VARIABLE;
|
||||
}
|
||||
[\\]ccTypedef{w} { /* typedef declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return TYPEDEF;
|
||||
}
|
||||
[\\]ccNestedType{w} { /* nested type declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return NESTEDTYPE;
|
||||
}
|
||||
[\\]ccEnum{w} { /* enum declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return ENUM;
|
||||
}
|
||||
[\\]ccStruct{w} { /* struct declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return STRUCT;
|
||||
}
|
||||
[\\]ccGlobalFunction{w} { /* function declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return GLOBALFUNCTION;
|
||||
}
|
||||
[\\]ccGlobalFunctionTemplate{w} { /* function template declaration:
|
||||
change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return GLOBALFUNCTIONTEMPLATE;
|
||||
}
|
||||
[\\]ccGlobalVariable{w} { /* variable declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return GLOBALVARIABLE;
|
||||
}
|
||||
[\\]ccGlobalTypedef{w} { /* typedef declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return GLOBALTYPEDEF;
|
||||
}
|
||||
[\\]ccGlobalEnum{w} { /* enum declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return GLOBALENUM;
|
||||
}
|
||||
[\\]ccGlobalStruct{w} { /* struct declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return GLOBALSTRUCT;
|
||||
}
|
||||
[\\]ccDeclaration{w} { /* general declaration: change to CCMode */
|
||||
BEGIN( CCMode);
|
||||
return DECLARATION;
|
||||
}
|
||||
[\\]ccHidden{w} { /* treat like a space */
|
||||
yylval.string.text = " ";
|
||||
yylval.string.len = 7;
|
||||
return SPACE;
|
||||
}
|
||||
[\\]ccUnchecked{w} { /* trigger a global boolean and treat it like a space */
|
||||
unchecked_tag = 1;
|
||||
yylval.string.text = " ";
|
||||
yylval.string.len = 10;
|
||||
return SPACE;
|
||||
}
|
||||
|
||||
|
||||
/* Specialized keywords, partly TeX, partly from the manual style */
|
||||
/* -------------------------------------------------------------- */
|
||||
[\\]ccStyle{w} { /* CCstyle formatting: change to NestingMode */
|
||||
BEGIN( NestingMode);
|
||||
return CCSTYLE;
|
||||
}
|
||||
[\\]cc(Pure)?Var{w} {
|
||||
if ( creationvariable) {
|
||||
yylval.string.text = creationvariable;
|
||||
yylval.string.len = strlen( creationvariable);
|
||||
} else {
|
||||
printErrorMessage( VariableUsedError);
|
||||
yylval.string.text = "Unknown creationvariable";
|
||||
yylval.string.len = strlen( yylval.string.text);
|
||||
}
|
||||
return STRING;
|
||||
}
|
||||
[\\]cc(Pure)?Class(Template)?Name{w} {
|
||||
if ( global_classname) {
|
||||
yylval.string.text = global_classname;
|
||||
yylval.string.len = strlen( global_classname);
|
||||
} else {
|
||||
printErrorMessage( ClassnameUsedError);
|
||||
yylval.string.text = "Unknown classname";
|
||||
yylval.string.len = strlen( yylval.string.text);
|
||||
}
|
||||
return STRING;
|
||||
}
|
||||
[\\]cc(Pure)?TemplateParameters{w} {
|
||||
if ( global_template_params) {
|
||||
yylval.string.text = global_template_params;
|
||||
yylval.string.len = strlen( global_template_params);
|
||||
} else {
|
||||
printErrorMessage( ClassnameUsedError);
|
||||
yylval.string.text = "Unknown template_params";
|
||||
yylval.string.len = strlen( yylval.string.text);
|
||||
}
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccSection{w} { return CCSECTION; }
|
||||
[\\]ccSubsection{w} { return CCSUBSECTION; }
|
||||
[\\]ldots{w} {
|
||||
yylval.string.text = "...";
|
||||
yylval.string.len = 3;
|
||||
return STRING;
|
||||
}
|
||||
[\\]RCSdef{w} {
|
||||
return GOBBLETWOPARAMS;
|
||||
}
|
||||
[\\]CC{w} {
|
||||
yylval.string.text = "C++";
|
||||
yylval.string.len = 3;
|
||||
return STRING;
|
||||
}
|
||||
[\\]gcc{w} {
|
||||
yylval.string.text = "g++";
|
||||
yylval.string.len = 3;
|
||||
return STRING;
|
||||
}
|
||||
[\\]nat{w} {
|
||||
yylval.string.text = "|N";
|
||||
yylval.string.len = 2;
|
||||
return STRING;
|
||||
}
|
||||
[\\]real{w} {
|
||||
yylval.string.text = "|R";
|
||||
yylval.string.len = 2;
|
||||
return STRING;
|
||||
}
|
||||
[\\]N{w} {
|
||||
yylval.string.text = "|N";
|
||||
yylval.string.len = 2;
|
||||
return STRING;
|
||||
}
|
||||
[\\]R{w} {
|
||||
yylval.string.text = "|R";
|
||||
yylval.string.len = 2;
|
||||
return STRING;
|
||||
}
|
||||
[\\]Q{w} {
|
||||
yylval.string.text = "|Q";
|
||||
yylval.string.len = 2;
|
||||
return STRING;
|
||||
}
|
||||
[\\]Z{w} {
|
||||
yylval.string.text = "Z";
|
||||
yylval.string.len = 1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]E{w} {
|
||||
yylval.string.text = "|E";
|
||||
yylval.string.len = 2;
|
||||
return STRING;
|
||||
}
|
||||
[\\]leda{w} {
|
||||
yylval.string.text = "LEDA";
|
||||
yylval.string.len = 4;
|
||||
return STRING;
|
||||
}
|
||||
[\\]cgal{w} {
|
||||
yylval.string.text = "CGAL";
|
||||
yylval.string.len = 4;
|
||||
return STRING;
|
||||
}
|
||||
[\\]protocgal{w} {
|
||||
yylval.string.text = "C++GAL";
|
||||
yylval.string.len = 6;
|
||||
return STRING;
|
||||
}
|
||||
[\\]plageo{w} {
|
||||
yylval.string.text = "PLAGEO";
|
||||
yylval.string.len = 6;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccDefinition{w} {
|
||||
yylval.string.text = "DEFINITION";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccParameters{w} {
|
||||
yylval.string.text = "PARAMETERS";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccConstants{w} {
|
||||
yylval.string.text = "CONSTANTS";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccTypes{w} {
|
||||
yylval.string.text = "TYPES";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccCreation{w} {
|
||||
yylval.string.text = "CREATION";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccOperations{w} {
|
||||
yylval.string.text = "OPERATIONS";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccImplementation{w} {
|
||||
yylval.string.text = "IMPLEMENTATION";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccExample{w} {
|
||||
yylval.string.text = "EXAMPLE";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccHeading{w} {
|
||||
return HEADING;
|
||||
}
|
||||
[\\]ccPrecond {
|
||||
yylval.string.text = "Precondition:";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccPostcond {
|
||||
yylval.string.text = "Postcondition:";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccCommentHeading{w} {
|
||||
return COMMENTHEADING;
|
||||
}
|
||||
[\\]leq {
|
||||
yylval.string.text = "<=";
|
||||
yylval.string.len = 2;
|
||||
return STRING;
|
||||
}
|
||||
[\\]geq {
|
||||
yylval.string.text = ">=";
|
||||
yylval.string.len = 2;
|
||||
return STRING;
|
||||
}
|
||||
[\\]neq {
|
||||
yylval.string.text = "!=";
|
||||
yylval.string.len = 2;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccSetTwoOfThreeColumns{w} {
|
||||
return GOBBLETWOPARAMS;
|
||||
}
|
||||
[\\]ccSetThreeColumns{w} {
|
||||
return GOBBLETHREEPARAMS;
|
||||
}
|
||||
[\\]ccSetOneOfTwoColumns{w} {
|
||||
return GOBBLEONEPARAM;
|
||||
}
|
||||
[\\]ccSetTwoColumns{w} {
|
||||
return GOBBLETWOPARAMS;
|
||||
}
|
||||
[\\]ccPropagateThreeToTwoColumns{w} {
|
||||
yylval.string.text = " ";
|
||||
yylval.string.len = 0;
|
||||
return SPACE;
|
||||
}
|
||||
[\\]g?def{w}[\\]{idfier}{w} {
|
||||
return GOBBLEONEPARAM;
|
||||
}
|
||||
[\\](re)?newcommand{w} {
|
||||
return NEWCOMMAND;
|
||||
}
|
||||
[\\]ccTag((Defaults)|(FullDeclarations)){w} {
|
||||
yylval.string.text = " ";
|
||||
yylval.string.len = 0;
|
||||
return SPACE;
|
||||
}
|
||||
[\\]ccChapterAuthor{w} {
|
||||
return GOBBLEONEPARAM;
|
||||
}
|
||||
|
||||
/* HTML support */
|
||||
/* ----------------------------------- */
|
||||
[\\]ccAnchor{w} {
|
||||
return GOBBLEONEPARAM;
|
||||
}
|
||||
[\\]ccTexHtml{w} {
|
||||
return GOBBLEAFTERONEPARAM;
|
||||
}
|
||||
[\\]begin{w}[\{]ccTexOnly[\}]{w} {
|
||||
return BEGINTEXONLY;
|
||||
}
|
||||
[\\]end{w}[\{]ccTexOnly[\}] {
|
||||
return ENDTEXONLY;
|
||||
}
|
||||
[\\]begin{w}[\{]ccHtmlOnly[\}]{w} {
|
||||
BEGIN( NestingMode);
|
||||
return BEGINHTMLONLY;
|
||||
}
|
||||
<NestingMode>[\\]end{w}[\{]ccHtmlOnly[\}] {
|
||||
return ENDHTMLONLY;
|
||||
}
|
||||
|
||||
/* make the $ delimiters for math mode disappear: */
|
||||
/* -------------------------------------------------------------- */
|
||||
[$] {}
|
||||
[\\]"&" {
|
||||
yylval.character = '&';
|
||||
return CHAR;
|
||||
}
|
||||
[\\]"_" {
|
||||
yylval.character = '_';
|
||||
return CHAR;
|
||||
}
|
||||
[\\]"^" {
|
||||
yylval.character = '^';
|
||||
return CHAR;
|
||||
}
|
||||
[\\]"#" {
|
||||
yylval.character = '#';
|
||||
return CHAR;
|
||||
}
|
||||
[~] {
|
||||
yylval.string.text = " ";
|
||||
yylval.string.len = 1;
|
||||
return SPACE;
|
||||
}
|
||||
[\\][\\] {
|
||||
yylval.string.text = " ";
|
||||
yylval.string.len = 1;
|
||||
return SPACE;
|
||||
}
|
||||
|
||||
|
||||
/* Grouping symbols */
|
||||
/* ---------------- */
|
||||
[\\][\{] {
|
||||
yylval.character = '{';
|
||||
return CHAR;
|
||||
}
|
||||
[\\][\}] {
|
||||
yylval.character = '}';
|
||||
return CHAR;
|
||||
}
|
||||
|
||||
<INITIAL,CCMode,NestingMode>[\{] {
|
||||
return '{';
|
||||
}
|
||||
<INITIAL,CCMode,NestingMode>[\}] {
|
||||
return '}';
|
||||
}
|
||||
|
||||
{blockintro} { /* A couple of TeX styles like {\tt ... */
|
||||
return BLOCKINTRO;
|
||||
}
|
||||
|
||||
<NestingMode>[\[] {
|
||||
return '[';
|
||||
}
|
||||
<NestingMode>[\]] {
|
||||
return ']';
|
||||
}
|
||||
|
||||
<NestingMode>[\(] {
|
||||
return '(';
|
||||
}
|
||||
<NestingMode>[\)] {
|
||||
return ')';
|
||||
}
|
||||
<NestingMode>[\\]"&" {
|
||||
yylval.character = '&';
|
||||
return CHAR;
|
||||
}
|
||||
<NestingMode>[\\]"_" {
|
||||
yylval.character = '_';
|
||||
return CHAR;
|
||||
}
|
||||
<NestingMode>[\\]"^" {
|
||||
yylval.character = '^';
|
||||
return CHAR;
|
||||
}
|
||||
<NestingMode>[\\]"#" {
|
||||
yylval.character = '#';
|
||||
return CHAR;
|
||||
}
|
||||
|
||||
/* The rest: spaces and single characters */
|
||||
/* -------------------------------------- */
|
||||
[\\]?{ws} {
|
||||
if ( *yytext == '\\') {
|
||||
yylval.string.text = yytext + 1;
|
||||
yylval.string.len = yyleng - 1;
|
||||
} else {
|
||||
yylval.string.text = yytext;
|
||||
yylval.string.len = yyleng;
|
||||
}
|
||||
return SPACE;
|
||||
}
|
||||
<CCMode,NestingMode>{ws} {
|
||||
yylval.string.text = yytext;
|
||||
yylval.string.len = yyleng;
|
||||
return SPACE;
|
||||
}
|
||||
<INITIAL,CCMode,NestingMode>. {
|
||||
yylval.character = yytext[0];
|
||||
return CHAR;
|
||||
}
|
||||
%%
|
||||
|
||||
void init_scanner( FILE* in){
|
||||
line_number = 1;
|
||||
set_CCMode = 0;
|
||||
set_NestingMode = 0;
|
||||
set_INITIAL = 0;
|
||||
unchecked_tag = 0;
|
||||
yyrestart( in);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,715 @@
|
|||
/**************************************************************************
|
||||
|
||||
extract_syntax.y
|
||||
=============================================================
|
||||
Project : CGAL merger tool for the specification task
|
||||
Function : grammatical parser for TeX and C++ code mixed files.
|
||||
System : bison, flex, C++ (g++)
|
||||
Author : (c) 1995 Lutz Kettner
|
||||
Revision : $Revision$
|
||||
Date : $Date$
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
%{
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Declarations from lex.yy */
|
||||
/* ======================== */
|
||||
extern int set_CCMode;
|
||||
extern int set_NestingMode;
|
||||
extern int set_INITIAL;
|
||||
extern int line_number;
|
||||
|
||||
extern const char* file_name;
|
||||
extern char* creationvariable;
|
||||
|
||||
extern char *yytext;
|
||||
|
||||
int yylex( void);
|
||||
void init_scanner( FILE* in);
|
||||
|
||||
|
||||
/* Declarations for the parser */
|
||||
/* =========================== */
|
||||
/* This variable flags for bison that we are in the CCMode */
|
||||
int CCMode = 0;
|
||||
|
||||
/* count the brace nesting level for debug purposes */
|
||||
int nesting = 0;
|
||||
|
||||
/* Own prototypes */
|
||||
int yyerror( char *s);
|
||||
|
||||
/* Datastructures for the parser */
|
||||
/* ============================= */
|
||||
#include <database.h>
|
||||
#include <config.h>
|
||||
%}
|
||||
|
||||
%union {
|
||||
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;
|
||||
}
|
||||
|
||||
/* Elementary data types */
|
||||
/* --------------------- */
|
||||
%token <string> STRING
|
||||
%token <string> SPACE
|
||||
%token <character> CHAR
|
||||
%token NEWLINE
|
||||
|
||||
/* Keywords to trigger on */
|
||||
/* ---------------------- */
|
||||
%token BEGINCLASS
|
||||
%token ENDCLASS
|
||||
%token BEGINCLASSTEMPLATE
|
||||
%token ENDCLASSTEMPLATE
|
||||
%token <string> CREATIONVARIABLE
|
||||
%token CONSTRUCTOR
|
||||
%token METHOD
|
||||
%token FUNCTION
|
||||
%token FUNCTIONTEMPLATE
|
||||
%token VARIABLE
|
||||
%token TYPEDEF
|
||||
%token NESTEDTYPE
|
||||
%token ENUM
|
||||
%token STRUCT
|
||||
%token GLOBALFUNCTION
|
||||
%token GLOBALFUNCTIONTEMPLATE
|
||||
%token GLOBALVARIABLE
|
||||
%token GLOBALTYPEDEF
|
||||
%token GLOBALENUM
|
||||
%token GLOBALSTRUCT
|
||||
%token DECLARATION
|
||||
%token BEGINTEXONLY
|
||||
%token ENDTEXONLY
|
||||
%token BEGINHTMLONLY
|
||||
%token ENDHTMLONLY
|
||||
|
||||
/* Special action keywords */
|
||||
/* ----------------------- */
|
||||
%token CCSTYLE
|
||||
%token CCSECTION
|
||||
%token CCSUBSECTION
|
||||
%token HEADING
|
||||
%token COMMENTHEADING
|
||||
%token GOBBLETHREEPARAMS
|
||||
%token GOBBLETWOPARAMS
|
||||
%token GOBBLEONEPARAM
|
||||
%token GOBBLEAFTERONEPARAM
|
||||
%token BLOCKINTRO
|
||||
%token NEWCOMMAND
|
||||
|
||||
/* handle LALR(1) restriction */
|
||||
/* -------------------------- */
|
||||
%token LALRRESTRICTION
|
||||
|
||||
%type <pBuffer> string
|
||||
%type <pBuffer> declaration classname template_params
|
||||
%type <pBuffer> cc_stmts cc_stmt cc_stmts_skip_space
|
||||
%type <pText> comment_group comment_sequence
|
||||
%type <pText> nested_token_sequence nested_token
|
||||
%type <pText> compound_comment full_comment_sequence
|
||||
%type <pText> non_empty_comment_sequence
|
||||
|
||||
%type <pText> whitespaces optional_whitespaces
|
||||
|
||||
%type <pTextToken> comment_token non_empty_token whitespace
|
||||
|
||||
|
||||
|
||||
%%
|
||||
/* Grammar: Top Level */
|
||||
/* ================== */
|
||||
|
||||
input: /* empty */
|
||||
| input stmt
|
||||
;
|
||||
|
||||
stmt: string { delete $1;}
|
||||
| SPACE {}
|
||||
| NEWLINE
|
||||
| BEGINCLASS
|
||||
classname { handleClass( $2->string());
|
||||
delete $2;}
|
||||
decl_sequence
|
||||
ENDCLASS
|
||||
{
|
||||
handleClassEnd();
|
||||
free( creationvariable);
|
||||
creationvariable = NULL;
|
||||
delete $2;
|
||||
}
|
||||
| BEGINCLASSTEMPLATE
|
||||
classname { handleClassTemplate( $2->string());
|
||||
delete $2;}
|
||||
decl_sequence
|
||||
ENDCLASSTEMPLATE
|
||||
{
|
||||
handleClassTemplateEnd();
|
||||
free( creationvariable);
|
||||
creationvariable = NULL;
|
||||
delete $2;
|
||||
}
|
||||
| CREATIONVARIABLE {}
|
||||
| CCSTYLE '{' nested_token_sequence '}' { set_INITIAL = 1; }
|
||||
| HEADING '{' comment_sequence '}' { delete $3; }
|
||||
| COMMENTHEADING '{' comment_sequence '}' { delete $3; }
|
||||
| BEGINTEXONLY nested_token_sequence ENDTEXONLY {;}
|
||||
| BEGINHTMLONLY nested_token_sequence ENDHTMLONLY {
|
||||
set_INITIAL = 1; }
|
||||
| gobble_parameters
|
||||
| GOBBLEAFTERONEPARAM reduced_group reduced_group
|
||||
| global_tagged_declarator
|
||||
| group
|
||||
;
|
||||
|
||||
group: '{' { nesting++; }
|
||||
input
|
||||
'}' { nesting--; }
|
||||
| BLOCKINTRO { nesting++; }
|
||||
input
|
||||
'}' { nesting--; }
|
||||
;
|
||||
|
||||
reduced_group: '{' { nesting++; }
|
||||
reduced_sequence
|
||||
'}' { nesting--; }
|
||||
| BLOCKINTRO { nesting++; }
|
||||
reduced_sequence
|
||||
'}' { nesting--; }
|
||||
;
|
||||
|
||||
reduced_sequence: /* empty */
|
||||
| reduced_sequence reduced_statement
|
||||
;
|
||||
|
||||
reduced_statement:
|
||||
string { delete $1;}
|
||||
| SPACE {}
|
||||
| NEWLINE
|
||||
| CREATIONVARIABLE {}
|
||||
| CCSTYLE '{' nested_token_sequence '}' { set_INITIAL = 1; }
|
||||
| HEADING '{' comment_sequence '}' { delete $3; }
|
||||
| COMMENTHEADING '{' comment_sequence '}' { delete $3; }
|
||||
| BEGINTEXONLY nested_token_sequence ENDTEXONLY {;}
|
||||
| BEGINHTMLONLY nested_token_sequence ENDHTMLONLY {
|
||||
set_INITIAL = 1; }
|
||||
| gobble_parameters
|
||||
| GOBBLEAFTERONEPARAM reduced_group reduced_group
|
||||
| reduced_group
|
||||
;
|
||||
|
||||
/* Auxiliary Rules */
|
||||
/* =============================== */
|
||||
string: STRING {
|
||||
$$ = new Buffer;
|
||||
$$->add( $1.text, $1.len);
|
||||
}
|
||||
| CHAR {
|
||||
$$ = new Buffer;
|
||||
$$->add( $1);
|
||||
}
|
||||
| string STRING {
|
||||
$1->add( $2.text, $2.len);
|
||||
$$ = $1;
|
||||
}
|
||||
| string CHAR {
|
||||
$1->add( $2);
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
non_empty_token: string { $$ = new TextToken(
|
||||
$1->string(), $1->length());
|
||||
delete $1;
|
||||
}
|
||||
;
|
||||
|
||||
optional_whitespaces: /* empty */ { $$ = new Text( managed); }
|
||||
| whitespaces { $$ = $1; }
|
||||
;
|
||||
|
||||
whitespaces: whitespace { $$ = new Text( * $1, managed); }
|
||||
| GOBBLEAFTERONEPARAM comment_group comment_group {
|
||||
$$ = $2;
|
||||
}
|
||||
| whitespaces whitespace {
|
||||
$$ = $1;
|
||||
$$->append( * $2);
|
||||
}
|
||||
| whitespaces GOBBLEAFTERONEPARAM comment_group comment_group {
|
||||
$$ = $3;
|
||||
}
|
||||
;
|
||||
|
||||
whitespace: SPACE { $$ = new TextToken( $1.text, $1.len, true); }
|
||||
| NEWLINE { $$ = new TextToken( "\n", 1, true); }
|
||||
| gobble_parameters
|
||||
{ $$ = new TextToken( " ", 1, true); }
|
||||
;
|
||||
|
||||
|
||||
|
||||
/* Class Declaration with Comments */
|
||||
/* =============================== */
|
||||
decl_sequence: comment_sequence {
|
||||
handleMainComment( * $1);
|
||||
}
|
||||
| decl_sequence
|
||||
tagged_declarator
|
||||
comment_sequence {
|
||||
handleMainComment( * $3);
|
||||
}
|
||||
;
|
||||
|
||||
tagged_declarator:
|
||||
global_tagged_declarator
|
||||
| CONSTRUCTOR declaration comment_group {
|
||||
handleFunctionDeclaration( $2->string());
|
||||
delete $2;
|
||||
handleComment( * $3);
|
||||
}
|
||||
| METHOD declaration comment_group {
|
||||
handleMethodDeclaration( $2->string());
|
||||
delete $2;
|
||||
handleComment( * $3);
|
||||
}
|
||||
;
|
||||
|
||||
global_tagged_declarator:
|
||||
FUNCTION declaration comment_group {
|
||||
handleFunctionDeclaration( $2->string());
|
||||
delete $2;
|
||||
handleComment( * $3);
|
||||
}
|
||||
| FUNCTIONTEMPLATE
|
||||
template_params
|
||||
optional_whitespaces
|
||||
declaration
|
||||
comment_group {
|
||||
handleFunctionTemplateDeclaration(
|
||||
$2->string(),
|
||||
$4->string());
|
||||
delete $2;
|
||||
delete $3;
|
||||
delete $4;
|
||||
handleComment( * $5);
|
||||
}
|
||||
| VARIABLE declaration comment_group {
|
||||
handleDeclaration( $2->string());
|
||||
delete $2;
|
||||
handleComment( * $3);
|
||||
}
|
||||
| TYPEDEF declaration comment_group {
|
||||
handleDeclaration( $2->string());
|
||||
delete $2;
|
||||
handleComment( * $3);
|
||||
}
|
||||
| NESTEDTYPE declaration comment_group {
|
||||
handleNestedType( $2->string());
|
||||
delete $2;
|
||||
handleComment( * $3);
|
||||
}
|
||||
| ENUM declaration comment_group {
|
||||
handleDeclaration( $2->string());
|
||||
delete $2;
|
||||
handleComment( * $3);
|
||||
}
|
||||
| STRUCT declaration comment_group {
|
||||
handleDeclaration( $2->string());
|
||||
delete $2;
|
||||
handleComment( * $3);
|
||||
}
|
||||
| GLOBALFUNCTION declaration {
|
||||
handleFunctionDeclaration( $2->string());
|
||||
delete $2;
|
||||
}
|
||||
| GLOBALFUNCTIONTEMPLATE
|
||||
template_params
|
||||
optional_whitespaces
|
||||
declaration {
|
||||
handleFunctionTemplateDeclaration(
|
||||
$2->string(),
|
||||
$4->string());
|
||||
delete $2;
|
||||
delete $3;
|
||||
delete $4;
|
||||
}
|
||||
| GLOBALVARIABLE declaration {
|
||||
handleDeclaration( $2->string());
|
||||
delete $2;
|
||||
}
|
||||
| GLOBALTYPEDEF declaration {
|
||||
handleDeclaration( $2->string());
|
||||
delete $2;
|
||||
}
|
||||
| GLOBALENUM declaration {
|
||||
handleDeclaration( $2->string());
|
||||
delete $2;
|
||||
}
|
||||
| GLOBALSTRUCT declaration {
|
||||
handleDeclaration( $2->string());
|
||||
delete $2;
|
||||
}
|
||||
| DECLARATION declaration {
|
||||
handleDeclaration( $2->string());
|
||||
delete $2;
|
||||
}
|
||||
;
|
||||
|
||||
/* A sequence of words forming a comment */
|
||||
/* ===================================== */
|
||||
comment_group: optional_whitespaces '{' comment_sequence '}' {
|
||||
$$ = $3;
|
||||
delete $1;
|
||||
}
|
||||
| optional_whitespaces BLOCKINTRO comment_sequence '}' {
|
||||
$$ = $3;
|
||||
delete $1;
|
||||
}
|
||||
;
|
||||
|
||||
comment_sequence: optional_whitespaces { $$ = new Text(managed); }
|
||||
| optional_whitespaces
|
||||
non_empty_comment_sequence
|
||||
optional_whitespaces { $$ = $2; }
|
||||
;
|
||||
|
||||
full_comment_sequence: /* empty */ { $$ = new Text(managed); }
|
||||
| whitespaces { $$ = $1; }
|
||||
| optional_whitespaces
|
||||
non_empty_comment_sequence
|
||||
optional_whitespaces {
|
||||
$$ = $1;
|
||||
$$->append( * $2);
|
||||
$$->append( * $3);
|
||||
delete $2;
|
||||
delete $3;
|
||||
}
|
||||
;
|
||||
|
||||
non_empty_comment_sequence:
|
||||
comment_token { $$ = new Text( * $1, managed); }
|
||||
| compound_comment { $$ = $1; }
|
||||
| non_empty_comment_sequence optional_whitespaces comment_token {
|
||||
$$ = $1;
|
||||
$$->append( * $2);
|
||||
$$->append( * $3);
|
||||
delete $2;
|
||||
}
|
||||
| non_empty_comment_sequence
|
||||
optional_whitespaces
|
||||
compound_comment {
|
||||
$$ = $1;
|
||||
$$->append( * $2);
|
||||
$$->append( * $3);
|
||||
delete $2;
|
||||
delete $3;
|
||||
}
|
||||
;
|
||||
|
||||
comment_token: non_empty_token { $$ = $1; }
|
||||
| comment_token non_empty_token {
|
||||
$$ = $1;
|
||||
$$->add( * $2);
|
||||
delete $2;
|
||||
}
|
||||
;
|
||||
|
||||
compound_comment: '{' full_comment_sequence '}' {
|
||||
$$ = $2;
|
||||
$$->cons( *new TextToken( "{", 1));
|
||||
$$->append( *new TextToken( "}", 1));
|
||||
}
|
||||
| BLOCKINTRO full_comment_sequence '}' {
|
||||
$$ = $2;
|
||||
}
|
||||
| CCSTYLE '{' nested_token_sequence '}' {
|
||||
$$ = $3;
|
||||
set_INITIAL = 1;
|
||||
if ( $$->head().isSpace) // should not
|
||||
$$->cons( *new TextToken( "`", 1));
|
||||
else
|
||||
$$->head().prepend( "`");
|
||||
InListFIter< TextToken> ix( * $$);
|
||||
ForAll( ix) {
|
||||
if ( ix.isLast())
|
||||
if ( ix->isSpace)
|
||||
$$->append( *new TextToken(
|
||||
"'", 1));
|
||||
else
|
||||
ix->add( "'");
|
||||
}
|
||||
}
|
||||
| BEGINTEXONLY nested_token_sequence ENDTEXONLY {
|
||||
$$ = $2;
|
||||
}
|
||||
| BEGINHTMLONLY nested_token_sequence ENDHTMLONLY {
|
||||
set_INITIAL = 1; }
|
||||
| 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(
|
||||
"===================================="
|
||||
"===================================="));
|
||||
$$->append( *new TextToken( "\n", 1, true));
|
||||
$$->append( *new TextToken( "\n", 1, true));
|
||||
}
|
||||
| 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(
|
||||
"------------------------------------"
|
||||
"------------------------------------"));
|
||||
$$->append( *new TextToken( "\n", 1, true));
|
||||
$$->append( *new TextToken( "\n", 1, true));
|
||||
}
|
||||
| HEADING '{' comment_sequence '}' {
|
||||
$$ = $3;
|
||||
}
|
||||
| COMMENTHEADING '{' comment_sequence '}' {
|
||||
$$ = $3;
|
||||
}
|
||||
| CREATIONVARIABLE {
|
||||
$$ = new Text( managed);
|
||||
$$->append( *new TextToken( "\n", 1, true));
|
||||
$$->append( *new TextToken( "\n", 1, true));
|
||||
$$->append( *new TextToken(
|
||||
"New creation variable is:"));
|
||||
$$->append( *new TextToken( " ", 1, true));
|
||||
TextToken* t = new TextToken($1.text,$1.len);
|
||||
t->prepend( "`");
|
||||
t->add( "'");
|
||||
$$->append( *t);
|
||||
$$->append( *new TextToken( "\n", 1, true));
|
||||
$$->append( *new TextToken( "\n", 1, true));
|
||||
}
|
||||
;
|
||||
|
||||
/* Parsing of a C++ expression/statement with nested expressions */
|
||||
/* ============================================================= */
|
||||
nested_token_sequence:
|
||||
/* empty */ {
|
||||
$$ = new Text(managed);
|
||||
}
|
||||
| nested_token_sequence nested_token
|
||||
{
|
||||
$1->append( * $2);
|
||||
free( $2);
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
nested_token: string {
|
||||
$$ = new Text(*new TextToken(
|
||||
$1->string(),
|
||||
$1->length()),
|
||||
managed);
|
||||
delete $1;
|
||||
}
|
||||
| SPACE {
|
||||
$$ = new Text(*new TextToken(
|
||||
$1.text,
|
||||
$1.len,
|
||||
true),
|
||||
managed);
|
||||
}
|
||||
| NEWLINE {
|
||||
$$ = new Text(*new TextToken( "\n", 1, true),
|
||||
managed);
|
||||
}
|
||||
| '{' nested_token_sequence '}' {
|
||||
$2->cons( *new TextToken( "{", 1));
|
||||
$2->append( *new TextToken( "}", 1));
|
||||
$$ = $2;
|
||||
}
|
||||
| BLOCKINTRO nested_token_sequence '}' {
|
||||
$$ = $2;
|
||||
}
|
||||
| '[' nested_token_sequence ']' {
|
||||
$2->cons( *new TextToken( "[", 1));
|
||||
$2->append( *new TextToken( "]", 1));
|
||||
$$ = $2;
|
||||
}
|
||||
| '(' nested_token_sequence ')' {
|
||||
$2->cons( *new TextToken( "(", 1));
|
||||
$2->append( *new TextToken( ")", 1));
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
/* Parsing of a C++ Declaration (function, method ..., not class) */
|
||||
/* ============================================================== */
|
||||
declaration: '{' { nesting++;
|
||||
CCMode = 1;
|
||||
}
|
||||
cc_stmts_skip_space
|
||||
'}' {
|
||||
nesting--;
|
||||
set_INITIAL = 1;
|
||||
CCMode = 0;
|
||||
$$ = $3;
|
||||
}
|
||||
;
|
||||
|
||||
classname: '{' { nesting++;
|
||||
CCMode = 1;
|
||||
}
|
||||
cc_stmts_skip_space
|
||||
'}' {
|
||||
nesting--;
|
||||
set_INITIAL = 1;
|
||||
CCMode = 0;
|
||||
$$ = $3;
|
||||
}
|
||||
;
|
||||
|
||||
template_params: '{' { nesting++;
|
||||
CCMode = 1;
|
||||
}
|
||||
cc_stmts_skip_space
|
||||
'}' {
|
||||
nesting--;
|
||||
set_INITIAL = 1;
|
||||
CCMode = 0;
|
||||
$$ = $3;
|
||||
}
|
||||
;
|
||||
|
||||
cc_stmts: /* empty */
|
||||
{ $$ = new Buffer;}
|
||||
| cc_stmts cc_stmt {
|
||||
$$ = $1;
|
||||
$$->add( $2);
|
||||
delete $2;
|
||||
}
|
||||
;
|
||||
|
||||
cc_stmt: string { $$ = $1;
|
||||
}
|
||||
| SPACE { $$ = new Buffer;
|
||||
$$->add( ' ');
|
||||
}
|
||||
| NEWLINE { $$ = new Buffer;
|
||||
$$->add( ' ');
|
||||
}
|
||||
| '{' { nesting++; }
|
||||
cc_stmts
|
||||
'}' { nesting--;
|
||||
$$ = $3;
|
||||
$$->prepend( '{');
|
||||
$$->add( '}');
|
||||
}
|
||||
;
|
||||
|
||||
cc_stmts_skip_space:
|
||||
/* empty */
|
||||
{ $$ = new Buffer;}
|
||||
| string
|
||||
cc_stmts { $$ = $1;
|
||||
$$->add( $2);
|
||||
delete $2;
|
||||
}
|
||||
| SPACE cc_stmts { $$ = $2;}
|
||||
| NEWLINE cc_stmts { $$ = $2;}
|
||||
| '{' { nesting++;}
|
||||
cc_stmts
|
||||
'}' { nesting--;}
|
||||
cc_stmts {
|
||||
$$ = $3;
|
||||
$$->prepend( '{');
|
||||
$$->add( '}');
|
||||
$$->add( $6);
|
||||
delete $6;
|
||||
}
|
||||
;
|
||||
|
||||
/* Parse over non useful parameters */
|
||||
/* -------------------------------- */
|
||||
gobble_parameters:
|
||||
GOBBLETHREEPARAMS reduced_group reduced_group reduced_group
|
||||
| GOBBLETWOPARAMS reduced_group reduced_group
|
||||
| GOBBLEONEPARAM reduced_group
|
||||
| NEWCOMMAND reduced_group reduced_group
|
||||
|
||||
|
||||
|
||||
/* End if Grammar */
|
||||
/* ============== */
|
||||
%%
|
||||
|
||||
int yyerror( char *s) {
|
||||
fprintf( stderr,
|
||||
"error 1 in line %d in %s: in %s-code: nesting %d: %s.\n",
|
||||
line_number,
|
||||
file_name,
|
||||
(CCMode ? "CC" : "TeX"),
|
||||
nesting,
|
||||
s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Functions belonging to the Error messages
|
||||
// -----------------------------------------
|
||||
// See their implementations in parser.y
|
||||
|
||||
const char* errorMessage( ErrorNumber n) {
|
||||
switch ( n) {
|
||||
case NoError:
|
||||
return "NO ERROR";
|
||||
case ParseError:
|
||||
return "parse error";
|
||||
case VariableUsedError:
|
||||
return "The creationvariable was used but not defined";
|
||||
case ClassnameUsedError:
|
||||
return "The classname was used but not defined";
|
||||
case TemplateParamExpectedError:
|
||||
return "A template parameter is missing";
|
||||
case MalformedFunctionDeclaration:
|
||||
return "The function declaration is malformed";
|
||||
case MalformedTemplateParamError:
|
||||
return "The template parameter is malformed (<> nesting ..)";
|
||||
case SemicolonMissingError:
|
||||
return "The declaration does not end in a semicolon";
|
||||
}
|
||||
return "UNKNOWN ERROR MESSAGE NUMBER";
|
||||
}
|
||||
|
||||
void printErrorMessage( ErrorNumber n){
|
||||
cerr << "error " << n << " in line " << line_number << " in `"
|
||||
<< file_name << "': " << errorMessage( n) << "." << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -19,6 +19,26 @@
|
|||
// There they can be taylored to the specific application, i.e.
|
||||
// extraction or checker.
|
||||
|
||||
/* Customization tags for the style */
|
||||
/* ================================ */
|
||||
extern bool tag_chapter_author;
|
||||
extern bool tag_replace_prefix;
|
||||
extern bool tag_replace_include;
|
||||
extern bool tag_long_param_layout;
|
||||
|
||||
extern bool tag_rm_const_ref_pair;
|
||||
extern bool tag_rm_eigen_class_name;
|
||||
extern bool tag_operator_layout;
|
||||
extern bool tag_rm_trailing_const;
|
||||
|
||||
void tag_defaults();
|
||||
void tag_full_declarations();
|
||||
|
||||
|
||||
/* read a file into a buffer */
|
||||
/* The name has a trailing '}' */
|
||||
Buffer* readFileInBuffer(const char* name);
|
||||
|
||||
/* An empty List as empty comment for global declarations */
|
||||
/* ====================================================== */
|
||||
extern Text empty_comment;
|
||||
|
|
@ -60,8 +80,16 @@ void handleFunctionTemplateDeclaration( const char* templ,
|
|||
const Text& T = empty_comment);
|
||||
void handleVariableDeclaration( const char* decl,
|
||||
const Text& T = empty_comment);
|
||||
void handleTypedefDeclaration( const char* decl,
|
||||
const Text& T = empty_comment);
|
||||
void handleNestedTypeDeclaration( const char* decl,
|
||||
const Text& T = empty_comment);
|
||||
void handleEnumDeclaration( const char* decl,
|
||||
const Text& T = empty_comment);
|
||||
void handleStructDeclaration( const char* decl,
|
||||
const Text& T = empty_comment);
|
||||
|
||||
void handleNewCommand( char* idfier, char* body);
|
||||
|
||||
|
||||
// Error messages and Numbers
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
html_lex.yy
|
||||
=============================================================
|
||||
Project : CGAL merger tool for the specification task
|
||||
Project : Tools for the CC manual writing task around cc_manual.sty.
|
||||
Function : lexical scanner for TeX and C++ code mixed files.
|
||||
Taylored for HTML manual generation.
|
||||
System : flex, bison, C++ (g++)
|
||||
|
|
@ -22,6 +22,13 @@ extern "C" int yylex( void );
|
|||
#include <html_config.h>
|
||||
#include <html_syntax.tab.h>
|
||||
|
||||
// This flag indicates whether we are in a tabbing or tabular environment.
|
||||
bool tab_tag = false;
|
||||
|
||||
// This flag is true if we are inside a definition. here, \input and
|
||||
// \include should not open a file.
|
||||
bool ignore_input_tag = false;
|
||||
|
||||
/* Set this flag to 1 to switch immediately to CCMode. */
|
||||
int set_CCMode = 0;
|
||||
/* Set this flag to 1 to switch immediately to NestingMode. */
|
||||
|
|
@ -31,7 +38,7 @@ int set_INITIAL = 0;
|
|||
int set_HTMLMODE = 0;
|
||||
int set_MMODE = 0;
|
||||
|
||||
/* Tag to mark the unchecked keyword */
|
||||
/* Tag to mark whenever the unchecked keyword occurs. */
|
||||
int unchecked_tag = 0;
|
||||
|
||||
/* Count the linenumber for better errormessages. */
|
||||
|
|
@ -101,6 +108,7 @@ noletter [^a-zA-Z]
|
|||
digit [0-9]
|
||||
CCletter [a-zA-Z_]
|
||||
idfier {letter}+
|
||||
texmacro [\\]{idfier}
|
||||
CCidfier ({CCletter}({CCletter}|{digit})*)
|
||||
filename [^ \t\n/\\\{\}\[\]()]+
|
||||
space [\t ]
|
||||
|
|
@ -115,6 +123,7 @@ floatNumber ({signNumber}\.|{signNumber}\.{number})
|
|||
expNumber ({floatNumber}|{signNumber}){exp}{signNumber}
|
||||
No ({signNumber}|{floatNumber}|{expNumber})
|
||||
operator [^a-zA-Z_0-9\n\r\t \\]
|
||||
measure {signNumber}{letter}{letter}
|
||||
ttblockintro [\{][\\](tt)
|
||||
emblockintro [\{][\\](em)
|
||||
itblockintro [\{][\\]((it)|(sl))
|
||||
|
|
@ -165,7 +174,17 @@ bfblockintro [\{][\\](bf)
|
|||
/* Handle include files */
|
||||
/* ------------------------- */
|
||||
|
||||
[\\]((include)|(input))[\{]{w} { BEGIN ( INCLUDEMODE); }
|
||||
[\\]((include)|(input))[\{]{w} {
|
||||
if (ignore_input_tag) {
|
||||
int c = yyinput();
|
||||
while( c && c != '}')
|
||||
c = yyinput();
|
||||
yylval.string.text = " ";
|
||||
yylval.string.len = 0;
|
||||
return SPACE;
|
||||
}
|
||||
BEGIN ( INCLUDEMODE);
|
||||
}
|
||||
<INCLUDEMODE>{filename} {
|
||||
/* remove trailing characters from the input/include statement */
|
||||
int c = yyinput();
|
||||
|
|
@ -294,21 +313,21 @@ bfblockintro [\{][\\](bf)
|
|||
|
||||
/* Different keywords from the manual style triggering C++ formatting */
|
||||
/* ------------------------------------------------------------------ */
|
||||
[\\]begin{w}[\{]class[\}]{w} {
|
||||
[\\]begin{w}[\{]ccClass[\}]{w} {
|
||||
BEGIN( CCMode);
|
||||
return BEGINCLASS;
|
||||
}
|
||||
[\\]end{w}[\{]class[\}] {
|
||||
[\\]end{w}[\{]ccClass[\}] {
|
||||
return ENDCLASS;
|
||||
}
|
||||
[\\]begin{w}[\{]classtemplate[\}]{w} {
|
||||
[\\]begin{w}[\{]ccClassTemplate[\}]{w} {
|
||||
BEGIN( CCMode);
|
||||
return BEGINCLASSTEMPLATE;
|
||||
}
|
||||
[\\]end{w}[\{]classtemplate[\}] {
|
||||
[\\]end{w}[\{]ccClassTemplate[\}] {
|
||||
return ENDCLASSTEMPLATE;
|
||||
}
|
||||
[\\]creationvariable{w}[\{]{w}[^\}]*{w}[\}] {
|
||||
[\\]ccCreationVariable{w}[\{]{w}[^\}]*{w}[\}] {
|
||||
char *s = yytext + yyleng - 2;
|
||||
while (( *s == ' ') || ( *s == '\t'))
|
||||
s--;
|
||||
|
|
@ -319,6 +338,7 @@ bfblockintro [\{][\\](bf)
|
|||
while (( *r == ' ') || ( *r == '\t'))
|
||||
r++;
|
||||
s[1] = 0;
|
||||
if ( creationvariable)
|
||||
delete[] creationvariable;
|
||||
if ( formatted_creationvariable)
|
||||
delete[] formatted_creationvariable;
|
||||
|
|
@ -332,78 +352,98 @@ bfblockintro [\{][\\](bf)
|
|||
yylval.string.len = s - r + 1;
|
||||
return CREATIONVARIABLE;
|
||||
}
|
||||
[\\]constructor/{noletter} { /* constructor declaration: change to CCMode */
|
||||
[\\]ccConstructor/{noletter} { /* constructor declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return CONSTRUCTOR;
|
||||
}
|
||||
[\\]method/{noletter} { /* method declaration: change to CCMode */
|
||||
[\\]ccMemberFunction/{noletter} { /* method declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return METHOD;
|
||||
}
|
||||
[\\]function/{noletter} { /* function declaration: change to CCMode */
|
||||
[\\]ccMethod/{noletter} { /* method declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return METHOD;
|
||||
}
|
||||
[\\]ccFunction/{noletter} { /* function declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return FUNCTION;
|
||||
}
|
||||
[\\]functiontemplate/{noletter} { /* function template declaration:
|
||||
[\\]ccFunctionTemplate/{noletter} { /* function template declaration:
|
||||
change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return FUNCTIONTEMPLATE;
|
||||
}
|
||||
[\\]variable/{noletter} { /* variable declaration: change to CCMode */
|
||||
[\\]ccVariable/{noletter} { /* variable declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return VARIABLE;
|
||||
}
|
||||
[\\]typedef/{noletter} { /* typedef declaration: change to CCMode */
|
||||
[\\]ccTypedef/{noletter} { /* typedef declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return TYPEDEF;
|
||||
}
|
||||
[\\]enum/{noletter} { /* enum declaration: change to CCMode */
|
||||
[\\]ccNestedType/{noletter} { /* nested type declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return NESTEDTYPE;
|
||||
}
|
||||
[\\]ccEnum/{noletter} { /* enum declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return ENUM;
|
||||
}
|
||||
[\\]globalfunction/{noletter} { /* function declaration: change to CCMode */
|
||||
[\\]ccStruct/{noletter} { /* struct declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return STRUCT;
|
||||
}
|
||||
[\\]ccGlobalFunction/{noletter} { /* function declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return GLOBALFUNCTION;
|
||||
}
|
||||
[\\]globalfunctiontemplate/{noletter} { /* function template declaration:
|
||||
[\\]ccGlobalFunctionTemplate/{noletter} { /* function template declaration:
|
||||
change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return GLOBALFUNCTIONTEMPLATE;
|
||||
}
|
||||
[\\]globalvariable/{noletter} { /* variable declaration: change to CCMode */
|
||||
[\\]ccGlobalVariable/{noletter} { /* variable declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return GLOBALVARIABLE;
|
||||
}
|
||||
[\\]globaltypedef/{noletter} { /* typedef declaration: change to CCMode */
|
||||
[\\]ccGlobalTypedef/{noletter} { /* typedef declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return GLOBALTYPEDEF;
|
||||
}
|
||||
[\\]globalenum/{noletter} { /* enum declaration: change to CCMode */
|
||||
[\\]ccGlobalEnum/{noletter} { /* enum declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return GLOBALENUM;
|
||||
}
|
||||
[\\]declaration/{noletter} { /* general declaration: change to CCMode */
|
||||
[\\]ccGlobalStruct/{noletter} { /* struct declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return GLOBALSTRUCT;
|
||||
}
|
||||
[\\]ccDeclaration/{noletter} { /* general declaration: change to CCMode */
|
||||
skipspaces();
|
||||
BEGIN( CCMode);
|
||||
return DECLARATION;
|
||||
}
|
||||
[\\]hidden/{noletter} {
|
||||
[\\]ccHidden/{noletter} {
|
||||
skipspaces();
|
||||
return HIDDEN;
|
||||
}
|
||||
[\\]unchecked/{noletter} {
|
||||
[\\]ccUnchecked/{noletter} {
|
||||
/* trigger a global boolean and treat it like a space */
|
||||
skipspaces();
|
||||
unchecked_tag = 1;
|
||||
|
|
@ -422,21 +462,26 @@ bfblockintro [\{][\\](bf)
|
|||
BEGIN( INITIAL);
|
||||
return CPROGEND;
|
||||
}
|
||||
[\\]"cprogfile{"[^\}]*"}" {
|
||||
yylval.string.text = yytext + 11;
|
||||
yylval.string.len = yyleng - 12;
|
||||
return CPROGFILE;
|
||||
}
|
||||
|
||||
[\\]"begin{HtmlOnly}" {
|
||||
[\\]"begin{ccHtmlOnly}" {
|
||||
BEGIN( HTMLGROUPMode);
|
||||
return HTMLBEGIN;
|
||||
}
|
||||
<HTMLGROUPMode>[\\]"end{HtmlOnly}" {
|
||||
<HTMLGROUPMode>[\\]"end{ccHtmlOnly}" {
|
||||
BEGIN( INITIAL);
|
||||
return HTMLEND;
|
||||
}
|
||||
|
||||
[\\]"begin{TexOnly}" {
|
||||
[\\]"begin{ccTexOnly}" {
|
||||
BEGIN( TEXONLYMODE);
|
||||
return TEXONLYBEGIN;
|
||||
}
|
||||
<TEXONLYMODE>[\\]"end{TexOnly}" {
|
||||
<TEXONLYMODE>[\\]"end{ccTexOnly}" {
|
||||
BEGIN( INITIAL);
|
||||
return TEXONLYEND;
|
||||
}
|
||||
|
|
@ -444,10 +489,10 @@ bfblockintro [\{][\\](bf)
|
|||
yylval.character = yytext[0];
|
||||
return CHAR;
|
||||
}
|
||||
[\\]LatexHtml{w}[\{] {
|
||||
[\\]ccTexHtml{w}[\{] {
|
||||
return LATEXHTML;
|
||||
}
|
||||
[\\]Anchor{w}[\{] {
|
||||
[\\]ccAnchor{w}[\{] {
|
||||
/* The first parameter is the URL, the second is the */
|
||||
/* message that will be highlighted */
|
||||
BEGIN( HTMLMODE);
|
||||
|
|
@ -464,12 +509,12 @@ bfblockintro [\{][\\](bf)
|
|||
|
||||
/* Specialized keywords from the manual style */
|
||||
/* -------------------------------------------------------------- */
|
||||
[\\]CCstyle/{noletter} { /* CCstyle formatting: change to NestingMode */
|
||||
[\\]ccStyle/{noletter} { /* CCstyle formatting: change to NestingMode */
|
||||
skipspaces();
|
||||
BEGIN( NestingMode);
|
||||
return CCSTYLE;
|
||||
}
|
||||
<INITIAL,MMODE,NestingMode>[\\]var/{noletter} {
|
||||
<INITIAL,MMODE,NestingMode>[\\]ccVar/{noletter} {
|
||||
skipspaces();
|
||||
if ( creationvariable) {
|
||||
yylval.string.text = formatted_creationvariable;
|
||||
|
|
@ -481,7 +526,7 @@ bfblockintro [\{][\\](bf)
|
|||
}
|
||||
return STRING;
|
||||
}
|
||||
<INITIAL,MMODE,NestingMode>[\\]purevar/{noletter} {
|
||||
<INITIAL,MMODE,NestingMode>[\\]ccPureVar/{noletter} {
|
||||
skipspaces();
|
||||
if ( creationvariable) {
|
||||
yylval.string.text = creationvariable;
|
||||
|
|
@ -493,7 +538,7 @@ bfblockintro [\{][\\](bf)
|
|||
}
|
||||
return STRING;
|
||||
}
|
||||
<INITIAL,MMODE,NestingMode>[\\]classname/{noletter} {
|
||||
<INITIAL,MMODE,NestingMode>[\\]ccClassName/{noletter} {
|
||||
skipspaces();
|
||||
if ( formatted_class_name) {
|
||||
yylval.string.text = formatted_class_name;
|
||||
|
|
@ -505,7 +550,7 @@ bfblockintro [\{][\\](bf)
|
|||
}
|
||||
return STRING;
|
||||
}
|
||||
<INITIAL,MMODE,NestingMode>[\\]pureclassname/{noletter} {
|
||||
<INITIAL,MMODE,NestingMode>[\\]ccPureClassName/{noletter} {
|
||||
skipspaces();
|
||||
if ( class_name) {
|
||||
yylval.string.text = class_name;
|
||||
|
|
@ -517,7 +562,7 @@ bfblockintro [\{][\\](bf)
|
|||
}
|
||||
return STRING;
|
||||
}
|
||||
<INITIAL,MMODE,NestingMode>[\\]classtemplatename/{noletter} {
|
||||
<INITIAL,MMODE,NestingMode>[\\]ccClassTemplateName/{noletter} {
|
||||
skipspaces();
|
||||
if ( formatted_template_class_name) {
|
||||
yylval.string.text = formatted_template_class_name;
|
||||
|
|
@ -529,7 +574,7 @@ bfblockintro [\{][\\](bf)
|
|||
}
|
||||
return STRING;
|
||||
}
|
||||
<INITIAL,MMODE,NestingMode>[\\]puretemplatename/{noletter} {
|
||||
<INITIAL,MMODE,NestingMode>[\\]ccPureClassTemplateName/{noletter} {
|
||||
skipspaces();
|
||||
if ( template_class_name) {
|
||||
yylval.string.text = template_class_name;
|
||||
|
|
@ -541,17 +586,21 @@ bfblockintro [\{][\\](bf)
|
|||
}
|
||||
return STRING;
|
||||
}
|
||||
[\\]CCsection/{noletter} {
|
||||
[\\]ccSection/{noletter} {
|
||||
skipspaces();
|
||||
return CCSECTION;
|
||||
}
|
||||
[\\]ccSubsection/{noletter} {
|
||||
skipspaces();
|
||||
return CCSUBSECTION;
|
||||
}
|
||||
[\\]CC/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text = "C++";
|
||||
yylval.string.len = 3;
|
||||
return STRING;
|
||||
}
|
||||
[\\]gg/{noletter} {
|
||||
[\\]gcc/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text = "g++";
|
||||
yylval.string.len = 3;
|
||||
|
|
@ -581,6 +630,12 @@ bfblockintro [\{][\\](bf)
|
|||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
<INITIAL,MMODE>[\\]Q/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text = "<B>Q</B>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
<INITIAL,MMODE>[\\]Z/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text = "<B>Z</B>";
|
||||
|
|
@ -621,50 +676,145 @@ bfblockintro [\{][\\](bf)
|
|||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]definition/{noletter} {
|
||||
[\\]ccDefinition/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text = "<H3>Definition</H3>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]creation/{noletter} {
|
||||
[\\]ccParameters/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text = "<H3>Parameters</H3>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccConstants/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text = "<H3>Constants</H3>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccTypes/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text = "<H3>Types</H3>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccCreation/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text = "<H3>Creation</H3>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]operations/{noletter} {
|
||||
[\\]ccOperations/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text = "<H3>Operations</H3>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]implementation/{noletter} {
|
||||
[\\]ccImplementation/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text = "<H3>Implementation</H3>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]example/{noletter} {
|
||||
[\\]ccExample/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text = "<H3>Example</H3>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]precond/{noletter} {
|
||||
[\\]ccHeading/{noletter} {
|
||||
return HEADING;
|
||||
}
|
||||
[\\]ccPrecond/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text = "<BR><STRONG>Precondition: </STRONG>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]threecolumns/{noletter} {
|
||||
[\\]ccPostcond/{noletter} {
|
||||
skipspaces();
|
||||
yylval.string.text ="<BR><STRONG>Postcondition: </STRONG>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
[\\]ccCommentHeading/{noletter} {
|
||||
return COMMENTHEADING;
|
||||
}
|
||||
[\\]ccSetTwoOfThreeColumns/{noletter} {
|
||||
skipspaces();
|
||||
return GOBBLETWOPARAMS;
|
||||
}
|
||||
[\\]constructorcolumn/{noletter} {
|
||||
[\\]ccSetThreeColumns/{noletter} {
|
||||
skipspaces();
|
||||
return GOBBLETHREEPARAMS;
|
||||
}
|
||||
[\\]ccSetOneOfTwoColumns/{noletter} {
|
||||
skipspaces();
|
||||
return GOBBLEONEPARAM;
|
||||
}
|
||||
[\\]ccSetTwoColumns/{noletter} {
|
||||
skipspaces();
|
||||
return GOBBLETWOPARAMS;
|
||||
}
|
||||
[\\]ccPropagateThreeToTwoColumns/{noletter} {
|
||||
yylval.string.text = " ";
|
||||
yylval.string.len = 0;
|
||||
return SPACE;
|
||||
}
|
||||
[\\]g?def{w}[\\]{idfier}[^\{]* {
|
||||
ignore_input_tag = true;
|
||||
BEGIN( NestingMode);
|
||||
return GOBBLEONEPARAM;
|
||||
}
|
||||
[\\](re)?newcommand{w} {
|
||||
ignore_input_tag = true;
|
||||
BEGIN( NestingMode);
|
||||
return NEWCOMMAND;
|
||||
}
|
||||
[\\]ccTagDefaults{w} {
|
||||
tag_defaults();
|
||||
yylval.string.text = " ";
|
||||
yylval.string.len = 0;
|
||||
return SPACE;
|
||||
}
|
||||
[\\]ccTagFullDeclarations{w} {
|
||||
tag_full_declarations();
|
||||
yylval.string.text = " ";
|
||||
yylval.string.len = 0;
|
||||
return SPACE;
|
||||
}
|
||||
[\\]ccChapterAuthor{w} {
|
||||
return CHAPTERAUTHOR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Try tabular and tabbing environments */
|
||||
/* -------------------------------------------------------------- */
|
||||
|
||||
<INITIAL,MMODE,NestingMode>[\\]begin[\{]((tabbing)|(eqnarray"*"?))[\}] |
|
||||
<INITIAL,MMODE,NestingMode>[\\]begin[\{]((tabular)|(array))[\}][\{][^\}]*[\}] {
|
||||
tab_tag = true;
|
||||
yylval.string.text =
|
||||
"<TABLE><TR><TD ALIGN=LEFT VALIGN=TOP NOWRAP>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
<INITIAL,MMODE,NestingMode>[\\]end[\{]((tabbing)|(tabular)|(eqnarray"*"?)|(array))[\}] {
|
||||
tab_tag = false;
|
||||
yylval.string.text = "</TD></TR></TABLE>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
<INITIAL,MMODE,NestingMode>[\\][=>] {
|
||||
yylval.string.text =
|
||||
"</TD><TD ALIGN=LEFT VALIGN=TOP NOWRAP>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
|
||||
|
||||
/* keywords from TeX/LaTeX that have an easy HTML counterpart */
|
||||
/* -------------------------------------------------------------- */
|
||||
|
|
@ -770,7 +920,7 @@ bfblockintro [\{][\\](bf)
|
|||
yylval.string.len = 5;
|
||||
return STRING;
|
||||
}
|
||||
<INITIAL,MMODE,NestingMode>[\\][_^#$] {
|
||||
<INITIAL,MMODE,NestingMode>[\\][_^#$~%] {
|
||||
yylval.character = yytext[1];
|
||||
return CHAR;
|
||||
}
|
||||
|
|
@ -782,6 +932,12 @@ bfblockintro [\{][\\](bf)
|
|||
}
|
||||
<INITIAL,MMODE,NestingMode>[\\][\\] {
|
||||
skipoptionalparam();
|
||||
if ( tab_tag) {
|
||||
yylval.string.text =
|
||||
"</TD></TR><TR><TD ALIGN=LEFT VALIGN=TOP NOWRAP>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
yylval.string.text = " ";
|
||||
yylval.string.len = 1;
|
||||
return SPACE;
|
||||
|
|
@ -895,12 +1051,13 @@ bfblockintro [\{][\\](bf)
|
|||
[\\]((smallskip)|(protect)|(sloppy))/{noletter} {}
|
||||
[\\]((maketitle)|(tableofcontents))/{noletter} {}
|
||||
[\\]((begin)|(end))[\{]document[\}] {}
|
||||
[\\]((tiny)|(scriptsize)|(footnotesize)|(small)|(normalsize)|(large)|(Large))/{noletter}
|
||||
|
||||
|
||||
[\\]newsavebox{w}[\{] |
|
||||
[\\]usebox{w}[\{] |
|
||||
[\\][*]?hspace{w}[\{] |
|
||||
[\\][*]?vspace{w}[\{] |
|
||||
[\\]g?def{w}[\\]{letter}+[^\{]*[\{] {
|
||||
[\\][*]?vspace{w}[\{] {
|
||||
/* CCstyle formatting: change to NestingMode */
|
||||
BEGIN( NestingMode);
|
||||
return IGNOREBLOCK;
|
||||
|
|
@ -911,13 +1068,8 @@ bfblockintro [\{][\\](bf)
|
|||
BEGIN( NestingMode);
|
||||
return IGNOREBLOCK;
|
||||
}
|
||||
[\\]((textwidth)|(textheight)|(topmargin)|(evensidemargin)|(oddsidemargin)|(headsep)|(parindent)|(parskip)){w}[-+0-9.]+{w}.. {}
|
||||
[\\]((textwidth)|(textheight)|(topmargin)|(evensidemargin)|(oddsidemargin)|(headsep)|(parindent)|(parskip)|(beforecprogskip)|(aftercprogskip)){w}(({texmacro})|({measure})) {}
|
||||
|
||||
[\\]newcommand{w}[\{][^\}]*[\}]([\[][^\]]*[\]])[\{] {
|
||||
/* CCstyle formatting: change to NestingMode */
|
||||
BEGIN( NestingMode);
|
||||
return IGNOREBLOCK;
|
||||
}
|
||||
[\\]((savebox)|(setlength)|(setcounter)){w}[\{] {
|
||||
/* CCstyle formatting: change to NestingMode */
|
||||
BEGIN( NestingMode);
|
||||
|
|
@ -961,19 +1113,19 @@ bfblockintro [\{][\\](bf)
|
|||
|
||||
/* Grouping symbols */
|
||||
/* ---------------- */
|
||||
[\\][\{] {
|
||||
<INITIAL,MMODE,NestingMode>[\\][\{] {
|
||||
yylval.character = '{';
|
||||
return CHAR;
|
||||
}
|
||||
[\\][\}] {
|
||||
<INITIAL,MMODE,NestingMode>[\\][\}] {
|
||||
yylval.character = '}';
|
||||
return CHAR;
|
||||
}
|
||||
[\\]left. {
|
||||
<INITIAL,MMODE,NestingMode>[\\]left. {
|
||||
yylval.character = yytext[5];
|
||||
return CHAR;
|
||||
}
|
||||
[\\]right. {
|
||||
<INITIAL,MMODE,NestingMode>[\\]right. {
|
||||
yylval.character = yytext[6];
|
||||
return CHAR;
|
||||
}
|
||||
|
|
@ -1027,6 +1179,19 @@ bfblockintro [\{][\\](bf)
|
|||
yylval.character = yytext[0];
|
||||
return CHAR;
|
||||
}
|
||||
<INITIAL,NestingMode>[\\][/] {}
|
||||
<INITIAL,MMODE,NestingMode>[&] {
|
||||
if ( tab_tag) {
|
||||
yylval.string.text =
|
||||
"</TD><TD ALIGN=LEFT VALIGN=TOP NOWRAP>";
|
||||
yylval.string.len = -1;
|
||||
return STRING;
|
||||
}
|
||||
yylval.string.text = html_multi_character(yytext[0]);
|
||||
yylval.string.len = strlen( yylval.string.text);
|
||||
return STRING;
|
||||
}
|
||||
|
||||
<INITIAL,NestingMode,MMODE,CPROGMode>. {
|
||||
yylval.character = yytext[0];
|
||||
if ( is_html_multi_character( yylval.character)) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
html_syntax.y
|
||||
=============================================================
|
||||
Project : CGAL merger tool for the specification task
|
||||
Project : Tools for the CC manual writing task around cc_manual.sty.
|
||||
Function : grammatical parser for TeX and C++ code mixed files.
|
||||
Taylored for HTML manual generation.
|
||||
System : bison, flex, C++ (g++)
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
/* Declarations from lex.yy */
|
||||
/* ======================== */
|
||||
|
||||
extern int set_CCMode;
|
||||
extern int set_NestingMode;
|
||||
extern int set_INITIAL;
|
||||
|
|
@ -57,6 +58,10 @@ char* text_block_to_string( const Text& T);
|
|||
/* ==================== */
|
||||
extern bool first_bibitem;
|
||||
|
||||
// This flag is true if we are inside a definition. here, \input and
|
||||
// \include should not open a file.
|
||||
extern bool ignore_input_tag;
|
||||
|
||||
/* Own prototypes */
|
||||
/* ============== */
|
||||
int yyerror( char *s);
|
||||
|
|
@ -104,18 +109,22 @@ Text* blockintroProcessing( const char* text, int len, Text* t);
|
|||
%token FUNCTIONTEMPLATE
|
||||
%token VARIABLE
|
||||
%token TYPEDEF
|
||||
%token NESTEDTYPE
|
||||
%token ENUM
|
||||
%token STRUCT
|
||||
%token GLOBALFUNCTION
|
||||
%token GLOBALFUNCTIONTEMPLATE
|
||||
%token GLOBALVARIABLE
|
||||
%token GLOBALTYPEDEF
|
||||
%token GLOBALENUM
|
||||
%token GLOBALSTRUCT
|
||||
%token DECLARATION
|
||||
|
||||
/* Special action keywords */
|
||||
/* ----------------------- */
|
||||
%token CPROGBEGIN
|
||||
%token CPROGEND
|
||||
%token <string> CPROGFILE
|
||||
%token HIDDEN
|
||||
|
||||
%token TEXONLYBEGIN
|
||||
|
|
@ -127,10 +136,16 @@ Text* blockintroProcessing( const char* text, int len, Text* t);
|
|||
|
||||
%token CCSTYLE
|
||||
%token CCSECTION
|
||||
%token CCSUBSECTION
|
||||
%token HEADING
|
||||
%token COMMENTHEADING
|
||||
%token CHAPTERAUTHOR
|
||||
%token GOBBLEONEPARAM
|
||||
%token GOBBLETWOPARAMS
|
||||
%token GOBBLETHREEPARAMS
|
||||
%token IGNOREBLOCK
|
||||
%token IGNORETWOBLOCKS
|
||||
%token NEWCOMMAND
|
||||
%token TTBLOCKINTRO
|
||||
%token EMBLOCKINTRO
|
||||
%token ITBLOCKINTRO
|
||||
|
|
@ -176,17 +191,24 @@ input: /* empty */
|
|||
| input stmt
|
||||
;
|
||||
|
||||
stmt: string { handleBuffer( * $1); delete $1;}
|
||||
stmt: string { handleBuffer( * $1);
|
||||
delete $1;
|
||||
}
|
||||
| whitespaces { handleText( * $1, true);
|
||||
delete $1;
|
||||
}
|
||||
| verbatim_style { handleBuffer( * $1); delete $1;}
|
||||
| verbatim_style { handleBuffer( * $1);
|
||||
delete $1;
|
||||
}
|
||||
| CHAPTER
|
||||
comment_sequence
|
||||
'}' { handleChapter( * $2); delete $2;}
|
||||
'}' { handleChapter( * $2);
|
||||
delete $2;
|
||||
}
|
||||
| BEGINCLASS
|
||||
classname { handleClass( $2->string());
|
||||
delete $2;}
|
||||
delete $2;
|
||||
}
|
||||
decl_sequence
|
||||
ENDCLASS
|
||||
{
|
||||
|
|
@ -196,7 +218,8 @@ stmt: string { handleBuffer( * $1); delete $1;}
|
|||
}
|
||||
| BEGINCLASSTEMPLATE
|
||||
classname { handleClassTemplate( $2->string());
|
||||
delete $2;}
|
||||
delete $2;
|
||||
}
|
||||
decl_sequence
|
||||
ENDCLASSTEMPLATE
|
||||
{
|
||||
|
|
@ -212,6 +235,26 @@ stmt: string { handleBuffer( * $1); delete $1;}
|
|||
handleString( "</VAR>");
|
||||
delete $3;
|
||||
}
|
||||
| HEADING '{' comment_sequence '}' {
|
||||
handleString( "<H3>");
|
||||
handleText( * $3);
|
||||
handleString( "</H3>");
|
||||
delete $3;
|
||||
}
|
||||
| COMMENTHEADING '{' comment_sequence '}' {
|
||||
handleString( "<BR><STRONG>");
|
||||
handleText( * $3);
|
||||
handleString( "</STRONG>");
|
||||
delete $3;
|
||||
}
|
||||
| CHAPTERAUTHOR '{' comment_sequence '}' {
|
||||
if ( tag_chapter_author) {
|
||||
handleString( "<P><EM>");
|
||||
handleText( * $3);
|
||||
handleString( "</EM><P>");
|
||||
}
|
||||
delete $3;
|
||||
}
|
||||
| global_tagged_declarator
|
||||
| group
|
||||
;
|
||||
|
|
@ -329,6 +372,12 @@ whitespaces: whitespace { $$ = new Text( * $1, managed); }
|
|||
|
||||
whitespace: SPACE { $$ = new TextToken( $1.text, $1.len, true); }
|
||||
| NEWLINE { $$ = new TextToken( "\n", 1, true); }
|
||||
| GOBBLETHREEPARAMS comment_group comment_group comment_group
|
||||
{ $$ = new TextToken( " ", 1, true);
|
||||
delete $2;
|
||||
delete $3;
|
||||
delete $4;
|
||||
}
|
||||
| GOBBLETWOPARAMS comment_group comment_group
|
||||
{ $$ = new TextToken( " ", 1, true);
|
||||
delete $2;
|
||||
|
|
@ -337,6 +386,33 @@ whitespace: SPACE { $$ = new TextToken( $1.text, $1.len, true); }
|
|||
| GOBBLEONEPARAM comment_group
|
||||
{ $$ = new TextToken( " ", 1, true);
|
||||
delete $2;
|
||||
if ( ignore_input_tag) {
|
||||
ignore_input_tag = false;
|
||||
set_INITIAL = 1;
|
||||
}
|
||||
}
|
||||
| NEWCOMMAND comment_group comment_group
|
||||
{ $$ = new TextToken( " ", 1, true);
|
||||
handleNewCommand( text_block_to_string(*$2),
|
||||
text_block_to_string(*$3));
|
||||
delete $2;
|
||||
delete $3;
|
||||
if ( ignore_input_tag) {
|
||||
ignore_input_tag = false;
|
||||
set_INITIAL = 1;
|
||||
}
|
||||
}
|
||||
| NEWCOMMAND comment_group
|
||||
'[' comment_sequence ']'
|
||||
comment_group
|
||||
{ $$ = new TextToken( " ", 1, true);
|
||||
delete $2;
|
||||
delete $4;
|
||||
delete $6;
|
||||
if ( ignore_input_tag) {
|
||||
ignore_input_tag = false;
|
||||
set_INITIAL = 1;
|
||||
}
|
||||
}
|
||||
| IGNOREBLOCK comment_sequence '}' {
|
||||
$$ = new TextToken( " ", 1, true);
|
||||
|
|
@ -389,7 +465,9 @@ tagged_declarator:
|
|||
global_tagged_declarator:
|
||||
SECTION
|
||||
comment_sequence
|
||||
'}' { handleSection( * $2); delete $2;}
|
||||
'}' { handleSection( * $2);
|
||||
; //delete $2;
|
||||
}
|
||||
| SUBSECTION
|
||||
comment_sequence
|
||||
'}' {
|
||||
|
|
@ -408,7 +486,9 @@ global_tagged_declarator:
|
|||
}
|
||||
| BEGINBIBLIO
|
||||
comment_sequence
|
||||
ENDBIBLIO { handleBiblio( * $2); delete $2;}
|
||||
ENDBIBLIO { handleBiblio( * $2);
|
||||
delete $2;
|
||||
}
|
||||
| FUNCTION declaration comment_group {
|
||||
handleFunctionDeclaration( $2->string(),
|
||||
* $3);
|
||||
|
|
@ -436,7 +516,14 @@ global_tagged_declarator:
|
|||
delete $3;
|
||||
}
|
||||
| TYPEDEF declaration comment_group {
|
||||
handleVariableDeclaration( $2->string(), * $3);
|
||||
handleTypedefDeclaration(
|
||||
$2->string(), * $3);
|
||||
delete $2;
|
||||
delete $3;
|
||||
}
|
||||
| NESTEDTYPE declaration comment_group {
|
||||
handleNestedTypeDeclaration(
|
||||
$2->string(), * $3);
|
||||
delete $2;
|
||||
delete $3;
|
||||
}
|
||||
|
|
@ -445,6 +532,11 @@ global_tagged_declarator:
|
|||
delete $2;
|
||||
delete $3;
|
||||
}
|
||||
| STRUCT declaration comment_group {
|
||||
handleStructDeclaration( $2->string(), * $3);
|
||||
delete $2;
|
||||
delete $3;
|
||||
}
|
||||
| GLOBALFUNCTION declaration {
|
||||
handleFunctionDeclaration( $2->string());
|
||||
delete $2;
|
||||
|
|
@ -472,6 +564,10 @@ global_tagged_declarator:
|
|||
handleEnumDeclaration( $2->string());
|
||||
delete $2;
|
||||
}
|
||||
| GLOBALSTRUCT declaration {
|
||||
handleEnumDeclaration( $2->string());
|
||||
delete $2;
|
||||
}
|
||||
| DECLARATION declaration {
|
||||
handleDeclaration( $2->string());
|
||||
delete $2;
|
||||
|
|
@ -492,7 +588,9 @@ hidden_keys: CONSTRUCTOR
|
|||
| FUNCTION
|
||||
| VARIABLE
|
||||
| TYPEDEF
|
||||
| NESTEDTYPE
|
||||
| ENUM
|
||||
| STRUCT
|
||||
;
|
||||
|
||||
/* A sequence of words forming a comment */
|
||||
|
|
@ -604,6 +702,41 @@ compound_comment: '{' full_comment_sequence '}' {
|
|||
$$->append( *new TextToken( ")</H1>"));
|
||||
$$->append( *new TextToken( "\n", 1, true));
|
||||
}
|
||||
| CCSUBSECTION '{' comment_sequence '}' {
|
||||
$$ = $3;
|
||||
$$->cons( *new TextToken( " ", 1, true));
|
||||
$$->cons( *new TextToken( "<H2>"));
|
||||
$$->cons( *new TextToken( "\n", 1, true));
|
||||
$$->append( *new TextToken( " ("));
|
||||
$$->append( *new TextToken(
|
||||
formatted_class_name));
|
||||
$$->append( *new TextToken( ")</H2>"));
|
||||
$$->append( *new TextToken( "\n", 1, true));
|
||||
}
|
||||
| HEADING '{' comment_sequence '}' {
|
||||
$$ = $3;
|
||||
$$->cons( *new TextToken( " ", 1, true));
|
||||
$$->cons( *new TextToken( "<H3>"));
|
||||
$$->append( *new TextToken( "</H3>"));
|
||||
$$->append( *new TextToken( "\n", 1, true));
|
||||
}
|
||||
| COMMENTHEADING '{' comment_sequence '}' {
|
||||
$$ = $3;
|
||||
$$->cons( *new TextToken( " ", 1, true));
|
||||
$$->cons( *new TextToken( "<BR><STRONG>"));
|
||||
$$->append( *new TextToken( "</STRONG>"));
|
||||
$$->append( *new TextToken( "\n", 1, true));
|
||||
}
|
||||
| CHAPTERAUTHOR comment_group {
|
||||
if ( tag_chapter_author) {
|
||||
$$ = $2;
|
||||
$$->cons( *new TextToken( "<P><EM>"));
|
||||
$$->append( *new TextToken( "</EM><P> "));
|
||||
} else {
|
||||
$$ = new Text( managed);
|
||||
delete $2;
|
||||
}
|
||||
}
|
||||
| CREATIONVARIABLE { $$ = new Text( managed);}
|
||||
;
|
||||
|
||||
|
|
@ -750,6 +883,11 @@ verbatim_style: CPROGBEGIN string_with_nl_or_mt CPROGEND {
|
|||
$$->prepend( "<PRE>" , 5);
|
||||
$$->add( "</PRE>", 6);
|
||||
}
|
||||
| CPROGFILE {
|
||||
$$ = readFileInBuffer($1.text);
|
||||
$$->prepend( "<PRE>" , 5);
|
||||
$$->add( "</PRE>", 6);
|
||||
}
|
||||
| HTMLBEGIN string_with_nl_or_mt HTMLEND {
|
||||
$$ = $2;
|
||||
}
|
||||
|
|
@ -774,7 +912,7 @@ verbatim_style: CPROGBEGIN string_with_nl_or_mt CPROGEND {
|
|||
char* s = text_block_to_string( * $4);
|
||||
$$->add( s);
|
||||
$$->add( "</A>");
|
||||
delete s;
|
||||
delete[] s;
|
||||
delete $4;
|
||||
}
|
||||
;
|
||||
|
|
@ -918,3 +1056,4 @@ Text* blockintroProcessing( const char* text, int len, Text* t) {
|
|||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue