Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
111
cde/programs/dtinfo/DtMmdb/StyleSheet/docparser.C
Normal file
111
cde/programs/dtinfo/DtMmdb/StyleSheet/docparser.C
Normal file
@@ -0,0 +1,111 @@
|
||||
// $XConsortium: docparser.C /main/4 1996/08/21 15:51:05 drk $
|
||||
#include "Debug.h"
|
||||
#include "DocParser.h"
|
||||
#include "Element.h"
|
||||
#include "PathTable.h"
|
||||
#include "Renderer.h"
|
||||
#include "Resolver.h"
|
||||
#include "StyleSheet.h"
|
||||
#include "StyleSheetExceptions.h"
|
||||
#include "VariableTable.h"
|
||||
#include <iostream.h>
|
||||
|
||||
Renderer *gRenderer = 0;
|
||||
class TestRenderer : public Renderer
|
||||
{
|
||||
public:
|
||||
|
||||
// inherited virtuals
|
||||
|
||||
void Begin() {} ;
|
||||
void End() {} ;
|
||||
|
||||
FeatureSet *initialize();
|
||||
unsigned int BeginElement(const Element &element,
|
||||
const FeatureSet &featureset,
|
||||
const FeatureSet &complete,
|
||||
const FeatureSet &parentComplete);
|
||||
|
||||
void data(const char *data, unsigned int size);
|
||||
|
||||
void EndElement(const Symbol &element_name);
|
||||
};
|
||||
|
||||
FeatureSet *
|
||||
TestRenderer::initialize()
|
||||
{
|
||||
return new FeatureSet;
|
||||
}
|
||||
unsigned int
|
||||
TestRenderer::BeginElement(const Element &element,
|
||||
const FeatureSet &localset,
|
||||
const FeatureSet &complete,
|
||||
const FeatureSet &/* parentComplete */)
|
||||
{
|
||||
ON_DEBUG(cerr << "TestRenderer::BeginElement()" << endl);
|
||||
|
||||
ON_DEBUG(cerr << localset<< endl);
|
||||
ON_DEBUG(cerr << complete << endl);
|
||||
|
||||
if (localset.lookup(gSymTab->intern("ignore")))
|
||||
return 1 ; // ignore
|
||||
|
||||
cout << element << endl;
|
||||
|
||||
return 0 ; // do not ignore
|
||||
}
|
||||
void
|
||||
TestRenderer::data(const char * data, unsigned int /* size */)
|
||||
{
|
||||
ON_DEBUG(cerr << "TestRenderer::data()" << endl);
|
||||
cout << data ;
|
||||
}
|
||||
void
|
||||
TestRenderer::EndElement(const Symbol &name)
|
||||
{
|
||||
ON_DEBUG(cerr << "TestRenderer::EndElement(" << name << ')' << endl);
|
||||
cout << "</" << name << '>';
|
||||
}
|
||||
void
|
||||
styleerror(char *errorstr)
|
||||
{
|
||||
cerr << errorstr ;
|
||||
}
|
||||
|
||||
// extern FILE *stylein;
|
||||
extern int styleparse();
|
||||
|
||||
extern PathTable *gPathTab;
|
||||
extern VariableTable *gVariableTable ;
|
||||
|
||||
extern istream *g_stylein;
|
||||
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
INIT_EXCEPTIONS();
|
||||
|
||||
StyleSheet ss ;
|
||||
|
||||
ifstream stylestream(argv[1]);
|
||||
g_stylein = &stylestream;
|
||||
g_stylein->unsetf(ios::skipws);
|
||||
styleparse();
|
||||
|
||||
try
|
||||
{
|
||||
TestRenderer renderer ;
|
||||
Resolver resolver(*gPathTab, renderer);
|
||||
DocParser docparser(resolver);
|
||||
docparser.parse(cin);
|
||||
}
|
||||
catch_any()
|
||||
{
|
||||
cerr << "docparser.C: exception thrown" << endl;
|
||||
rethrow;
|
||||
}
|
||||
end_try;
|
||||
|
||||
cout << endl;
|
||||
|
||||
exit (0);
|
||||
}
|
||||
Reference in New Issue
Block a user