Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Source/LexerParser/cmListFileLexer.c
5000 views
1
#include "cmStandardLexer.h"
2
3
#define FLEXINT_H 1
4
#define YY_INT_ALIGNED short int
5
6
/* A lexical scanner generated by flex */
7
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
15
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
21
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
27
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
33
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
39
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
45
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
51
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
57
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
63
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
69
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
75
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
81
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
87
88
#ifdef yylex
89
#define cmListFileLexer_yylex_ALREADY_DEFINED
90
#else
91
#define yylex cmListFileLexer_yylex
92
#endif
93
94
#ifdef yyrestart
95
#define cmListFileLexer_yyrestart_ALREADY_DEFINED
96
#else
97
#define yyrestart cmListFileLexer_yyrestart
98
#endif
99
100
#ifdef yylex_init
101
#define cmListFileLexer_yylex_init_ALREADY_DEFINED
102
#else
103
#define yylex_init cmListFileLexer_yylex_init
104
#endif
105
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
111
112
#ifdef yylex_destroy
113
#define cmListFileLexer_yylex_destroy_ALREADY_DEFINED
114
#else
115
#define yylex_destroy cmListFileLexer_yylex_destroy
116
#endif
117
118
#ifdef yyget_debug
119
#define cmListFileLexer_yyget_debug_ALREADY_DEFINED
120
#else
121
#define yyget_debug cmListFileLexer_yyget_debug
122
#endif
123
124
#ifdef yyset_debug
125
#define cmListFileLexer_yyset_debug_ALREADY_DEFINED
126
#else
127
#define yyset_debug cmListFileLexer_yyset_debug
128
#endif
129
130
#ifdef yyget_extra
131
#define cmListFileLexer_yyget_extra_ALREADY_DEFINED
132
#else
133
#define yyget_extra cmListFileLexer_yyget_extra
134
#endif
135
136
#ifdef yyset_extra
137
#define cmListFileLexer_yyset_extra_ALREADY_DEFINED
138
#else
139
#define yyset_extra cmListFileLexer_yyset_extra
140
#endif
141
142
#ifdef yyget_in
143
#define cmListFileLexer_yyget_in_ALREADY_DEFINED
144
#else
145
#define yyget_in cmListFileLexer_yyget_in
146
#endif
147
148
#ifdef yyset_in
149
#define cmListFileLexer_yyset_in_ALREADY_DEFINED
150
#else
151
#define yyset_in cmListFileLexer_yyset_in
152
#endif
153
154
#ifdef yyget_out
155
#define cmListFileLexer_yyget_out_ALREADY_DEFINED
156
#else
157
#define yyget_out cmListFileLexer_yyget_out
158
#endif
159
160
#ifdef yyset_out
161
#define cmListFileLexer_yyset_out_ALREADY_DEFINED
162
#else
163
#define yyset_out cmListFileLexer_yyset_out
164
#endif
165
166
#ifdef yyget_leng
167
#define cmListFileLexer_yyget_leng_ALREADY_DEFINED
168
#else
169
#define yyget_leng cmListFileLexer_yyget_leng
170
#endif
171
172
#ifdef yyget_text
173
#define cmListFileLexer_yyget_text_ALREADY_DEFINED
174
#else
175
#define yyget_text cmListFileLexer_yyget_text
176
#endif
177
178
#ifdef yyget_lineno
179
#define cmListFileLexer_yyget_lineno_ALREADY_DEFINED
180
#else
181
#define yyget_lineno cmListFileLexer_yyget_lineno
182
#endif
183
184
#ifdef yyset_lineno
185
#define cmListFileLexer_yyset_lineno_ALREADY_DEFINED
186
#else
187
#define yyset_lineno cmListFileLexer_yyset_lineno
188
#endif
189
190
#ifdef yyget_column
191
#define cmListFileLexer_yyget_column_ALREADY_DEFINED
192
#else
193
#define yyget_column cmListFileLexer_yyget_column
194
#endif
195
196
#ifdef yyset_column
197
#define cmListFileLexer_yyset_column_ALREADY_DEFINED
198
#else
199
#define yyset_column cmListFileLexer_yyset_column
200
#endif
201
202
#ifdef yywrap
203
#define cmListFileLexer_yywrap_ALREADY_DEFINED
204
#else
205
#define yywrap cmListFileLexer_yywrap
206
#endif
207
208
#ifdef yyalloc
209
#define cmListFileLexer_yyalloc_ALREADY_DEFINED
210
#else
211
#define yyalloc cmListFileLexer_yyalloc
212
#endif
213
214
#ifdef yyrealloc
215
#define cmListFileLexer_yyrealloc_ALREADY_DEFINED
216
#else
217
#define yyrealloc cmListFileLexer_yyrealloc
218
#endif
219
220
#ifdef yyfree
221
#define cmListFileLexer_yyfree_ALREADY_DEFINED
222
#else
223
#define yyfree cmListFileLexer_yyfree
224
#endif
225
226
/* First, we deal with platform-specific or compiler-specific issues. */
227
228
/* begin standard C headers. */
229
#include <stdio.h>
230
#include <string.h>
231
#include <errno.h>
232
#include <stdlib.h>
233
234
/* end standard C headers. */
235
236
/* flex integer type definitions */
237
238
#ifndef FLEXINT_H
239
#define FLEXINT_H
240
241
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
242
243
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
244
245
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
246
* if you want the limit (max/min) macros for int types.
247
*/
248
#ifndef __STDC_LIMIT_MACROS
249
#define __STDC_LIMIT_MACROS 1
250
#endif
251
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;
266
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
295
296
#ifndef SIZE_MAX
297
#define SIZE_MAX (~(size_t)0)
298
#endif
299
300
#endif /* ! C99 */
301
302
#endif /* ! FLEXINT_H */
303
304
/* begin standard C++ headers. */
305
306
/* TODO: this is always defined, so inline it */
307
#define yyconst const
308
309
#if defined(__GNUC__) && __GNUC__ >= 3
310
#define yynoreturn __attribute__((__noreturn__))
311
#else
312
#define yynoreturn
313
#endif
314
315
/* Returned upon end-of-file. */
316
#define YY_NULL 0
317
318
/* Promotes a possibly negative, possibly signed char to an
319
* integer in range [0..255] for use as an array index.
320
*/
321
#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
322
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
328
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
339
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.
343
*/
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.
348
*/
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
356
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.
363
*/
364
#define YY_BUF_SIZE 32768
365
#else
366
#define YY_BUF_SIZE 16384
367
#endif /* __ia64__ */
368
#endif
369
370
/* The state buf must be large enough to hold one state per character in the main buffer.
371
*/
372
#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
373
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
378
379
#ifndef YY_TYPEDEF_YY_SIZE_T
380
#define YY_TYPEDEF_YY_SIZE_T
381
typedef size_t yy_size_t;
382
#endif
383
384
#define EOB_ACT_CONTINUE_SCAN 0
385
#define EOB_ACT_END_OF_FILE 1
386
#define EOB_ACT_LAST_MATCH 2
387
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.
394
*/
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)
409
410
/* Return all but the first "n" matched characters back to the input stream. */
411
#define yyless(n) \
412
do \
413
{ \
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 */ \
421
} \
422
while ( 0 )
423
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
424
425
#ifndef YY_STRUCT_YY_BUFFER_STATE
426
#define YY_STRUCT_YY_BUFFER_STATE
427
struct yy_buffer_state
428
{
429
FILE *yy_input_file;
430
431
char *yy_ch_buf; /* input buffer */
432
char *yy_buf_pos; /* current position in input buffer */
433
434
/* Size of input buffer in bytes, not including room for EOB
435
* characters.
436
*/
437
int yy_buf_size;
438
439
/* Number of characters read into yy_ch_buf, not including EOB
440
* characters.
441
*/
442
int yy_n_chars;
443
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.
447
*/
448
int yy_is_our_buffer;
449
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.
454
*/
455
int yy_is_interactive;
456
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.
460
*/
461
int yy_at_bol;
462
463
int yy_bs_lineno; /**< The line count. */
464
int yy_bs_column; /**< The column count. */
465
466
/* Whether to try to fill the input buffer when we reach the
467
* end of it.
468
*/
469
int yy_fill_buffer;
470
471
int yy_buffer_status;
472
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.
480
*
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.
484
*/
485
#define YY_BUFFER_EOF_PENDING 2
486
487
};
488
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
489
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".
493
*
494
* Returns the top of the stack, or NULL.
495
*/
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.
501
*/
502
#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
503
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 );
511
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)
516
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 );
520
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 );
524
525
#define yy_new_buffer yy_create_buffer
526
#define yy_set_interactive(is_interactive) \
527
{ \
528
if ( ! YY_CURRENT_BUFFER ){ \
529
yyensure_buffer_stack (yyscanner); \
530
YY_CURRENT_BUFFER_LVALUE = \
531
yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
532
} \
533
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
534
}
535
#define yy_set_bol(at_bol) \
536
{ \
537
if ( ! YY_CURRENT_BUFFER ){\
538
yyensure_buffer_stack (yyscanner); \
539
YY_CURRENT_BUFFER_LVALUE = \
540
yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
541
} \
542
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
543
}
544
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
545
546
/* Begin user sect3 */
547
548
#define cmListFileLexer_yywrap(yyscanner) (/*CONSTCOND*/1)
549
#define YY_SKIP_YYWRAP
550
typedef flex_uint8_t YY_CHAR;
551
552
typedef int yy_state_type;
553
554
#define yytext_ptr yytext_r
555
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 );
560
561
/* Done after the current pattern has been matched and before the
562
* corresponding action - sets up yytext.
563
*/
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
575
{
576
flex_int32_t yy_verify;
577
flex_int32_t yy_nxt;
578
};
579
static const flex_int16_t yy_accept[77] =
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, 17, 19, 20, 21, 10, 11, 8, 12,
584
9, 4, 13, 0, 13, 0, 22, 0, 0, 7,
585
13, 0, 13, 0, 2, 0, 13, 17, 0, 18,
586
10, 8, 4, 0, 14, 0, 0, 0, 0, 14,
587
0, 0, 14, 0, 0, 0, 2, 14, 0, 0,
588
0, 0, 0, 0, 0, 0
589
} ;
590
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,
603
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,
614
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
621
} ;
622
623
static const YY_CHAR yy_meta[16] =
624
{ 0,
625
1, 1, 2, 3, 4, 3, 1, 3, 5, 6,
626
1, 6, 1, 1, 7
627
} ;
628
629
static const flex_int16_t yy_base[95] =
630
{ 0,
631
0, 0, 13, 25, 14, 16, 17, 18, 90, 88,
632
88, 39, 20, 237, 237, 74, 78, 237, 237, 13,
633
54, 0, 71, 237, 237, 31, 0, 237, 73, 237,
634
237, 0, 0, 65, 75, 0, 33, 30, 72, 0,
635
0, 75, 70, 0, 74, 0, 0, 62, 70, 237,
636
0, 63, 0, 85, 99, 65, 111, 62, 34, 0,
637
54, 116, 0, 54, 127, 51, 237, 50, 0, 48,
638
47, 39, 33, 29, 17, 237, 136, 143, 150, 157,
639
164, 171, 178, 184, 191, 198, 201, 207, 214, 217,
640
219, 225, 228, 230
641
642
} ;
643
644
static const flex_int16_t yy_def[95] =
645
{ 0,
646
76, 1, 77, 77, 78, 78, 79, 79, 80, 80,
647
76, 76, 76, 76, 76, 76, 12, 76, 76, 12,
648
76, 81, 82, 76, 76, 82, 83, 76, 76, 76,
649
76, 84, 12, 85, 12, 86, 76, 76, 87, 20,
650
12, 88, 12, 21, 76, 89, 12, 82, 82, 76,
651
83, 76, 84, 85, 76, 54, 85, 90, 76, 55,
652
87, 88, 55, 62, 88, 91, 76, 55, 92, 93,
653
90, 94, 91, 93, 94, 0, 76, 76, 76, 76,
654
76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
655
76, 76, 76, 76
656
657
} ;
658
659
static const flex_int16_t yy_nxt[253] =
660
{ 0,
661
12, 13, 14, 13, 15, 16, 17, 18, 19, 12,
662
12, 20, 21, 22, 12, 24, 28, 25, 28, 28,
663
28, 37, 40, 37, 40, 62, 26, 24, 29, 25,
664
29, 31, 31, 50, 37, 48, 37, 54, 26, 33,
665
59, 63, 45, 34, 59, 35, 45, 62, 33, 33,
666
33, 33, 36, 33, 41, 55, 54, 58, 42, 63,
667
43, 72, 60, 41, 44, 41, 45, 46, 41, 55,
668
55, 56, 70, 52, 48, 49, 67, 66, 57, 63,
669
60, 64, 58, 52, 49, 39, 38, 76, 65, 55,
670
14, 56, 14, 76, 76, 76, 76, 76, 57, 55,
671
672
76, 76, 76, 34, 76, 68, 76, 76, 55, 55,
673
55, 55, 69, 55, 54, 76, 54, 76, 54, 54,
674
63, 76, 64, 76, 76, 76, 76, 76, 76, 65,
675
62, 76, 62, 76, 62, 62, 23, 23, 23, 23,
676
23, 23, 23, 27, 27, 27, 27, 27, 27, 27,
677
30, 30, 30, 30, 30, 30, 30, 32, 32, 32,
678
32, 32, 32, 32, 47, 76, 47, 47, 47, 47,
679
47, 48, 76, 48, 76, 48, 48, 48, 51, 76,
680
51, 51, 51, 51, 53, 76, 53, 53, 53, 53,
681
53, 54, 76, 76, 54, 76, 54, 54, 33, 76,
682
683
33, 33, 33, 33, 33, 61, 61, 62, 76, 76,
684
62, 76, 62, 62, 41, 76, 41, 41, 41, 41,
685
41, 71, 71, 73, 73, 55, 76, 55, 55, 55,
686
55, 55, 74, 74, 75, 75, 11, 76, 76, 76,
687
76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
688
76, 76
689
} ;
690
691
static const flex_int16_t yy_chk[253] =
692
{ 0,
693
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
694
1, 1, 1, 1, 1, 3, 5, 3, 6, 7,
695
8, 13, 20, 13, 20, 75, 3, 4, 5, 4,
696
6, 7, 8, 26, 37, 26, 37, 74, 4, 12,
697
38, 73, 38, 12, 59, 12, 59, 72, 12, 12,
698
12, 12, 12, 12, 21, 71, 70, 68, 21, 66,
699
21, 64, 61, 21, 21, 21, 21, 21, 21, 34,
700
58, 34, 56, 52, 49, 48, 45, 43, 34, 42,
701
39, 42, 35, 29, 23, 17, 16, 11, 42, 54,
702
10, 54, 9, 0, 0, 0, 0, 0, 54, 55,
703
704
0, 0, 0, 55, 0, 55, 0, 0, 55, 55,
705
55, 55, 55, 55, 57, 0, 57, 0, 57, 57,
706
62, 0, 62, 0, 0, 0, 0, 0, 0, 62,
707
65, 0, 65, 0, 65, 65, 77, 77, 77, 77,
708
77, 77, 77, 78, 78, 78, 78, 78, 78, 78,
709
79, 79, 79, 79, 79, 79, 79, 80, 80, 80,
710
80, 80, 80, 80, 81, 0, 81, 81, 81, 81,
711
81, 82, 0, 82, 0, 82, 82, 82, 83, 0,
712
83, 83, 83, 83, 84, 0, 84, 84, 84, 84,
713
84, 85, 0, 0, 85, 0, 85, 85, 86, 0,
714
715
86, 86, 86, 86, 86, 87, 87, 88, 0, 0,
716
88, 0, 88, 88, 89, 0, 89, 89, 89, 89,
717
89, 90, 90, 91, 91, 92, 0, 92, 92, 92,
718
92, 92, 93, 93, 94, 94, 76, 76, 76, 76,
719
76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
720
76, 76
721
} ;
722
723
/* Table of booleans, true if rule could match eol. */
724
static const flex_int32_t yy_rule_can_match_eol[25] =
725
{ 0,
726
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1,
727
0, 0, 0, 0, 0, };
728
729
/* The intent behind this definition is that it'll catch
730
* any uses of REJECT which flex missed.
731
*/
732
#define REJECT reject_used_but_not_detected
733
#define yymore() yymore_used_but_not_detected
734
#define YY_MORE_ADJ 0
735
#define YY_RESTORE_YY_MORE_OFFSET
736
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
737
file LICENSE.rst or https://cmake.org/licensing for details. */
738
/*
739
740
This file must be translated to C and modified to build everywhere.
741
742
Run flex >= 2.6 like this:
743
744
flex --nounistd -DFLEXINT_H --noline -ocmListFileLexer.c cmListFileLexer.in.l
745
746
Modify cmListFileLexer.c:
747
- remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c
748
- remove blank lines at end of file: sed -i '${/^$/d;}' cmListFileLexer.c
749
- #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmListFileLexer.c
750
751
*/
752
753
/* IWYU pragma: no_forward_declare yyguts_t */
754
755
#ifdef _WIN32
756
#include "cmsys/Encoding.h"
757
#endif
758
759
/* Setup the proper cmListFileLexer_yylex declaration. */
760
#define YY_EXTRA_TYPE cmListFileLexer*
761
#define YY_DECL int cmListFileLexer_yylex (yyscan_t yyscanner, cmListFileLexer* lexer)
762
763
#include "cmListFileLexer.h"
764
765
/*--------------------------------------------------------------------------*/
766
struct cmListFileLexer_s
767
{
768
cmListFileLexer_Token token;
769
int bracket;
770
int comment;
771
int line;
772
int column;
773
size_t size;
774
FILE* file;
775
size_t cr;
776
char read_buffer[4];
777
size_t read_size;
778
size_t read_position;
779
char* string_buffer;
780
char* string_position;
781
size_t string_left;
782
yyscan_t scanner;
783
};
784
785
static void cmListFileLexerSetToken(cmListFileLexer* lexer, const char* text,
786
size_t length);
787
static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
788
size_t length);
789
static int cmListFileLexerInput(cmListFileLexer* lexer, char* buffer,
790
size_t bufferSize);
791
static void cmListFileLexerInit(cmListFileLexer* lexer);
792
static void cmListFileLexerDestroy(cmListFileLexer* lexer);
793
794
/* Replace the lexer input function. */
795
#undef YY_INPUT
796
#define YY_INPUT(buf, result, max_size) \
797
do { result = cmListFileLexerInput(cmListFileLexer_yyget_extra(yyscanner), buf, max_size); } while (0)
798
799
/*--------------------------------------------------------------------------*/
800
801
#define INITIAL 0
802
#define STRING 1
803
#define BRACKET 2
804
#define BRACKETEND 3
805
#define COMMENT 4
806
807
#ifndef YY_EXTRA_TYPE
808
#define YY_EXTRA_TYPE void *
809
#endif
810
811
/* Holds the entire state of the reentrant scanner. */
812
struct yyguts_t
813
{
814
815
/* User-defined. Not touched by flex. */
816
YY_EXTRA_TYPE yyextra_r;
817
818
/* The rest are the same as the globals declared in the non-reentrant scanner. */
819
FILE *yyin_r, *yyout_r;
820
size_t yy_buffer_stack_top; /**< index of top of stack. */
821
size_t yy_buffer_stack_max; /**< capacity of stack. */
822
YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
823
char yy_hold_char;
824
int yy_n_chars;
825
int yyleng_r;
826
char *yy_c_buf_p;
827
int yy_init;
828
int yy_start;
829
int yy_did_buffer_switch_on_eof;
830
int yy_start_stack_ptr;
831
int yy_start_stack_depth;
832
int *yy_start_stack;
833
yy_state_type yy_last_accepting_state;
834
char* yy_last_accepting_cpos;
835
836
int yylineno_r;
837
int yy_flex_debug_r;
838
839
char *yytext_r;
840
int yy_more_flag;
841
int yy_more_len;
842
843
}; /* end struct yyguts_t */
844
845
static int yy_init_globals ( yyscan_t yyscanner );
846
847
int yylex_init (yyscan_t* scanner);
848
849
int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
850
851
/* Accessor methods to globals.
852
These are made visible to non-reentrant scanners for convenience. */
853
854
int yylex_destroy ( yyscan_t yyscanner );
855
856
int yyget_debug ( yyscan_t yyscanner );
857
858
void yyset_debug ( int debug_flag , yyscan_t yyscanner );
859
860
YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
861
862
void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
863
864
FILE *yyget_in ( yyscan_t yyscanner );
865
866
void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
867
868
FILE *yyget_out ( yyscan_t yyscanner );
869
870
void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
871
872
int yyget_leng ( yyscan_t yyscanner );
873
874
char *yyget_text ( yyscan_t yyscanner );
875
876
int yyget_lineno ( yyscan_t yyscanner );
877
878
void yyset_lineno ( int _line_number , yyscan_t yyscanner );
879
880
int yyget_column ( yyscan_t yyscanner );
881
882
void yyset_column ( int _column_no , yyscan_t yyscanner );
883
884
/* Macros after this point can all be overridden by user definitions in
885
* section 1.
886
*/
887
888
#ifndef YY_SKIP_YYWRAP
889
#ifdef __cplusplus
890
extern "C" int yywrap ( yyscan_t yyscanner );
891
#else
892
extern int yywrap ( yyscan_t yyscanner );
893
#endif
894
#endif
895
896
#ifndef YY_NO_UNPUT
897
898
static void yyunput ( int c, char *buf_ptr , yyscan_t yyscanner);
899
900
#endif
901
902
#ifndef yytext_ptr
903
static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
904
#endif
905
906
#ifdef YY_NEED_STRLEN
907
static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
908
#endif
909
910
#ifndef YY_NO_INPUT
911
#ifdef __cplusplus
912
static int yyinput ( yyscan_t yyscanner );
913
#else
914
static int input ( yyscan_t yyscanner );
915
#endif
916
917
#endif
918
919
/* Amount of stuff to slurp up with each read. */
920
#ifndef YY_READ_BUF_SIZE
921
#ifdef __ia64__
922
/* On IA-64, the buffer size is 16k, not 8k */
923
#define YY_READ_BUF_SIZE 16384
924
#else
925
#define YY_READ_BUF_SIZE 8192
926
#endif /* __ia64__ */
927
#endif
928
929
/* Copy whatever the last rule matched to the standard output. */
930
#ifndef ECHO
931
/* This used to be an fputs(), but since the string might contain NUL's,
932
* we now use fwrite().
933
*/
934
#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
935
#endif
936
937
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
938
* is returned in "result".
939
*/
940
#ifndef YY_INPUT
941
#define YY_INPUT(buf,result,max_size) \
942
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
943
{ \
944
int c = '*'; \
945
int n; \
946
for ( n = 0; n < max_size && \
947
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
948
buf[n] = (char) c; \
949
if ( c == '\n' ) \
950
buf[n++] = (char) c; \
951
if ( c == EOF && ferror( yyin ) ) \
952
YY_FATAL_ERROR( "input in flex scanner failed" ); \
953
result = n; \
954
} \
955
else \
956
{ \
957
errno=0; \
958
while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
959
{ \
960
if( errno != EINTR) \
961
{ \
962
YY_FATAL_ERROR( "input in flex scanner failed" ); \
963
break; \
964
} \
965
errno=0; \
966
clearerr(yyin); \
967
} \
968
}\
969
\
970
971
#endif
972
973
/* No semi-colon after return; correct usage is to write "yyterminate();" -
974
* we don't want an extra ';' after the "return" because that will cause
975
* some compilers to complain about unreachable statements.
976
*/
977
#ifndef yyterminate
978
#define yyterminate() return YY_NULL
979
#endif
980
981
/* Number of entries by which start-condition stack grows. */
982
#ifndef YY_START_STACK_INCR
983
#define YY_START_STACK_INCR 25
984
#endif
985
986
/* Report a fatal error. */
987
#ifndef YY_FATAL_ERROR
988
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
989
#endif
990
991
/* end tables serialization structures and prototypes */
992
993
/* Default declaration of generated scanner - a define so the user can
994
* easily add parameters.
995
*/
996
#ifndef YY_DECL
997
#define YY_DECL_IS_OURS 1
998
999
extern int yylex (yyscan_t yyscanner);
1000
1001
#define YY_DECL int yylex (yyscan_t yyscanner)
1002
#endif /* !YY_DECL */
1003
1004
/* Code executed at the beginning of each rule, after yytext and yyleng
1005
* have been set up.
1006
*/
1007
#ifndef YY_USER_ACTION
1008
#define YY_USER_ACTION
1009
#endif
1010
1011
/* Code executed at the end of each rule. */
1012
#ifndef YY_BREAK
1013
#define YY_BREAK /*LINTED*/break;
1014
#endif
1015
1016
#define YY_RULE_SETUP \
1017
YY_USER_ACTION
1018
1019
/** The main scanner function which does all the work.
1020
*/
1021
YY_DECL
1022
{
1023
yy_state_type yy_current_state;
1024
char *yy_cp, *yy_bp;
1025
int yy_act;
1026
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1027
1028
if ( !yyg->yy_init )
1029
{
1030
yyg->yy_init = 1;
1031
1032
#ifdef YY_USER_INIT
1033
YY_USER_INIT;
1034
#endif
1035
1036
if ( ! yyg->yy_start )
1037
yyg->yy_start = 1; /* first start state */
1038
1039
if ( ! yyin )
1040
yyin = stdin;
1041
1042
if ( ! yyout )
1043
yyout = stdout;
1044
1045
if ( ! YY_CURRENT_BUFFER ) {
1046
yyensure_buffer_stack (yyscanner);
1047
YY_CURRENT_BUFFER_LVALUE =
1048
yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
1049
}
1050
1051
yy_load_buffer_state( yyscanner );
1052
}
1053
1054
{
1055
1056
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
1057
{
1058
yy_cp = yyg->yy_c_buf_p;
1059
1060
/* Support of yytext. */
1061
*yy_cp = yyg->yy_hold_char;
1062
1063
/* yy_bp points to the position in yy_ch_buf of the start of
1064
* the current run.
1065
*/
1066
yy_bp = yy_cp;
1067
1068
yy_current_state = yyg->yy_start;
1069
yy_match:
1070
do
1071
{
1072
YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
1073
if ( yy_accept[yy_current_state] )
1074
{
1075
yyg->yy_last_accepting_state = yy_current_state;
1076
yyg->yy_last_accepting_cpos = yy_cp;
1077
}
1078
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1079
{
1080
yy_current_state = (int) yy_def[yy_current_state];
1081
if ( yy_current_state >= 77 )
1082
yy_c = yy_meta[yy_c];
1083
}
1084
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1085
++yy_cp;
1086
}
1087
while ( yy_base[yy_current_state] != 237 );
1088
1089
yy_find_action:
1090
yy_act = yy_accept[yy_current_state];
1091
if ( yy_act == 0 )
1092
{ /* have to back up */
1093
yy_cp = yyg->yy_last_accepting_cpos;
1094
yy_current_state = yyg->yy_last_accepting_state;
1095
yy_act = yy_accept[yy_current_state];
1096
}
1097
1098
YY_DO_BEFORE_ACTION;
1099
1100
if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
1101
{
1102
int yyl;
1103
for ( yyl = 0; yyl < yyleng; ++yyl )
1104
if ( yytext[yyl] == '\n' )
1105
1106
do{ yylineno++;
1107
yycolumn=0;
1108
}while(0)
1109
;
1110
}
1111
1112
do_action: /* This label is used only to access EOF actions. */
1113
1114
switch ( yy_act )
1115
{ /* beginning of action switch */
1116
case 0: /* must back up */
1117
/* undo the effects of YY_DO_BEFORE_ACTION */
1118
*yy_cp = yyg->yy_hold_char;
1119
yy_cp = yyg->yy_last_accepting_cpos;
1120
yy_current_state = yyg->yy_last_accepting_state;
1121
goto yy_find_action;
1122
1123
case 1:
1124
/* rule 1 can match eol */
1125
YY_RULE_SETUP
1126
{
1127
lexer->token.type = cmListFileLexer_Token_Newline;
1128
cmListFileLexerSetToken(lexer, yytext, yyleng);
1129
++lexer->line;
1130
lexer->column = 1;
1131
BEGIN(INITIAL);
1132
return 1;
1133
}
1134
YY_BREAK
1135
case 2:
1136
/* rule 2 can match eol */
1137
YY_RULE_SETUP
1138
{
1139
const char* bracket = yytext;
1140
size_t length = yyleng;
1141
lexer->comment = yytext[0] == '#';
1142
if (lexer->comment) {
1143
lexer->token.type = cmListFileLexer_Token_CommentBracket;
1144
bracket += 1;
1145
--length;
1146
} else {
1147
lexer->token.type = cmListFileLexer_Token_ArgumentBracket;
1148
}
1149
cmListFileLexerSetToken(lexer, "", 0);
1150
lexer->bracket = (char*)memchr(bracket + 1, '[', length - 1) - bracket;
1151
if (yytext[yyleng-1] == '\n') {
1152
++lexer->line;
1153
lexer->column = 1;
1154
} else {
1155
lexer->column += yyleng;
1156
}
1157
BEGIN(BRACKET);
1158
}
1159
YY_BREAK
1160
case 3:
1161
YY_RULE_SETUP
1162
{
1163
lexer->column += yyleng;
1164
BEGIN(COMMENT);
1165
}
1166
YY_BREAK
1167
case 4:
1168
YY_RULE_SETUP
1169
{
1170
if (memchr(yytext, '\0', yyleng) != NULL) {
1171
lexer->token.type = cmListFileLexer_Token_BadCharacter;
1172
}
1173
lexer->column += yyleng;
1174
}
1175
YY_BREAK
1176
case 5:
1177
YY_RULE_SETUP
1178
{
1179
lexer->token.type = cmListFileLexer_Token_ParenLeft;
1180
cmListFileLexerSetToken(lexer, yytext, yyleng);
1181
lexer->column += yyleng;
1182
return 1;
1183
}
1184
YY_BREAK
1185
case 6:
1186
YY_RULE_SETUP
1187
{
1188
lexer->token.type = cmListFileLexer_Token_ParenRight;
1189
cmListFileLexerSetToken(lexer, yytext, yyleng);
1190
lexer->column += yyleng;
1191
return 1;
1192
}
1193
YY_BREAK
1194
case 7:
1195
YY_RULE_SETUP
1196
{
1197
lexer->token.type = cmListFileLexer_Token_Identifier;
1198
cmListFileLexerSetToken(lexer, yytext, yyleng);
1199
lexer->column += yyleng;
1200
return 1;
1201
}
1202
YY_BREAK
1203
case 8:
1204
YY_RULE_SETUP
1205
{
1206
/* Handle ]]====]=======]*/
1207
cmListFileLexerAppend(lexer, yytext, yyleng);
1208
lexer->column += yyleng;
1209
if (yyleng == lexer->bracket) {
1210
BEGIN(BRACKETEND);
1211
}
1212
}
1213
YY_BREAK
1214
case 9:
1215
YY_RULE_SETUP
1216
{
1217
lexer->column += yyleng;
1218
/* Erase the partial bracket from the token. */
1219
lexer->token.length -= lexer->bracket;
1220
BEGIN(INITIAL);
1221
return 1;
1222
}
1223
YY_BREAK
1224
case 10:
1225
YY_RULE_SETUP
1226
{
1227
if (memchr(yytext, '\0', yyleng) != NULL) {
1228
lexer->token.type = cmListFileLexer_Token_BadCharacter;
1229
}
1230
cmListFileLexerAppend(lexer, yytext, yyleng);
1231
lexer->column += yyleng;
1232
}
1233
YY_BREAK
1234
case 11:
1235
/* rule 11 can match eol */
1236
YY_RULE_SETUP
1237
{
1238
cmListFileLexerAppend(lexer, yytext, yyleng);
1239
++lexer->line;
1240
lexer->column = 1;
1241
BEGIN(BRACKET);
1242
}
1243
YY_BREAK
1244
case 12:
1245
YY_RULE_SETUP
1246
{
1247
if (memchr(yytext, '\0', yyleng) != NULL) {
1248
lexer->token.type = cmListFileLexer_Token_BadCharacter;
1249
}
1250
cmListFileLexerAppend(lexer, yytext, yyleng);
1251
lexer->column += yyleng;
1252
BEGIN(BRACKET);
1253
}
1254
YY_BREAK
1255
case YY_STATE_EOF(BRACKET):
1256
case YY_STATE_EOF(BRACKETEND):
1257
{
1258
lexer->token.type = cmListFileLexer_Token_BadBracket;
1259
BEGIN(INITIAL);
1260
return 1;
1261
}
1262
YY_BREAK
1263
case 13:
1264
YY_RULE_SETUP
1265
{
1266
if (memchr(yytext, '\0', yyleng) != NULL) {
1267
/* An unquoted argument that contains a null character. */
1268
lexer->token.type = cmListFileLexer_Token_BadCharacter;
1269
} else {
1270
lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
1271
}
1272
cmListFileLexerSetToken(lexer, yytext, yyleng);
1273
lexer->column += yyleng;
1274
return 1;
1275
}
1276
YY_BREAK
1277
case 14:
1278
YY_RULE_SETUP
1279
{
1280
lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
1281
cmListFileLexerSetToken(lexer, yytext, yyleng);
1282
lexer->column += yyleng;
1283
return 1;
1284
}
1285
YY_BREAK
1286
case 15:
1287
YY_RULE_SETUP
1288
{
1289
lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
1290
cmListFileLexerSetToken(lexer, yytext, yyleng);
1291
lexer->column += yyleng;
1292
return 1;
1293
}
1294
YY_BREAK
1295
case 16:
1296
YY_RULE_SETUP
1297
{
1298
lexer->token.type = cmListFileLexer_Token_ArgumentQuoted;
1299
cmListFileLexerSetToken(lexer, "", 0);
1300
lexer->column += yyleng;
1301
BEGIN(STRING);
1302
}
1303
YY_BREAK
1304
case 17:
1305
YY_RULE_SETUP
1306
{
1307
if (memchr(yytext, '\0', yyleng) != NULL) {
1308
lexer->token.type = cmListFileLexer_Token_BadCharacter;
1309
}
1310
cmListFileLexerAppend(lexer, yytext, yyleng);
1311
lexer->column += yyleng;
1312
}
1313
YY_BREAK
1314
case 18:
1315
/* rule 18 can match eol */
1316
YY_RULE_SETUP
1317
{
1318
/* Continuation: text is not part of string */
1319
++lexer->line;
1320
lexer->column = 1;
1321
}
1322
YY_BREAK
1323
case 19:
1324
/* rule 19 can match eol */
1325
YY_RULE_SETUP
1326
{
1327
cmListFileLexerAppend(lexer, yytext, yyleng);
1328
++lexer->line;
1329
lexer->column = 1;
1330
}
1331
YY_BREAK
1332
case 20:
1333
YY_RULE_SETUP
1334
{
1335
lexer->column += yyleng;
1336
BEGIN(INITIAL);
1337
return 1;
1338
}
1339
YY_BREAK
1340
case 21:
1341
YY_RULE_SETUP
1342
{
1343
if (memchr(yytext, '\0', yyleng) != NULL) {
1344
lexer->token.type = cmListFileLexer_Token_BadCharacter;
1345
}
1346
cmListFileLexerAppend(lexer, yytext, yyleng);
1347
lexer->column += yyleng;
1348
}
1349
YY_BREAK
1350
case YY_STATE_EOF(STRING):
1351
{
1352
lexer->token.type = cmListFileLexer_Token_BadString;
1353
BEGIN(INITIAL);
1354
return 1;
1355
}
1356
YY_BREAK
1357
case 22:
1358
YY_RULE_SETUP
1359
{
1360
lexer->token.type = cmListFileLexer_Token_Space;
1361
cmListFileLexerSetToken(lexer, yytext, yyleng);
1362
lexer->column += yyleng;
1363
return 1;
1364
}
1365
YY_BREAK
1366
case 23:
1367
YY_RULE_SETUP
1368
{
1369
lexer->token.type = cmListFileLexer_Token_BadCharacter;
1370
cmListFileLexerSetToken(lexer, yytext, yyleng);
1371
lexer->column += yyleng;
1372
return 1;
1373
}
1374
YY_BREAK
1375
case YY_STATE_EOF(INITIAL):
1376
case YY_STATE_EOF(COMMENT):
1377
{
1378
lexer->token.type = cmListFileLexer_Token_None;
1379
cmListFileLexerSetToken(lexer, 0, 0);
1380
return 0;
1381
}
1382
YY_BREAK
1383
case 24:
1384
YY_RULE_SETUP
1385
ECHO;
1386
YY_BREAK
1387
1388
case YY_END_OF_BUFFER:
1389
{
1390
/* Amount of text matched not including the EOB char. */
1391
int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1392
1393
/* Undo the effects of YY_DO_BEFORE_ACTION. */
1394
*yy_cp = yyg->yy_hold_char;
1395
YY_RESTORE_YY_MORE_OFFSET
1396
1397
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1398
{
1399
/* We're scanning a new file or input source. It's
1400
* possible that this happened because the user
1401
* just pointed yyin at a new source and called
1402
* yylex(). If so, then we have to assure
1403
* consistency between YY_CURRENT_BUFFER and our
1404
* globals. Here is the right place to do so, because
1405
* this is the first action (other than possibly a
1406
* back-up) that will match for the new input source.
1407
*/
1408
yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1409
YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1410
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1411
}
1412
1413
/* Note that here we test for yy_c_buf_p "<=" to the position
1414
* of the first EOB in the buffer, since yy_c_buf_p will
1415
* already have been incremented past the NUL character
1416
* (since all states make transitions on EOB to the
1417
* end-of-buffer state). Contrast this with the test
1418
* in input().
1419
*/
1420
if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1421
{ /* This was really a NUL. */
1422
yy_state_type yy_next_state;
1423
1424
yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1425
1426
yy_current_state = yy_get_previous_state( yyscanner );
1427
1428
/* Okay, we're now positioned to make the NUL
1429
* transition. We couldn't have
1430
* yy_get_previous_state() go ahead and do it
1431
* for us because it doesn't know how to deal
1432
* with the possibility of jamming (and we don't
1433
* want to build jamming into it because then it
1434
* will run more slowly).
1435
*/
1436
1437
yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1438
1439
yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1440
1441
if ( yy_next_state )
1442
{
1443
/* Consume the NUL. */
1444
yy_cp = ++yyg->yy_c_buf_p;
1445
yy_current_state = yy_next_state;
1446
goto yy_match;
1447
}
1448
1449
else
1450
{
1451
yy_cp = yyg->yy_c_buf_p;
1452
goto yy_find_action;
1453
}
1454
}
1455
1456
else switch ( yy_get_next_buffer( yyscanner ) )
1457
{
1458
case EOB_ACT_END_OF_FILE:
1459
{
1460
yyg->yy_did_buffer_switch_on_eof = 0;
1461
1462
if ( yywrap( yyscanner ) )
1463
{
1464
/* Note: because we've taken care in
1465
* yy_get_next_buffer() to have set up
1466
* yytext, we can now set up
1467
* yy_c_buf_p so that if some total
1468
* hoser (like flex itself) wants to
1469
* call the scanner after we return the
1470
* YY_NULL, it'll still work - another
1471
* YY_NULL will get returned.
1472
*/
1473
yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1474
1475
yy_act = YY_STATE_EOF(YY_START);
1476
goto do_action;
1477
}
1478
1479
else
1480
{
1481
if ( ! yyg->yy_did_buffer_switch_on_eof )
1482
YY_NEW_FILE;
1483
}
1484
break;
1485
}
1486
1487
case EOB_ACT_CONTINUE_SCAN:
1488
yyg->yy_c_buf_p =
1489
yyg->yytext_ptr + yy_amount_of_matched_text;
1490
1491
yy_current_state = yy_get_previous_state( yyscanner );
1492
1493
yy_cp = yyg->yy_c_buf_p;
1494
yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1495
goto yy_match;
1496
1497
case EOB_ACT_LAST_MATCH:
1498
yyg->yy_c_buf_p =
1499
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1500
1501
yy_current_state = yy_get_previous_state( yyscanner );
1502
1503
yy_cp = yyg->yy_c_buf_p;
1504
yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1505
goto yy_find_action;
1506
}
1507
break;
1508
}
1509
1510
default:
1511
YY_FATAL_ERROR(
1512
"fatal flex scanner internal error--no action found" );
1513
} /* end of action switch */
1514
} /* end of scanning one token */
1515
} /* end of user's declarations */
1516
} /* end of yylex */
1517
1518
/* yy_get_next_buffer - try to read in a new buffer
1519
*
1520
* Returns a code representing an action:
1521
* EOB_ACT_LAST_MATCH -
1522
* EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1523
* EOB_ACT_END_OF_FILE - end of file
1524
*/
1525
static int yy_get_next_buffer (yyscan_t yyscanner)
1526
{
1527
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1528
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1529
char *source = yyg->yytext_ptr;
1530
int number_to_move, i;
1531
int ret_val;
1532
1533
if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1534
YY_FATAL_ERROR(
1535
"fatal flex scanner internal error--end of buffer missed" );
1536
1537
if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1538
{ /* Don't try to fill the buffer, so this is an EOF. */
1539
if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1540
{
1541
/* We matched a single character, the EOB, so
1542
* treat this as a final EOF.
1543
*/
1544
return EOB_ACT_END_OF_FILE;
1545
}
1546
1547
else
1548
{
1549
/* We matched some text prior to the EOB, first
1550
* process it.
1551
*/
1552
return EOB_ACT_LAST_MATCH;
1553
}
1554
}
1555
1556
/* Try to read more data. */
1557
1558
/* First move last chars to start of buffer. */
1559
number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
1560
1561
for ( i = 0; i < number_to_move; ++i )
1562
*(dest++) = *(source++);
1563
1564
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1565
/* don't do the read, it's not guaranteed to return an EOF,
1566
* just force an EOF
1567
*/
1568
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1569
1570
else
1571
{
1572
int num_to_read =
1573
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1574
1575
while ( num_to_read <= 0 )
1576
{ /* Not enough room in the buffer - grow it. */
1577
1578
/* just a shorter name for the current buffer */
1579
YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1580
1581
int yy_c_buf_p_offset =
1582
(int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1583
1584
if ( b->yy_is_our_buffer )
1585
{
1586
int new_size = b->yy_buf_size * 2;
1587
1588
if ( new_size <= 0 )
1589
b->yy_buf_size += b->yy_buf_size / 8;
1590
else
1591
b->yy_buf_size *= 2;
1592
1593
b->yy_ch_buf = (char *)
1594
/* Include room in for 2 EOB chars. */
1595
yyrealloc( (void *) b->yy_ch_buf,
1596
(yy_size_t) (b->yy_buf_size + 2) , yyscanner );
1597
}
1598
else
1599
/* Can't grow it, we don't own it. */
1600
b->yy_ch_buf = NULL;
1601
1602
if ( ! b->yy_ch_buf )
1603
YY_FATAL_ERROR(
1604
"fatal error - scanner input buffer overflow" );
1605
1606
yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1607
1608
num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1609
number_to_move - 1;
1610
1611
}
1612
1613
if ( num_to_read > YY_READ_BUF_SIZE )
1614
num_to_read = YY_READ_BUF_SIZE;
1615
1616
/* Read in more data. */
1617
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1618
yyg->yy_n_chars, num_to_read );
1619
1620
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1621
}
1622
1623
if ( yyg->yy_n_chars == 0 )
1624
{
1625
if ( number_to_move == YY_MORE_ADJ )
1626
{
1627
ret_val = EOB_ACT_END_OF_FILE;
1628
yyrestart( yyin , yyscanner);
1629
}
1630
1631
else
1632
{
1633
ret_val = EOB_ACT_LAST_MATCH;
1634
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1635
YY_BUFFER_EOF_PENDING;
1636
}
1637
}
1638
1639
else
1640
ret_val = EOB_ACT_CONTINUE_SCAN;
1641
1642
if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1643
/* Extend the array by 50%, plus the number we really need. */
1644
int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1645
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
1646
(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
1647
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1648
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1649
/* "- 2" to take care of EOB's */
1650
YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
1651
}
1652
1653
yyg->yy_n_chars += number_to_move;
1654
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1655
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1656
1657
yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1658
1659
return ret_val;
1660
}
1661
1662
/* yy_get_previous_state - get the state just before the EOB char was reached */
1663
1664
static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1665
{
1666
yy_state_type yy_current_state;
1667
char *yy_cp;
1668
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1669
1670
yy_current_state = yyg->yy_start;
1671
1672
for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1673
{
1674
YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1675
if ( yy_accept[yy_current_state] )
1676
{
1677
yyg->yy_last_accepting_state = yy_current_state;
1678
yyg->yy_last_accepting_cpos = yy_cp;
1679
}
1680
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1681
{
1682
yy_current_state = (int) yy_def[yy_current_state];
1683
if ( yy_current_state >= 77 )
1684
yy_c = yy_meta[yy_c];
1685
}
1686
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1687
}
1688
1689
return yy_current_state;
1690
}
1691
1692
/* yy_try_NUL_trans - try to make a transition on the NUL character
1693
*
1694
* synopsis
1695
* next_state = yy_try_NUL_trans( current_state );
1696
*/
1697
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1698
{
1699
int yy_is_jam;
1700
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1701
char *yy_cp = yyg->yy_c_buf_p;
1702
1703
YY_CHAR yy_c = 1;
1704
if ( yy_accept[yy_current_state] )
1705
{
1706
yyg->yy_last_accepting_state = yy_current_state;
1707
yyg->yy_last_accepting_cpos = yy_cp;
1708
}
1709
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1710
{
1711
yy_current_state = (int) yy_def[yy_current_state];
1712
if ( yy_current_state >= 77 )
1713
yy_c = yy_meta[yy_c];
1714
}
1715
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1716
yy_is_jam = (yy_current_state == 76);
1717
1718
(void)yyg;
1719
return yy_is_jam ? 0 : yy_current_state;
1720
}
1721
1722
#ifndef YY_NO_UNPUT
1723
1724
static void yyunput (int c, char * yy_bp , yyscan_t yyscanner)
1725
{
1726
char *yy_cp;
1727
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1728
1729
yy_cp = yyg->yy_c_buf_p;
1730
1731
/* undo effects of setting up yytext */
1732
*yy_cp = yyg->yy_hold_char;
1733
1734
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1735
{ /* need to shift things up to make room */
1736
/* +2 for EOB chars. */
1737
int number_to_move = yyg->yy_n_chars + 2;
1738
char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1739
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1740
char *source =
1741
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1742
1743
while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1744
*--dest = *--source;
1745
1746
yy_cp += (int) (dest - source);
1747
yy_bp += (int) (dest - source);
1748
YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1749
yyg->yy_n_chars = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1750
1751
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1752
YY_FATAL_ERROR( "flex scanner push-back overflow" );
1753
}
1754
1755
*--yy_cp = (char) c;
1756
1757
if ( c == '\n' ){
1758
--yylineno;
1759
}
1760
1761
yyg->yytext_ptr = yy_bp;
1762
yyg->yy_hold_char = *yy_cp;
1763
yyg->yy_c_buf_p = yy_cp;
1764
}
1765
1766
#endif
1767
1768
#ifndef YY_NO_INPUT
1769
#ifdef __cplusplus
1770
static int yyinput (yyscan_t yyscanner)
1771
#else
1772
static int input (yyscan_t yyscanner)
1773
#endif
1774
1775
{
1776
int c;
1777
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1778
1779
*yyg->yy_c_buf_p = yyg->yy_hold_char;
1780
1781
if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1782
{
1783
/* yy_c_buf_p now points to the character we want to return.
1784
* If this occurs *before* the EOB characters, then it's a
1785
* valid NUL; if not, then we've hit the end of the buffer.
1786
*/
1787
if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1788
/* This was really a NUL. */
1789
*yyg->yy_c_buf_p = '\0';
1790
1791
else
1792
{ /* need more input */
1793
int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
1794
++yyg->yy_c_buf_p;
1795
1796
switch ( yy_get_next_buffer( yyscanner ) )
1797
{
1798
case EOB_ACT_LAST_MATCH:
1799
/* This happens because yy_g_n_b()
1800
* sees that we've accumulated a
1801
* token and flags that we need to
1802
* try matching the token before
1803
* proceeding. But for input(),
1804
* there's no matching to consider.
1805
* So convert the EOB_ACT_LAST_MATCH
1806
* to EOB_ACT_END_OF_FILE.
1807
*/
1808
1809
/* Reset buffer status. */
1810
yyrestart( yyin , yyscanner);
1811
1812
/*FALLTHROUGH*/
1813
1814
case EOB_ACT_END_OF_FILE:
1815
{
1816
if ( yywrap( yyscanner ) )
1817
return 0;
1818
1819
if ( ! yyg->yy_did_buffer_switch_on_eof )
1820
YY_NEW_FILE;
1821
#ifdef __cplusplus
1822
return yyinput(yyscanner);
1823
#else
1824
return input(yyscanner);
1825
#endif
1826
}
1827
1828
case EOB_ACT_CONTINUE_SCAN:
1829
yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1830
break;
1831
}
1832
}
1833
}
1834
1835
c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1836
*yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1837
yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1838
1839
if ( c == '\n' )
1840
1841
do{ yylineno++;
1842
yycolumn=0;
1843
}while(0)
1844
;
1845
1846
return c;
1847
}
1848
#endif /* ifndef YY_NO_INPUT */
1849
1850
/** Immediately switch to a different input stream.
1851
* @param input_file A readable stream.
1852
* @param yyscanner The scanner object.
1853
* @note This function does not reset the start condition to @c INITIAL .
1854
*/
1855
void yyrestart (FILE * input_file , yyscan_t yyscanner)
1856
{
1857
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1858
1859
if ( ! YY_CURRENT_BUFFER ){
1860
yyensure_buffer_stack (yyscanner);
1861
YY_CURRENT_BUFFER_LVALUE =
1862
yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
1863
}
1864
1865
yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
1866
yy_load_buffer_state( yyscanner );
1867
}
1868
1869
/** Switch to a different input buffer.
1870
* @param new_buffer The new input buffer.
1871
* @param yyscanner The scanner object.
1872
*/
1873
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1874
{
1875
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1876
1877
/* TODO. We should be able to replace this entire function body
1878
* with
1879
* yypop_buffer_state();
1880
* yypush_buffer_state(new_buffer);
1881
*/
1882
yyensure_buffer_stack (yyscanner);
1883
if ( YY_CURRENT_BUFFER == new_buffer )
1884
return;
1885
1886
if ( YY_CURRENT_BUFFER )
1887
{
1888
/* Flush out information for old buffer. */
1889
*yyg->yy_c_buf_p = yyg->yy_hold_char;
1890
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1891
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1892
}
1893
1894
YY_CURRENT_BUFFER_LVALUE = new_buffer;
1895
yy_load_buffer_state( yyscanner );
1896
1897
/* We don't actually know whether we did this switch during
1898
* EOF (yywrap()) processing, but the only time this flag
1899
* is looked at is after yywrap() is called, so it's safe
1900
* to go ahead and always set it.
1901
*/
1902
yyg->yy_did_buffer_switch_on_eof = 1;
1903
}
1904
1905
static void yy_load_buffer_state (yyscan_t yyscanner)
1906
{
1907
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1908
yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1909
yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1910
yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1911
yyg->yy_hold_char = *yyg->yy_c_buf_p;
1912
}
1913
1914
/** Allocate and initialize an input buffer state.
1915
* @param file A readable stream.
1916
* @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1917
* @param yyscanner The scanner object.
1918
* @return the allocated buffer state.
1919
*/
1920
YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
1921
{
1922
YY_BUFFER_STATE b;
1923
1924
b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
1925
if ( ! b )
1926
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1927
1928
b->yy_buf_size = size;
1929
1930
/* yy_ch_buf has to be 2 characters longer than the size given because
1931
* we need to put in 2 end-of-buffer characters.
1932
*/
1933
b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
1934
if ( ! b->yy_ch_buf )
1935
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1936
1937
b->yy_is_our_buffer = 1;
1938
1939
yy_init_buffer( b, file , yyscanner);
1940
1941
return b;
1942
}
1943
1944
/** Destroy the buffer.
1945
* @param b a buffer created with yy_create_buffer()
1946
* @param yyscanner The scanner object.
1947
*/
1948
void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1949
{
1950
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1951
1952
if ( ! b )
1953
return;
1954
1955
if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1956
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1957
1958
if ( b->yy_is_our_buffer )
1959
yyfree( (void *) b->yy_ch_buf , yyscanner );
1960
1961
yyfree( (void *) b , yyscanner );
1962
}
1963
1964
/* Initializes or reinitializes a buffer.
1965
* This function is sometimes called more than once on the same buffer,
1966
* such as during a yyrestart() or at EOF.
1967
*/
1968
static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
1969
1970
{
1971
int oerrno = errno;
1972
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1973
1974
yy_flush_buffer( b , yyscanner);
1975
1976
b->yy_input_file = file;
1977
b->yy_fill_buffer = 1;
1978
1979
/* If b is the current buffer, then yy_init_buffer was _probably_
1980
* called from yyrestart() or through yy_get_next_buffer.
1981
* In that case, we don't want to reset the lineno or column.
1982
*/
1983
if (b != YY_CURRENT_BUFFER){
1984
b->yy_bs_lineno = 1;
1985
b->yy_bs_column = 0;
1986
}
1987
1988
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1989
1990
errno = oerrno;
1991
}
1992
1993
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1994
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1995
* @param yyscanner The scanner object.
1996
*/
1997
void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1998
{
1999
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2000
if ( ! b )
2001
return;
2002
2003
b->yy_n_chars = 0;
2004
2005
/* We always need two end-of-buffer characters. The first causes
2006
* a transition to the end-of-buffer state. The second causes
2007
* a jam in that state.
2008
*/
2009
b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2010
b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2011
2012
b->yy_buf_pos = &b->yy_ch_buf[0];
2013
2014
b->yy_at_bol = 1;
2015
b->yy_buffer_status = YY_BUFFER_NEW;
2016
2017
if ( b == YY_CURRENT_BUFFER )
2018
yy_load_buffer_state( yyscanner );
2019
}
2020
2021
/** Pushes the new state onto the stack. The new state becomes
2022
* the current state. This function will allocate the stack
2023
* if necessary.
2024
* @param new_buffer The new state.
2025
* @param yyscanner The scanner object.
2026
*/
2027
void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
2028
{
2029
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2030
if (new_buffer == NULL)
2031
return;
2032
2033
yyensure_buffer_stack(yyscanner);
2034
2035
/* This block is copied from yy_switch_to_buffer. */
2036
if ( YY_CURRENT_BUFFER )
2037
{
2038
/* Flush out information for old buffer. */
2039
*yyg->yy_c_buf_p = yyg->yy_hold_char;
2040
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2041
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2042
}
2043
2044
/* Only push if top exists. Otherwise, replace top. */
2045
if (YY_CURRENT_BUFFER)
2046
yyg->yy_buffer_stack_top++;
2047
YY_CURRENT_BUFFER_LVALUE = new_buffer;
2048
2049
/* copied from yy_switch_to_buffer. */
2050
yy_load_buffer_state( yyscanner );
2051
yyg->yy_did_buffer_switch_on_eof = 1;
2052
}
2053
2054
/** Removes and deletes the top of the stack, if present.
2055
* The next element becomes the new top.
2056
* @param yyscanner The scanner object.
2057
*/
2058
void yypop_buffer_state (yyscan_t yyscanner)
2059
{
2060
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2061
if (!YY_CURRENT_BUFFER)
2062
return;
2063
2064
yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
2065
YY_CURRENT_BUFFER_LVALUE = NULL;
2066
if (yyg->yy_buffer_stack_top > 0)
2067
--yyg->yy_buffer_stack_top;
2068
2069
if (YY_CURRENT_BUFFER) {
2070
yy_load_buffer_state( yyscanner );
2071
yyg->yy_did_buffer_switch_on_eof = 1;
2072
}
2073
}
2074
2075
/* Allocates the stack if it does not exist.
2076
* Guarantees space for at least one push.
2077
*/
2078
static void yyensure_buffer_stack (yyscan_t yyscanner)
2079
{
2080
yy_size_t num_to_alloc;
2081
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2082
2083
if (!yyg->yy_buffer_stack) {
2084
2085
/* First allocation is just for 2 elements, since we don't know if this
2086
* scanner will even need a stack. We use 2 instead of 1 to avoid an
2087
* immediate realloc on the next call.
2088
*/
2089
num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
2090
yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
2091
(num_to_alloc * sizeof(struct yy_buffer_state*)
2092
, yyscanner);
2093
if ( ! yyg->yy_buffer_stack )
2094
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2095
2096
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2097
2098
yyg->yy_buffer_stack_max = num_to_alloc;
2099
yyg->yy_buffer_stack_top = 0;
2100
return;
2101
}
2102
2103
if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
2104
2105
/* Increase the buffer to prepare for a possible push. */
2106
yy_size_t grow_size = 8 /* arbitrary grow size */;
2107
2108
num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
2109
yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
2110
(yyg->yy_buffer_stack,
2111
num_to_alloc * sizeof(struct yy_buffer_state*)
2112
, yyscanner);
2113
if ( ! yyg->yy_buffer_stack )
2114
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2115
2116
/* zero only the new slots.*/
2117
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
2118
yyg->yy_buffer_stack_max = num_to_alloc;
2119
}
2120
}
2121
2122
/** Setup the input buffer state to scan directly from a user-specified character buffer.
2123
* @param base the character buffer
2124
* @param size the size in bytes of the character buffer
2125
* @param yyscanner The scanner object.
2126
* @return the newly allocated buffer state object.
2127
*/
2128
YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
2129
{
2130
YY_BUFFER_STATE b;
2131
2132
if ( size < 2 ||
2133
base[size-2] != YY_END_OF_BUFFER_CHAR ||
2134
base[size-1] != YY_END_OF_BUFFER_CHAR )
2135
/* They forgot to leave room for the EOB's. */
2136
return NULL;
2137
2138
b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
2139
if ( ! b )
2140
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
2141
2142
b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
2143
b->yy_buf_pos = b->yy_ch_buf = base;
2144
b->yy_is_our_buffer = 0;
2145
b->yy_input_file = NULL;
2146
b->yy_n_chars = b->yy_buf_size;
2147
b->yy_is_interactive = 0;
2148
b->yy_at_bol = 1;
2149
b->yy_fill_buffer = 0;
2150
b->yy_buffer_status = YY_BUFFER_NEW;
2151
2152
yy_switch_to_buffer( b , yyscanner );
2153
2154
return b;
2155
}
2156
2157
/** Setup the input buffer state to scan a string. The next call to yylex() will
2158
* scan from a @e copy of @a str.
2159
* @param yystr a NUL-terminated string to scan
2160
* @param yyscanner The scanner object.
2161
* @return the newly allocated buffer state object.
2162
* @note If you want to scan bytes that may contain NUL values, then use
2163
* yy_scan_bytes() instead.
2164
*/
2165
YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
2166
{
2167
2168
return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
2169
}
2170
2171
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
2172
* scan from a @e copy of @a bytes.
2173
* @param yybytes the byte buffer to scan
2174
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2175
* @param yyscanner The scanner object.
2176
* @return the newly allocated buffer state object.
2177
*/
2178
YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner)
2179
{
2180
YY_BUFFER_STATE b;
2181
char *buf;
2182
yy_size_t n;
2183
int i;
2184
2185
/* Get memory for full buffer, including space for trailing EOB's. */
2186
n = (yy_size_t) (_yybytes_len + 2);
2187
buf = (char *) yyalloc( n , yyscanner );
2188
if ( ! buf )
2189
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
2190
2191
for ( i = 0; i < _yybytes_len; ++i )
2192
buf[i] = yybytes[i];
2193
2194
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2195
2196
b = yy_scan_buffer( buf, n , yyscanner);
2197
if ( ! b )
2198
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2199
2200
/* It's okay to grow etc. this buffer, and we should throw it
2201
* away when we're done.
2202
*/
2203
b->yy_is_our_buffer = 1;
2204
2205
return b;
2206
}
2207
2208
#ifndef YY_EXIT_FAILURE
2209
#define YY_EXIT_FAILURE 2
2210
#endif
2211
2212
static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
2213
{
2214
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2215
(void)yyg;
2216
fprintf( stderr, "%s\n", msg );
2217
exit( YY_EXIT_FAILURE );
2218
}
2219
2220
/* Redefine yyless() so it works in section 3 code. */
2221
2222
#undef yyless
2223
#define yyless(n) \
2224
do \
2225
{ \
2226
/* Undo effects of setting up yytext. */ \
2227
int yyless_macro_arg = (n); \
2228
YY_LESS_LINENO(yyless_macro_arg);\
2229
yytext[yyleng] = yyg->yy_hold_char; \
2230
yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2231
yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2232
*yyg->yy_c_buf_p = '\0'; \
2233
yyleng = yyless_macro_arg; \
2234
} \
2235
while ( 0 )
2236
2237
/* Accessor methods (get/set functions) to struct members. */
2238
2239
/** Get the user-defined data for this scanner.
2240
* @param yyscanner The scanner object.
2241
*/
2242
YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner)
2243
{
2244
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2245
return yyextra;
2246
}
2247
2248
/** Get the current line number.
2249
* @param yyscanner The scanner object.
2250
*/
2251
int yyget_lineno (yyscan_t yyscanner)
2252
{
2253
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2254
2255
if (! YY_CURRENT_BUFFER)
2256
return 0;
2257
2258
return yylineno;
2259
}
2260
2261
/** Get the current column number.
2262
* @param yyscanner The scanner object.
2263
*/
2264
int yyget_column (yyscan_t yyscanner)
2265
{
2266
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2267
2268
if (! YY_CURRENT_BUFFER)
2269
return 0;
2270
2271
return yycolumn;
2272
}
2273
2274
/** Get the input stream.
2275
* @param yyscanner The scanner object.
2276
*/
2277
FILE *yyget_in (yyscan_t yyscanner)
2278
{
2279
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2280
return yyin;
2281
}
2282
2283
/** Get the output stream.
2284
* @param yyscanner The scanner object.
2285
*/
2286
FILE *yyget_out (yyscan_t yyscanner)
2287
{
2288
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2289
return yyout;
2290
}
2291
2292
/** Get the length of the current token.
2293
* @param yyscanner The scanner object.
2294
*/
2295
int yyget_leng (yyscan_t yyscanner)
2296
{
2297
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2298
return yyleng;
2299
}
2300
2301
/** Get the current token.
2302
* @param yyscanner The scanner object.
2303
*/
2304
2305
char *yyget_text (yyscan_t yyscanner)
2306
{
2307
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2308
return yytext;
2309
}
2310
2311
/** Set the user-defined data. This data is never touched by the scanner.
2312
* @param user_defined The data to be associated with this scanner.
2313
* @param yyscanner The scanner object.
2314
*/
2315
void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
2316
{
2317
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2318
yyextra = user_defined ;
2319
}
2320
2321
/** Set the current line number.
2322
* @param _line_number line number
2323
* @param yyscanner The scanner object.
2324
*/
2325
void yyset_lineno (int _line_number , yyscan_t yyscanner)
2326
{
2327
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2328
2329
/* lineno is only valid if an input buffer exists. */
2330
if (! YY_CURRENT_BUFFER )
2331
YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
2332
2333
yylineno = _line_number;
2334
}
2335
2336
/** Set the current column.
2337
* @param _column_no column number
2338
* @param yyscanner The scanner object.
2339
*/
2340
void yyset_column (int _column_no , yyscan_t yyscanner)
2341
{
2342
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2343
2344
/* column is only valid if an input buffer exists. */
2345
if (! YY_CURRENT_BUFFER )
2346
YY_FATAL_ERROR( "yyset_column called with no buffer" );
2347
2348
yycolumn = _column_no;
2349
}
2350
2351
/** Set the input stream. This does not discard the current
2352
* input buffer.
2353
* @param _in_str A readable stream.
2354
* @param yyscanner The scanner object.
2355
* @see yy_switch_to_buffer
2356
*/
2357
void yyset_in (FILE * _in_str , yyscan_t yyscanner)
2358
{
2359
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2360
yyin = _in_str ;
2361
}
2362
2363
void yyset_out (FILE * _out_str , yyscan_t yyscanner)
2364
{
2365
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2366
yyout = _out_str ;
2367
}
2368
2369
int yyget_debug (yyscan_t yyscanner)
2370
{
2371
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2372
return yy_flex_debug;
2373
}
2374
2375
void yyset_debug (int _bdebug , yyscan_t yyscanner)
2376
{
2377
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2378
yy_flex_debug = _bdebug ;
2379
}
2380
2381
/* Accessor methods for yylval and yylloc */
2382
2383
/* User-visible API */
2384
2385
/* yylex_init is special because it creates the scanner itself, so it is
2386
* the ONLY reentrant function that doesn't take the scanner as the last argument.
2387
* That's why we explicitly handle the declaration, instead of using our macros.
2388
*/
2389
int yylex_init(yyscan_t* ptr_yy_globals)
2390
{
2391
if (ptr_yy_globals == NULL){
2392
errno = EINVAL;
2393
return 1;
2394
}
2395
2396
*ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
2397
2398
if (*ptr_yy_globals == NULL){
2399
errno = ENOMEM;
2400
return 1;
2401
}
2402
2403
/* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2404
memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2405
2406
return yy_init_globals ( *ptr_yy_globals );
2407
}
2408
2409
/* yylex_init_extra has the same functionality as yylex_init, but follows the
2410
* convention of taking the scanner as the last argument. Note however, that
2411
* this is a *pointer* to a scanner, as it will be allocated by this call (and
2412
* is the reason, too, why this function also must handle its own declaration).
2413
* The user defined value in the first argument will be available to yyalloc in
2414
* the yyextra field.
2415
*/
2416
int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
2417
{
2418
struct yyguts_t dummy_yyguts;
2419
2420
yyset_extra (yy_user_defined, &dummy_yyguts);
2421
2422
if (ptr_yy_globals == NULL){
2423
errno = EINVAL;
2424
return 1;
2425
}
2426
2427
*ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2428
2429
if (*ptr_yy_globals == NULL){
2430
errno = ENOMEM;
2431
return 1;
2432
}
2433
2434
/* By setting to 0xAA, we expose bugs in
2435
yy_init_globals. Leave at 0x00 for releases. */
2436
memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2437
2438
yyset_extra (yy_user_defined, *ptr_yy_globals);
2439
2440
return yy_init_globals ( *ptr_yy_globals );
2441
}
2442
2443
static int yy_init_globals (yyscan_t yyscanner)
2444
{
2445
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2446
/* Initialization is the same as for the non-reentrant scanner.
2447
* This function is called from yylex_destroy(), so don't allocate here.
2448
*/
2449
2450
yyg->yy_buffer_stack = NULL;
2451
yyg->yy_buffer_stack_top = 0;
2452
yyg->yy_buffer_stack_max = 0;
2453
yyg->yy_c_buf_p = NULL;
2454
yyg->yy_init = 0;
2455
yyg->yy_start = 0;
2456
2457
yyg->yy_start_stack_ptr = 0;
2458
yyg->yy_start_stack_depth = 0;
2459
yyg->yy_start_stack = NULL;
2460
2461
/* Defined in main.c */
2462
#ifdef YY_STDINIT
2463
yyin = stdin;
2464
yyout = stdout;
2465
#else
2466
yyin = NULL;
2467
yyout = NULL;
2468
#endif
2469
2470
/* For future reference: Set errno on error, since we are called by
2471
* yylex_init()
2472
*/
2473
return 0;
2474
}
2475
2476
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
2477
int yylex_destroy (yyscan_t yyscanner)
2478
{
2479
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2480
2481
/* Pop the buffer stack, destroying each element. */
2482
while(YY_CURRENT_BUFFER){
2483
yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
2484
YY_CURRENT_BUFFER_LVALUE = NULL;
2485
yypop_buffer_state(yyscanner);
2486
}
2487
2488
/* Destroy the stack itself. */
2489
yyfree(yyg->yy_buffer_stack , yyscanner);
2490
yyg->yy_buffer_stack = NULL;
2491
2492
/* Destroy the start condition stack. */
2493
yyfree( yyg->yy_start_stack , yyscanner );
2494
yyg->yy_start_stack = NULL;
2495
2496
/* Reset the globals. This is important in a non-reentrant scanner so the next time
2497
* yylex() is called, initialization will occur. */
2498
yy_init_globals( yyscanner);
2499
2500
/* Destroy the main struct (reentrant only). */
2501
yyfree ( yyscanner , yyscanner );
2502
yyscanner = NULL;
2503
return 0;
2504
}
2505
2506
/*
2507
* Internal utility routines.
2508
*/
2509
2510
#ifndef yytext_ptr
2511
static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
2512
{
2513
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2514
(void)yyg;
2515
2516
int i;
2517
for ( i = 0; i < n; ++i )
2518
s1[i] = s2[i];
2519
}
2520
#endif
2521
2522
#ifdef YY_NEED_STRLEN
2523
static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
2524
{
2525
int n;
2526
for ( n = 0; s[n]; ++n )
2527
;
2528
2529
return n;
2530
}
2531
#endif
2532
2533
void *yyalloc (yy_size_t size , yyscan_t yyscanner)
2534
{
2535
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2536
(void)yyg;
2537
return malloc(size);
2538
}
2539
2540
void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
2541
{
2542
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2543
(void)yyg;
2544
2545
/* The cast to (char *) in the following accommodates both
2546
* implementations that use char* generic pointers, and those
2547
* that use void* generic pointers. It works with the latter
2548
* because both ANSI C and C++ allow castless assignment from
2549
* any pointer type to void*, and deal with argument conversions
2550
* as though doing an assignment.
2551
*/
2552
return realloc(ptr, size);
2553
}
2554
2555
void yyfree (void * ptr , yyscan_t yyscanner)
2556
{
2557
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2558
(void)yyg;
2559
free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
2560
}
2561
2562
#define YYTABLES_NAME "yytables"
2563
2564
/*--------------------------------------------------------------------------*/
2565
static void cmListFileLexerSetToken(cmListFileLexer* lexer, const char* text,
2566
size_t length)
2567
{
2568
/* Set the token line and column number. */
2569
lexer->token.line = lexer->line;
2570
lexer->token.column = lexer->column;
2571
2572
/* Use the same buffer if possible. */
2573
if (lexer->token.text) {
2574
if (text && length < lexer->size) {
2575
memcpy(lexer->token.text, text, length);
2576
lexer->token.length = length;
2577
return;
2578
}
2579
free(lexer->token.text);
2580
lexer->token.text = 0;
2581
lexer->size = 0;
2582
}
2583
2584
/* Need to extend the buffer. */
2585
if (length > 0) {
2586
lexer->token.text = (char*)malloc(length);
2587
memcpy(lexer->token.text, text, length);
2588
lexer->token.length = length;
2589
lexer->size = length;
2590
} else {
2591
lexer->token.length = 0;
2592
}
2593
}
2594
2595
/*--------------------------------------------------------------------------*/
2596
static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
2597
size_t length)
2598
{
2599
char* temp;
2600
size_t newSize;
2601
2602
/* If the appended text will fit in the buffer, do not reallocate. */
2603
newSize = lexer->token.length + length;
2604
if (lexer->token.text && newSize <= lexer->size) {
2605
memcpy(lexer->token.text + lexer->token.length, text, length);
2606
lexer->token.length += length;
2607
return;
2608
}
2609
2610
/* We need to extend the buffer. */
2611
temp = malloc(newSize);
2612
if (lexer->token.text) {
2613
memcpy(temp, lexer->token.text, lexer->token.length);
2614
free(lexer->token.text);
2615
}
2616
memcpy(temp + lexer->token.length, text, length);
2617
lexer->token.text = temp;
2618
lexer->token.length += length;
2619
lexer->size = newSize;
2620
}
2621
2622
/*--------------------------------------------------------------------------*/
2623
static int cmListFileLexerInput(cmListFileLexer* lexer, char* buffer,
2624
size_t bufferSize)
2625
{
2626
if (lexer) {
2627
if (lexer->file) {
2628
/* Convert CRLF -> LF explicitly. The C FILE "t"ext mode
2629
does not convert newlines on all platforms. Move any
2630
trailing CR to the start of the buffer for the next read. */
2631
size_t cr = lexer->cr;
2632
size_t n = 0;
2633
buffer[0] = '\r';
2634
2635
size_t actualBufferSize = bufferSize - cr;
2636
char* p = buffer + cr;
2637
size_t readLeft = lexer->read_size - lexer->read_position;
2638
2639
/* Absorb the bytes that were read during BOM detection, if any. */
2640
if (readLeft > 0) {
2641
size_t actualReadSize =
2642
actualBufferSize >= readLeft ? readLeft : actualBufferSize;
2643
memcpy(p, lexer->read_buffer + lexer->read_position, actualReadSize);
2644
lexer->read_position += actualReadSize;
2645
p += actualReadSize;
2646
n += actualReadSize;
2647
actualBufferSize -= actualReadSize;
2648
}
2649
2650
n += fread(p, 1, actualBufferSize, lexer->file);
2651
2652
if (n) {
2653
char* o = buffer;
2654
const char* i = buffer;
2655
const char* e;
2656
n += cr;
2657
cr = (buffer[n - 1] == '\r') ? 1 : 0;
2658
e = buffer + n - cr;
2659
while (i != e) {
2660
if (i[0] == '\r' && i[1] == '\n') {
2661
++i;
2662
}
2663
*o++ = *i++;
2664
}
2665
n = o - buffer;
2666
} else {
2667
n = cr;
2668
cr = 0;
2669
}
2670
lexer->cr = cr;
2671
return n;
2672
} else if (lexer->string_left) {
2673
size_t length = lexer->string_left;
2674
if (bufferSize < length) {
2675
length = bufferSize;
2676
}
2677
memcpy(buffer, lexer->string_position, length);
2678
lexer->string_position += length;
2679
lexer->string_left -= length;
2680
return length;
2681
}
2682
}
2683
return 0;
2684
}
2685
2686
/*--------------------------------------------------------------------------*/
2687
static void cmListFileLexerInit(cmListFileLexer* lexer)
2688
{
2689
if (lexer->file || lexer->string_buffer) {
2690
cmListFileLexer_yylex_init(&lexer->scanner);
2691
cmListFileLexer_yyset_extra(lexer, lexer->scanner);
2692
}
2693
}
2694
2695
/*--------------------------------------------------------------------------*/
2696
static void cmListFileLexerDestroy(cmListFileLexer* lexer)
2697
{
2698
cmListFileLexerSetToken(lexer, 0, 0);
2699
if (lexer->file || lexer->string_buffer) {
2700
cmListFileLexer_yylex_destroy(lexer->scanner);
2701
if (lexer->file) {
2702
fclose(lexer->file);
2703
lexer->file = 0;
2704
}
2705
if (lexer->read_size != 0) {
2706
memset(lexer->read_buffer, 0, sizeof(lexer->read_buffer));
2707
lexer->read_size = 0;
2708
lexer->read_position = 0;
2709
}
2710
if (lexer->string_buffer) {
2711
free(lexer->string_buffer);
2712
lexer->string_buffer = 0;
2713
lexer->string_left = 0;
2714
lexer->string_position = 0;
2715
}
2716
}
2717
}
2718
2719
/*--------------------------------------------------------------------------*/
2720
cmListFileLexer* cmListFileLexer_New(void)
2721
{
2722
cmListFileLexer* lexer = (cmListFileLexer*)malloc(sizeof(cmListFileLexer));
2723
if (!lexer) {
2724
return 0;
2725
}
2726
memset(lexer, 0, sizeof(*lexer));
2727
lexer->line = 1;
2728
lexer->column = 1;
2729
return lexer;
2730
}
2731
2732
/*--------------------------------------------------------------------------*/
2733
void cmListFileLexer_Delete(cmListFileLexer* lexer)
2734
{
2735
cmListFileLexer_SetFileName(lexer, 0, 0);
2736
free(lexer);
2737
}
2738
2739
/*--------------------------------------------------------------------------*/
2740
static cmListFileLexer_BOM cmListFileLexer_ReadBOM(FILE* f,
2741
unsigned char readBuffer[4],
2742
size_t* readSize)
2743
{
2744
/* Read the up to four bytes that might correspond to a BOM. In case these
2745
bytes turn out not to represent a BOM, save them for later consumption in
2746
order to avoid seeking the file (which might not be seekable, e.g., if
2747
it's a pipe). */
2748
unsigned char* b = readBuffer;
2749
2750
size_t n = fread(b, 1, 2, f);
2751
*readSize = n; /* Initialize first and then accumulate */
2752
2753
if (n == 2) {
2754
if (b[0] == 0xEF && b[1] == 0xBB) {
2755
n = fread(b + 2, 1, 1, f);
2756
*readSize += n;
2757
2758
if (n == 1) {
2759
if (b[2] == 0xBF) {
2760
*readSize = 0; /* We consumed the BOM: discard it */
2761
return cmListFileLexer_BOM_UTF8;
2762
}
2763
}
2764
} else if (b[0] == 0xFE && b[1] == 0xFF) {
2765
*readSize = 0; /* We consumed the BOM: discard it */
2766
/* UTF-16 BE */
2767
return cmListFileLexer_BOM_UTF16BE;
2768
} else if (b[0] == 0 && b[1] == 0) {
2769
n = fread(b + 2, 1, 2, f);
2770
*readSize += n;
2771
2772
if (n == 2) {
2773
if (b[2] == 0xFE && b[3] == 0xFF) {
2774
*readSize = 0; /* We consumed the BOM: discard it */
2775
return cmListFileLexer_BOM_UTF32BE;
2776
}
2777
}
2778
} else if (b[0] == 0xFF && b[1] == 0xFE) {
2779
n = fread(b + 2, 1, 2, f);
2780
*readSize += n;
2781
2782
if (n == 2 && b[2] == 0 && b[3] == 0) {
2783
*readSize = 0; /* We consumed the BOM: discard it */
2784
return cmListFileLexer_BOM_UTF32LE;
2785
}
2786
2787
/* In case we were able to subsequently read only a single byte out of two
2788
(i.e., three in total), the file must be corrupt and the BOM cannot
2789
represent a UTF-16-LE BOM since each code unit must consist of two
2790
bytes. This avoids incorrectly detecting an incomplete UTF-32-LE BOM as
2791
UTF-16-LE input. */
2792
if (n % 2 == 0) {
2793
*readSize = n; /* We consumed the read bytes as BOM only partially */
2794
memmove(b, b + 2, n);
2795
return cmListFileLexer_BOM_UTF16LE;
2796
}
2797
}
2798
}
2799
2800
return cmListFileLexer_BOM_None;
2801
}
2802
2803
/*--------------------------------------------------------------------------*/
2804
int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name,
2805
cmListFileLexer_BOM* bom)
2806
{
2807
int result = 1;
2808
cmListFileLexerDestroy(lexer);
2809
if (name) {
2810
#ifdef _WIN32
2811
wchar_t* wname = cmsysEncoding_DupToWide(name);
2812
lexer->file = _wfopen(wname, L"rb");
2813
free(wname);
2814
#else
2815
lexer->file = fopen(name, "rb");
2816
#endif
2817
if (lexer->file) {
2818
if (bom) {
2819
*bom = cmListFileLexer_ReadBOM(
2820
lexer->file, (unsigned char*)lexer->read_buffer, &lexer->read_size);
2821
lexer->read_position = 0;
2822
} else {
2823
memset(lexer->read_buffer, 0, sizeof(lexer->read_buffer));
2824
lexer->read_size = 0;
2825
lexer->read_position = 0;
2826
}
2827
} else {
2828
result = 0;
2829
}
2830
}
2831
cmListFileLexerInit(lexer);
2832
return result;
2833
}
2834
2835
/*--------------------------------------------------------------------------*/
2836
int cmListFileLexer_SetString(cmListFileLexer* lexer, char const* text,
2837
size_t length)
2838
{
2839
int result = 1;
2840
cmListFileLexerDestroy(lexer);
2841
/* text might be not NULL while length is 0. However, on some platforms
2842
malloc(0) will return NULL. To avoid signaling an error to the caller in
2843
such cases, ensure nonzero length. */
2844
size_t read_size = lexer->read_size - lexer->read_position;
2845
size_t string_size = read_size + length;
2846
if (string_size > 0) {
2847
lexer->string_buffer = (char*)malloc(string_size);
2848
if (lexer->string_buffer) {
2849
memcpy(lexer->string_buffer, lexer->read_buffer + lexer->read_position,
2850
read_size);
2851
memcpy(lexer->string_buffer + read_size, text, length);
2852
lexer->read_position += read_size;
2853
lexer->string_position = lexer->string_buffer;
2854
lexer->string_left = length;
2855
} else {
2856
result = 0;
2857
}
2858
}
2859
cmListFileLexerInit(lexer);
2860
return result;
2861
}
2862
2863
/*--------------------------------------------------------------------------*/
2864
cmListFileLexer_Token* cmListFileLexer_Scan(cmListFileLexer* lexer)
2865
{
2866
if (!lexer->file && !lexer->string_buffer) {
2867
return 0;
2868
}
2869
if (cmListFileLexer_yylex(lexer->scanner, lexer)) {
2870
return &lexer->token;
2871
} else {
2872
cmListFileLexer_SetFileName(lexer, 0, 0);
2873
return 0;
2874
}
2875
}
2876
2877
/*--------------------------------------------------------------------------*/
2878
long cmListFileLexer_GetCurrentLine(cmListFileLexer* lexer)
2879
{
2880
return lexer->line;
2881
}
2882
2883
/*--------------------------------------------------------------------------*/
2884
long cmListFileLexer_GetCurrentColumn(cmListFileLexer* lexer)
2885
{
2886
return lexer->column;
2887
}
2888
2889
/*--------------------------------------------------------------------------*/
2890
const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer,
2891
cmListFileLexer_Type type)
2892
{
2893
(void)lexer;
2894
switch (type) {
2895
case cmListFileLexer_Token_None:
2896
return "nothing";
2897
case cmListFileLexer_Token_Space:
2898
return "space";
2899
case cmListFileLexer_Token_Newline:
2900
return "newline";
2901
case cmListFileLexer_Token_Identifier:
2902
return "identifier";
2903
case cmListFileLexer_Token_ParenLeft:
2904
return "left paren";
2905
case cmListFileLexer_Token_ParenRight:
2906
return "right paren";
2907
case cmListFileLexer_Token_ArgumentUnquoted:
2908
return "unquoted argument";
2909
case cmListFileLexer_Token_ArgumentQuoted:
2910
return "quoted argument";
2911
case cmListFileLexer_Token_ArgumentBracket:
2912
return "bracket argument";
2913
case cmListFileLexer_Token_CommentBracket:
2914
return "bracket comment";
2915
case cmListFileLexer_Token_BadCharacter:
2916
return "bad character";
2917
case cmListFileLexer_Token_BadBracket:
2918
return "unterminated bracket";
2919
case cmListFileLexer_Token_BadString:
2920
return "unterminated string";
2921
}
2922
return "unknown token";
2923
}
2924
2925