/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk

« back to all changes in this revision

Viewing changes to parse/parabix.cpp

  • Committer: Suren A. Chilingaryan
  • Date: 2009-02-16 09:27:17 UTC
  • Revision ID: csa@dside.dyndns.org-20090216092717-wipyvaaw2srxhgns
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  markup_stats.c - parabix demo program
 
2
    Copyright (c) 2007, Robert D. Cameron.
 
3
    Licensed to the public under the Open Software License 3.0.
 
4
    Licensed to International Characters, Inc., under the Academic
 
5
    Free License 3.0.
 
6
 
 
7
*/
 
8
 
 
9
#include <stdio.h>
 
10
#include <stdlib.h>
 
11
#include <string.h>
 
12
#include <errno.h>
 
13
#include <sys/types.h>
 
14
#include <sys/stat.h>
 
15
#include <string>
 
16
#include <iostream>
 
17
using namespace std;
 
18
 
 
19
#define ON 1
 
20
#define OFF 2
 
21
 
 
22
#define TEMPLATED_SIMD_LIB
 
23
#define VALIDATION_MODE OFF
 
24
 
 
25
//#include "src/ilax.h"
 
26
#include "src/engine.h"
 
27
 
 
28
#include "tools.h"
 
29
 
 
30
 
 
31
/* Internals */
 
32
#include "src/xmlmodel.h"
 
33
#include "src/xml_error.h"
 
34
#include "src/bitplex.h"
 
35
#include "src/byteplex.h"
 
36
#include "src/xmldecl.h"
 
37
#include "src/bitlex.h"
 
38
 
 
39
 
 
40
#include "src/xmlmodel.c"
 
41
#include "src/xml_error.c"
 
42
#include "src/bitplex.c"
 
43
#include "src/byteplex.c"
 
44
#include "src/xmldecl.c"
 
45
#include "src/bitlex.c"
 
46
#include "src/engine.c"
 
47
#include "src/symtab.c"
 
48
 
 
49
/* Global declarations of parsing engine. */
 
50
Parser_Interface<UTF_8> * parser;
 
51
 
 
52
 
 
53
#ifdef LEAF_COUNTING
 
54
int at_start = 1;
 
55
int leaf_count = 0;
 
56
int interior_count = 0;
 
57
#endif
 
58
 
 
59
template<>
 
60
inline void Parser_Interface<UTF_8>::Comment_action(unsigned char * item, int lgth) {
 
61
}
 
62
 
 
63
template<>
 
64
inline void Parser_Interface<UTF_8>::CDATA_start_action(unsigned char * CDATA_ptr){
 
65
}
 
66
 
 
67
template<>
 
68
inline void Parser_Interface<UTF_8>::CDATA_end_action(unsigned char * CDATA_end_ptr) {
 
69
}
 
70
 
 
71
template<>
 
72
inline void Parser_Interface<UTF_8>::PI_action(unsigned char * item, int lgth) {
 
73
}
 
74
 
 
75
template<>
 
76
inline void Parser_Interface<UTF_8>::EmptyElement_action(unsigned char * item, int lgth) {
 
77
}
 
78
 
 
79
template<>
 
80
inline void Parser_Interface<UTF_8>::StartTag_action(unsigned char * item, int lgth) {
 
81
    return;
 
82
}
 
83
 
 
84
template<>
 
85
inline void Parser_Interface<UTF_8>::EndTag_action(unsigned char * item, int lgth) {
 
86
    return;
 
87
}
 
88
 
 
89
template<>
 
90
inline void Parser_Interface<UTF_8>::Error_action(unsigned char * item, int lgth) {
 
91
}
 
92
 
 
93
template<>
 
94
inline void Parser_Interface<UTF_8>::Text_action(unsigned char * item, int lgth, bool more) {
 
95
    return;
 
96
}
 
97
 
 
98
template<>
 
99
inline void Parser_Interface<UTF_8>::Reference_action(unsigned char * item, int lgth) {
 
100
}
 
101
 
 
102
 
 
103
template<>
 
