1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
/* Automatically generated by Kelbt from "xmlparse.kh".
*
* Parts of this file are copied from Kelbt source covered by the GNU
* GPL. As a special exception, you may use the parts of this file copied
* from Kelbt source without restriction. The remainder is derived from
* "xmlparse.kh" and inherits the copyright status of that file.
*/
#line 1 "xmlparse.kh"
/*
* Copyright 2001-2007 Adrian Thurston <thurston@cs.queensu.ca>
*/
/* This file is part of Ragel.
*
* Ragel is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Ragel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Ragel; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _XMLPARSE_H
#define _XMLPARSE_H
#include "vector.h"
#include "gendata.h"
#include <iostream>
using std::ostream;
struct AttrMarker
{
char *id;
int idLen;
char *value;
int valueLen;
};
struct Attribute
{
char *id;
char *value;
};
typedef Vector<AttrMarker> AttrMkList;
typedef Vector<Attribute> AttrList;
struct XMLTagHashPair;
struct XMLTag
{
enum TagType { Open, Close };
XMLTag( XMLTagHashPair *tagId, TagType type ) :
tagId(tagId), type(type),
content(0), attrList(0) {}
Attribute *findAttr(const char *id )
{
if ( attrList != 0 ) {
for ( AttrList::Iter attr = *attrList; attr.lte(); attr++ ) {
if ( strcmp( id, attr->id ) == 0 )
return attr;
}
}
return 0;
}
XMLTagHashPair *tagId;
TagType type;
/* Content is associtated with closing tags. */
char *content;
/* Attribute lists are associated with opening tags. */
AttrList *attrList;
};
struct XMLTagHashPair
{
const char *name;
int id;
};
struct Token
{
XMLTag *tag;
InputLoc loc;
};
struct InlineItem;
struct InlineList;
struct LmSwitchVect;
struct LmSwitchAction;
struct Parser
{
#line 117 "xmlparse.kh"
#line 111 "xmlparse.h"
struct Parser_LangEl *freshEl;
int freshPos;
struct Parser_LangEl *pool;
int numRetry;
int numNodes;
struct Parser_LangEl *stackTop;
struct Parser_LangEl *lastFinal;
int errCount;
int curs;
#line 120 "xmlparse.kh"
void init();
int parseLangEl( int type, const Token *token );
Parser(const char *fileName, bool outputActive, bool wantComplete ) :
fileName(fileName), sourceFileName(0), outStream(0),
outputActive(outputActive), wantComplete(wantComplete),
cgd(0) { }
int token( int tokenId, Token &token );
int token( int tokenId, int col, int line );
int token( XMLTag *tag, int col, int line );
/* Report an error encountered by the parser. */
ostream &warning( const InputLoc &loc );
ostream &error();
ostream &error( const InputLoc &loc );
ostream &parser_error( int tokId, Token &token );
/* The name of the root section, this does not change during an include. */
const char *fileName;
char *sourceFileName;
ostream *outStream;
bool outputActive;
bool wantComplete;
/* Collected during parsing. */
char *attrKey;
char *attrValue;
int curAction;
int curActionTable;
int curTrans;
int curState;
int curCondSpace;
int curStateCond;
CodeGenData *cgd;
CodeGenMap codeGenMap;
Vector <char*> writeOptions;
};
#line 164 "xmlparse.h"
#define TAG_unknown 128
#define TAG_ragel 129
#define TAG_ragel_def 130
#define TAG_host 131
#define TAG_state_list 132
#define TAG_state 133
#define TAG_trans_list 134
#define TAG_t 135
#define TAG_machine 136
#define TAG_start_state 137
#define TAG_error_state 138
#define TAG_action_list 139
#define TAG_action_table_list 140
#define TAG_action 141
#define TAG_action_table 142
#define TAG_alphtype 143
#define TAG_element 144
#define TAG_getkey 145
#define TAG_state_actions 146
#define TAG_entry_points 147
#define TAG_sub_action 148
#define TAG_cond_space_list 149
#define TAG_cond_space 150
#define TAG_cond_list 151
#define TAG_c 152
#define TAG_exports 153
#define TAG_ex 154
#define TAG_text 155
#define TAG_goto 156
#define TAG_call 157
#define TAG_next 158
#define TAG_goto_expr 159
#define TAG_call_expr 160
#define TAG_next_expr 161
#define TAG_ret 162
#define TAG_pchar 163
#define TAG_char 164
#define TAG_hold 165
#define TAG_exec 166
#define TAG_holdte 167
#define TAG_execte 168
#define TAG_curs 169
#define TAG_targs 170
#define TAG_entry 171
#define TAG_data 172
#define TAG_lm_switch 173
#define TAG_init_act 174
#define TAG_set_act 175
#define TAG_set_tokend 176
#define TAG_get_tokend 177
#define TAG_init_tokstart 178
#define TAG_set_tokstart 179
#define TAG_write 180
#define TAG_curstate 181
#define TAG_access 182
#define TAG_break 183
#define TAG_arg 184
#define _eof 185
#line 163 "xmlparse.kh"
int xml_parse( std::istream &input, const char *fileName,
bool outputActive, bool wantComplete );
#endif /* _XMLPARSE_H */
|