Debian Codegraph @

CodeLite/XmlLexer.cpp

raw
1 #line 2 "XmlLexer.cpp"
2
3 #line 4 "XmlLexer.cpp"
4
5 #define YY_INT_ALIGNED short int
6
7 /* A lexical scanner generated by flex */
8
9 #define FLEX_SCANNER
10 #define YY_FLEX_MAJOR_VERSION 2
11 #define YY_FLEX_MINOR_VERSION 5
12 #define YY_FLEX_SUBMINOR_VERSION 35
13 #if YY_FLEX_SUBMINOR_VERSION > 0
14 #define FLEX_BETA
15 #endif
16
17 /* First, we deal with platform-specific or compiler-specific issues. */
18
19 /* begin standard C headers. */
20 #include <stdio.h>
21 #include <string.h>
22 #include <errno.h>
23 #include <stdlib.h>
24
25 /* end standard C headers. */
26
27 /* flex integer type definitions */
28
29 #ifndef FLEXINT_H
30 #define FLEXINT_H
31
32 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
33
34 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
35
36 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
37 * if you want the limit (max/min) macros for int types.
38 */
39 #ifndef __STDC_LIMIT_MACROS
40 #define __STDC_LIMIT_MACROS 1
41 #endif
42
43 #include <inttypes.h>
44 typedef int8_t flex_int8_t;
45 typedef uint8_t flex_uint8_t;
46 typedef int16_t flex_int16_t;
47 typedef uint16_t flex_uint16_t;
48 typedef int32_t flex_int32_t;
49 typedef uint32_t flex_uint32_t;
50 #else
51 typedef signed char flex_int8_t;
52 typedef short int flex_int16_t;
53 typedef int flex_int32_t;
54 typedef unsigned char flex_uint8_t;
55 typedef unsigned short int flex_uint16_t;
56 typedef unsigned int flex_uint32_t;
57
58 /* Limits of integral types. */
59 #ifndef INT8_MIN
60 #define INT8_MIN (-128)
61 #endif
62 #ifndef INT16_MIN
63 #define INT16_MIN (-32767-1)
64 #endif
65 #ifndef INT32_MIN
66 #define INT32_MIN (-2147483647-1)
67 #endif
68 #ifndef INT8_MAX
69 #define INT8_MAX (127)
70 #endif
71 #ifndef INT16_MAX
72 #define INT16_MAX (32767)
73 #endif
74 #ifndef INT32_MAX
75 #define INT32_MAX (2147483647)
76 #endif
77 #ifndef UINT8_MAX
78 #define UINT8_MAX (255U)
79 #endif
80 #ifndef UINT16_MAX
81 #define UINT16_MAX (65535U)
82 #endif
83 #ifndef UINT32_MAX
84 #define UINT32_MAX (4294967295U)
85 #endif
86
87 #endif /* ! C99 */
88
89 #endif /* ! FLEXINT_H */
90
91 #ifdef __cplusplus
92
93 /* The "const" storage-class-modifier is valid. */
94 #define YY_USE_CONST
95
96 #else /* ! __cplusplus */
97
98 /* C99 requires __STDC__ to be defined as 1. */
99 #if defined (__STDC__)
100
101 #define YY_USE_CONST
102
103 #endif /* defined (__STDC__) */
104 #endif /* ! __cplusplus */
105
106 #ifdef YY_USE_CONST
107 #define yyconst const
108 #else
109 #define yyconst
110 #endif
111
112 /* Returned upon end-of-file. */
113 #define YY_NULL 0
114
115 /* Promotes a possibly negative, possibly signed char to an unsigned
116 * integer for use as an array index. If the signed char is negative,
117 * we want to instead treat it as an 8-bit unsigned char, hence the
118 * double cast.
119 */
120 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
121
122 /* An opaque pointer. */
123 #ifndef YY_TYPEDEF_YY_SCANNER_T
124 #define YY_TYPEDEF_YY_SCANNER_T
125 typedef void* yyscan_t;
126 #endif
127
128 /* For convenience, these vars (plus the bison vars far below)
129 are macros in the reentrant scanner. */
130 #define yyin yyg->yyin_r
131 #define yyout yyg->yyout_r
132 #define yyextra yyg->yyextra_r
133 #define yyleng yyg->yyleng_r
134 #define yytext yyg->yytext_r
135 #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
136 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
137 #define yy_flex_debug yyg->yy_flex_debug_r
138
139 /* Enter a start condition. This macro really ought to take a parameter,
140 * but we do it the disgusting crufty way forced on us by the ()-less
141 * definition of BEGIN.
142 */
143 #define BEGIN yyg->yy_start = 1 + 2 *
144
145 /* Translate the current start state into a value that can be later handed
146 * to BEGIN to return to the state. The YYSTATE alias is for lex
147 * compatibility.
148 */
149 #define YY_START ((yyg->yy_start - 1) / 2)
150 #define YYSTATE YY_START
151
152 /* Action number for EOF rule of a given start state. */
153 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
154
155 /* Special action meaning "start processing a new file". */
156 #define YY_NEW_FILE xmlrestart(yyin ,yyscanner )
157
158 #define YY_END_OF_BUFFER_CHAR 0
159
160 /* Size of default input buffer. */
161 #ifndef YY_BUF_SIZE
162 #ifdef __ia64__
163 /* On IA-64, the buffer size is 16k, not 8k.
164 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
165 * Ditto for the __ia64__ case accordingly.
166 */
167 #define YY_BUF_SIZE 32768
168 #else
169 #define YY_BUF_SIZE 16384
170 #endif /* __ia64__ */
171 #endif
172
173 /* The state buf must be large enough to hold one state per character in the main buffer.
174 */
175 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
176
177 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
178 #define YY_TYPEDEF_YY_BUFFER_STATE
179 typedef struct yy_buffer_state *YY_BUFFER_STATE;
180 #endif
181
182 #define EOB_ACT_CONTINUE_SCAN 0
183 #define EOB_ACT_END_OF_FILE 1
184 #define EOB_ACT_LAST_MATCH 2
185
186 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
187 * access to the local variable yy_act. Since yyless() is a macro, it would break
188 * existing scanners that call yyless() from OUTSIDE xmllex.
189 * One obvious solution it to make yy_act a global. I tried that, and saw
190 * a 5% performance hit in a non-yylineno scanner, because yy_act is
191 * normally declared as a register variable-- so it is not worth it.
192 */
193 #define YY_LESS_LINENO(n) \
194 do { \
195 int yyl;\
196 for ( yyl = n; yyl < yyleng; ++yyl )\
197 if ( yytext[yyl] == '\n' )\
198 --yylineno;\
199 }while(0)
200
201 /* Return all but the first "n" matched characters back to the input stream. */
202 #define yyless(n) \
203 do \
204 { \
205 /* Undo effects of setting up yytext. */ \
206 int yyless_macro_arg = (n); \
207 YY_LESS_LINENO(yyless_macro_arg);\
208 *yy_cp = yyg->yy_hold_char; \
209 YY_RESTORE_YY_MORE_OFFSET \
210 yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
211 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
212 } \
213 while ( 0 )
214
215 #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
216
217 #ifndef YY_TYPEDEF_YY_SIZE_T
218 #define YY_TYPEDEF_YY_SIZE_T
219 typedef size_t yy_size_t;
220 #endif
221
222 #ifndef YY_STRUCT_YY_BUFFER_STATE
223 #define YY_STRUCT_YY_BUFFER_STATE
224 struct yy_buffer_state
225 {
226 FILE *yy_input_file;
227
228 char *yy_ch_buf; /* input buffer */
229 char *yy_buf_pos; /* current position in input buffer */
230
231 /* Size of input buffer in bytes, not including room for EOB
232 * characters.
233 */
234 yy_size_t yy_buf_size;
235
236 /* Number of characters read into yy_ch_buf, not including EOB
237 * characters.
238 */
239 int yy_n_chars;
240
241 /* Whether we "own" the buffer - i.e., we know we created it,
242 * and can realloc() it to grow it, and should free() it to
243 * delete it.
244 */
245 int yy_is_our_buffer;
246
247 /* Whether this is an "interactive" input source; if so, and
248 * if we're using stdio for input, then we want to use getc()
249 * instead of fread(), to make sure we stop fetching input after
250 * each newline.
251 */
252 int yy_is_interactive;
253
254 /* Whether we're considered to be at the beginning of a line.
255 * If so, '^' rules will be active on the next match, otherwise
256 * not.
257 */
258 int yy_at_bol;
259
260 int yy_bs_lineno; /**< The line count. */
261 int yy_bs_column; /**< The column count. */
262
263 /* Whether to try to fill the input buffer when we reach the
264 * end of it.
265 */
266 int yy_fill_buffer;
267
268 int yy_buffer_status;
269
270 #define YY_BUFFER_NEW 0
271 #define YY_BUFFER_NORMAL 1
272 /* When an EOF's been seen but there's still some text to process
273 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
274 * shouldn't try reading from the input source any more. We might
275 * still have a bunch of tokens to match, though, because of
276 * possible backing-up.
277 *
278 * When we actually see the EOF, we change the status to "new"
279 * (via xmlrestart()), so that the user can continue scanning by
280 * just pointing yyin at a new input file.
281 */
282 #define YY_BUFFER_EOF_PENDING 2
283
284 };
285 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
286
287 /* We provide macros for accessing buffer states in case in the
288 * future we want to put the buffer states in a more general
289 * "scanner state".
290 *
291 * Returns the top of the stack, or NULL.
292 */
293 #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
294 ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
295 : NULL)
296
297 /* Same as previous macro, but useful when we know that the buffer stack is not
298 * NULL or when we need an lvalue. For internal use only.
299 */
300 #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
301
302 void xmlrestart (FILE *input_file ,yyscan_t yyscanner );
303 void xml_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
304 YY_BUFFER_STATE xml_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
305 void xml_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
306 void xml_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
307 void xmlpush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
308 void xmlpop_buffer_state (yyscan_t yyscanner );
309
310 static void xmlensure_buffer_stack (yyscan_t yyscanner );
311 static void xml_load_buffer_state (yyscan_t yyscanner );
312 static void xml_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
313
314 #define YY_FLUSH_BUFFER xml_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
315
316 YY_BUFFER_STATE xml_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
317 YY_BUFFER_STATE xml_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
318 YY_BUFFER_STATE xml_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
319
320 void *xmlalloc (yy_size_t ,yyscan_t yyscanner );
321 void *xmlrealloc (void *,yy_size_t ,yyscan_t yyscanner );
322 void xmlfree (void * ,yyscan_t yyscanner );
323
324 #define yy_new_buffer xml_create_buffer
325
326 #define yy_set_interactive(is_interactive) \
327 { \
328 if ( ! YY_CURRENT_BUFFER ){ \
329 xmlensure_buffer_stack (yyscanner); \
330 YY_CURRENT_BUFFER_LVALUE = \
331 xml_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
332 } \
333 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
334 }
335
336 #define yy_set_bol(at_bol) \
337 { \
338 if ( ! YY_CURRENT_BUFFER ){\
339 xmlensure_buffer_stack (yyscanner); \
340 YY_CURRENT_BUFFER_LVALUE = \
341 xml_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
342 } \
343 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
344 }
345
346 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
347
348 /* Begin user sect3 */
349
350 typedef unsigned char YY_CHAR;
351
352 typedef int yy_state_type;
353
354 #define yytext_ptr yytext_r
355
356 static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
357 static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
358 static int yy_get_next_buffer (yyscan_t yyscanner );
359 static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
360
361 /* Done after the current pattern has been matched and before the
362 * corresponding action - sets up yytext.
363 */
364 #define YY_DO_BEFORE_ACTION \
365 yyg->yytext_ptr = yy_bp; \
366 yyleng = (size_t) (yy_cp - yy_bp); \
367 yyg->yy_hold_char = *yy_cp; \
368 *yy_cp = '\0'; \
369 yyg->yy_c_buf_p = yy_cp;
370
371 #define YY_NUM_RULES 23
372 #define YY_END_OF_BUFFER 24
373 /* This struct is not used in this scanner,
374 but its presence is necessary. */
375 struct yy_trans_info
376 {
377 flex_int32_t yy_verify;
378 flex_int32_t yy_nxt;
379 };
380 static yyconst flex_int16_t yy_accept[89] =
381 { 0,
382 0, 0, 0, 0, 0, 0, 0, 0, 24, 16,
383 1, 23, 16, 13, 16, 16, 16, 16, 18, 18,
384 20, 20, 22, 22, 0, 15, 0, 13, 0, 0,
385 0, 0, 0, 14, 0, 2, 0, 3, 4, 0,
386 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
387 0, 0, 0, 0, 17, 19, 0, 0, 0, 0,
388 8, 7, 0, 0, 0, 12, 0, 0, 0, 0,
389 9, 0, 0, 0, 0, 0, 0, 10, 11, 0,
390 0, 0, 0, 0, 0, 5, 6, 0
391 } ;
392
393 static yyconst flex_int32_t yy_ec[256] =
394 { 0,
395 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
396 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
397 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
398 1, 4, 5, 6, 1, 7, 1, 8, 9, 1,
399 1, 1, 1, 1, 10, 1, 11, 12, 12, 12,
400 12, 12, 12, 12, 12, 13, 13, 1, 14, 15,
401 1, 16, 17, 1, 18, 19, 20, 21, 22, 19,
402 7, 7, 7, 7, 7, 7, 7, 7, 23, 24,
403 7, 7, 7, 25, 7, 7, 7, 7, 26, 7,
404 27, 28, 29, 1, 7, 1, 30, 31, 19, 19,
405
406 19, 31, 32, 7, 7, 7, 7, 33, 34, 35,
407 36, 37, 38, 35, 39, 40, 41, 35, 7, 42,
408 7, 7, 1, 1, 1, 1, 1, 1, 1, 1,
409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
410 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
411 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
413 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
414 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
416
417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
418 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
419 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
420 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
422 1, 1, 1, 1, 1
423 } ;
424
425 static yyconst flex_int32_t yy_meta[43] =
426 { 0,
427 1, 1, 2, 1, 1, 3, 4, 1, 3, 4,
428 1, 5, 6, 1, 1, 1, 3, 6, 6, 6,
429 6, 6, 4, 4, 4, 4, 1, 3, 1, 5,
430 5, 4, 4, 4, 7, 4, 4, 4, 4, 7,
431 4, 7
432 } ;
433
434 static yyconst flex_int16_t yy_base[99] =
435 { 0,
436 0, 0, 40, 41, 42, 43, 44, 45, 146, 208,
437 208, 208, 43, 0, 25, 45, 124, 55, 208, 110,
438 208, 128, 208, 121, 50, 208, 38, 0, 30, 94,
439 93, 88, 56, 208, 39, 208, 58, 208, 208, 111,
440 110, 208, 70, 0, 88, 88, 109, 103, 80, 65,
441 0, 105, 91, 91, 208, 208, 77, 100, 96, 69,
442 208, 208, 64, 79, 123, 208, 83, 81, 69, 0,
443 208, 87, 86, 81, 0, 74, 78, 208, 208, 69,
444 69, 68, 69, 64, 32, 208, 208, 208, 154, 161,
445 168, 175, 179, 186, 191, 196, 199, 201
446
447 } ;
448
449 static yyconst flex_int16_t yy_def[99] =
450 { 0,
451 88, 1, 89, 89, 90, 90, 91, 91, 88, 88,
452 88, 88, 92, 93, 88, 94, 88, 88, 88, 88,
453 88, 88, 88, 88, 92, 88, 95, 93, 88, 88,
454 88, 88, 94, 88, 96, 88, 88, 88, 88, 88,
455 88, 88, 92, 97, 88, 88, 88, 88, 88, 94,
456 98, 88, 88, 88, 88, 88, 92, 92, 88, 88,
457 88, 88, 88, 94, 94, 88, 88, 88, 92, 58,
458 88, 88, 88, 94, 65, 88, 88, 88, 88, 88,
459 88, 88, 88, 88, 88, 88, 88, 0, 88, 88,
460 88, 88, 88, 88, 88, 88, 88, 88
461
462 } ;
463
464 static yyconst flex_int16_t yy_nxt[251] =
465 { 0,
466 10, 11, 12, 11, 10, 13, 14, 15, 16, 10,
467 17, 10, 10, 10, 18, 10, 10, 14, 14, 14,
468 14, 14, 14, 14, 14, 14, 10, 10, 10, 14,
469 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
470 14, 14, 12, 12, 12, 12, 12, 12, 26, 43,
471 50, 22, 22, 34, 29, 26, 30, 31, 87, 37,
472 24, 24, 32, 45, 34, 38, 46, 52, 20, 20,
473 27, 39, 35, 34, 26, 26, 64, 27, 53, 44,
474 51, 57, 26, 35, 54, 86, 85, 34, 69, 34,
475 74, 84, 35, 83, 82, 81, 27, 27, 80, 79,
476
477 78, 77, 76, 73, 27, 26, 35, 72, 35, 71,
478 68, 70, 70, 67, 66, 63, 62, 70, 70, 70,
479 70, 70, 61, 60, 59, 56, 55, 27, 49, 70,
480 70, 34, 48, 47, 75, 75, 42, 41, 40, 36,
481 75, 75, 75, 75, 75, 88, 88, 88, 88, 88,
482 35, 88, 75, 75, 19, 19, 19, 19, 19, 19,
483 19, 21, 21, 21, 21, 21, 21, 21, 23, 23,
484 23, 23, 23, 23, 23, 25, 88, 25, 25, 25,
485 25, 25, 28, 28, 28, 28, 33, 88, 33, 33,
486 33, 33, 33, 25, 88, 25, 88, 25, 33, 88,
487
488 33, 88, 33, 58, 58, 65, 65, 9, 88, 88,
489 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
490 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
491 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
492 88, 88, 88, 88, 88, 88, 88, 88, 88, 88
493 } ;
494
495 static yyconst flex_int16_t yy_chk[251] =
496 { 0,
497 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
498 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
499 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
500 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
501 1, 1, 3, 4, 5, 6, 7, 8, 13, 27,
502 35, 5, 6, 16, 15, 25, 15, 15, 85, 18,
503 7, 8, 15, 29, 33, 18, 29, 37, 3, 4,
504 13, 18, 16, 50, 69, 43, 50, 25, 37, 27,
505 35, 43, 57, 33, 37, 84, 83, 64, 57, 74,
506 64, 82, 50, 81, 80, 77, 69, 43, 76, 73,
507
508 72, 68, 67, 63, 57, 58, 64, 60, 74, 59,
509 54, 58, 58, 53, 52, 49, 48, 58, 58, 58,
510 58, 58, 47, 46, 45, 41, 40, 58, 32, 58,
511 58, 65, 31, 30, 65, 65, 24, 22, 20, 17,
512 65, 65, 65, 65, 65, 9, 0, 0, 0, 0,
513 65, 0, 65, 65, 89, 89, 89, 89, 89, 89,
514 89, 90, 90, 90, 90, 90, 90, 90, 91, 91,
515 91, 91, 91, 91, 91, 92, 0, 92, 92, 92,
516 92, 92, 93, 93, 93, 93, 94, 0, 94, 94,
517 94, 94, 94, 95, 0, 95, 0, 95, 96, 0,
518
519 96, 0, 96, 97, 97, 98, 98, 88, 88, 88,
520 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
521 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
522 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
523 88, 88, 88, 88, 88, 88, 88, 88, 88, 88
524 } ;
525
526 /* Table of booleans, true if rule could match eol. */
527 static yyconst flex_int32_t yy_rule_can_match_eol[24] =
528 { 0,
529 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
530 0, 0, 0, 0, };
531
532 /* The intent behind this definition is that it'll catch
533 * any uses of REJECT which flex missed.
534 */
535 #define REJECT reject_used_but_not_detected
536 #define yymore() yymore_used_but_not_detected
537 #define YY_MORE_ADJ 0
538 #define YY_RESTORE_YY_MORE_OFFSET
539 #line 1 "XMLLexer.l"
540 #line 2 "XMLLexer.l"
541 //
542 //====================--------------------------------------------------------------
543 // Eran Ifrah 2014 (c)
544 //====================--------------------------------------------------------------
545 //
546 // To generate a source file from this .l file, you will need
547 // a flex version 2.5.34 and later
548 // Under Windows, you will need to run the following command
549 // from within *MSYS* terminal (or run codelite from an MSYS shell):
550 // /usr/bin/flex -Pxml --batch --outfile=XmlLexer.cpp XMLLexer.l
551 //
552 //====================--------------------------------------------------------------
553 //
554 extern "C" int xmlwrap(void*) { return 1; }
555
556 #include <wx/string.h>
557 #include <string>
558 #include <wx/filename.h>
559 #include "XMLLexerAPI.h"
560 #include "XMLLexerTokens.h"
561
562 #define YY_FATAL_ERROR(x)
563 #define YYSTYPE char*
564 #define ECHO
565 #define P(s) fprintf(stderr, "%s\n", s)
566
567 #define YY_NO_UNISTD_H
568 #define YY_USER_ACTION yycolumn += yyleng;
569
570 #define RETURN_WHITESPACE()
571 #define RETURN_NEWLINE()
572
573 /* regex and modes */
574 /* options */
575
576
577
578 #line 579 "XmlLexer.cpp"
579
580 #define INITIAL 0
581 #define CDATA 1
582 #define COMMENT 2
583 #define NOXML 3
584
585 #ifndef YY_NO_UNISTD_H
586 /* Special case for "unistd.h", since it is non-ANSI. We include it way
587 * down here because we want the user's section 1 to have been scanned first.
588 * The user has a chance to override it with an option.
589 */
590 #include <unistd.h>
591 #endif
592
593 #ifndef YY_EXTRA_TYPE
594 #define YY_EXTRA_TYPE void *
595 #endif
596
597 /* Holds the entire state of the reentrant scanner. */
598 struct yyguts_t
599 {
600
601 /* User-defined. Not touched by flex. */
602 YY_EXTRA_TYPE yyextra_r;
603
604 /* The rest are the same as the globals declared in the non-reentrant scanner. */
605 FILE *yyin_r, *yyout_r;
606 size_t yy_buffer_stack_top; /**< index of top of stack. */
607 size_t yy_buffer_stack_max; /**< capacity of stack. */
608 YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
609 char yy_hold_char;
610 int yy_n_chars;
611 int yyleng_r;
612 char *yy_c_buf_p;
613 int yy_init;
614 int yy_start;
615 int yy_did_buffer_switch_on_eof;
616 int yy_start_stack_ptr;
617 int yy_start_stack_depth;
618 int *yy_start_stack;
619 yy_state_type yy_last_accepting_state;
620 char* yy_last_accepting_cpos;
621
622 int yylineno_r;
623 int yy_flex_debug_r;
624
625 char *yytext_r;
626 int yy_more_flag;
627 int yy_more_len;
628
629 }; /* end struct yyguts_t */
630
631 static int yy_init_globals (yyscan_t yyscanner );
632
633 int xmllex_init (yyscan_t* scanner);
634
635 int xmllex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
636
637 /* Accessor methods to globals.
638 These are made visible to non-reentrant scanners for convenience. */
639
640 int xmllex_destroy (yyscan_t yyscanner );
641
642 int xmlget_debug (yyscan_t yyscanner );
643
644 void xmlset_debug (int debug_flag ,yyscan_t yyscanner );
645
646 YY_EXTRA_TYPE xmlget_extra (yyscan_t yyscanner );
647
648 void xmlset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
649
650 FILE *xmlget_in (yyscan_t yyscanner );
651
652 void xmlset_in (FILE * in_str ,yyscan_t yyscanner );
653
654 FILE *xmlget_out (yyscan_t yyscanner );
655
656 void xmlset_out (FILE * out_str ,yyscan_t yyscanner );
657
658 int xmlget_leng (yyscan_t yyscanner );
659
660 char *xmlget_text (yyscan_t yyscanner );
661
662 int xmlget_lineno (yyscan_t yyscanner );
663
664 void xmlset_lineno (int line_number ,yyscan_t yyscanner );
665
666 /* Macros after this point can all be overridden by user definitions in
667 * section 1.
668 */
669
670 #ifndef YY_SKIP_YYWRAP
671 #ifdef __cplusplus
672 extern "C" int xmlwrap (yyscan_t yyscanner );
673 #else
674 extern int xmlwrap (yyscan_t yyscanner );
675 #endif
676 #endif
677
678 static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner);
679
680 #ifndef yytext_ptr
681 static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
682 #endif
683
684 #ifdef YY_NEED_STRLEN
685 static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
686 #endif
687
688 #ifndef YY_NO_INPUT
689
690 #ifdef __cplusplus
691 static int yyinput (yyscan_t yyscanner );
692 #else
693 static int input (yyscan_t yyscanner );
694 #endif
695
696 #endif
697
698 /* Amount of stuff to slurp up with each read. */
699 #ifndef YY_READ_BUF_SIZE
700 #ifdef __ia64__
701 /* On IA-64, the buffer size is 16k, not 8k */
702 #define YY_READ_BUF_SIZE 16384
703 #else
704 #define YY_READ_BUF_SIZE 8192
705 #endif /* __ia64__ */
706 #endif
707
708 /* Copy whatever the last rule matched to the standard output. */
709 #ifndef ECHO
710 /* This used to be an fputs(), but since the string might contain NUL's,
711 * we now use fwrite().
712 */
713 #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
714 #endif
715
716 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
717 * is returned in "result".
718 */
719 #ifndef YY_INPUT
720 #define YY_INPUT(buf,result,max_size) \
721 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
722 { \
723 int c = '*'; \
724 size_t n; \
725 for ( n = 0; n < max_size && \
726 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
727 buf[n] = (char) c; \
728 if ( c == '\n' ) \
729 buf[n++] = (char) c; \
730 if ( c == EOF && ferror( yyin ) ) \
731 YY_FATAL_ERROR( "input in flex scanner failed" ); \
732 result = n; \
733 } \
734 else \
735 { \
736 errno=0; \
737 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
738 { \
739 if( errno != EINTR) \
740 { \
741 YY_FATAL_ERROR( "input in flex scanner failed" ); \
742 break; \
743 } \
744 errno=0; \
745 clearerr(yyin); \
746 } \
747 }\
748 \
749
750 #endif
751
752 /* No semi-colon after return; correct usage is to write "yyterminate();" -
753 * we don't want an extra ';' after the "return" because that will cause
754 * some compilers to complain about unreachable statements.
755 */
756 #ifndef yyterminate
757 #define yyterminate() return YY_NULL
758 #endif
759
760 /* Number of entries by which start-condition stack grows. */
761 #ifndef YY_START_STACK_INCR
762 #define YY_START_STACK_INCR 25
763 #endif
764
765 /* Report a fatal error. */
766 #ifndef YY_FATAL_ERROR
767 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
768 #endif
769
770 /* end tables serialization structures and prototypes */
771
772 /* Default declaration of generated scanner - a define so the user can
773 * easily add parameters.
774 */
775 #ifndef YY_DECL
776 #define YY_DECL_IS_OURS 1
777
778 extern int xmllex (yyscan_t yyscanner);
779
780 #define YY_DECL int xmllex (yyscan_t yyscanner)
781 #endif /* !YY_DECL */
782
783 /* Code executed at the beginning of each rule, after yytext and yyleng
784 * have been set up.
785 */
786 #ifndef YY_USER_ACTION
787 #define YY_USER_ACTION
788 #endif
789
790 /* Code executed at the end of each rule. */
791 #ifndef YY_BREAK
792 #define YY_BREAK break;
793 #endif
794
795 #define YY_RULE_SETUP \
796 YY_USER_ACTION
797
798 /** The main scanner function which does all the work.
799 */
800 YY_DECL
801 {
802 register yy_state_type yy_current_state;
803 register char *yy_cp, *yy_bp;
804 register int yy_act;
805 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
806
807 #line 72 "XMLLexer.l"
808
809 #line 810 "XmlLexer.cpp"
810
811 if ( !yyg->yy_init )
812 {
813 yyg->yy_init = 1;
814
815 #ifdef YY_USER_INIT
816 YY_USER_INIT;
817 #endif
818
819 if ( ! yyg->yy_start )
820 yyg->yy_start = 1; /* first start state */
821
822 if ( ! yyin )
823 yyin = stdin;
824
825 if ( ! yyout )
826 yyout = stdout;
827
828 if ( ! YY_CURRENT_BUFFER ) {
829 xmlensure_buffer_stack (yyscanner);
830 YY_CURRENT_BUFFER_LVALUE =
831 xml_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
832 }
833
834 xml_load_buffer_state(yyscanner );
835 }
836
837 while ( 1 ) /* loops until end-of-file is reached */
838 {
839 yy_cp = yyg->yy_c_buf_p;
840
841 /* Support of yytext. */
842 *yy_cp = yyg->yy_hold_char;
843
844 /* yy_bp points to the position in yy_ch_buf of the start of
845 * the current run.
846 */
847 yy_bp = yy_cp;
848
849 yy_current_state = yyg->yy_start;
850 yy_match:
851 do
852 {
853 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
854 if ( yy_accept[yy_current_state] )
855 {
856 yyg->yy_last_accepting_state = yy_current_state;
857 yyg->yy_last_accepting_cpos = yy_cp;
858 }
859 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
860 {
861 yy_current_state = (int) yy_def[yy_current_state];
862 if ( yy_current_state >= 89 )
863 yy_c = yy_meta[(unsigned int) yy_c];
864 }
865 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
866 ++yy_cp;
867 }
868 while ( yy_current_state != 88 );
869 yy_cp = yyg->yy_last_accepting_cpos;
870 yy_current_state = yyg->yy_last_accepting_state;
871
872 yy_find_action:
873 yy_act = yy_accept[yy_current_state];
874
875 YY_DO_BEFORE_ACTION;
876
877 if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
878 {
879 int yyl;
880 for ( yyl = 0; yyl < yyleng; ++yyl )
881 if ( yytext[yyl] == '\n' )
882
883 do{ yylineno++;
884 yycolumn=0;
885 }while(0)
886 ;
887 }
888
889 do_action: /* This label is used only to access EOF actions. */
890
891 switch ( yy_act )
892 { /* beginning of action switch */
893 case 0: /* must back up */
894 /* undo the effects of YY_DO_BEFORE_ACTION */
895 *yy_cp = yyg->yy_hold_char;
896 yy_cp = yyg->yy_last_accepting_cpos;
897 yy_current_state = yyg->yy_last_accepting_state;
898 goto yy_find_action;
899
900 case YY_STATE_EOF(INITIAL):
901 case YY_STATE_EOF(CDATA):
902 case YY_STATE_EOF(COMMENT):
903 case YY_STATE_EOF(NOXML):
904 #line 73 "XMLLexer.l"
905 {yyterminate();}
906 YY_BREAK
907 case 1:
908 YY_RULE_SETUP
909 #line 74 "XMLLexer.l"
910 {}
911 YY_BREAK
912 case 2:
913 YY_RULE_SETUP
914 #line 75 "XMLLexer.l"
915 {return kXML_T_CLOSE_TAG_SUFFIX;}
916 YY_BREAK
917 case 3:
918 YY_RULE_SETUP
919 #line 76 "XMLLexer.l"
920 {return kXML_T_CLOSE_TAG_PREFIX;}
921 YY_BREAK
922 case 4:
923 YY_RULE_SETUP
924 #line 77 "XMLLexer.l"
925 { BEGIN NOXML; return kXML_T_XML_OPEN_TAG;}
926 YY_BREAK
927 case 5:
928 YY_RULE_SETUP
929 #line 78 "XMLLexer.l"
930 {return kXML_T_HTML_DOCTYPE;}
931 YY_BREAK
932 case 6:
933 YY_RULE_SETUP
934 #line 79 "XMLLexer.l"
935 { BEGIN CDATA; return kXML_T_CDATA_START; }
936 YY_BREAK
937 case 7:
938 YY_RULE_SETUP
939 #line 80 "XMLLexer.l"
940 {return kXML_T_ENTITY_LT;}
941 YY_BREAK
942 case 8:
943 YY_RULE_SETUP
944 #line 81 "XMLLexer.l"
945 {return kXML_T_ENTITY_GT;}
946 YY_BREAK
947 case 9:
948 YY_RULE_SETUP
949 #line 82 "XMLLexer.l"
950 {return kXML_T_ENTITY_AMP;}
951 YY_BREAK
952 case 10:
953 YY_RULE_SETUP
954 #line 83 "XMLLexer.l"
955 {return kXML_T_ENTITY_APOS;}
956 YY_BREAK
957 case 11:
958 YY_RULE_SETUP
959 #line 84 "XMLLexer.l"
960 {return kXML_T_ENTITY_QUOATATION_MARK;}
961 YY_BREAK
962 case 12:
963 YY_RULE_SETUP
964 #line 85 "XMLLexer.l"
965 { BEGIN COMMENT; return kXML_T_COMMENT_START;}
966 YY_BREAK
967 case 13:
968 YY_RULE_SETUP
969 #line 86 "XMLLexer.l"
970 {return kXML_T_IDENTIFIER;}
971 YY_BREAK
972 case 14:
973 YY_RULE_SETUP
974 #line 87 "XMLLexer.l"
975 { return kXML_T_STRING;}
976 YY_BREAK
977 case 15:
978 YY_RULE_SETUP
979 #line 88 "XMLLexer.l"
980 { return kXML_T_STRING;}
981 YY_BREAK
982 case 16:
983 YY_RULE_SETUP
984 #line 89 "XMLLexer.l"
985 { return yytext[0];}
986 YY_BREAK
987 case 17:
988 YY_RULE_SETUP
989 #line 90 "XMLLexer.l"
990 {
991 BEGIN INITIAL;
992 return kXML_T_CDATA_END;
993 }
994 YY_BREAK
995 case 18:
996 YY_RULE_SETUP
997 #line 94 "XMLLexer.l"
998 { return yytext[0];}
999 YY_BREAK
1000 case 19:
1001 YY_RULE_SETUP
1002 #line 95 "XMLLexer.l"
1003 {
1004 BEGIN INITIAL;
1005 return kXML_T_COMMENT_END;
1006 }
1007 YY_BREAK
1008 case 20:
1009 YY_RULE_SETUP
1010 #line 99 "XMLLexer.l"
1011 { return yytext[0];}
1012 YY_BREAK
1013 case 21:
1014 YY_RULE_SETUP
1015 #line 100 "XMLLexer.l"
1016 {
1017 BEGIN INITIAL;
1018 return kXML_T_XML_CLOSE_TAG;
1019 }
1020 YY_BREAK
1021 case 22:
1022 YY_RULE_SETUP
1023 #line 104 "XMLLexer.l"
1024 { return yytext[0];}
1025 YY_BREAK
1026 case 23:
1027 YY_RULE_SETUP
1028 #line 105 "XMLLexer.l"
1029 ECHO;
1030 YY_BREAK
1031 #line 1032 "XmlLexer.cpp"
1032
1033 case YY_END_OF_BUFFER:
1034 {
1035 /* Amount of text matched not including the EOB char. */
1036 int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1037
1038 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1039 *yy_cp = yyg->yy_hold_char;
1040 YY_RESTORE_YY_MORE_OFFSET
1041
1042 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1043 {
1044 /* We're scanning a new file or input source. It's
1045 * possible that this happened because the user
1046 * just pointed yyin at a new source and called
1047 * xmllex(). If so, then we have to assure
1048 * consistency between YY_CURRENT_BUFFER and our
1049 * globals. Here is the right place to do so, because
1050 * this is the first action (other than possibly a
1051 * back-up) that will match for the new input source.
1052 */
1053 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1054 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1055 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1056 }
1057
1058 /* Note that here we test for yy_c_buf_p "<=" to the position
1059 * of the first EOB in the buffer, since yy_c_buf_p will
1060 * already have been incremented past the NUL character
1061 * (since all states make transitions on EOB to the
1062 * end-of-buffer state). Contrast this with the test
1063 * in input().
1064 */
1065 if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1066 { /* This was really a NUL. */
1067 yy_state_type yy_next_state;
1068
1069 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1070
1071 yy_current_state = yy_get_previous_state( yyscanner );
1072
1073 /* Okay, we're now positioned to make the NUL
1074 * transition. We couldn't have
1075 * yy_get_previous_state() go ahead and do it
1076 * for us because it doesn't know how to deal
1077 * with the possibility of jamming (and we don't
1078 * want to build jamming into it because then it
1079 * will run more slowly).
1080 */
1081
1082 yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1083
1084 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1085
1086 if ( yy_next_state )
1087 {
1088 /* Consume the NUL. */
1089 yy_cp = ++yyg->yy_c_buf_p;
1090 yy_current_state = yy_next_state;
1091 goto yy_match;
1092 }
1093
1094 else
1095 {
1096 yy_cp = yyg->yy_last_accepting_cpos;
1097 yy_current_state = yyg->yy_last_accepting_state;
1098 goto yy_find_action;
1099 }
1100 }
1101
1102 else switch ( yy_get_next_buffer( yyscanner ) )
1103 {
1104 case EOB_ACT_END_OF_FILE:
1105 {
1106 yyg->yy_did_buffer_switch_on_eof = 0;
1107
1108 if ( xmlwrap(yyscanner ) )
1109 {
1110 /* Note: because we've taken care in
1111 * yy_get_next_buffer() to have set up
1112 * yytext, we can now set up
1113 * yy_c_buf_p so that if some total
1114 * hoser (like flex itself) wants to
1115 * call the scanner after we return the
1116 * YY_NULL, it'll still work - another
1117 * YY_NULL will get returned.
1118 */
1119 yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1120
1121 yy_act = YY_STATE_EOF(YY_START);
1122 goto do_action;
1123 }
1124
1125 else
1126 {
1127 if ( ! yyg->yy_did_buffer_switch_on_eof )
1128 YY_NEW_FILE;
1129 }
1130 break;
1131 }
1132
1133 case EOB_ACT_CONTINUE_SCAN:
1134 yyg->yy_c_buf_p =
1135 yyg->yytext_ptr + yy_amount_of_matched_text;
1136
1137 yy_current_state = yy_get_previous_state( yyscanner );
1138
1139 yy_cp = yyg->yy_c_buf_p;
1140 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1141 goto yy_match;
1142
1143 case EOB_ACT_LAST_MATCH:
1144 yyg->yy_c_buf_p =
1145 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1146
1147 yy_current_state = yy_get_previous_state( yyscanner );
1148
1149 yy_cp = yyg->yy_c_buf_p;
1150 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1151 goto yy_find_action;
1152 }
1153 break;
1154 }
1155
1156 default:
1157 YY_FATAL_ERROR(
1158 "fatal flex scanner internal error--no action found" );
1159 } /* end of action switch */
1160 } /* end of scanning one token */
1161 } /* end of xmllex */
1162
1163 /* yy_get_next_buffer - try to read in a new buffer
1164 *
1165 * Returns a code representing an action:
1166 * EOB_ACT_LAST_MATCH -
1167 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1168 * EOB_ACT_END_OF_FILE - end of file
1169 */
1170 static int yy_get_next_buffer (yyscan_t yyscanner)
1171 {
1172 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1173 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1174 register char *source = yyg->yytext_ptr;
1175 register int number_to_move, i;
1176 int ret_val;
1177
1178 if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1179 YY_FATAL_ERROR(
1180 "fatal flex scanner internal error--end of buffer missed" );
1181
1182 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1183 { /* Don't try to fill the buffer, so this is an EOF. */
1184 if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1185 {
1186 /* We matched a single character, the EOB, so
1187 * treat this as a final EOF.
1188 */
1189 return EOB_ACT_END_OF_FILE;
1190 }
1191
1192 else
1193 {
1194 /* We matched some text prior to the EOB, first
1195 * process it.
1196 */
1197 return EOB_ACT_LAST_MATCH;
1198 }
1199 }
1200
1201 /* Try to read more data. */
1202
1203 /* First move last chars to start of buffer. */
1204 number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
1205
1206 for ( i = 0; i < number_to_move; ++i )
1207 *(dest++) = *(source++);
1208
1209 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1210 /* don't do the read, it's not guaranteed to return an EOF,
1211 * just force an EOF
1212 */
1213 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1214
1215 else
1216 {
1217 int num_to_read =
1218 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1219
1220 while ( num_to_read <= 0 )
1221 { /* Not enough room in the buffer - grow it. */
1222
1223 /* just a shorter name for the current buffer */
1224 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1225
1226 int yy_c_buf_p_offset =
1227 (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1228
1229 if ( b->yy_is_our_buffer )
1230 {
1231 int new_size = b->yy_buf_size * 2;
1232
1233 if ( new_size <= 0 )
1234 b->yy_buf_size += b->yy_buf_size / 8;
1235 else
1236 b->yy_buf_size *= 2;
1237
1238 b->yy_ch_buf = (char *)
1239 /* Include room in for 2 EOB chars. */
1240 xmlrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
1241 }
1242 else
1243 /* Can't grow it, we don't own it. */
1244 b->yy_ch_buf = 0;
1245
1246 if ( ! b->yy_ch_buf )
1247 YY_FATAL_ERROR(
1248 "fatal error - scanner input buffer overflow" );
1249
1250 yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1251
1252 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1253 number_to_move - 1;
1254
1255 }
1256
1257 if ( num_to_read > YY_READ_BUF_SIZE )
1258 num_to_read = YY_READ_BUF_SIZE;
1259
1260 /* Read in more data. */
1261 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1262 yyg->yy_n_chars, (size_t) num_to_read );
1263
1264 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1265 }
1266
1267 if ( yyg->yy_n_chars == 0 )
1268 {
1269 if ( number_to_move == YY_MORE_ADJ )
1270 {
1271 ret_val = EOB_ACT_END_OF_FILE;
1272 xmlrestart(yyin ,yyscanner);
1273 }
1274
1275 else
1276 {
1277 ret_val = EOB_ACT_LAST_MATCH;
1278 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1279 YY_BUFFER_EOF_PENDING;
1280 }
1281 }
1282
1283 else
1284 ret_val = EOB_ACT_CONTINUE_SCAN;
1285
1286 if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1287 /* Extend the array by 50%, plus the number we really need. */
1288 yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1289 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) xmlrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
1290 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1291 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1292 }
1293
1294 yyg->yy_n_chars += number_to_move;
1295 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1296 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1297
1298 yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1299
1300 return ret_val;
1301 }
1302
1303 /* yy_get_previous_state - get the state just before the EOB char was reached */
1304
1305 static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1306 {
1307 register yy_state_type yy_current_state;
1308 register char *yy_cp;
1309 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1310
1311 yy_current_state = yyg->yy_start;
1312
1313 for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1314 {
1315 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1316 if ( yy_accept[yy_current_state] )
1317 {
1318 yyg->yy_last_accepting_state = yy_current_state;
1319 yyg->yy_last_accepting_cpos = yy_cp;
1320 }
1321 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1322 {
1323 yy_current_state = (int) yy_def[yy_current_state];
1324 if ( yy_current_state >= 89 )
1325 yy_c = yy_meta[(unsigned int) yy_c];
1326 }
1327 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1328 }
1329
1330 return yy_current_state;
1331 }
1332
1333 /* yy_try_NUL_trans - try to make a transition on the NUL character
1334 *
1335 * synopsis
1336 * next_state = yy_try_NUL_trans( current_state );
1337 */
1338 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1339 {
1340 register int yy_is_jam;
1341 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1342 register char *yy_cp = yyg->yy_c_buf_p;
1343
1344 register YY_CHAR yy_c = 1;
1345 if ( yy_accept[yy_current_state] )
1346 {
1347 yyg->yy_last_accepting_state = yy_current_state;
1348 yyg->yy_last_accepting_cpos = yy_cp;
1349 }
1350 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1351 {
1352 yy_current_state = (int) yy_def[yy_current_state];
1353 if ( yy_current_state >= 89 )
1354 yy_c = yy_meta[(unsigned int) yy_c];
1355 }
1356 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1357 yy_is_jam = (yy_current_state == 88);
1358
1359 return yy_is_jam ? 0 : yy_current_state;
1360 }
1361
1362 static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
1363 {
1364 register char *yy_cp;
1365 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1366
1367 yy_cp = yyg->yy_c_buf_p;
1368
1369 /* undo effects of setting up yytext */
1370 *yy_cp = yyg->yy_hold_char;
1371
1372 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1373 { /* need to shift things up to make room */
1374 /* +2 for EOB chars. */
1375 register int number_to_move = yyg->yy_n_chars + 2;
1376 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1377 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1378 register char *source =
1379 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1380
1381 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1382 *--dest = *--source;
1383
1384 yy_cp += (int) (dest - source);
1385 yy_bp += (int) (dest - source);
1386 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1387 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1388
1389 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1390 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1391 }
1392
1393 *--yy_cp = (char) c;
1394
1395 if ( c == '\n' ){
1396 --yylineno;
1397 }
1398
1399 yyg->yytext_ptr = yy_bp;
1400 yyg->yy_hold_char = *yy_cp;
1401 yyg->yy_c_buf_p = yy_cp;
1402 }
1403
1404 #ifndef YY_NO_INPUT
1405 #ifdef __cplusplus
1406 static int yyinput (yyscan_t yyscanner)
1407 #else
1408 static int input (yyscan_t yyscanner)
1409 #endif
1410
1411 {
1412 int c;
1413 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1414
1415 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1416
1417 if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1418 {
1419 /* yy_c_buf_p now points to the character we want to return.
1420 * If this occurs *before* the EOB characters, then it's a
1421 * valid NUL; if not, then we've hit the end of the buffer.
1422 */
1423 if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1424 /* This was really a NUL. */
1425 *yyg->yy_c_buf_p = '\0';
1426
1427 else
1428 { /* need more input */
1429 int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
1430 ++yyg->yy_c_buf_p;
1431
1432 switch ( yy_get_next_buffer( yyscanner ) )
1433 {
1434 case EOB_ACT_LAST_MATCH:
1435 /* This happens because yy_g_n_b()
1436 * sees that we've accumulated a
1437 * token and flags that we need to
1438 * try matching the token before
1439 * proceeding. But for input(),
1440 * there's no matching to consider.
1441 * So convert the EOB_ACT_LAST_MATCH
1442 * to EOB_ACT_END_OF_FILE.
1443 */
1444
1445 /* Reset buffer status. */
1446 xmlrestart(yyin ,yyscanner);
1447
1448 /*FALLTHROUGH*/
1449
1450 case EOB_ACT_END_OF_FILE:
1451 {
1452 if ( xmlwrap(yyscanner ) )
1453 return EOF;
1454
1455 if ( ! yyg->yy_did_buffer_switch_on_eof )
1456 YY_NEW_FILE;
1457 #ifdef __cplusplus
1458 return yyinput(yyscanner);
1459 #else
1460 return input(yyscanner);
1461 #endif
1462 }
1463
1464 case EOB_ACT_CONTINUE_SCAN:
1465 yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1466 break;
1467 }
1468 }
1469 }
1470
1471 c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1472 *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1473 yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1474
1475 if ( c == '\n' )
1476
1477 do{ yylineno++;
1478 yycolumn=0;
1479 }while(0)
1480 ;
1481
1482 return c;
1483 }
1484 #endif /* ifndef YY_NO_INPUT */
1485
1486 /** Immediately switch to a different input stream.
1487 * @param input_file A readable stream.
1488 * @param yyscanner The scanner object.
1489 * @note This function does not reset the start condition to @c INITIAL .
1490 */
1491 void xmlrestart (FILE * input_file , yyscan_t yyscanner)
1492 {
1493 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1494
1495 if ( ! YY_CURRENT_BUFFER ){
1496 xmlensure_buffer_stack (yyscanner);
1497 YY_CURRENT_BUFFER_LVALUE =
1498 xml_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1499 }
1500
1501 xml_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
1502 xml_load_buffer_state(yyscanner );
1503 }
1504
1505 /** Switch to a different input buffer.
1506 * @param new_buffer The new input buffer.
1507 * @param yyscanner The scanner object.
1508 */
1509 void xml_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1510 {
1511 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1512
1513 /* TODO. We should be able to replace this entire function body
1514 * with
1515 * xmlpop_buffer_state();
1516 * xmlpush_buffer_state(new_buffer);
1517 */
1518 xmlensure_buffer_stack (yyscanner);
1519 if ( YY_CURRENT_BUFFER == new_buffer )
1520 return;
1521
1522 if ( YY_CURRENT_BUFFER )
1523 {
1524 /* Flush out information for old buffer. */
1525 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1526 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1527 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1528 }
1529
1530 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1531 xml_load_buffer_state(yyscanner );
1532
1533 /* We don't actually know whether we did this switch during
1534 * EOF (xmlwrap()) processing, but the only time this flag
1535 * is looked at is after xmlwrap() is called, so it's safe
1536 * to go ahead and always set it.
1537 */
1538 yyg->yy_did_buffer_switch_on_eof = 1;
1539 }
1540
1541 static void xml_load_buffer_state (yyscan_t yyscanner)
1542 {
1543 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1544 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1545 yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1546 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1547 yyg->yy_hold_char = *yyg->yy_c_buf_p;
1548 }
1549
1550 /** Allocate and initialize an input buffer state.
1551 * @param file A readable stream.
1552 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1553 * @param yyscanner The scanner object.
1554 * @return the allocated buffer state.
1555 */
1556 YY_BUFFER_STATE xml_create_buffer (FILE * file, int size , yyscan_t yyscanner)
1557 {
1558 YY_BUFFER_STATE b;
1559
1560 b = (YY_BUFFER_STATE) xmlalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1561 if ( ! b )
1562 YY_FATAL_ERROR( "out of dynamic memory in xml_create_buffer()" );
1563
1564 b->yy_buf_size = size;
1565
1566 /* yy_ch_buf has to be 2 characters longer than the size given because
1567 * we need to put in 2 end-of-buffer characters.
1568 */
1569 b->yy_ch_buf = (char *) xmlalloc(b->yy_buf_size + 2 ,yyscanner );
1570 if ( ! b->yy_ch_buf )
1571 YY_FATAL_ERROR( "out of dynamic memory in xml_create_buffer()" );
1572
1573 b->yy_is_our_buffer = 1;
1574
1575 xml_init_buffer(b,file ,yyscanner);
1576
1577 return b;
1578 }
1579
1580 /** Destroy the buffer.
1581 * @param b a buffer created with xml_create_buffer()
1582 * @param yyscanner The scanner object.
1583 */
1584 void xml_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1585 {
1586 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1587
1588 if ( ! b )
1589 return;
1590
1591 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1592 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1593
1594 if ( b->yy_is_our_buffer )
1595 xmlfree((void *) b->yy_ch_buf ,yyscanner );
1596
1597 xmlfree((void *) b ,yyscanner );
1598 }
1599
1600 #ifndef __cplusplus
1601 extern int isatty (int );
1602 #endif /* __cplusplus */
1603
1604 /* Initializes or reinitializes a buffer.
1605 * This function is sometimes called more than once on the same buffer,
1606 * such as during a xmlrestart() or at EOF.
1607 */
1608 static void xml_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
1609
1610 {
1611 int oerrno = errno;
1612 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1613
1614 xml_flush_buffer(b ,yyscanner);
1615
1616 b->yy_input_file = file;
1617 b->yy_fill_buffer = 1;
1618
1619 /* If b is the current buffer, then xml_init_buffer was _probably_
1620 * called from xmlrestart() or through yy_get_next_buffer.
1621 * In that case, we don't want to reset the lineno or column.
1622 */
1623 if (b != YY_CURRENT_BUFFER){
1624 b->yy_bs_lineno = 1;
1625 b->yy_bs_column = 0;
1626 }
1627
1628 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1629
1630 errno = oerrno;
1631 }
1632
1633 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1634 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1635 * @param yyscanner The scanner object.
1636 */
1637 void xml_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1638 {
1639 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1640 if ( ! b )
1641 return;
1642
1643 b->yy_n_chars = 0;
1644
1645 /* We always need two end-of-buffer characters. The first causes
1646 * a transition to the end-of-buffer state. The second causes
1647 * a jam in that state.
1648 */
1649 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1650 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1651
1652 b->yy_buf_pos = &b->yy_ch_buf[0];
1653
1654 b->yy_at_bol = 1;
1655 b->yy_buffer_status = YY_BUFFER_NEW;
1656
1657 if ( b == YY_CURRENT_BUFFER )
1658 xml_load_buffer_state(yyscanner );
1659 }
1660
1661 /** Pushes the new state onto the stack. The new state becomes
1662 * the current state. This function will allocate the stack
1663 * if necessary.
1664 * @param new_buffer The new state.
1665 * @param yyscanner The scanner object.
1666 */
1667 void xmlpush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1668 {
1669 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1670 if (new_buffer == NULL)
1671 return;
1672
1673 xmlensure_buffer_stack(yyscanner);
1674
1675 /* This block is copied from xml_switch_to_buffer. */
1676 if ( YY_CURRENT_BUFFER )
1677 {
1678 /* Flush out information for old buffer. */
1679 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1680 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1681 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1682 }
1683
1684 /* Only push if top exists. Otherwise, replace top. */
1685 if (YY_CURRENT_BUFFER)
1686 yyg->yy_buffer_stack_top++;
1687 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1688
1689 /* copied from xml_switch_to_buffer. */
1690 xml_load_buffer_state(yyscanner );
1691 yyg->yy_did_buffer_switch_on_eof = 1;
1692 }
1693
1694 /** Removes and deletes the top of the stack, if present.
1695 * The next element becomes the new top.
1696 * @param yyscanner The scanner object.
1697 */
1698 void xmlpop_buffer_state (yyscan_t yyscanner)
1699 {
1700 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1701 if (!YY_CURRENT_BUFFER)
1702 return;
1703
1704 xml_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
1705 YY_CURRENT_BUFFER_LVALUE = NULL;
1706 if (yyg->yy_buffer_stack_top > 0)
1707 --yyg->yy_buffer_stack_top;
1708
1709 if (YY_CURRENT_BUFFER) {
1710 xml_load_buffer_state(yyscanner );
1711 yyg->yy_did_buffer_switch_on_eof = 1;
1712 }
1713 }
1714
1715 /* Allocates the stack if it does not exist.
1716 * Guarantees space for at least one push.
1717 */
1718 static void xmlensure_buffer_stack (yyscan_t yyscanner)
1719 {
1720 int num_to_alloc;
1721 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1722
1723 if (!yyg->yy_buffer_stack) {
1724
1725 /* First allocation is just for 2 elements, since we don't know if this
1726 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1727 * immediate realloc on the next call.
1728 */
1729 num_to_alloc = 1;
1730 yyg->yy_buffer_stack = (struct yy_buffer_state**)xmlalloc
1731 (num_to_alloc * sizeof(struct yy_buffer_state*)
1732 , yyscanner);
1733 if ( ! yyg->yy_buffer_stack )
1734 YY_FATAL_ERROR( "out of dynamic memory in xmlensure_buffer_stack()" );
1735
1736 memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1737
1738 yyg->yy_buffer_stack_max = num_to_alloc;
1739 yyg->yy_buffer_stack_top = 0;
1740 return;
1741 }
1742
1743 if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
1744
1745 /* Increase the buffer to prepare for a possible push. */
1746 int grow_size = 8 /* arbitrary grow size */;
1747
1748 num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
1749 yyg->yy_buffer_stack = (struct yy_buffer_state**)xmlrealloc
1750 (yyg->yy_buffer_stack,
1751 num_to_alloc * sizeof(struct yy_buffer_state*)
1752 , yyscanner);
1753 if ( ! yyg->yy_buffer_stack )
1754 YY_FATAL_ERROR( "out of dynamic memory in xmlensure_buffer_stack()" );
1755
1756 /* zero only the new slots.*/
1757 memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
1758 yyg->yy_buffer_stack_max = num_to_alloc;
1759 }
1760 }
1761
1762 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1763 * @param base the character buffer
1764 * @param size the size in bytes of the character buffer
1765 * @param yyscanner The scanner object.
1766 * @return the newly allocated buffer state object.
1767 */
1768 YY_BUFFER_STATE xml_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
1769 {
1770 YY_BUFFER_STATE b;
1771
1772 if ( size < 2 ||
1773 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1774 base[size-1] != YY_END_OF_BUFFER_CHAR )
1775 /* They forgot to leave room for the EOB's. */
1776 return 0;
1777
1778 b = (YY_BUFFER_STATE) xmlalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1779 if ( ! b )
1780 YY_FATAL_ERROR( "out of dynamic memory in xml_scan_buffer()" );
1781
1782 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1783 b->yy_buf_pos = b->yy_ch_buf = base;
1784 b->yy_is_our_buffer = 0;
1785 b->yy_input_file = 0;
1786 b->yy_n_chars = b->yy_buf_size;
1787 b->yy_is_interactive = 0;
1788 b->yy_at_bol = 1;
1789 b->yy_fill_buffer = 0;
1790 b->yy_buffer_status = YY_BUFFER_NEW;
1791
1792 xml_switch_to_buffer(b ,yyscanner );
1793
1794 return b;
1795 }
1796
1797 /** Setup the input buffer state to scan a string. The next call to xmllex() will
1798 * scan from a @e copy of @a str.
1799 * @param yystr a NUL-terminated string to scan
1800 * @param yyscanner The scanner object.
1801 * @return the newly allocated buffer state object.
1802 * @note If you want to scan bytes that may contain NUL values, then use
1803 * xml_scan_bytes() instead.
1804 */
1805 YY_BUFFER_STATE xml_scan_string (yyconst char * yystr , yyscan_t yyscanner)
1806 {
1807
1808 return xml_scan_bytes(yystr,strlen(yystr) ,yyscanner);
1809 }
1810
1811 /** Setup the input buffer state to scan the given bytes. The next call to xmllex() will
1812 * scan from a @e copy of @a bytes.
1813 * @param yybytes the byte buffer to scan
1814 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1815 * @param yyscanner The scanner object.
1816 * @return the newly allocated buffer state object.
1817 */
1818 YY_BUFFER_STATE xml_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
1819 {
1820 YY_BUFFER_STATE b;
1821 char *buf;
1822 yy_size_t n;
1823 int i;
1824
1825 /* Get memory for full buffer, including space for trailing EOB's. */
1826 n = _yybytes_len + 2;
1827 buf = (char *) xmlalloc(n ,yyscanner );
1828 if ( ! buf )
1829 YY_FATAL_ERROR( "out of dynamic memory in xml_scan_bytes()" );
1830
1831 for ( i = 0; i < _yybytes_len; ++i )
1832 buf[i] = yybytes[i];
1833
1834 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1835
1836 b = xml_scan_buffer(buf,n ,yyscanner);
1837 if ( ! b )
1838 YY_FATAL_ERROR( "bad buffer in xml_scan_bytes()" );
1839
1840 /* It's okay to grow etc. this buffer, and we should throw it
1841 * away when we're done.
1842 */
1843 b->yy_is_our_buffer = 1;
1844
1845 return b;
1846 }
1847
1848 #ifndef YY_EXIT_FAILURE
1849 #define YY_EXIT_FAILURE 2
1850 #endif
1851
1852 static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
1853 {
1854 (void) fprintf( stderr, "%s\n", msg );
1855
1856 }
1857
1858 /* Redefine yyless() so it works in section 3 code. */
1859
1860 #undef yyless
1861 #define yyless(n) \
1862 do \
1863 { \
1864 /* Undo effects of setting up yytext. */ \
1865 int yyless_macro_arg = (n); \
1866 YY_LESS_LINENO(yyless_macro_arg);\
1867 yytext[yyleng] = yyg->yy_hold_char; \
1868 yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
1869 yyg->yy_hold_char = *yyg->yy_c_buf_p; \
1870 *yyg->yy_c_buf_p = '\0'; \
1871 yyleng = yyless_macro_arg; \
1872 } \
1873 while ( 0 )
1874
1875 /* Accessor methods (get/set functions) to struct members. */
1876
1877 /** Get the user-defined data for this scanner.
1878 * @param yyscanner The scanner object.
1879 */
1880 YY_EXTRA_TYPE xmlget_extra (yyscan_t yyscanner)
1881 {
1882 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1883 return yyextra;
1884 }
1885
1886 /** Get the current line number.
1887 * @param yyscanner The scanner object.
1888 */
1889 int xmlget_lineno (yyscan_t yyscanner)
1890 {
1891 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1892
1893 if (! YY_CURRENT_BUFFER)
1894 return 0;
1895
1896 return yylineno;
1897 }
1898
1899 /** Get the current column number.
1900 * @param yyscanner The scanner object.
1901 */
1902 int xmlget_column (yyscan_t yyscanner)
1903 {
1904 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1905
1906 if (! YY_CURRENT_BUFFER)
1907 return 0;
1908
1909 return yycolumn;
1910 }
1911
1912 /** Get the input stream.
1913 * @param yyscanner The scanner object.
1914 */
1915 FILE *xmlget_in (yyscan_t yyscanner)
1916 {
1917 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1918 return yyin;
1919 }
1920
1921 /** Get the output stream.
1922 * @param yyscanner The scanner object.
1923 */
1924 FILE *xmlget_out (yyscan_t yyscanner)
1925 {
1926 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1927 return yyout;
1928 }
1929
1930 /** Get the length of the current token.
1931 * @param yyscanner The scanner object.
1932 */
1933 int xmlget_leng (yyscan_t yyscanner)
1934 {
1935 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1936 return yyleng;
1937 }
1938
1939 /** Get the current token.
1940 * @param yyscanner The scanner object.
1941 */
1942
1943 char *xmlget_text (yyscan_t yyscanner)
1944 {
1945 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1946 return yytext;
1947 }
1948
1949 /** Set the user-defined data. This data is never touched by the scanner.
1950 * @param user_defined The data to be associated with this scanner.
1951 * @param yyscanner The scanner object.
1952 */
1953 void xmlset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
1954 {
1955 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1956 yyextra = user_defined ;
1957 }
1958
1959 /** Set the current line number.
1960 * @param line_number
1961 * @param yyscanner The scanner object.
1962 */
1963 void xmlset_lineno (int line_number , yyscan_t yyscanner)
1964 {
1965 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1966
1967 /* lineno is only valid if an input buffer exists. */
1968 if (! YY_CURRENT_BUFFER )
1969 yy_fatal_error( "xmlset_lineno called with no buffer" , yyscanner);
1970
1971 yylineno = line_number;
1972 }
1973
1974 /** Set the current column.
1975 * @param line_number
1976 * @param yyscanner The scanner object.
1977 */
1978 void xmlset_column (int column_no , yyscan_t yyscanner)
1979 {
1980 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1981
1982 /* column is only valid if an input buffer exists. */
1983 if (! YY_CURRENT_BUFFER )
1984 yy_fatal_error( "xmlset_column called with no buffer" , yyscanner);
1985
1986 yycolumn = column_no;
1987 }
1988
1989 /** Set the input stream. This does not discard the current
1990 * input buffer.
1991 * @param in_str A readable stream.
1992 * @param yyscanner The scanner object.
1993 * @see xml_switch_to_buffer
1994 */
1995 void xmlset_in (FILE * in_str , yyscan_t yyscanner)
1996 {
1997 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1998 yyin = in_str ;
1999 }
2000
2001 void xmlset_out (FILE * out_str , yyscan_t yyscanner)
2002 {
2003 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2004 yyout = out_str ;
2005 }
2006
2007 int xmlget_debug (yyscan_t yyscanner)
2008 {
2009 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2010 return yy_flex_debug;
2011 }
2012
2013 void xmlset_debug (int bdebug , yyscan_t yyscanner)
2014 {
2015 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2016 yy_flex_debug = bdebug ;
2017 }
2018
2019 /* Accessor methods for yylval and yylloc */
2020
2021 /* User-visible API */
2022
2023 /* xmllex_init is special because it creates the scanner itself, so it is
2024 * the ONLY reentrant function that doesn't take the scanner as the last argument.
2025 * That's why we explicitly handle the declaration, instead of using our macros.
2026 */
2027
2028 int xmllex_init(yyscan_t* ptr_yy_globals)
2029
2030 {
2031 if (ptr_yy_globals == NULL){
2032 errno = EINVAL;
2033 return 1;
2034 }
2035
2036 *ptr_yy_globals = (yyscan_t) xmlalloc ( sizeof( struct yyguts_t ), NULL );
2037
2038 if (*ptr_yy_globals == NULL){
2039 errno = ENOMEM;
2040 return 1;
2041 }
2042
2043 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2044 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2045
2046 return yy_init_globals ( *ptr_yy_globals );
2047 }
2048
2049 /* xmllex_init_extra has the same functionality as xmllex_init, but follows the
2050 * convention of taking the scanner as the last argument. Note however, that
2051 * this is a *pointer* to a scanner, as it will be allocated by this call (and
2052 * is the reason, too, why this function also must handle its own declaration).
2053 * The user defined value in the first argument will be available to xmlalloc in
2054 * the yyextra field.
2055 */
2056
2057 int xmllex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
2058
2059 {
2060 struct yyguts_t dummy_yyguts;
2061
2062 xmlset_extra (yy_user_defined, &dummy_yyguts);
2063
2064 if (ptr_yy_globals == NULL){
2065 errno = EINVAL;
2066 return 1;
2067 }
2068
2069 *ptr_yy_globals = (yyscan_t) xmlalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2070
2071 if (*ptr_yy_globals == NULL){
2072 errno = ENOMEM;
2073 return 1;
2074 }
2075
2076 /* By setting to 0xAA, we expose bugs in
2077 yy_init_globals. Leave at 0x00 for releases. */
2078 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2079
2080 xmlset_extra (yy_user_defined, *ptr_yy_globals);
2081
2082 return yy_init_globals ( *ptr_yy_globals );
2083 }
2084
2085 static int yy_init_globals (yyscan_t yyscanner)
2086 {
2087 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2088 /* Initialization is the same as for the non-reentrant scanner.
2089 * This function is called from xmllex_destroy(), so don't allocate here.
2090 */
2091
2092 yyg->yy_buffer_stack = 0;
2093 yyg->yy_buffer_stack_top = 0;
2094 yyg->yy_buffer_stack_max = 0;
2095 yyg->yy_c_buf_p = (char *) 0;
2096 yyg->yy_init = 0;
2097 yyg->yy_start = 0;
2098
2099 yyg->yy_start_stack_ptr = 0;
2100 yyg->yy_start_stack_depth = 0;
2101 yyg->yy_start_stack = NULL;
2102
2103 /* Defined in main.c */
2104 #ifdef YY_STDINIT
2105 yyin = stdin;
2106 yyout = stdout;
2107 #else
2108 yyin = (FILE *) 0;
2109 yyout = (FILE *) 0;
2110 #endif
2111
2112 /* For future reference: Set errno on error, since we are called by
2113 * xmllex_init()
2114 */
2115 return 0;
2116 }
2117
2118 /* xmllex_destroy is for both reentrant and non-reentrant scanners. */
2119 int xmllex_destroy (yyscan_t yyscanner)
2120 {
2121 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2122
2123 /* Pop the buffer stack, destroying each element. */
2124 while(YY_CURRENT_BUFFER){
2125 xml_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
2126 YY_CURRENT_BUFFER_LVALUE = NULL;
2127 xmlpop_buffer_state(yyscanner);
2128 }
2129
2130 /* Destroy the stack itself. */
2131 xmlfree(yyg->yy_buffer_stack ,yyscanner);
2132 yyg->yy_buffer_stack = NULL;
2133
2134 /* Destroy the start condition stack. */
2135 xmlfree(yyg->yy_start_stack ,yyscanner );
2136 yyg->yy_start_stack = NULL;
2137
2138 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2139 * xmllex() is called, initialization will occur. */
2140 yy_init_globals( yyscanner);
2141
2142 /* Destroy the main struct (reentrant only). */
2143 xmlfree ( yyscanner , yyscanner );
2144 yyscanner = NULL;
2145 return 0;
2146 }
2147
2148 /*
2149 * Internal utility routines.
2150 */
2151
2152 #ifndef yytext_ptr
2153 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
2154 {
2155 register int i;
2156 for ( i = 0; i < n; ++i )
2157 s1[i] = s2[i];
2158 }
2159 #endif
2160
2161 #ifdef YY_NEED_STRLEN
2162 static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
2163 {
2164 register int n;
2165 for ( n = 0; s[n]; ++n )
2166 ;
2167
2168 return n;
2169 }
2170 #endif
2171
2172 void *xmlalloc (yy_size_t size , yyscan_t yyscanner)
2173 {
2174 return (void *) malloc( size );
2175 }
2176
2177 void *xmlrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
2178 {
2179 /* The cast to (char *) in the following accommodates both
2180 * implementations that use char* generic pointers, and those
2181 * that use void* generic pointers. It works with the latter
2182 * because both ANSI C and C++ allow castless assignment from
2183 * any pointer type to void*, and deal with argument conversions
2184 * as though doing an assignment.
2185 */
2186 return (void *) realloc( (char *) ptr, size );
2187 }
2188
2189 void xmlfree (void * ptr , yyscan_t yyscanner)
2190 {
2191 free( (char *) ptr ); /* see xmlrealloc() for (char *) cast */
2192 }
2193
2194 #define YYTABLES_NAME "yytables"
2195
2196 #line 105 "XMLLexer.l"
2197
2198
2199
2200 //=============-------------------------------
2201 // API methods implementation
2202 //=============-------------------------------
2203
2204 void* xmlLexerNew(const wxString& content)
2205 {
2206 yyscan_t scanner;
2207 xmllex_init(&scanner);
2208 struct yyguts_t * yyg = (struct yyguts_t*)scanner;
2209 XMLLexerUserData *userData = new XMLLexerUserData();
2210
2211 // keep the file pointer (and make sure we close it at the end)
2212 userData->SetCurrentPF(NULL);
2213 yyg->yyextra_r = userData;
2214
2215 wxCharBuffer cb = content.mb_str(wxConvUTF8);
2216 xml_switch_to_buffer(xml_scan_string(cb.data(),scanner),scanner);
2217 yycolumn = 1;
2218 yylineno = 0;
2219 return scanner;
2220 }
2221
2222 void* xmlLexerNew(const wxFileName& filename)
2223 {
2224 wxFileName fn = filename;
2225 if(fn.IsRelative()) {
2226 fn.MakeAbsolute();
2227 }
2228
2229 FILE* fp = ::fopen(fn.GetFullPath().mb_str(wxConvUTF8).data(), "rb");
2230 if(!fp) {
2231 return NULL;
2232 }
2233 yyscan_t scanner;
2234 xmllex_init(&scanner);
2235 struct yyguts_t * yyg = (struct yyguts_t*)scanner;
2236 XMLLexerUserData *userData = new XMLLexerUserData();
2237
2238 // keep the file pointer (and make sure we close it at the end)
2239 userData->SetCurrentPF(fp);
2240 yyg->yyextra_r = userData;
2241
2242 xml_switch_to_buffer(xml_create_buffer(fp,YY_BUF_SIZE,scanner),scanner);
2243 yycolumn = 1;
2244 yylineno = 0;
2245 return scanner;
2246 }
2247
2248 void xmlLexerDestroy(void** scanner)
2249 {
2250 struct yyguts_t * yyg = (struct yyguts_t*)(*scanner);
2251 delete (XMLLexerUserData*)yyg->yyextra_r;
2252 xml_delete_buffer(YY_CURRENT_BUFFER,*scanner);
2253
2254 xmllex_destroy(*scanner);
2255 *scanner = NULL;
2256 }
2257
2258 void xmlLexerUnget(void* scanner)
2259 {
2260 // return the entire token back to the input stream
2261 struct yyguts_t * yyg = (struct yyguts_t*)scanner;
2262 yyless(0);
2263 }
2264
2265 wxString xmlLexerText(void* scanner)
2266 {
2267 struct yyguts_t * yyg = (struct yyguts_t*)scanner;
2268 return wxString(yytext, wxConvUTF8);
2269 }
2270
2271 bool xmlLexerNext(void* scanner, XMLLexerToken& token)
2272 {
2273 struct yyguts_t * yyg = (struct yyguts_t*)scanner;
2274 token.Clear();
2275 token.column = 0;
2276 token.type = xmllex(scanner);
2277 if(token.type != 0) {
2278 token.lineNumber = yylineno;
2279 token.text = wxString(yytext, wxConvUTF8);
2280 token.column = yycolumn;
2281 }
2282 return token.type != 0;
2283 }
2284
2285 wxString xmlLexerCurrentToken(void* scanner)
2286 {
2287 struct yyguts_t * yyg = (struct yyguts_t*)scanner;
2288 return yytext;
2289 }
2290
2291 XMLLexerUserData* xmlLexerGetUserData(void* scanner)
2292 {
2293 struct yyguts_t * yyg = (struct yyguts_t*)scanner;
2294 return (XMLLexerUserData*) yyg->yyextra_r;
2295 }
2296