104
inline void Parser_Interface<UTF_8>::ElementName_action(unsigned char * item, int lgth) {
 
105
}
 
106
 
 
107
template<>
 
108
inline void Parser_Interface<UTF_8>::PI_Target_action(unsigned char * item, int lgth) {
 
109
}
 
110
 
 
111
template<>
 
112
inline void Parser_Interface<UTF_8>::AttributeValue_action(unsigned char * name, int name_lgth, 
 
113
                                 unsigned char * val, int val_lgth) {
 
114
}
 
115
 
 
116
template<>
 
117
inline void Parser_Interface<UTF_8>::Namespace_action(unsigned char * name, int name_lgth,
 
118
                             unsigned char * URI, int URI_lgth) {
 
119
}
 
120
 
 
121
 
 
122
template<>
 
123
void Parser_Interface<UTF_8>::FinalizeBuffer_action() {
 
124
}
 
125
 
 
126
 
 
127
template<>
 
128
inline void Parser_Interface<UTF_8>::DocumentStart_action() {
 
129
}
 
130
 
 
131
template<>
 
132
inline void Parser_Interface<UTF_8>::DocumentEnd_action() {
 
133
}
 
134
 
 
135
template<>
 
136
inline void Parser_Interface<UTF_8>::Doctype_action(unsigned char * item, int lgth) {
 
137
}
 
138
 
 
139
template<>
 
140
inline void Parser_Interface<UTF_8>::PEReference_action(unsigned char * item, int lgth) {
 
141
}
 
142
 
 
143
 
 
144
template<>
 
145
inline void Parser_Interface<UTF_8>::ExtSubsetDecl_action(unsigned char * item, int lgth) {
 
146
}
 
147
 
 
148
template<>
 
149
inline void Parser_Interface<UTF_8>::Prolog_action(unsigned char * item, int lgth) {
 
150
}
 
151
 
 
152
 
 
153
 
 
154
void initXML(struct TestData *td) {
 
155
}
 
156
 
 
157
void releaseXML(struct TestData *td) {
 
158
}
 
159
 
 
160
 
 
161
void parseXML(struct TestData *td, unsigned long iter) {
 
162
/*
 
163
    int i = 0;
 
164
    Entity_Info * e;
 
165
    Model_Info * m;
 
166
    while ((td->xml[i] == ' ')||(td->xml[i] == '\r')||(td->xml[i] == '\n')||(td->xml[i] == '\t')) i++;
 
167
    if ((td->xml[i]=='<')&&(td->xml[i+1]=='?')) {
 
168
        for (i+=2;((td->xml[i]!='?')||(td->xml[i+1]!='>'))&&(td->xml[i]);i++);
 
169
        for (i+=2;(td->xml[i] == ' ')||(td->xml[i] == '\r')||(td->xml[i] == '\n')||(td->xml[i] == '\t');i++);
 
170
        if ((td->xml[i]=='<')&&(td->xml[i+1]=='?')) {
 
171
            for (i+=2;((td->xml[i]!='?')||(td->xml[i+1]!='>'))&&(td->xml[i]);i++);
 
172
            for (i+=2;(td->xml[i] == ' ')||(td->xml[i] == '\r')||(td->xml[i] == '\n')||(td->xml[i] == '\t');i++);
 
173
        }
 
174
    }
 
175
    e = new Entity_Info;
 
176
    m = new Model_Info;
 
177
    e->AnalyzeSignature((unsigned char*)"<?xml");
 
178
*/    
 
179
 
 
180
    parser = Parser_Interface<UTF_8>::ParserFactory("/tmp/parabix.test");//td->xml+i, td->xmllen-i, e, m);
 
181
    parser->Parse_Prolog();
 
182
    parser->Parse_DocumentContent();
 
183
//    parser->~Parser_Interface();
 
184
    delete parser;
 
185
/*
 
186
    delete m;
 
187
    delete e;
 
188
*/
 
189
}
 
190
 
 
191
int main(int argc, char *argv[]) {
 
192
    return Test(argc,argv);
 
193
}