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