Merge branch 'release-3.31'
[kiteware-cmake.git] / Source / LexerParser / cmListFileLexer.c
blobec7424c4f96a8e65bd28b5578b6f8b738a5b9561
1 #include "cmStandardLexer.h"
3 #define FLEXINT_H 1
4 #define YY_INT_ALIGNED short int
6 /* A lexical scanner generated by flex */
8 #define FLEX_SCANNER
9 #define YY_FLEX_MAJOR_VERSION 2
10 #define YY_FLEX_MINOR_VERSION 6
11 #define YY_FLEX_SUBMINOR_VERSION 4
12 #if YY_FLEX_SUBMINOR_VERSION > 0
13 #define FLEX_BETA
14 #endif
16 #ifdef yy_create_buffer
17 #define cmListFileLexer_yy_create_buffer_ALREADY_DEFINED
18 #else
19 #define yy_create_buffer cmListFileLexer_yy_create_buffer
20 #endif
22 #ifdef yy_delete_buffer
23 #define cmListFileLexer_yy_delete_buffer_ALREADY_DEFINED
24 #else
25 #define yy_delete_buffer cmListFileLexer_yy_delete_buffer
26 #endif
28 #ifdef yy_scan_buffer
29 #define cmListFileLexer_yy_scan_buffer_ALREADY_DEFINED
30 #else
31 #define yy_scan_buffer cmListFileLexer_yy_scan_buffer
32 #endif
34 #ifdef yy_scan_string
35 #define cmListFileLexer_yy_scan_string_ALREADY_DEFINED
36 #else
37 #define yy_scan_string cmListFileLexer_yy_scan_string
38 #endif
40 #ifdef yy_scan_bytes
41 #define cmListFileLexer_yy_scan_bytes_ALREADY_DEFINED
42 #else
43 #define yy_scan_bytes cmListFileLexer_yy_scan_bytes
44 #endif
46 #ifdef yy_init_buffer
47 #define cmListFileLexer_yy_init_buffer_ALREADY_DEFINED
48 #else
49 #define yy_init_buffer cmListFileLexer_yy_init_buffer
50 #endif
52 #ifdef yy_flush_buffer
53 #define cmListFileLexer_yy_flush_buffer_ALREADY_DEFINED
54 #else
55 #define yy_flush_buffer cmListFileLexer_yy_flush_buffer
56 #endif
58 #ifdef yy_load_buffer_state
59 #define cmListFileLexer_yy_load_buffer_state_ALREADY_DEFINED
60 #else
61 #define yy_load_buffer_state cmListFileLexer_yy_load_buffer_state
62 #endif
64 #ifdef yy_switch_to_buffer
65 #define cmListFileLexer_yy_switch_to_buffer_ALREADY_DEFINED
66 #else
67 #define yy_switch_to_buffer cmListFileLexer_yy_switch_to_buffer
68 #endif
70 #ifdef yypush_buffer_state
71 #define cmListFileLexer_yypush_buffer_state_ALREADY_DEFINED
72 #else
73 #define yypush_buffer_state cmListFileLexer_yypush_buffer_state
74 #endif
76 #ifdef yypop_buffer_state
77 #define cmListFileLexer_yypop_buffer_state_ALREADY_DEFINED
78 #else
79 #define yypop_buffer_state cmListFileLexer_yypop_buffer_state
80 #endif
82 #ifdef yyensure_buffer_stack
83 #define cmListFileLexer_yyensure_buffer_stack_ALREADY_DEFINED
84 #else
85 #define yyensure_buffer_stack cmListFileLexer_yyensure_buffer_stack
86 #endif
88 #ifdef yylex
89 #define cmListFileLexer_yylex_ALREADY_DEFINED
90 #else
91 #define yylex cmListFileLexer_yylex
92 #endif
94 #ifdef yyrestart
95 #define cmListFileLexer_yyrestart_ALREADY_DEFINED
96 #else
97 #define yyrestart cmListFileLexer_yyrestart
98 #endif
100 #ifdef yylex_init
101 #define cmListFileLexer_yylex_init_ALREADY_DEFINED
102 #else
103 #define yylex_init cmListFileLexer_yylex_init
104 #endif
106 #ifdef yylex_init_extra
107 #define cmListFileLexer_yylex_init_extra_ALREADY_DEFINED
108 #else
109 #define yylex_init_extra cmListFileLexer_yylex_init_extra
110 #endif
112 #ifdef yylex_destroy
113 #define cmListFileLexer_yylex_destroy_ALREADY_DEFINED
114 #else
115 #define yylex_destroy cmListFileLexer_yylex_destroy
116 #endif
118 #ifdef yyget_debug
119 #define cmListFileLexer_yyget_debug_ALREADY_DEFINED
120 #else
121 #define yyget_debug cmListFileLexer_yyget_debug
122 #endif
124 #ifdef yyset_debug
125 #define cmListFileLexer_yyset_debug_ALREADY_DEFINED
126 #else
127 #define yyset_debug cmListFileLexer_yyset_debug
128 #endif
130 #ifdef yyget_extra
131 #define cmListFileLexer_yyget_extra_ALREADY_DEFINED
132 #else
133 #define yyget_extra cmListFileLexer_yyget_extra
134 #endif
136 #ifdef yyset_extra
137 #define cmListFileLexer_yyset_extra_ALREADY_DEFINED
138 #else
139 #define yyset_extra cmListFileLexer_yyset_extra
140 #endif
142 #ifdef yyget_in
143 #define cmListFileLexer_yyget_in_ALREADY_DEFINED
144 #else
145 #define yyget_in cmListFileLexer_yyget_in
146 #endif
148 #ifdef yyset_in
149 #define cmListFileLexer_yyset_in_ALREADY_DEFINED
150 #else
151 #define yyset_in cmListFileLexer_yyset_in
152 #endif
154 #ifdef yyget_out
155 #define cmListFileLexer_yyget_out_ALREADY_DEFINED
156 #else
157 #define yyget_out cmListFileLexer_yyget_out
158 #endif
160 #ifdef yyset_out
161 #define cmListFileLexer_yyset_out_ALREADY_DEFINED
162 #else
163 #define yyset_out cmListFileLexer_yyset_out
164 #endif
166 #ifdef yyget_leng
167 #define cmListFileLexer_yyget_leng_ALREADY_DEFINED
168 #else
169 #define yyget_leng cmListFileLexer_yyget_leng
170 #endif
172 #ifdef yyget_text
173 #define cmListFileLexer_yyget_text_ALREADY_DEFINED
174 #else
175 #define yyget_text cmListFileLexer_yyget_text
176 #endif
178 #ifdef yyget_lineno
179 #define cmListFileLexer_yyget_lineno_ALREADY_DEFINED
180 #else
181 #define yyget_lineno cmListFileLexer_yyget_lineno
182 #endif
184 #ifdef yyset_lineno
185 #define cmListFileLexer_yyset_lineno_ALREADY_DEFINED
186 #else
187 #define yyset_lineno cmListFileLexer_yyset_lineno
188 #endif
190 #ifdef yyget_column
191 #define cmListFileLexer_yyget_column_ALREADY_DEFINED
192 #else
193 #define yyget_column cmListFileLexer_yyget_column
194 #endif
196 #ifdef yyset_column
197 #define cmListFileLexer_yyset_column_ALREADY_DEFINED
198 #else
199 #define yyset_column cmListFileLexer_yyset_column
200 #endif
202 #ifdef yywrap
203 #define cmListFileLexer_yywrap_ALREADY_DEFINED
204 #else
205 #define yywrap cmListFileLexer_yywrap
206 #endif
208 #ifdef yyalloc
209 #define cmListFileLexer_yyalloc_ALREADY_DEFINED
210 #else
211 #define yyalloc cmListFileLexer_yyalloc
212 #endif
214 #ifdef yyrealloc
215 #define cmListFileLexer_yyrealloc_ALREADY_DEFINED
216 #else
217 #define yyrealloc cmListFileLexer_yyrealloc
218 #endif
220 #ifdef yyfree
221 #define cmListFileLexer_yyfree_ALREADY_DEFINED
222 #else
223 #define yyfree cmListFileLexer_yyfree
224 #endif
226 /* First, we deal with platform-specific or compiler-specific issues. */
228 /* begin standard C headers. */
229 #include <stdio.h>
230 #include <string.h>
231 #include <errno.h>
232 #include <stdlib.h>
234 /* end standard C headers. */
236 /* flex integer type definitions */
238 #ifndef FLEXINT_H
239 #define FLEXINT_H
241 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
243 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
245 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
246 * if you want the limit (max/min) macros for int types.
248 #ifndef __STDC_LIMIT_MACROS
249 #define __STDC_LIMIT_MACROS 1
250 #endif
252 #include <inttypes.h>
253 typedef int8_t flex_int8_t;
254 typedef uint8_t flex_uint8_t;
255 typedef int16_t flex_int16_t;
256 typedef uint16_t flex_uint16_t;
257 typedef int32_t flex_int32_t;
258 typedef uint32_t flex_uint32_t;
259 #else
260 typedef signed char flex_int8_t;
261 typedef short int flex_int16_t;
262 typedef int flex_int32_t;
263 typedef unsigned char flex_uint8_t;
264 typedef unsigned short int flex_uint16_t;
265 typedef unsigned int flex_uint32_t;
267 /* Limits of integral types. */
268 #ifndef INT8_MIN
269 #define INT8_MIN (-128)
270 #endif
271 #ifndef INT16_MIN
272 #define INT16_MIN (-32767-1)
273 #endif
274 #ifndef INT32_MIN
275 #define INT32_MIN (-2147483647-1)
276 #endif
277 #ifndef INT8_MAX
278 #define INT8_MAX (127)
279 #endif
280 #ifndef INT16_MAX
281 #define INT16_MAX (32767)
282 #endif
283 #ifndef INT32_MAX
284 #define INT32_MAX (2147483647)
285 #endif
286 #ifndef UINT8_MAX
287 #define UINT8_MAX (255U)
288 #endif
289 #ifndef UINT16_MAX
290 #define UINT16_MAX (65535U)
291 #endif
292 #ifndef UINT32_MAX
293 #define UINT32_MAX (4294967295U)
294 #endif
296 #ifndef SIZE_MAX
297 #define SIZE_MAX (~(size_t)0)
298 #endif
300 #endif /* ! C99 */
302 #endif /* ! FLEXINT_H */
304 /* begin standard C++ headers. */
306 /* TODO: this is always defined, so inline it */
307 #define yyconst const
309 #if defined(__GNUC__) && __GNUC__ >= 3
310 #define yynoreturn __attribute__((__noreturn__))
311 #else
312 #define yynoreturn
313 #endif
315 /* Returned upon end-of-file. */
316 #define YY_NULL 0
318 /* Promotes a possibly negative, possibly signed char to an
319 * integer in range [0..255] for use as an array index.
321 #define YY_SC_TO_UI(c) ((YY_CHAR) (c))
323 /* An opaque pointer. */
324 #ifndef YY_TYPEDEF_YY_SCANNER_T
325 #define YY_TYPEDEF_YY_SCANNER_T
326 typedef void* yyscan_t;
327 #endif
329 /* For convenience, these vars (plus the bison vars far below)
330 are macros in the reentrant scanner. */
331 #define yyin yyg->yyin_r
332 #define yyout yyg->yyout_r
333 #define yyextra yyg->yyextra_r
334 #define yyleng yyg->yyleng_r
335 #define yytext yyg->yytext_r
336 #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
337 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
338 #define yy_flex_debug yyg->yy_flex_debug_r
340 /* Enter a start condition. This macro really ought to take a parameter,
341 * but we do it the disgusting crufty way forced on us by the ()-less
342 * definition of BEGIN.
344 #define BEGIN yyg->yy_start = 1 + 2 *
345 /* Translate the current start state into a value that can be later handed
346 * to BEGIN to return to the state. The YYSTATE alias is for lex
347 * compatibility.
349 #define YY_START ((yyg->yy_start - 1) / 2)
350 #define YYSTATE YY_START
351 /* Action number for EOF rule of a given start state. */
352 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
353 /* Special action meaning "start processing a new file". */
354 #define YY_NEW_FILE yyrestart( yyin , yyscanner )
355 #define YY_END_OF_BUFFER_CHAR 0
357 /* Size of default input buffer. */
358 #ifndef YY_BUF_SIZE
359 #ifdef __ia64__
360 /* On IA-64, the buffer size is 16k, not 8k.
361 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
362 * Ditto for the __ia64__ case accordingly.
364 #define YY_BUF_SIZE 32768
365 #else
366 #define YY_BUF_SIZE 16384
367 #endif /* __ia64__ */
368 #endif
370 /* The state buf must be large enough to hold one state per character in the main buffer.
372 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
374 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
375 #define YY_TYPEDEF_YY_BUFFER_STATE
376 typedef struct yy_buffer_state *YY_BUFFER_STATE;
377 #endif
379 #ifndef YY_TYPEDEF_YY_SIZE_T
380 #define YY_TYPEDEF_YY_SIZE_T
381 typedef size_t yy_size_t;
382 #endif
384 #define EOB_ACT_CONTINUE_SCAN 0
385 #define EOB_ACT_END_OF_FILE 1
386 #define EOB_ACT_LAST_MATCH 2
388 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
389 * access to the local variable yy_act. Since yyless() is a macro, it would break
390 * existing scanners that call yyless() from OUTSIDE yylex.
391 * One obvious solution it to make yy_act a global. I tried that, and saw
392 * a 5% performance hit in a non-yylineno scanner, because yy_act is
393 * normally declared as a register variable-- so it is not worth it.
395 #define YY_LESS_LINENO(n) \
396 do { \
397 int yyl;\
398 for ( yyl = n; yyl < yyleng; ++yyl )\
399 if ( yytext[yyl] == '\n' )\
400 --yylineno;\
401 }while(0)
402 #define YY_LINENO_REWIND_TO(dst) \
403 do {\
404 const char *p;\
405 for ( p = yy_cp-1; p >= (dst); --p)\
406 if ( *p == '\n' )\
407 --yylineno;\
408 }while(0)
410 /* Return all but the first "n" matched characters back to the input stream. */
411 #define yyless(n) \
412 do \
414 /* Undo effects of setting up yytext. */ \
415 int yyless_macro_arg = (n); \
416 YY_LESS_LINENO(yyless_macro_arg);\
417 *yy_cp = yyg->yy_hold_char; \
418 YY_RESTORE_YY_MORE_OFFSET \
419 yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
420 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
422 while ( 0 )
423 #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
425 #ifndef YY_STRUCT_YY_BUFFER_STATE
426 #define YY_STRUCT_YY_BUFFER_STATE
427 struct yy_buffer_state
429 FILE *yy_input_file;
431 char *yy_ch_buf; /* input buffer */
432 char *yy_buf_pos; /* current position in input buffer */
434 /* Size of input buffer in bytes, not including room for EOB
435 * characters.
437 int yy_buf_size;
439 /* Number of characters read into yy_ch_buf, not including EOB
440 * characters.
442 int yy_n_chars;
444 /* Whether we "own" the buffer - i.e., we know we created it,
445 * and can realloc() it to grow it, and should free() it to
446 * delete it.
448 int yy_is_our_buffer;
450 /* Whether this is an "interactive" input source; if so, and
451 * if we're using stdio for input, then we want to use getc()
452 * instead of fread(), to make sure we stop fetching input after
453 * each newline.
455 int yy_is_interactive;
457 /* Whether we're considered to be at the beginning of a line.
458 * If so, '^' rules will be active on the next match, otherwise
459 * not.
461 int yy_at_bol;
463 int yy_bs_lineno; /**< The line count. */
464 int yy_bs_column; /**< The column count. */
466 /* Whether to try to fill the input buffer when we reach the
467 * end of it.
469 int yy_fill_buffer;
471 int yy_buffer_status;
473 #define YY_BUFFER_NEW 0
474 #define YY_BUFFER_NORMAL 1
475 /* When an EOF's been seen but there's still some text to process
476 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
477 * shouldn't try reading from the input source any more. We might
478 * still have a bunch of tokens to match, though, because of
479 * possible backing-up.
481 * When we actually see the EOF, we change the status to "new"
482 * (via yyrestart()), so that the user can continue scanning by
483 * just pointing yyin at a new input file.
485 #define YY_BUFFER_EOF_PENDING 2
488 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
490 /* We provide macros for accessing buffer states in case in the
491 * future we want to put the buffer states in a more general
492 * "scanner state".
494 * Returns the top of the stack, or NULL.
496 #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
497 ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
498 : NULL)
499 /* Same as previous macro, but useful when we know that the buffer stack is not
500 * NULL or when we need an lvalue. For internal use only.
502 #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
504 void yyrestart ( FILE *input_file , yyscan_t yyscanner );
505 void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
506 YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
507 void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
508 void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
509 void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
510 void yypop_buffer_state ( yyscan_t yyscanner );
512 static void yyensure_buffer_stack ( yyscan_t yyscanner );
513 static void yy_load_buffer_state ( yyscan_t yyscanner );
514 static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
515 #define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)
517 YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
518 YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
519 YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
521 void *yyalloc ( yy_size_t , yyscan_t yyscanner );
522 void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
523 void yyfree ( void * , yyscan_t yyscanner );
525 #define yy_new_buffer yy_create_buffer
526 #define yy_set_interactive(is_interactive) \
528 if ( ! YY_CURRENT_BUFFER ){ \
529 yyensure_buffer_stack (yyscanner); \
530 YY_CURRENT_BUFFER_LVALUE = \
531 yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
533 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
535 #define yy_set_bol(at_bol) \
537 if ( ! YY_CURRENT_BUFFER ){\
538 yyensure_buffer_stack (yyscanner); \
539 YY_CURRENT_BUFFER_LVALUE = \
540 yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
542 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
544 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
546 /* Begin user sect3 */
548 #define cmListFileLexer_yywrap(yyscanner) (/*CONSTCOND*/1)
549 #define YY_SKIP_YYWRAP
550 typedef flex_uint8_t YY_CHAR;
552 typedef int yy_state_type;
554 #define yytext_ptr yytext_r
556 static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
557 static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner);
558 static int yy_get_next_buffer ( yyscan_t yyscanner );
559 static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
561 /* Done after the current pattern has been matched and before the
562 * corresponding action - sets up yytext.
564 #define YY_DO_BEFORE_ACTION \
565 yyg->yytext_ptr = yy_bp; \
566 yyleng = (int) (yy_cp - yy_bp); \
567 yyg->yy_hold_char = *yy_cp; \
568 *yy_cp = '\0'; \
569 yyg->yy_c_buf_p = yy_cp;
570 #define YY_NUM_RULES 24
571 #define YY_END_OF_BUFFER 25
572 /* This struct is not used in this scanner,
573 but its presence is necessary. */
574 struct yy_trans_info
576 flex_int32_t yy_verify;
577 flex_int32_t yy_nxt;
579 static const flex_int16_t yy_accept[79] =
580 { 0,
581 0, 0, 0, 0, 0, 0, 0, 0, 4, 4,
582 25, 13, 22, 1, 16, 3, 13, 5, 6, 7,
583 15, 23, 23, 17, 19, 20, 21, 24, 10, 11,
584 8, 12, 9, 4, 13, 0, 13, 0, 22, 0,
585 0, 7, 13, 0, 13, 0, 2, 0, 13, 17,
586 0, 18, 10, 8, 4, 0, 14, 0, 0, 0,
587 0, 14, 0, 0, 14, 0, 0, 0, 2, 14,
588 0, 0, 0, 0, 0, 0, 0, 0
591 static const YY_CHAR yy_ec[256] =
592 { 0,
593 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
594 1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
595 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
596 1, 2, 1, 5, 6, 7, 1, 1, 1, 8,
597 9, 1, 1, 1, 1, 1, 1, 10, 10, 10,
598 10, 10, 10, 10, 10, 10, 10, 1, 1, 1,
599 11, 1, 1, 1, 12, 12, 12, 12, 12, 12,
600 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
601 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
602 13, 14, 15, 1, 12, 1, 12, 12, 12, 12,
604 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
605 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
606 12, 12, 1, 1, 1, 1, 1, 1, 1, 1,
607 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
608 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
609 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
610 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
611 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
612 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
613 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
615 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
616 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
617 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
618 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
619 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
620 1, 1, 1, 1, 1
623 static const YY_CHAR yy_meta[17] =
624 { 0,
625 1, 1, 2, 3, 4, 3, 1, 3, 5, 6,
626 1, 6, 1, 1, 7, 2
629 static const flex_int16_t yy_base[97] =
630 { 0,
631 0, 0, 14, 28, 42, 56, 70, 84, 18, 19,
632 68, 100, 16, 298, 298, 54, 58, 298, 298, 13,
633 115, 0, 298, 51, 298, 298, 21, 298, 0, 298,
634 53, 298, 298, 0, 0, 126, 55, 0, 25, 25,
635 53, 0, 0, 136, 53, 0, 57, 0, 0, 42,
636 50, 298, 0, 43, 0, 146, 160, 45, 172, 43,
637 26, 0, 42, 177, 0, 42, 188, 40, 298, 40,
638 0, 38, 37, 34, 32, 31, 23, 298, 197, 204,
639 211, 218, 225, 232, 239, 245, 252, 259, 262, 268,
640 275, 278, 280, 286, 289, 291
644 static const flex_int16_t yy_def[97] =
645 { 0,
646 78, 1, 79, 79, 80, 80, 81, 81, 82, 82,
647 78, 78, 78, 78, 78, 78, 12, 78, 78, 12,
648 78, 83, 78, 84, 78, 78, 84, 78, 85, 78,
649 78, 78, 78, 86, 12, 87, 12, 88, 78, 78,
650 89, 20, 12, 90, 12, 21, 78, 91, 12, 84,
651 84, 78, 85, 78, 86, 87, 78, 56, 87, 92,
652 78, 57, 89, 90, 57, 64, 90, 93, 78, 57,
653 94, 95, 92, 96, 93, 95, 96, 0, 78, 78,
654 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
655 78, 78, 78, 78, 78, 78
659 static const flex_int16_t yy_nxt[315] =
660 { 0,
661 12, 13, 14, 13, 15, 16, 17, 18, 19, 12,
662 12, 20, 21, 22, 12, 23, 25, 39, 26, 39,
663 14, 14, 42, 52, 42, 50, 39, 27, 39, 28,
664 25, 64, 26, 28, 28, 61, 61, 47, 47, 56,
665 65, 27, 64, 28, 30, 57, 56, 60, 65, 74,
666 62, 57, 72, 54, 50, 51, 31, 28, 30, 69,
667 68, 62, 60, 54, 51, 41, 40, 78, 78, 78,
668 31, 28, 30, 78, 78, 78, 78, 78, 78, 78,
669 78, 78, 78, 78, 33, 28, 30, 78, 78, 78,
670 78, 78, 78, 78, 78, 78, 78, 78, 33, 28,
672 35, 78, 78, 78, 36, 78, 37, 78, 78, 35,
673 35, 35, 35, 38, 35, 43, 78, 78, 78, 44,
674 78, 45, 78, 78, 43, 46, 43, 47, 48, 43,
675 57, 78, 58, 78, 78, 78, 78, 78, 78, 59,
676 65, 78, 66, 78, 78, 78, 78, 78, 78, 67,
677 57, 78, 58, 78, 78, 78, 78, 78, 78, 59,
678 57, 78, 78, 78, 36, 78, 70, 78, 78, 57,
679 57, 57, 57, 71, 57, 56, 78, 56, 78, 56,
680 56, 65, 78, 66, 78, 78, 78, 78, 78, 78,
681 67, 64, 78, 64, 78, 64, 64, 24, 24, 24,
683 24, 24, 24, 24, 29, 29, 29, 29, 29, 29,
684 29, 32, 32, 32, 32, 32, 32, 32, 34, 34,
685 34, 34, 34, 34, 34, 49, 78, 49, 49, 49,
686 49, 49, 50, 78, 50, 78, 50, 50, 50, 53,
687 78, 53, 53, 53, 53, 55, 78, 55, 55, 55,
688 55, 55, 56, 78, 78, 56, 78, 56, 56, 35,
689 78, 35, 35, 35, 35, 35, 63, 63, 64, 78,
690 78, 64, 78, 64, 64, 43, 78, 43, 43, 43,
691 43, 43, 73, 73, 75, 75, 57, 78, 57, 57,
692 57, 57, 57, 76, 76, 77, 77, 11, 78, 78,
694 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
695 78, 78, 78, 78
698 static const flex_int16_t yy_chk[315] =
699 { 0,
700 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
701 1, 1, 1, 1, 1, 1, 3, 13, 3, 13,
702 9, 10, 20, 27, 20, 27, 39, 3, 39, 3,
703 4, 77, 4, 9, 10, 40, 61, 40, 61, 76,
704 75, 4, 74, 4, 5, 73, 72, 70, 68, 66,
705 63, 60, 58, 54, 51, 50, 5, 5, 6, 47,
706 45, 41, 37, 31, 24, 17, 16, 11, 0, 0,
707 6, 6, 7, 0, 0, 0, 0, 0, 0, 0,
708 0, 0, 0, 0, 7, 7, 8, 0, 0, 0,
709 0, 0, 0, 0, 0, 0, 0, 0, 8, 8,
711 12, 0, 0, 0, 12, 0, 12, 0, 0, 12,
712 12, 12, 12, 12, 12, 21, 0, 0, 0, 21,
713 0, 21, 0, 0, 21, 21, 21, 21, 21, 21,
714 36, 0, 36, 0, 0, 0, 0, 0, 0, 36,
715 44, 0, 44, 0, 0, 0, 0, 0, 0, 44,
716 56, 0, 56, 0, 0, 0, 0, 0, 0, 56,
717 57, 0, 0, 0, 57, 0, 57, 0, 0, 57,
718 57, 57, 57, 57, 57, 59, 0, 59, 0, 59,
719 59, 64, 0, 64, 0, 0, 0, 0, 0, 0,
720 64, 67, 0, 67, 0, 67, 67, 79, 79, 79,
722 79, 79, 79, 79, 80, 80, 80, 80, 80, 80,
723 80, 81, 81, 81, 81, 81, 81, 81, 82, 82,
724 82, 82, 82, 82, 82, 83, 0, 83, 83, 83,
725 83, 83, 84, 0, 84, 0, 84, 84, 84, 85,
726 0, 85, 85, 85, 85, 86, 0, 86, 86, 86,
727 86, 86, 87, 0, 0, 87, 0, 87, 87, 88,
728 0, 88, 88, 88, 88, 88, 89, 89, 90, 0,
729 0, 90, 0, 90, 90, 91, 0, 91, 91, 91,
730 91, 91, 92, 92, 93, 93, 94, 0, 94, 94,
731 94, 94, 94, 95, 95, 96, 96, 78, 78, 78,
733 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
734 78, 78, 78, 78
737 /* Table of booleans, true if rule could match eol. */
738 static const flex_int32_t yy_rule_can_match_eol[25] =
739 { 0,
740 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1,
741 0, 0, 0, 0, 0, };
743 /* The intent behind this definition is that it'll catch
744 * any uses of REJECT which flex missed.
746 #define REJECT reject_used_but_not_detected
747 #define yymore() yymore_used_but_not_detected
748 #define YY_MORE_ADJ 0
749 #define YY_RESTORE_YY_MORE_OFFSET
750 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
751 file Copyright.txt or https://cmake.org/licensing for details. */
754 This file must be translated to C and modified to build everywhere.
756 Run flex >= 2.6 like this:
758 flex --nounistd -DFLEXINT_H --noline -ocmListFileLexer.c cmListFileLexer.in.l
760 Modify cmListFileLexer.c:
761 - remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c
762 - remove blank lines at end of file: sed -i '${/^$/d;}' cmListFileLexer.c
763 - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmListFileLexer.c
767 /* IWYU pragma: no_forward_declare yyguts_t */
769 #ifdef _WIN32
770 #include "cmsys/Encoding.h"
771 #endif
773 /* Setup the proper cmListFileLexer_yylex declaration. */
774 #define YY_EXTRA_TYPE cmListFileLexer*
775 #define YY_DECL int cmListFileLexer_yylex (yyscan_t yyscanner, cmListFileLexer* lexer)
777 #include "cmListFileLexer.h"
779 /*--------------------------------------------------------------------------*/
780 struct cmListFileLexer_s
782 cmListFileLexer_Token token;
783 int bracket;
784 int comment;
785 int line;
786 int column;
787 int size;
788 FILE* file;
789 size_t cr;
790 char* string_buffer;
791 char* string_position;
792 int string_left;
793 yyscan_t scanner;
796 static void cmListFileLexerSetToken(cmListFileLexer* lexer, const char* text,
797 int length);
798 static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
799 int length);
800 static int cmListFileLexerInput(cmListFileLexer* lexer, char* buffer,
801 size_t bufferSize);
802 static void cmListFileLexerInit(cmListFileLexer* lexer);
803 static void cmListFileLexerDestroy(cmListFileLexer* lexer);
805 /* Replace the lexer input function. */
806 #undef YY_INPUT
807 #define YY_INPUT(buf, result, max_size) \
808 do { result = cmListFileLexerInput(cmListFileLexer_yyget_extra(yyscanner), buf, max_size); } while (0)
810 /*--------------------------------------------------------------------------*/
812 #define INITIAL 0
813 #define STRING 1
814 #define BRACKET 2
815 #define BRACKETEND 3
816 #define COMMENT 4
818 #ifndef YY_EXTRA_TYPE
819 #define YY_EXTRA_TYPE void *
820 #endif
822 /* Holds the entire state of the reentrant scanner. */
823 struct yyguts_t
826 /* User-defined. Not touched by flex. */
827 YY_EXTRA_TYPE yyextra_r;
829 /* The rest are the same as the globals declared in the non-reentrant scanner. */
830 FILE *yyin_r, *yyout_r;
831 size_t yy_buffer_stack_top; /**< index of top of stack. */
832 size_t yy_buffer_stack_max; /**< capacity of stack. */
833 YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
834 char yy_hold_char;
835 int yy_n_chars;
836 int yyleng_r;
837 char *yy_c_buf_p;
838 int yy_init;
839 int yy_start;
840 int yy_did_buffer_switch_on_eof;
841 int yy_start_stack_ptr;
842 int yy_start_stack_depth;
843 int *yy_start_stack;
844 yy_state_type yy_last_accepting_state;
845 char* yy_last_accepting_cpos;
847 int yylineno_r;
848 int yy_flex_debug_r;
850 char *yytext_r;
851 int yy_more_flag;
852 int yy_more_len;
854 }; /* end struct yyguts_t */
856 static int yy_init_globals ( yyscan_t yyscanner );
858 int yylex_init (yyscan_t* scanner);
860 int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
862 /* Accessor methods to globals.
863 These are made visible to non-reentrant scanners for convenience. */
865 int yylex_destroy ( yyscan_t yyscanner );
867 int yyget_debug ( yyscan_t yyscanner );
869 void yyset_debug ( int debug_flag , yyscan_t yyscanner );
871 YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
873 void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
875 FILE *yyget_in ( yyscan_t yyscanner );
877 void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
879 FILE *yyget_out ( yyscan_t yyscanner );
881 void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
883 int yyget_leng ( yyscan_t yyscanner );
885 char *yyget_text ( yyscan_t yyscanner );
887 int yyget_lineno ( yyscan_t yyscanner );
889 void yyset_lineno ( int _line_number , yyscan_t yyscanner );
891 int yyget_column ( yyscan_t yyscanner );
893 void yyset_column ( int _column_no , yyscan_t yyscanner );
895 /* Macros after this point can all be overridden by user definitions in
896 * section 1.
899 #ifndef YY_SKIP_YYWRAP
900 #ifdef __cplusplus
901 extern "C" int yywrap ( yyscan_t yyscanner );
902 #else
903 extern int yywrap ( yyscan_t yyscanner );
904 #endif
905 #endif
907 #ifndef YY_NO_UNPUT
909 static void yyunput ( int c, char *buf_ptr , yyscan_t yyscanner);
911 #endif
913 #ifndef yytext_ptr
914 static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
915 #endif
917 #ifdef YY_NEED_STRLEN
918 static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
919 #endif
921 #ifndef YY_NO_INPUT
922 #ifdef __cplusplus
923 static int yyinput ( yyscan_t yyscanner );
924 #else
925 static int input ( yyscan_t yyscanner );
926 #endif
928 #endif
930 /* Amount of stuff to slurp up with each read. */
931 #ifndef YY_READ_BUF_SIZE
932 #ifdef __ia64__
933 /* On IA-64, the buffer size is 16k, not 8k */
934 #define YY_READ_BUF_SIZE 16384
935 #else
936 #define YY_READ_BUF_SIZE 8192
937 #endif /* __ia64__ */
938 #endif
940 /* Copy whatever the last rule matched to the standard output. */
941 #ifndef ECHO
942 /* This used to be an fputs(), but since the string might contain NUL's,
943 * we now use fwrite().
945 #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
946 #endif
948 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
949 * is returned in "result".
951 #ifndef YY_INPUT
952 #define YY_INPUT(buf,result,max_size) \
953 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
955 int c = '*'; \
956 int n; \
957 for ( n = 0; n < max_size && \
958 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
959 buf[n] = (char) c; \
960 if ( c == '\n' ) \
961 buf[n++] = (char) c; \
962 if ( c == EOF && ferror( yyin ) ) \
963 YY_FATAL_ERROR( "input in flex scanner failed" ); \
964 result = n; \
966 else \
968 errno=0; \
969 while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
971 if( errno != EINTR) \
973 YY_FATAL_ERROR( "input in flex scanner failed" ); \
974 break; \
976 errno=0; \
977 clearerr(yyin); \
982 #endif
984 /* No semi-colon after return; correct usage is to write "yyterminate();" -
985 * we don't want an extra ';' after the "return" because that will cause
986 * some compilers to complain about unreachable statements.
988 #ifndef yyterminate
989 #define yyterminate() return YY_NULL
990 #endif
992 /* Number of entries by which start-condition stack grows. */
993 #ifndef YY_START_STACK_INCR
994 #define YY_START_STACK_INCR 25
995 #endif
997 /* Report a fatal error. */
998 #ifndef YY_FATAL_ERROR
999 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
1000 #endif
1002 /* end tables serialization structures and prototypes */
1004 /* Default declaration of generated scanner - a define so the user can
1005 * easily add parameters.
1007 #ifndef YY_DECL
1008 #define YY_DECL_IS_OURS 1
1010 extern int yylex (yyscan_t yyscanner);
1012 #define YY_DECL int yylex (yyscan_t yyscanner)
1013 #endif /* !YY_DECL */
1015 /* Code executed at the beginning of each rule, after yytext and yyleng
1016 * have been set up.
1018 #ifndef YY_USER_ACTION
1019 #define YY_USER_ACTION
1020 #endif
1022 /* Code executed at the end of each rule. */
1023 #ifndef YY_BREAK
1024 #define YY_BREAK /*LINTED*/break;
1025 #endif
1027 #define YY_RULE_SETUP \
1028 YY_USER_ACTION
1030 /** The main scanner function which does all the work.
1032 YY_DECL
1034 yy_state_type yy_current_state;
1035 char *yy_cp, *yy_bp;
1036 int yy_act;
1037 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1039 if ( !yyg->yy_init )
1041 yyg->yy_init = 1;
1043 #ifdef YY_USER_INIT
1044 YY_USER_INIT;
1045 #endif
1047 if ( ! yyg->yy_start )
1048 yyg->yy_start = 1; /* first start state */
1050 if ( ! yyin )
1051 yyin = stdin;
1053 if ( ! yyout )
1054 yyout = stdout;
1056 if ( ! YY_CURRENT_BUFFER ) {
1057 yyensure_buffer_stack (yyscanner);
1058 YY_CURRENT_BUFFER_LVALUE =
1059 yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
1062 yy_load_buffer_state( yyscanner );
1067 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
1069 yy_cp = yyg->yy_c_buf_p;
1071 /* Support of yytext. */
1072 *yy_cp = yyg->yy_hold_char;
1074 /* yy_bp points to the position in yy_ch_buf of the start of
1075 * the current run.
1077 yy_bp = yy_cp;
1079 yy_current_state = yyg->yy_start;
1080 yy_match:
1083 YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
1084 if ( yy_accept[yy_current_state] )
1086 yyg->yy_last_accepting_state = yy_current_state;
1087 yyg->yy_last_accepting_cpos = yy_cp;
1089 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1091 yy_current_state = (int) yy_def[yy_current_state];
1092 if ( yy_current_state >= 79 )
1093 yy_c = yy_meta[yy_c];
1095 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1096 ++yy_cp;
1098 while ( yy_base[yy_current_state] != 298 );
1100 yy_find_action:
1101 yy_act = yy_accept[yy_current_state];
1102 if ( yy_act == 0 )
1103 { /* have to back up */
1104 yy_cp = yyg->yy_last_accepting_cpos;
1105 yy_current_state = yyg->yy_last_accepting_state;
1106 yy_act = yy_accept[yy_current_state];
1109 YY_DO_BEFORE_ACTION;
1111 if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
1113 int yyl;
1114 for ( yyl = 0; yyl < yyleng; ++yyl )
1115 if ( yytext[yyl] == '\n' )
1117 do{ yylineno++;
1118 yycolumn=0;
1119 }while(0)
1123 do_action: /* This label is used only to access EOF actions. */
1125 switch ( yy_act )
1126 { /* beginning of action switch */
1127 case 0: /* must back up */
1128 /* undo the effects of YY_DO_BEFORE_ACTION */
1129 *yy_cp = yyg->yy_hold_char;
1130 yy_cp = yyg->yy_last_accepting_cpos;
1131 yy_current_state = yyg->yy_last_accepting_state;
1132 goto yy_find_action;
1134 case 1:
1135 /* rule 1 can match eol */
1136 YY_RULE_SETUP
1138 lexer->token.type = cmListFileLexer_Token_Newline;
1139 cmListFileLexerSetToken(lexer, yytext, yyleng);
1140 ++lexer->line;
1141 lexer->column = 1;
1142 BEGIN(INITIAL);
1143 return 1;
1145 YY_BREAK
1146 case 2:
1147 /* rule 2 can match eol */
1148 YY_RULE_SETUP
1150 const char* bracket = yytext;
1151 lexer->comment = yytext[0] == '#';
1152 if (lexer->comment) {
1153 lexer->token.type = cmListFileLexer_Token_CommentBracket;
1154 bracket += 1;
1155 } else {
1156 lexer->token.type = cmListFileLexer_Token_ArgumentBracket;
1158 cmListFileLexerSetToken(lexer, "", 0);
1159 lexer->bracket = strchr(bracket+1, '[') - bracket;
1160 if (yytext[yyleng-1] == '\n') {
1161 ++lexer->line;
1162 lexer->column = 1;
1163 } else {
1164 lexer->column += yyleng;
1166 BEGIN(BRACKET);
1168 YY_BREAK
1169 case 3:
1170 YY_RULE_SETUP
1172 lexer->column += yyleng;
1173 BEGIN(COMMENT);
1175 YY_BREAK
1176 case 4:
1177 YY_RULE_SETUP
1179 lexer->column += yyleng;
1181 YY_BREAK
1182 case 5:
1183 YY_RULE_SETUP
1185 lexer->token.type = cmListFileLexer_Token_ParenLeft;
1186 cmListFileLexerSetToken(lexer, yytext, yyleng);
1187 lexer->column += yyleng;
1188 return 1;
1190 YY_BREAK
1191 case 6:
1192 YY_RULE_SETUP
1194 lexer->token.type = cmListFileLexer_Token_ParenRight;
1195 cmListFileLexerSetToken(lexer, yytext, yyleng);
1196 lexer->column += yyleng;
1197 return 1;
1199 YY_BREAK
1200 case 7:
1201 YY_RULE_SETUP
1203 lexer->token.type = cmListFileLexer_Token_Identifier;
1204 cmListFileLexerSetToken(lexer, yytext, yyleng);
1205 lexer->column += yyleng;
1206 return 1;
1208 YY_BREAK
1209 case 8:
1210 YY_RULE_SETUP
1212 /* Handle ]]====]=======]*/
1213 cmListFileLexerAppend(lexer, yytext, yyleng);
1214 lexer->column += yyleng;
1215 if (yyleng == lexer->bracket) {
1216 BEGIN(BRACKETEND);
1219 YY_BREAK
1220 case 9:
1221 YY_RULE_SETUP
1223 lexer->column += yyleng;
1224 /* Erase the partial bracket from the token. */
1225 lexer->token.length -= lexer->bracket;
1226 lexer->token.text[lexer->token.length] = 0;
1227 BEGIN(INITIAL);
1228 return 1;
1230 YY_BREAK
1231 case 10:
1232 YY_RULE_SETUP
1234 cmListFileLexerAppend(lexer, yytext, yyleng);
1235 lexer->column += yyleng;
1237 YY_BREAK
1238 case 11:
1239 /* rule 11 can match eol */
1240 YY_RULE_SETUP
1242 cmListFileLexerAppend(lexer, yytext, yyleng);
1243 ++lexer->line;
1244 lexer->column = 1;
1245 BEGIN(BRACKET);
1247 YY_BREAK
1248 case 12:
1249 YY_RULE_SETUP
1251 cmListFileLexerAppend(lexer, yytext, yyleng);
1252 lexer->column += yyleng;
1253 BEGIN(BRACKET);
1255 YY_BREAK
1256 case YY_STATE_EOF(BRACKET):
1257 case YY_STATE_EOF(BRACKETEND):
1259 lexer->token.type = cmListFileLexer_Token_BadBracket;
1260 BEGIN(INITIAL);
1261 return 1;
1263 YY_BREAK
1264 case 13:
1265 YY_RULE_SETUP
1267 lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
1268 cmListFileLexerSetToken(lexer, yytext, yyleng);
1269 lexer->column += yyleng;
1270 return 1;
1272 YY_BREAK
1273 case 14:
1274 YY_RULE_SETUP
1276 lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
1277 cmListFileLexerSetToken(lexer, yytext, yyleng);
1278 lexer->column += yyleng;
1279 return 1;
1281 YY_BREAK
1282 case 15:
1283 YY_RULE_SETUP
1285 lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
1286 cmListFileLexerSetToken(lexer, yytext, yyleng);
1287 lexer->column += yyleng;
1288 return 1;
1290 YY_BREAK
1291 case 16:
1292 YY_RULE_SETUP
1294 lexer->token.type = cmListFileLexer_Token_ArgumentQuoted;
1295 cmListFileLexerSetToken(lexer, "", 0);
1296 lexer->column += yyleng;
1297 BEGIN(STRING);
1299 YY_BREAK
1300 case 17:
1301 YY_RULE_SETUP
1303 cmListFileLexerAppend(lexer, yytext, yyleng);
1304 lexer->column += yyleng;
1306 YY_BREAK
1307 case 18:
1308 /* rule 18 can match eol */
1309 YY_RULE_SETUP
1311 /* Continuation: text is not part of string */
1312 ++lexer->line;
1313 lexer->column = 1;
1315 YY_BREAK
1316 case 19:
1317 /* rule 19 can match eol */
1318 YY_RULE_SETUP
1320 cmListFileLexerAppend(lexer, yytext, yyleng);
1321 ++lexer->line;
1322 lexer->column = 1;
1324 YY_BREAK
1325 case 20:
1326 YY_RULE_SETUP
1328 lexer->column += yyleng;
1329 BEGIN(INITIAL);
1330 return 1;
1332 YY_BREAK
1333 case 21:
1334 YY_RULE_SETUP
1336 cmListFileLexerAppend(lexer, yytext, yyleng);
1337 lexer->column += yyleng;
1339 YY_BREAK
1340 case YY_STATE_EOF(STRING):
1342 lexer->token.type = cmListFileLexer_Token_BadString;
1343 BEGIN(INITIAL);
1344 return 1;
1346 YY_BREAK
1347 case 22:
1348 YY_RULE_SETUP
1350 lexer->token.type = cmListFileLexer_Token_Space;
1351 cmListFileLexerSetToken(lexer, yytext, yyleng);
1352 lexer->column += yyleng;
1353 return 1;
1355 YY_BREAK
1356 case 23:
1357 YY_RULE_SETUP
1359 lexer->token.type = cmListFileLexer_Token_BadCharacter;
1360 cmListFileLexerSetToken(lexer, yytext, yyleng);
1361 lexer->column += yyleng;
1362 return 1;
1364 YY_BREAK
1365 case YY_STATE_EOF(INITIAL):
1366 case YY_STATE_EOF(COMMENT):
1368 lexer->token.type = cmListFileLexer_Token_None;
1369 cmListFileLexerSetToken(lexer, 0, 0);
1370 return 0;
1372 YY_BREAK
1373 case 24:
1374 YY_RULE_SETUP
1375 ECHO;
1376 YY_BREAK
1378 case YY_END_OF_BUFFER:
1380 /* Amount of text matched not including the EOB char. */
1381 int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1383 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1384 *yy_cp = yyg->yy_hold_char;
1385 YY_RESTORE_YY_MORE_OFFSET
1387 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1389 /* We're scanning a new file or input source. It's
1390 * possible that this happened because the user
1391 * just pointed yyin at a new source and called
1392 * yylex(). If so, then we have to assure
1393 * consistency between YY_CURRENT_BUFFER and our
1394 * globals. Here is the right place to do so, because
1395 * this is the first action (other than possibly a
1396 * back-up) that will match for the new input source.
1398 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1399 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1400 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1403 /* Note that here we test for yy_c_buf_p "<=" to the position
1404 * of the first EOB in the buffer, since yy_c_buf_p will
1405 * already have been incremented past the NUL character
1406 * (since all states make transitions on EOB to the
1407 * end-of-buffer state). Contrast this with the test
1408 * in input().
1410 if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1411 { /* This was really a NUL. */
1412 yy_state_type yy_next_state;
1414 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1416 yy_current_state = yy_get_previous_state( yyscanner );
1418 /* Okay, we're now positioned to make the NUL
1419 * transition. We couldn't have
1420 * yy_get_previous_state() go ahead and do it
1421 * for us because it doesn't know how to deal
1422 * with the possibility of jamming (and we don't
1423 * want to build jamming into it because then it
1424 * will run more slowly).
1427 yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1429 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1431 if ( yy_next_state )
1433 /* Consume the NUL. */
1434 yy_cp = ++yyg->yy_c_buf_p;
1435 yy_current_state = yy_next_state;
1436 goto yy_match;
1439 else
1441 yy_cp = yyg->yy_c_buf_p;
1442 goto yy_find_action;
1446 else switch ( yy_get_next_buffer( yyscanner ) )
1448 case EOB_ACT_END_OF_FILE:
1450 yyg->yy_did_buffer_switch_on_eof = 0;
1452 if ( yywrap( yyscanner ) )
1454 /* Note: because we've taken care in
1455 * yy_get_next_buffer() to have set up
1456 * yytext, we can now set up
1457 * yy_c_buf_p so that if some total
1458 * hoser (like flex itself) wants to
1459 * call the scanner after we return the
1460 * YY_NULL, it'll still work - another
1461 * YY_NULL will get returned.
1463 yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1465 yy_act = YY_STATE_EOF(YY_START);
1466 goto do_action;
1469 else
1471 if ( ! yyg->yy_did_buffer_switch_on_eof )
1472 YY_NEW_FILE;
1474 break;
1477 case EOB_ACT_CONTINUE_SCAN:
1478 yyg->yy_c_buf_p =
1479 yyg->yytext_ptr + yy_amount_of_matched_text;
1481 yy_current_state = yy_get_previous_state( yyscanner );
1483 yy_cp = yyg->yy_c_buf_p;
1484 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1485 goto yy_match;
1487 case EOB_ACT_LAST_MATCH:
1488 yyg->yy_c_buf_p =
1489 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1491 yy_current_state = yy_get_previous_state( yyscanner );
1493 yy_cp = yyg->yy_c_buf_p;
1494 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1495 goto yy_find_action;
1497 break;
1500 default:
1501 YY_FATAL_ERROR(
1502 "fatal flex scanner internal error--no action found" );
1503 } /* end of action switch */
1504 } /* end of scanning one token */
1505 } /* end of user's declarations */
1506 } /* end of yylex */
1508 /* yy_get_next_buffer - try to read in a new buffer
1510 * Returns a code representing an action:
1511 * EOB_ACT_LAST_MATCH -
1512 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1513 * EOB_ACT_END_OF_FILE - end of file
1515 static int yy_get_next_buffer (yyscan_t yyscanner)
1517 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1518 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1519 char *source = yyg->yytext_ptr;
1520 int number_to_move, i;
1521 int ret_val;
1523 if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1524 YY_FATAL_ERROR(
1525 "fatal flex scanner internal error--end of buffer missed" );
1527 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1528 { /* Don't try to fill the buffer, so this is an EOF. */
1529 if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1531 /* We matched a single character, the EOB, so
1532 * treat this as a final EOF.
1534 return EOB_ACT_END_OF_FILE;
1537 else
1539 /* We matched some text prior to the EOB, first
1540 * process it.
1542 return EOB_ACT_LAST_MATCH;
1546 /* Try to read more data. */
1548 /* First move last chars to start of buffer. */
1549 number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
1551 for ( i = 0; i < number_to_move; ++i )
1552 *(dest++) = *(source++);
1554 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1555 /* don't do the read, it's not guaranteed to return an EOF,
1556 * just force an EOF
1558 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1560 else
1562 int num_to_read =
1563 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1565 while ( num_to_read <= 0 )
1566 { /* Not enough room in the buffer - grow it. */
1568 /* just a shorter name for the current buffer */
1569 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1571 int yy_c_buf_p_offset =
1572 (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1574 if ( b->yy_is_our_buffer )
1576 int new_size = b->yy_buf_size * 2;
1578 if ( new_size <= 0 )
1579 b->yy_buf_size += b->yy_buf_size / 8;
1580 else
1581 b->yy_buf_size *= 2;
1583 b->yy_ch_buf = (char *)
1584 /* Include room in for 2 EOB chars. */
1585 yyrealloc( (void *) b->yy_ch_buf,
1586 (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
1588 else
1589 /* Can't grow it, we don't own it. */
1590 b->yy_ch_buf = NULL;
1592 if ( ! b->yy_ch_buf )
1593 YY_FATAL_ERROR(
1594 "fatal error - scanner input buffer overflow" );
1596 yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1598 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1599 number_to_move - 1;
1603 if ( num_to_read > YY_READ_BUF_SIZE )
1604 num_to_read = YY_READ_BUF_SIZE;
1606 /* Read in more data. */
1607 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1608 yyg->yy_n_chars, num_to_read );
1610 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1613 if ( yyg->yy_n_chars == 0 )
1615 if ( number_to_move == YY_MORE_ADJ )
1617 ret_val = EOB_ACT_END_OF_FILE;
1618 yyrestart( yyin , yyscanner);
1621 else
1623 ret_val = EOB_ACT_LAST_MATCH;
1624 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1625 YY_BUFFER_EOF_PENDING;
1629 else
1630 ret_val = EOB_ACT_CONTINUE_SCAN;
1632 if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1633 /* Extend the array by 50%, plus the number we really need. */
1634 int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1635 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
1636 (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
1637 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1638 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1639 /* "- 2" to take care of EOB's */
1640 YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
1643 yyg->yy_n_chars += number_to_move;
1644 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1645 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1647 yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1649 return ret_val;
1652 /* yy_get_previous_state - get the state just before the EOB char was reached */
1654 static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1656 yy_state_type yy_current_state;
1657 char *yy_cp;
1658 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1660 yy_current_state = yyg->yy_start;
1662 for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1664 YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 16);
1665 if ( yy_accept[yy_current_state] )
1667 yyg->yy_last_accepting_state = yy_current_state;
1668 yyg->yy_last_accepting_cpos = yy_cp;
1670 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1672 yy_current_state = (int) yy_def[yy_current_state];
1673 if ( yy_current_state >= 79 )
1674 yy_c = yy_meta[yy_c];
1676 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1679 return yy_current_state;
1682 /* yy_try_NUL_trans - try to make a transition on the NUL character
1684 * synopsis
1685 * next_state = yy_try_NUL_trans( current_state );
1687 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1689 int yy_is_jam;
1690 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1691 char *yy_cp = yyg->yy_c_buf_p;
1693 YY_CHAR yy_c = 16;
1694 if ( yy_accept[yy_current_state] )
1696 yyg->yy_last_accepting_state = yy_current_state;
1697 yyg->yy_last_accepting_cpos = yy_cp;
1699 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1701 yy_current_state = (int) yy_def[yy_current_state];
1702 if ( yy_current_state >= 79 )
1703 yy_c = yy_meta[yy_c];
1705 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1706 yy_is_jam = (yy_current_state == 78);
1708 (void)yyg;
1709 return yy_is_jam ? 0 : yy_current_state;
1712 #ifndef YY_NO_UNPUT
1714 static void yyunput (int c, char * yy_bp , yyscan_t yyscanner)
1716 char *yy_cp;
1717 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1719 yy_cp = yyg->yy_c_buf_p;
1721 /* undo effects of setting up yytext */
1722 *yy_cp = yyg->yy_hold_char;
1724 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1725 { /* need to shift things up to make room */
1726 /* +2 for EOB chars. */
1727 int number_to_move = yyg->yy_n_chars + 2;
1728 char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1729 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1730 char *source =
1731 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1733 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1734 *--dest = *--source;
1736 yy_cp += (int) (dest - source);
1737 yy_bp += (int) (dest - source);
1738 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1739 yyg->yy_n_chars = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1741 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1742 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1745 *--yy_cp = (char) c;
1747 if ( c == '\n' ){
1748 --yylineno;
1751 yyg->yytext_ptr = yy_bp;
1752 yyg->yy_hold_char = *yy_cp;
1753 yyg->yy_c_buf_p = yy_cp;
1756 #endif
1758 #ifndef YY_NO_INPUT
1759 #ifdef __cplusplus
1760 static int yyinput (yyscan_t yyscanner)
1761 #else
1762 static int input (yyscan_t yyscanner)
1763 #endif
1766 int c;
1767 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1769 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1771 if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1773 /* yy_c_buf_p now points to the character we want to return.
1774 * If this occurs *before* the EOB characters, then it's a
1775 * valid NUL; if not, then we've hit the end of the buffer.
1777 if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1778 /* This was really a NUL. */
1779 *yyg->yy_c_buf_p = '\0';
1781 else
1782 { /* need more input */
1783 int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
1784 ++yyg->yy_c_buf_p;
1786 switch ( yy_get_next_buffer( yyscanner ) )
1788 case EOB_ACT_LAST_MATCH:
1789 /* This happens because yy_g_n_b()
1790 * sees that we've accumulated a
1791 * token and flags that we need to
1792 * try matching the token before
1793 * proceeding. But for input(),
1794 * there's no matching to consider.
1795 * So convert the EOB_ACT_LAST_MATCH
1796 * to EOB_ACT_END_OF_FILE.
1799 /* Reset buffer status. */
1800 yyrestart( yyin , yyscanner);
1802 /*FALLTHROUGH*/
1804 case EOB_ACT_END_OF_FILE:
1806 if ( yywrap( yyscanner ) )
1807 return 0;
1809 if ( ! yyg->yy_did_buffer_switch_on_eof )
1810 YY_NEW_FILE;
1811 #ifdef __cplusplus
1812 return yyinput(yyscanner);
1813 #else
1814 return input(yyscanner);
1815 #endif
1818 case EOB_ACT_CONTINUE_SCAN:
1819 yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1820 break;
1825 c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1826 *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1827 yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1829 if ( c == '\n' )
1831 do{ yylineno++;
1832 yycolumn=0;
1833 }while(0)
1836 return c;
1838 #endif /* ifndef YY_NO_INPUT */
1840 /** Immediately switch to a different input stream.
1841 * @param input_file A readable stream.
1842 * @param yyscanner The scanner object.
1843 * @note This function does not reset the start condition to @c INITIAL .
1845 void yyrestart (FILE * input_file , yyscan_t yyscanner)
1847 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1849 if ( ! YY_CURRENT_BUFFER ){
1850 yyensure_buffer_stack (yyscanner);
1851 YY_CURRENT_BUFFER_LVALUE =
1852 yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
1855 yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
1856 yy_load_buffer_state( yyscanner );
1859 /** Switch to a different input buffer.
1860 * @param new_buffer The new input buffer.
1861 * @param yyscanner The scanner object.
1863 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1865 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1867 /* TODO. We should be able to replace this entire function body
1868 * with
1869 * yypop_buffer_state();
1870 * yypush_buffer_state(new_buffer);
1872 yyensure_buffer_stack (yyscanner);
1873 if ( YY_CURRENT_BUFFER == new_buffer )
1874 return;
1876 if ( YY_CURRENT_BUFFER )
1878 /* Flush out information for old buffer. */
1879 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1880 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1881 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1884 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1885 yy_load_buffer_state( yyscanner );
1887 /* We don't actually know whether we did this switch during
1888 * EOF (yywrap()) processing, but the only time this flag
1889 * is looked at is after yywrap() is called, so it's safe
1890 * to go ahead and always set it.
1892 yyg->yy_did_buffer_switch_on_eof = 1;
1895 static void yy_load_buffer_state (yyscan_t yyscanner)
1897 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1898 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1899 yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1900 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1901 yyg->yy_hold_char = *yyg->yy_c_buf_p;
1904 /** Allocate and initialize an input buffer state.
1905 * @param file A readable stream.
1906 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1907 * @param yyscanner The scanner object.
1908 * @return the allocated buffer state.
1910 YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
1912 YY_BUFFER_STATE b;
1914 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
1915 if ( ! b )
1916 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1918 b->yy_buf_size = size;
1920 /* yy_ch_buf has to be 2 characters longer than the size given because
1921 * we need to put in 2 end-of-buffer characters.
1923 b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
1924 if ( ! b->yy_ch_buf )
1925 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1927 b->yy_is_our_buffer = 1;
1929 yy_init_buffer( b, file , yyscanner);
1931 return b;
1934 /** Destroy the buffer.
1935 * @param b a buffer created with yy_create_buffer()
1936 * @param yyscanner The scanner object.
1938 void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1940 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1942 if ( ! b )
1943 return;
1945 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1946 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1948 if ( b->yy_is_our_buffer )
1949 yyfree( (void *) b->yy_ch_buf , yyscanner );
1951 yyfree( (void *) b , yyscanner );
1954 /* Initializes or reinitializes a buffer.
1955 * This function is sometimes called more than once on the same buffer,
1956 * such as during a yyrestart() or at EOF.
1958 static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
1961 int oerrno = errno;
1962 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1964 yy_flush_buffer( b , yyscanner);
1966 b->yy_input_file = file;
1967 b->yy_fill_buffer = 1;
1969 /* If b is the current buffer, then yy_init_buffer was _probably_
1970 * called from yyrestart() or through yy_get_next_buffer.
1971 * In that case, we don't want to reset the lineno or column.
1973 if (b != YY_CURRENT_BUFFER){
1974 b->yy_bs_lineno = 1;
1975 b->yy_bs_column = 0;
1978 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1980 errno = oerrno;
1983 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1984 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1985 * @param yyscanner The scanner object.
1987 void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1989 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1990 if ( ! b )
1991 return;
1993 b->yy_n_chars = 0;
1995 /* We always need two end-of-buffer characters. The first causes
1996 * a transition to the end-of-buffer state. The second causes
1997 * a jam in that state.
1999 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2000 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2002 b->yy_buf_pos = &b->yy_ch_buf[0];
2004 b->yy_at_bol = 1;
2005 b->yy_buffer_status = YY_BUFFER_NEW;
2007 if ( b == YY_CURRENT_BUFFER )
2008 yy_load_buffer_state( yyscanner );
2011 /** Pushes the new state onto the stack. The new state becomes
2012 * the current state. This function will allocate the stack
2013 * if necessary.
2014 * @param new_buffer The new state.
2015 * @param yyscanner The scanner object.
2017 void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
2019 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2020 if (new_buffer == NULL)
2021 return;
2023 yyensure_buffer_stack(yyscanner);
2025 /* This block is copied from yy_switch_to_buffer. */
2026 if ( YY_CURRENT_BUFFER )
2028 /* Flush out information for old buffer. */
2029 *yyg->yy_c_buf_p = yyg->yy_hold_char;
2030 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2031 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2034 /* Only push if top exists. Otherwise, replace top. */
2035 if (YY_CURRENT_BUFFER)
2036 yyg->yy_buffer_stack_top++;
2037 YY_CURRENT_BUFFER_LVALUE = new_buffer;
2039 /* copied from yy_switch_to_buffer. */
2040 yy_load_buffer_state( yyscanner );
2041 yyg->yy_did_buffer_switch_on_eof = 1;
2044 /** Removes and deletes the top of the stack, if present.
2045 * The next element becomes the new top.
2046 * @param yyscanner The scanner object.
2048 void yypop_buffer_state (yyscan_t yyscanner)
2050 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2051 if (!YY_CURRENT_BUFFER)
2052 return;
2054 yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
2055 YY_CURRENT_BUFFER_LVALUE = NULL;
2056 if (yyg->yy_buffer_stack_top > 0)
2057 --yyg->yy_buffer_stack_top;
2059 if (YY_CURRENT_BUFFER) {
2060 yy_load_buffer_state( yyscanner );
2061 yyg->yy_did_buffer_switch_on_eof = 1;
2065 /* Allocates the stack if it does not exist.
2066 * Guarantees space for at least one push.
2068 static void yyensure_buffer_stack (yyscan_t yyscanner)
2070 yy_size_t num_to_alloc;
2071 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2073 if (!yyg->yy_buffer_stack) {
2075 /* First allocation is just for 2 elements, since we don't know if this
2076 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2077 * immediate realloc on the next call.
2079 num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
2080 yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
2081 (num_to_alloc * sizeof(struct yy_buffer_state*)
2082 , yyscanner);
2083 if ( ! yyg->yy_buffer_stack )
2084 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2086 memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2088 yyg->yy_buffer_stack_max = num_to_alloc;
2089 yyg->yy_buffer_stack_top = 0;
2090 return;
2093 if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
2095 /* Increase the buffer to prepare for a possible push. */
2096 yy_size_t grow_size = 8 /* arbitrary grow size */;
2098 num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
2099 yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
2100 (yyg->yy_buffer_stack,
2101 num_to_alloc * sizeof(struct yy_buffer_state*)
2102 , yyscanner);
2103 if ( ! yyg->yy_buffer_stack )
2104 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2106 /* zero only the new slots.*/
2107 memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
2108 yyg->yy_buffer_stack_max = num_to_alloc;
2112 /** Setup the input buffer state to scan directly from a user-specified character buffer.
2113 * @param base the character buffer
2114 * @param size the size in bytes of the character buffer
2115 * @param yyscanner The scanner object.
2116 * @return the newly allocated buffer state object.
2118 YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
2120 YY_BUFFER_STATE b;
2122 if ( size < 2 ||
2123 base[size-2] != YY_END_OF_BUFFER_CHAR ||
2124 base[size-1] != YY_END_OF_BUFFER_CHAR )
2125 /* They forgot to leave room for the EOB's. */
2126 return NULL;
2128 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
2129 if ( ! b )
2130 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
2132 b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
2133 b->yy_buf_pos = b->yy_ch_buf = base;
2134 b->yy_is_our_buffer = 0;
2135 b->yy_input_file = NULL;
2136 b->yy_n_chars = b->yy_buf_size;
2137 b->yy_is_interactive = 0;
2138 b->yy_at_bol = 1;
2139 b->yy_fill_buffer = 0;
2140 b->yy_buffer_status = YY_BUFFER_NEW;
2142 yy_switch_to_buffer( b , yyscanner );
2144 return b;
2147 /** Setup the input buffer state to scan a string. The next call to yylex() will
2148 * scan from a @e copy of @a str.
2149 * @param yystr a NUL-terminated string to scan
2150 * @param yyscanner The scanner object.
2151 * @return the newly allocated buffer state object.
2152 * @note If you want to scan bytes that may contain NUL values, then use
2153 * yy_scan_bytes() instead.
2155 YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
2158 return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
2161 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
2162 * scan from a @e copy of @a bytes.
2163 * @param yybytes the byte buffer to scan
2164 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2165 * @param yyscanner The scanner object.
2166 * @return the newly allocated buffer state object.
2168 YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner)
2170 YY_BUFFER_STATE b;
2171 char *buf;
2172 yy_size_t n;
2173 int i;
2175 /* Get memory for full buffer, including space for trailing EOB's. */
2176 n = (yy_size_t) (_yybytes_len + 2);
2177 buf = (char *) yyalloc( n , yyscanner );
2178 if ( ! buf )
2179 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
2181 for ( i = 0; i < _yybytes_len; ++i )
2182 buf[i] = yybytes[i];
2184 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2186 b = yy_scan_buffer( buf, n , yyscanner);
2187 if ( ! b )
2188 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2190 /* It's okay to grow etc. this buffer, and we should throw it
2191 * away when we're done.
2193 b->yy_is_our_buffer = 1;
2195 return b;
2198 #ifndef YY_EXIT_FAILURE
2199 #define YY_EXIT_FAILURE 2
2200 #endif
2202 static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
2204 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2205 (void)yyg;
2206 fprintf( stderr, "%s\n", msg );
2207 exit( YY_EXIT_FAILURE );
2210 /* Redefine yyless() so it works in section 3 code. */
2212 #undef yyless
2213 #define yyless(n) \
2214 do \
2216 /* Undo effects of setting up yytext. */ \
2217 int yyless_macro_arg = (n); \
2218 YY_LESS_LINENO(yyless_macro_arg);\
2219 yytext[yyleng] = yyg->yy_hold_char; \
2220 yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2221 yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2222 *yyg->yy_c_buf_p = '\0'; \
2223 yyleng = yyless_macro_arg; \
2225 while ( 0 )
2227 /* Accessor methods (get/set functions) to struct members. */
2229 /** Get the user-defined data for this scanner.
2230 * @param yyscanner The scanner object.
2232 YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner)
2234 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2235 return yyextra;
2238 /** Get the current line number.
2239 * @param yyscanner The scanner object.
2241 int yyget_lineno (yyscan_t yyscanner)
2243 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2245 if (! YY_CURRENT_BUFFER)
2246 return 0;
2248 return yylineno;
2251 /** Get the current column number.
2252 * @param yyscanner The scanner object.
2254 int yyget_column (yyscan_t yyscanner)
2256 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2258 if (! YY_CURRENT_BUFFER)
2259 return 0;
2261 return yycolumn;
2264 /** Get the input stream.
2265 * @param yyscanner The scanner object.
2267 FILE *yyget_in (yyscan_t yyscanner)
2269 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2270 return yyin;
2273 /** Get the output stream.
2274 * @param yyscanner The scanner object.
2276 FILE *yyget_out (yyscan_t yyscanner)
2278 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2279 return yyout;
2282 /** Get the length of the current token.
2283 * @param yyscanner The scanner object.
2285 int yyget_leng (yyscan_t yyscanner)
2287 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2288 return yyleng;
2291 /** Get the current token.
2292 * @param yyscanner The scanner object.
2295 char *yyget_text (yyscan_t yyscanner)
2297 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2298 return yytext;
2301 /** Set the user-defined data. This data is never touched by the scanner.
2302 * @param user_defined The data to be associated with this scanner.
2303 * @param yyscanner The scanner object.
2305 void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
2307 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2308 yyextra = user_defined ;
2311 /** Set the current line number.
2312 * @param _line_number line number
2313 * @param yyscanner The scanner object.
2315 void yyset_lineno (int _line_number , yyscan_t yyscanner)
2317 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2319 /* lineno is only valid if an input buffer exists. */
2320 if (! YY_CURRENT_BUFFER )
2321 YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
2323 yylineno = _line_number;
2326 /** Set the current column.
2327 * @param _column_no column number
2328 * @param yyscanner The scanner object.
2330 void yyset_column (int _column_no , yyscan_t yyscanner)
2332 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2334 /* column is only valid if an input buffer exists. */
2335 if (! YY_CURRENT_BUFFER )
2336 YY_FATAL_ERROR( "yyset_column called with no buffer" );
2338 yycolumn = _column_no;
2341 /** Set the input stream. This does not discard the current
2342 * input buffer.
2343 * @param _in_str A readable stream.
2344 * @param yyscanner The scanner object.
2345 * @see yy_switch_to_buffer
2347 void yyset_in (FILE * _in_str , yyscan_t yyscanner)
2349 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2350 yyin = _in_str ;
2353 void yyset_out (FILE * _out_str , yyscan_t yyscanner)
2355 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2356 yyout = _out_str ;
2359 int yyget_debug (yyscan_t yyscanner)
2361 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2362 return yy_flex_debug;
2365 void yyset_debug (int _bdebug , yyscan_t yyscanner)
2367 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2368 yy_flex_debug = _bdebug ;
2371 /* Accessor methods for yylval and yylloc */
2373 /* User-visible API */
2375 /* yylex_init is special because it creates the scanner itself, so it is
2376 * the ONLY reentrant function that doesn't take the scanner as the last argument.
2377 * That's why we explicitly handle the declaration, instead of using our macros.
2379 int yylex_init(yyscan_t* ptr_yy_globals)
2381 if (ptr_yy_globals == NULL){
2382 errno = EINVAL;
2383 return 1;
2386 *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
2388 if (*ptr_yy_globals == NULL){
2389 errno = ENOMEM;
2390 return 1;
2393 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2394 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2396 return yy_init_globals ( *ptr_yy_globals );
2399 /* yylex_init_extra has the same functionality as yylex_init, but follows the
2400 * convention of taking the scanner as the last argument. Note however, that
2401 * this is a *pointer* to a scanner, as it will be allocated by this call (and
2402 * is the reason, too, why this function also must handle its own declaration).
2403 * The user defined value in the first argument will be available to yyalloc in
2404 * the yyextra field.
2406 int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
2408 struct yyguts_t dummy_yyguts;
2410 yyset_extra (yy_user_defined, &dummy_yyguts);
2412 if (ptr_yy_globals == NULL){
2413 errno = EINVAL;
2414 return 1;
2417 *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2419 if (*ptr_yy_globals == NULL){
2420 errno = ENOMEM;
2421 return 1;
2424 /* By setting to 0xAA, we expose bugs in
2425 yy_init_globals. Leave at 0x00 for releases. */
2426 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2428 yyset_extra (yy_user_defined, *ptr_yy_globals);
2430 return yy_init_globals ( *ptr_yy_globals );
2433 static int yy_init_globals (yyscan_t yyscanner)
2435 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2436 /* Initialization is the same as for the non-reentrant scanner.
2437 * This function is called from yylex_destroy(), so don't allocate here.
2440 yyg->yy_buffer_stack = NULL;
2441 yyg->yy_buffer_stack_top = 0;
2442 yyg->yy_buffer_stack_max = 0;
2443 yyg->yy_c_buf_p = NULL;
2444 yyg->yy_init = 0;
2445 yyg->yy_start = 0;
2447 yyg->yy_start_stack_ptr = 0;
2448 yyg->yy_start_stack_depth = 0;
2449 yyg->yy_start_stack = NULL;
2451 /* Defined in main.c */
2452 #ifdef YY_STDINIT
2453 yyin = stdin;
2454 yyout = stdout;
2455 #else
2456 yyin = NULL;
2457 yyout = NULL;
2458 #endif
2460 /* For future reference: Set errno on error, since we are called by
2461 * yylex_init()
2463 return 0;
2466 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
2467 int yylex_destroy (yyscan_t yyscanner)
2469 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2471 /* Pop the buffer stack, destroying each element. */
2472 while(YY_CURRENT_BUFFER){
2473 yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
2474 YY_CURRENT_BUFFER_LVALUE = NULL;
2475 yypop_buffer_state(yyscanner);
2478 /* Destroy the stack itself. */
2479 yyfree(yyg->yy_buffer_stack , yyscanner);
2480 yyg->yy_buffer_stack = NULL;
2482 /* Destroy the start condition stack. */
2483 yyfree( yyg->yy_start_stack , yyscanner );
2484 yyg->yy_start_stack = NULL;
2486 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2487 * yylex() is called, initialization will occur. */
2488 yy_init_globals( yyscanner);
2490 /* Destroy the main struct (reentrant only). */
2491 yyfree ( yyscanner , yyscanner );
2492 yyscanner = NULL;
2493 return 0;
2497 * Internal utility routines.
2500 #ifndef yytext_ptr
2501 static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
2503 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2504 (void)yyg;
2506 int i;
2507 for ( i = 0; i < n; ++i )
2508 s1[i] = s2[i];
2510 #endif
2512 #ifdef YY_NEED_STRLEN
2513 static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
2515 int n;
2516 for ( n = 0; s[n]; ++n )
2519 return n;
2521 #endif
2523 void *yyalloc (yy_size_t size , yyscan_t yyscanner)
2525 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2526 (void)yyg;
2527 return malloc(size);
2530 void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
2532 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2533 (void)yyg;
2535 /* The cast to (char *) in the following accommodates both
2536 * implementations that use char* generic pointers, and those
2537 * that use void* generic pointers. It works with the latter
2538 * because both ANSI C and C++ allow castless assignment from
2539 * any pointer type to void*, and deal with argument conversions
2540 * as though doing an assignment.
2542 return realloc(ptr, size);
2545 void yyfree (void * ptr , yyscan_t yyscanner)
2547 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2548 (void)yyg;
2549 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
2552 #define YYTABLES_NAME "yytables"
2554 /*--------------------------------------------------------------------------*/
2555 static void cmListFileLexerSetToken(cmListFileLexer* lexer, const char* text,
2556 int length)
2558 /* Set the token line and column number. */
2559 lexer->token.line = lexer->line;
2560 lexer->token.column = lexer->column;
2562 /* Use the same buffer if possible. */
2563 if (lexer->token.text) {
2564 if (text && length < lexer->size) {
2565 strcpy(lexer->token.text, text);
2566 lexer->token.length = length;
2567 return;
2569 free(lexer->token.text);
2570 lexer->token.text = 0;
2571 lexer->size = 0;
2574 /* Need to extend the buffer. */
2575 if (text) {
2576 lexer->token.text = strdup(text);
2577 lexer->token.length = length;
2578 lexer->size = length + 1;
2579 } else {
2580 lexer->token.length = 0;
2584 /*--------------------------------------------------------------------------*/
2585 static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
2586 int length)
2588 char* temp;
2589 int newSize;
2591 /* If the appended text will fit in the buffer, do not reallocate. */
2592 newSize = lexer->token.length + length + 1;
2593 if (lexer->token.text && newSize <= lexer->size) {
2594 strcpy(lexer->token.text + lexer->token.length, text);
2595 lexer->token.length += length;
2596 return;
2599 /* We need to extend the buffer. */
2600 temp = malloc(newSize);
2601 if (lexer->token.text) {
2602 memcpy(temp, lexer->token.text, lexer->token.length);
2603 free(lexer->token.text);
2605 memcpy(temp + lexer->token.length, text, length);
2606 temp[lexer->token.length + length] = 0;
2607 lexer->token.text = temp;
2608 lexer->token.length += length;
2609 lexer->size = newSize;
2612 /*--------------------------------------------------------------------------*/
2613 static int cmListFileLexerInput(cmListFileLexer* lexer, char* buffer,
2614 size_t bufferSize)
2616 if (lexer) {
2617 if (lexer->file) {
2618 /* Convert CRLF -> LF explicitly. The C FILE "t"ext mode
2619 does not convert newlines on all platforms. Move any
2620 trailing CR to the start of the buffer for the next read. */
2621 size_t cr = lexer->cr;
2622 size_t n;
2623 buffer[0] = '\r';
2624 n = fread(buffer + cr, 1, bufferSize - cr, lexer->file);
2625 if (n) {
2626 char* o = buffer;
2627 const char* i = buffer;
2628 const char* e;
2629 n += cr;
2630 cr = (buffer[n - 1] == '\r') ? 1 : 0;
2631 e = buffer + n - cr;
2632 while (i != e) {
2633 if (i[0] == '\r' && i[1] == '\n') {
2634 ++i;
2636 *o++ = *i++;
2638 n = o - buffer;
2639 } else {
2640 n = cr;
2641 cr = 0;
2643 lexer->cr = cr;
2644 return n;
2645 } else if (lexer->string_left) {
2646 int length = lexer->string_left;
2647 if ((int)bufferSize < length) {
2648 length = (int)bufferSize;
2650 memcpy(buffer, lexer->string_position, length);
2651 lexer->string_position += length;
2652 lexer->string_left -= length;
2653 return length;
2656 return 0;
2659 /*--------------------------------------------------------------------------*/
2660 static void cmListFileLexerInit(cmListFileLexer* lexer)
2662 if (lexer->file || lexer->string_buffer) {
2663 cmListFileLexer_yylex_init(&lexer->scanner);
2664 cmListFileLexer_yyset_extra(lexer, lexer->scanner);
2668 /*--------------------------------------------------------------------------*/
2669 static void cmListFileLexerDestroy(cmListFileLexer* lexer)
2671 cmListFileLexerSetToken(lexer, 0, 0);
2672 if (lexer->file || lexer->string_buffer) {
2673 cmListFileLexer_yylex_destroy(lexer->scanner);
2674 if (lexer->file) {
2675 fclose(lexer->file);
2676 lexer->file = 0;
2678 if (lexer->string_buffer) {
2679 free(lexer->string_buffer);
2680 lexer->string_buffer = 0;
2681 lexer->string_left = 0;
2682 lexer->string_position = 0;
2687 /*--------------------------------------------------------------------------*/
2688 cmListFileLexer* cmListFileLexer_New(void)
2690 cmListFileLexer* lexer = (cmListFileLexer*)malloc(sizeof(cmListFileLexer));
2691 if (!lexer) {
2692 return 0;
2694 memset(lexer, 0, sizeof(*lexer));
2695 lexer->line = 1;
2696 lexer->column = 1;
2697 return lexer;
2700 /*--------------------------------------------------------------------------*/
2701 void cmListFileLexer_Delete(cmListFileLexer* lexer)
2703 cmListFileLexer_SetFileName(lexer, 0, 0);
2704 free(lexer);
2707 /*--------------------------------------------------------------------------*/
2708 static cmListFileLexer_BOM cmListFileLexer_ReadBOM(FILE* f)
2710 unsigned char b[2];
2711 if (fread(b, 1, 2, f) == 2) {
2712 if (b[0] == 0xEF && b[1] == 0xBB) {
2713 if (fread(b, 1, 1, f) == 1 && b[0] == 0xBF) {
2714 return cmListFileLexer_BOM_UTF8;
2716 } else if (b[0] == 0xFE && b[1] == 0xFF) {
2717 /* UTF-16 BE */
2718 return cmListFileLexer_BOM_UTF16BE;
2719 } else if (b[0] == 0 && b[1] == 0) {
2720 if (fread(b, 1, 2, f) == 2 && b[0] == 0xFE && b[1] == 0xFF) {
2721 return cmListFileLexer_BOM_UTF32BE;
2723 } else if (b[0] == 0xFF && b[1] == 0xFE) {
2724 fpos_t p;
2725 fgetpos(f, &p);
2726 if (fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0) {
2727 return cmListFileLexer_BOM_UTF32LE;
2729 if (fsetpos(f, &p) != 0) {
2730 return cmListFileLexer_BOM_Broken;
2732 return cmListFileLexer_BOM_UTF16LE;
2735 if (fseek(f, 0, SEEK_SET) != 0) {
2736 return cmListFileLexer_BOM_Broken;
2738 return cmListFileLexer_BOM_None;
2741 /*--------------------------------------------------------------------------*/
2742 int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name,
2743 cmListFileLexer_BOM* bom)
2745 int result = 1;
2746 cmListFileLexerDestroy(lexer);
2747 if (name) {
2748 #ifdef _WIN32
2749 wchar_t* wname = cmsysEncoding_DupToWide(name);
2750 lexer->file = _wfopen(wname, L"rb");
2751 free(wname);
2752 #else
2753 lexer->file = fopen(name, "rb");
2754 #endif
2755 if (lexer->file) {
2756 if (bom) {
2757 *bom = cmListFileLexer_ReadBOM(lexer->file);
2759 } else {
2760 result = 0;
2763 cmListFileLexerInit(lexer);
2764 return result;
2767 /*--------------------------------------------------------------------------*/
2768 int cmListFileLexer_SetString(cmListFileLexer* lexer, const char* text)
2770 int result = 1;
2771 cmListFileLexerDestroy(lexer);
2772 if (text) {
2773 int length = (int)strlen(text);
2774 lexer->string_buffer = (char*)malloc(length + 1);
2775 if (lexer->string_buffer) {
2776 strcpy(lexer->string_buffer, text);
2777 lexer->string_position = lexer->string_buffer;
2778 lexer->string_left = length;
2779 } else {
2780 result = 0;
2783 cmListFileLexerInit(lexer);
2784 return result;
2787 /*--------------------------------------------------------------------------*/
2788 cmListFileLexer_Token* cmListFileLexer_Scan(cmListFileLexer* lexer)
2790 if (!lexer->file && !lexer->string_buffer) {
2791 return 0;
2793 if (cmListFileLexer_yylex(lexer->scanner, lexer)) {
2794 return &lexer->token;
2795 } else {
2796 cmListFileLexer_SetFileName(lexer, 0, 0);
2797 return 0;
2801 /*--------------------------------------------------------------------------*/
2802 long cmListFileLexer_GetCurrentLine(cmListFileLexer* lexer)
2804 return lexer->line;
2807 /*--------------------------------------------------------------------------*/
2808 long cmListFileLexer_GetCurrentColumn(cmListFileLexer* lexer)
2810 return lexer->column;
2813 /*--------------------------------------------------------------------------*/
2814 const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer,
2815 cmListFileLexer_Type type)
2817 (void)lexer;
2818 switch (type) {
2819 case cmListFileLexer_Token_None:
2820 return "nothing";
2821 case cmListFileLexer_Token_Space:
2822 return "space";
2823 case cmListFileLexer_Token_Newline:
2824 return "newline";
2825 case cmListFileLexer_Token_Identifier:
2826 return "identifier";
2827 case cmListFileLexer_Token_ParenLeft:
2828 return "left paren";
2829 case cmListFileLexer_Token_ParenRight:
2830 return "right paren";
2831 case cmListFileLexer_Token_ArgumentUnquoted:
2832 return "unquoted argument";
2833 case cmListFileLexer_Token_ArgumentQuoted:
2834 return "quoted argument";
2835 case cmListFileLexer_Token_ArgumentBracket:
2836 return "bracket argument";
2837 case cmListFileLexer_Token_CommentBracket:
2838 return "bracket comment";
2839 case cmListFileLexer_Token_BadCharacter:
2840 return "bad character";
2841 case cmListFileLexer_Token_BadBracket:
2842 return "unterminated bracket";
2843 case cmListFileLexer_Token_BadString:
2844 return "unterminated string";
2846 return "unknown token";