1 #line 16 "preprocessor.l"
2 // GENERATED FILE - DO NOT EDIT.
3 // Generated by generate_parser.py from preprocessor.l
4 //
5 // Copyright 2019 The ANGLE Project Authors. All rights reserved.
6 // Use of this source code is governed by a BSD-style license that can be
7 // found in the LICENSE file.
8 //
9 // preprocessor.l:
10 // Lexer for the OpenGL shading language preprocessor.
11
12 #define YY_INT_ALIGNED short int
13
14 /* A lexical scanner generated by flex */
15
16 #define FLEX_SCANNER
17 #define YY_FLEX_MAJOR_VERSION 2
18 #define YY_FLEX_MINOR_VERSION 6
19 #define YY_FLEX_SUBMINOR_VERSION 4
20 #if YY_FLEX_SUBMINOR_VERSION > 0
21 # define FLEX_BETA
22 #endif
23
24 #ifdef yy_create_buffer
25 # define pp_create_buffer_ALREADY_DEFINED
26 #else
27 # define yy_create_buffer pp_create_buffer
28 #endif
29
30 #ifdef yy_delete_buffer
31 # define pp_delete_buffer_ALREADY_DEFINED
32 #else
33 # define yy_delete_buffer pp_delete_buffer
34 #endif
35
36 #ifdef yy_scan_buffer
37 # define pp_scan_buffer_ALREADY_DEFINED
38 #else
39 # define yy_scan_buffer pp_scan_buffer
40 #endif
41
42 #ifdef yy_scan_string
43 # define pp_scan_string_ALREADY_DEFINED
44 #else
45 # define yy_scan_string pp_scan_string
46 #endif
47
48 #ifdef yy_scan_bytes
49 # define pp_scan_bytes_ALREADY_DEFINED
50 #else
51 # define yy_scan_bytes pp_scan_bytes
52 #endif
53
54 #ifdef yy_init_buffer
55 # define pp_init_buffer_ALREADY_DEFINED
56 #else
57 # define yy_init_buffer pp_init_buffer
58 #endif
59
60 #ifdef yy_flush_buffer
61 # define pp_flush_buffer_ALREADY_DEFINED
62 #else
63 # define yy_flush_buffer pp_flush_buffer
64 #endif
65
66 #ifdef yy_load_buffer_state
67 # define pp_load_buffer_state_ALREADY_DEFINED
68 #else
69 # define yy_load_buffer_state pp_load_buffer_state
70 #endif
71
72 #ifdef yy_switch_to_buffer
73 # define pp_switch_to_buffer_ALREADY_DEFINED
74 #else
75 # define yy_switch_to_buffer pp_switch_to_buffer
76 #endif
77
78 #ifdef yypush_buffer_state
79 # define pppush_buffer_state_ALREADY_DEFINED
80 #else
81 # define yypush_buffer_state pppush_buffer_state
82 #endif
83
84 #ifdef yypop_buffer_state
85 # define pppop_buffer_state_ALREADY_DEFINED
86 #else
87 # define yypop_buffer_state pppop_buffer_state
88 #endif
89
90 #ifdef yyensure_buffer_stack
91 # define ppensure_buffer_stack_ALREADY_DEFINED
92 #else
93 # define yyensure_buffer_stack ppensure_buffer_stack
94 #endif
95
96 #ifdef yylex
97 # define pplex_ALREADY_DEFINED
98 #else
99 # define yylex pplex
100 #endif
101
102 #ifdef yyrestart
103 # define pprestart_ALREADY_DEFINED
104 #else
105 # define yyrestart pprestart
106 #endif
107
108 #ifdef yylex_init
109 # define pplex_init_ALREADY_DEFINED
110 #else
111 # define yylex_init pplex_init
112 #endif
113
114 #ifdef yylex_init_extra
115 # define pplex_init_extra_ALREADY_DEFINED
116 #else
117 # define yylex_init_extra pplex_init_extra
118 #endif
119
120 #ifdef yylex_destroy
121 # define pplex_destroy_ALREADY_DEFINED
122 #else
123 # define yylex_destroy pplex_destroy
124 #endif
125
126 #ifdef yyget_debug
127 # define ppget_debug_ALREADY_DEFINED
128 #else
129 # define yyget_debug ppget_debug
130 #endif
131
132 #ifdef yyset_debug
133 # define ppset_debug_ALREADY_DEFINED
134 #else
135 # define yyset_debug ppset_debug
136 #endif
137
138 #ifdef yyget_extra
139 # define ppget_extra_ALREADY_DEFINED
140 #else
141 # define yyget_extra ppget_extra
142 #endif
143
144 #ifdef yyset_extra
145 # define ppset_extra_ALREADY_DEFINED
146 #else
147 # define yyset_extra ppset_extra
148 #endif
149
150 #ifdef yyget_in
151 # define ppget_in_ALREADY_DEFINED
152 #else
153 # define yyget_in ppget_in
154 #endif
155
156 #ifdef yyset_in
157 # define ppset_in_ALREADY_DEFINED
158 #else
159 # define yyset_in ppset_in
160 #endif
161
162 #ifdef yyget_out
163 # define ppget_out_ALREADY_DEFINED
164 #else
165 # define yyget_out ppget_out
166 #endif
167
168 #ifdef yyset_out
169 # define ppset_out_ALREADY_DEFINED
170 #else
171 # define yyset_out ppset_out
172 #endif
173
174 #ifdef yyget_leng
175 # define ppget_leng_ALREADY_DEFINED
176 #else
177 # define yyget_leng ppget_leng
178 #endif
179
180 #ifdef yyget_text
181 # define ppget_text_ALREADY_DEFINED
182 #else
183 # define yyget_text ppget_text
184 #endif
185
186 #ifdef yyget_lineno
187 # define ppget_lineno_ALREADY_DEFINED
188 #else
189 # define yyget_lineno ppget_lineno
190 #endif
191
192 #ifdef yyset_lineno
193 # define ppset_lineno_ALREADY_DEFINED
194 #else
195 # define yyset_lineno ppset_lineno
196 #endif
197
198 #ifdef yyget_column
199 # define ppget_column_ALREADY_DEFINED
200 #else
201 # define yyget_column ppget_column
202 #endif
203
204 #ifdef yyset_column
205 # define ppset_column_ALREADY_DEFINED
206 #else
207 # define yyset_column ppset_column
208 #endif
209
210 #ifdef yywrap
211 # define ppwrap_ALREADY_DEFINED
212 #else
213 # define yywrap ppwrap
214 #endif
215
216 #ifdef yyget_lval
217 # define ppget_lval_ALREADY_DEFINED
218 #else
219 # define yyget_lval ppget_lval
220 #endif
221
222 #ifdef yyset_lval
223 # define ppset_lval_ALREADY_DEFINED
224 #else
225 # define yyset_lval ppset_lval
226 #endif
227
228 #ifdef yyget_lloc
229 # define ppget_lloc_ALREADY_DEFINED
230 #else
231 # define yyget_lloc ppget_lloc
232 #endif
233
234 #ifdef yyset_lloc
235 # define ppset_lloc_ALREADY_DEFINED
236 #else
237 # define yyset_lloc ppset_lloc
238 #endif
239
240 #ifdef yyalloc
241 # define ppalloc_ALREADY_DEFINED
242 #else
243 # define yyalloc ppalloc
244 #endif
245
246 #ifdef yyrealloc
247 # define pprealloc_ALREADY_DEFINED
248 #else
249 # define yyrealloc pprealloc
250 #endif
251
252 #ifdef yyfree
253 # define ppfree_ALREADY_DEFINED
254 #else
255 # define yyfree ppfree
256 #endif
257
258 /* First, we deal with platform-specific or compiler-specific issues. */
259
260 /* begin standard C headers. */
261 #include <errno.h>
262 #include <stdio.h>
263 #include <stdlib.h>
264 #include <string.h>
265
266 /* end standard C headers. */
267
268 /* flex integer type definitions */
269
270 #ifndef FLEXINT_H
271 # define FLEXINT_H
272
273 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
274
275 # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
276
277 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
278 * if you want the limit (max/min) macros for int types.
279 */
280 # ifndef __STDC_LIMIT_MACROS
281 # define __STDC_LIMIT_MACROS 1
282 # endif
283
284 # include <inttypes.h>
285 typedef int8_t flex_int8_t;
286 typedef uint8_t flex_uint8_t;
287 typedef int16_t flex_int16_t;
288 typedef uint16_t flex_uint16_t;
289 typedef int32_t flex_int32_t;
290 typedef uint32_t flex_uint32_t;
291 # else
292 typedef signed char flex_int8_t;
293 typedef short int flex_int16_t;
294 typedef int flex_int32_t;
295 typedef unsigned char flex_uint8_t;
296 typedef unsigned short int flex_uint16_t;
297 typedef unsigned int flex_uint32_t;
298
299 /* Limits of integral types. */
300 # ifndef INT8_MIN
301 # define INT8_MIN (-128)
302 # endif
303 # ifndef INT16_MIN
304 # define INT16_MIN (-32767 - 1)
305 # endif
306 # ifndef INT32_MIN
307 # define INT32_MIN (-2147483647 - 1)
308 # endif
309 # ifndef INT8_MAX
310 # define INT8_MAX (127)
311 # endif
312 # ifndef INT16_MAX
313 # define INT16_MAX (32767)
314 # endif
315 # ifndef INT32_MAX
316 # define INT32_MAX (2147483647)
317 # endif
318 # ifndef UINT8_MAX
319 # define UINT8_MAX (255U)
320 # endif
321 # ifndef UINT16_MAX
322 # define UINT16_MAX (65535U)
323 # endif
324 # ifndef UINT32_MAX
325 # define UINT32_MAX (4294967295U)
326 # endif
327
328 # ifndef SIZE_MAX
329 # define SIZE_MAX (~(size_t)0)
330 # endif
331
332 # endif /* ! C99 */
333
334 #endif /* ! FLEXINT_H */
335
336 /* begin standard C++ headers. */
337
338 /* TODO: this is always defined, so inline it */
339 #define yyconst const
340
341 #if defined(__GNUC__) && __GNUC__ >= 3
342 # define yynoreturn __attribute__((__noreturn__))
343 #else
344 # define yynoreturn
345 #endif
346
347 /* Returned upon end-of-file. */
348 #define YY_NULL 0
349
350 /* Promotes a possibly negative, possibly signed char to an
351 * integer in range [0..255] for use as an array index.
352 */
353 #define YY_SC_TO_UI(c) ((YY_CHAR)(c))
354
355 /* An opaque pointer. */
356 #ifndef YY_TYPEDEF_YY_SCANNER_T
357 # define YY_TYPEDEF_YY_SCANNER_T
358 typedef void *yyscan_t;
359 #endif
360
361 /* For convenience, these vars (plus the bison vars far below)
362 are macros in the reentrant scanner. */
363 #define yyin yyg->yyin_r
364 #define yyout yyg->yyout_r
365 #define yyextra yyg->yyextra_r
366 #define yyleng yyg->yyleng_r
367 #define yytext yyg->yytext_r
368 #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
369 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
370 #define yy_flex_debug yyg->yy_flex_debug_r
371
372 /* Enter a start condition. This macro really ought to take a parameter,
373 * but we do it the disgusting crufty way forced on us by the ()-less
374 * definition of BEGIN.
375 */
376 #define BEGIN yyg->yy_start = 1 + 2 *
377 /* Translate the current start state into a value that can be later handed
378 * to BEGIN to return to the state. The YYSTATE alias is for lex
379 * compatibility.
380 */
381 #define YY_START ((yyg->yy_start - 1) / 2)
382 #define YYSTATE YY_START
383 /* Action number for EOF rule of a given start state. */
384 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
385 /* Special action meaning "start processing a new file". */
386 #define YY_NEW_FILE yyrestart(yyin, yyscanner)
387 #define YY_END_OF_BUFFER_CHAR 0
388
389 /* Size of default input buffer. */
390 #ifndef YY_BUF_SIZE
391 # ifdef __ia64__
392 /* On IA-64, the buffer size is 16k, not 8k.
393 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
394 * Ditto for the __ia64__ case accordingly.
395 */
396 # define YY_BUF_SIZE 32768
397 # else
398 # define YY_BUF_SIZE 16384
399 # endif /* __ia64__ */
400 #endif
401
402 /* The state buf must be large enough to hold one state per character in the main buffer.
403 */
404 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
405
406 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
407 # define YY_TYPEDEF_YY_BUFFER_STATE
408 typedef struct yy_buffer_state *YY_BUFFER_STATE;
409 #endif
410
411 #ifndef YY_TYPEDEF_YY_SIZE_T
412 # define YY_TYPEDEF_YY_SIZE_T
413 typedef size_t yy_size_t;
414 #endif
415
416 #define EOB_ACT_CONTINUE_SCAN 0
417 #define EOB_ACT_END_OF_FILE 1
418 #define EOB_ACT_LAST_MATCH 2
419
420 #define YY_LESS_LINENO(n)
421 #define YY_LINENO_REWIND_TO(ptr)
422
423 /* Return all but the first "n" matched characters back to the input stream. */
424 #define yyless(n) \
425 do \
426 { \
427 /* Undo effects of setting up yytext. */ \
428 int yyless_macro_arg = (n); \
429 YY_LESS_LINENO(yyless_macro_arg); \
430 *yy_cp = yyg->yy_hold_char; \
431 YY_RESTORE_YY_MORE_OFFSET \
432 yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
433 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
434 } while (0)
435 #define unput(c) yyunput(c, yyg->yytext_ptr, yyscanner)
436
437 #ifndef YY_STRUCT_YY_BUFFER_STATE
438 # define YY_STRUCT_YY_BUFFER_STATE
439 struct yy_buffer_state
440 {
441 FILE *yy_input_file;
442
443 char *yy_ch_buf; /* input buffer */
444 char *yy_buf_pos; /* current position in input buffer */
445
446 /* Size of input buffer in bytes, not including room for EOB
447 * characters.
448 */
449 int yy_buf_size;
450
451 /* Number of characters read into yy_ch_buf, not including EOB
452 * characters.
453 */
454 int yy_n_chars;
455
456 /* Whether we "own" the buffer - i.e., we know we created it,
457 * and can realloc() it to grow it, and should free() it to
458 * delete it.
459 */
460 int yy_is_our_buffer;
461
462 /* Whether this is an "interactive" input source; if so, and
463 * if we're using stdio for input, then we want to use getc()
464 * instead of fread(), to make sure we stop fetching input after
465 * each newline.
466 */
467 int yy_is_interactive;
468
469 /* Whether we're considered to be at the beginning of a line.
470 * If so, '^' rules will be active on the next match, otherwise
471 * not.
472 */
473 int yy_at_bol;
474
475 int yy_bs_lineno; /**< The line count. */
476 int yy_bs_column; /**< The column count. */
477
478 /* Whether to try to fill the input buffer when we reach the
479 * end of it.
480 */
481 int yy_fill_buffer;
482
483 int yy_buffer_status;
484
485 # define YY_BUFFER_NEW 0
486 # define YY_BUFFER_NORMAL 1
487 /* When an EOF's been seen but there's still some text to process
488 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
489 * shouldn't try reading from the input source any more. We might
490 * still have a bunch of tokens to match, though, because of
491 * possible backing-up.
492 *
493 * When we actually see the EOF, we change the status to "new"
494 * (via yyrestart()), so that the user can continue scanning by
495 * just pointing yyin at a new input file.
496 */
497 # define YY_BUFFER_EOF_PENDING 2
498 };
499 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
500
501 /* We provide macros for accessing buffer states in case in the
502 * future we want to put the buffer states in a more general
503 * "scanner state".
504 *
505 * Returns the top of the stack, or NULL.
506 */
507 #define YY_CURRENT_BUFFER \
508 (yyg->yy_buffer_stack ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] : NULL)
509 /* Same as previous macro, but useful when we know that the buffer stack is not
510 * NULL or when we need an lvalue. For internal use only.
511 */
512 #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
513
514 void yyrestart(FILE *input_file, yyscan_t yyscanner);
515 void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner);
516 YY_BUFFER_STATE yy_create_buffer(FILE *file, int size, yyscan_t yyscanner);
517 void yy_delete_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner);
518 void yy_flush_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner);
519 void yypush_buffer_state(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner);
520 void yypop_buffer_state(yyscan_t yyscanner);
521
522 static void yyensure_buffer_stack(yyscan_t yyscanner);
523 static void yy_load_buffer_state(yyscan_t yyscanner);
524 static void yy_init_buffer(YY_BUFFER_STATE b, FILE *file, yyscan_t yyscanner);
525 #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER, yyscanner)
526
527 YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size, yyscan_t yyscanner);
528 YY_BUFFER_STATE yy_scan_string(const char *yy_str, yyscan_t yyscanner);
529 YY_BUFFER_STATE yy_scan_bytes(const char *bytes, int len, yyscan_t yyscanner);
530
531 void *yyalloc(yy_size_t, yyscan_t yyscanner);
532 void *yyrealloc(void *, yy_size_t, yyscan_t yyscanner);
533 void yyfree(void *, yyscan_t yyscanner);
534
535 #define yy_new_buffer yy_create_buffer
536 #define yy_set_interactive(is_interactive) \
537 { \
538 if (!YY_CURRENT_BUFFER) \
539 { \
540 yyensure_buffer_stack(yyscanner); \
541 YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner); \
542 } \
543 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
544 }
545 #define yy_set_bol(at_bol) \
546 { \
547 if (!YY_CURRENT_BUFFER) \
548 { \
549 yyensure_buffer_stack(yyscanner); \
550 YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner); \
551 } \
552 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
553 }
554 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
555
556 /* Begin user sect3 */
557
558 #define ppwrap(yyscanner) (/*CONSTCOND*/ 1)
559 #define YY_SKIP_YYWRAP
560 typedef flex_uint8_t YY_CHAR;
561
562 typedef int yy_state_type;
563
564 #define yytext_ptr yytext_r
565
566 static yy_state_type yy_get_previous_state(yyscan_t yyscanner);
567 static yy_state_type yy_try_NUL_trans(yy_state_type current_state, yyscan_t yyscanner);
568 static int yy_get_next_buffer(yyscan_t yyscanner);
569 static void yynoreturn yy_fatal_error(const char *msg, yyscan_t yyscanner);
570
571 /* Done after the current pattern has been matched and before the
572 * corresponding action - sets up yytext.
573 */
574 #define YY_DO_BEFORE_ACTION \
575 yyg->yytext_ptr = yy_bp; \
576 yyleng = (int)(yy_cp - yy_bp); \
577 yyg->yy_hold_char = *yy_cp; \
578 *yy_cp = '\0'; \
579 yyg->yy_c_buf_p = yy_cp;
580 #define YY_NUM_RULES 37
581 #define YY_END_OF_BUFFER 38
582 /* This struct is not used in this scanner,
583 but its presence is necessary. */
584 struct yy_trans_info
585 {
586 flex_int32_t yy_verify;
587 flex_int32_t yy_nxt;
588 };
589 static const flex_int16_t yy_accept[95] = {
590 0, 0, 0, 0, 0, 38, 36, 34, 35, 35, 33, 7, 33, 33, 33, 33, 33, 33, 33, 33, 9, 9, 33, 33,
591 33, 8, 33, 33, 3, 5, 5, 4, 34, 35, 19, 27, 20, 30, 25, 12, 23, 13, 24, 10, 2, 1, 26, 10,
592 9, 11, 11, 11, 9, 11, 9, 9, 14, 16, 18, 17, 15, 8, 31, 21, 32, 22, 3, 5, 6, 11, 10, 11,
593 10, 1, 10, 11, 10, 0, 10, 9, 9, 9, 28, 29, 0, 10, 10, 10, 10, 9, 10, 10, 9, 10, 0
594
595 };
596
597 static const YY_CHAR yy_ec[256] = {
598 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 4, 1, 1, 1, 1, 1, 1, 1,
599 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, 9,
600 10, 11, 9, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 17, 17, 9, 9, 18, 19, 20,
601 9, 1, 21, 21, 21, 21, 22, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
602 24, 25, 24, 24, 26, 24, 24, 9, 1, 9, 27, 24, 1, 21, 21, 21, 21,
603
604 22, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 24, 24, 26, 24,
605 24, 9, 28, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
606 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
607 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
608 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
609
610 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
611 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
612 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
613
614 static const YY_CHAR yy_meta[29] = {0, 1, 1, 2, 2, 1, 1, 1, 1, 1, 3, 1, 1, 4, 1,
615 5, 5, 5, 1, 1, 1, 5, 5, 5, 5, 5, 5, 1, 1};
616
617 static const flex_int16_t yy_base[100] = {
618 0, 0, 0, 26, 28, 133, 195, 130, 195, 128, 105, 195, 104, 25, 195, 100, 23,
619 27, 32, 31, 38, 50, 38, 93, 49, 0, 16, 51, 0, 195, 105, 87, 93, 195,
620 195, 195, 195, 195, 195, 195, 195, 195, 195, 67, 195, 0, 195, 81, 55, 84, 98,
621 110, 53, 61, 0, 52, 39, 195, 195, 195, 33, 0, 195, 195, 195, 195, 0, 195,
622 195, 113, 0, 126, 0, 0, 0, 133, 0, 56, 128, 0, 133, 0, 195, 195, 101,
623 141, 143, 145, 0, 15, 154, 195, 0, 195, 195, 177, 32, 182, 187, 189
624
625 };
626
627 static const flex_int16_t yy_def[100] = {
628 0, 94, 1, 95, 95, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
629 20, 94, 94, 94, 96, 94, 94, 97, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
630 94, 94, 94, 98, 94, 94, 20, 20, 49, 50, 50, 99, 21, 50, 94, 94, 94, 94, 94, 96, 94,
631 94, 94, 94, 97, 94, 94, 43, 43, 69, 69, 98, 47, 50, 50, 94, 51, 50, 99, 50, 94, 94,
632 94, 71, 75, 94, 50, 50, 94, 94, 50, 94, 0, 94, 94, 94, 94, 94
633
634 };
635
636 static const flex_int16_t yy_nxt[224] = {
637 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, 22, 23, 24, 25, 25,
638 25, 25, 25, 25, 26, 27, 29, 30, 29, 30, 36, 39, 62, 31, 61, 31, 41, 92, 44, 40, 63, 37, 45,
639 42, 43, 43, 43, 46, 47, 83, 48, 48, 49, 56, 57, 82, 50, 51, 50, 50, 52, 53, 54, 54, 54, 59,
640 60, 64, 87, 87, 87, 50, 55, 50, 81, 79, 65, 69, 50, 70, 70, 70, 50, 50, 50, 69, 71, 72, 69,
641 69, 69, 50, 32, 74, 74, 74, 49, 49,
642
643 68, 50, 75, 76, 50, 50, 50, 67, 50, 50, 50, 58, 50, 50, 50, 90, 90, 90, 38, 50, 77, 77, 35,
644 34, 78, 78, 78, 69, 69, 69, 33, 32, 94, 94, 69, 69, 84, 84, 94, 94, 85, 85, 85, 84, 84, 50,
645 94, 86, 86, 86, 88, 94, 94, 94, 94, 94, 50, 89, 50, 87, 87, 87, 94, 72, 94, 76, 94, 91, 90,
646 90, 90, 94, 94, 94, 94, 94, 93, 28, 28, 28, 28, 28, 66, 94, 94, 66, 66, 73, 94, 73, 73, 73,
647 80, 80, 5, 94, 94, 94, 94, 94,
648
649 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94};
650
651 static const flex_int16_t yy_chk[224] = {
652 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
653 1, 1, 1, 1, 1, 1, 3, 3, 4, 4, 13, 16, 26, 3, 96, 4, 17, 89, 19, 16, 26, 13, 19,
654 17, 18, 18, 18, 19, 20, 60, 20, 20, 20, 22, 22, 56, 20, 20, 20, 20, 20, 20, 21, 21, 21, 24,
655 24, 27, 77, 77, 77, 53, 21, 21, 55, 52, 27, 43, 48, 43, 43, 43, 53, 53, 53, 43, 43, 43, 43,
656 43, 43, 47, 32, 47, 47, 47, 49, 49,
657
658 31, 47, 47, 47, 47, 47, 47, 30, 49, 49, 50, 23, 50, 50, 50, 84, 84, 84, 15, 50, 51, 51, 12,
659 10, 51, 51, 51, 69, 69, 69, 9, 7, 5, 0, 69, 69, 71, 71, 78, 78, 71, 71, 71, 75, 75, 80,
660 0, 75, 75, 75, 78, 85, 85, 86, 86, 0, 80, 80, 80, 87, 87, 87, 0, 85, 0, 86, 0, 87, 90,
661 90, 90, 0, 0, 0, 0, 0, 90, 95, 95, 95, 95, 95, 97, 0, 0, 97, 97, 98, 0, 98, 98, 98,
662 99, 99, 94, 94, 94, 94, 94, 94,
663
664 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94};
665
666 /* The intent behind this definition is that it'll catch
667 * any uses of REJECT which flex missed.
668 */
669 #define REJECT reject_used_but_not_detected
670 #define yymore() yymore_used_but_not_detected
671 #define YY_MORE_ADJ 0
672 #define YY_RESTORE_YY_MORE_OFFSET
673 /*
674 //
675 // Copyright 2002 The ANGLE Project Authors. All rights reserved.
676 // Use of this source code is governed by a BSD-style license that can be
677 // found in the LICENSE file.
678 //
679
680 This file contains the Lex specification for GLSL ES preprocessor.
681 Based on Microsoft Visual Studio 2010 Preprocessor Grammar:
682 http://msdn.microsoft.com/en-us/library/2scxys89.aspx
683
684 IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN scripts/run_code_generation.py
685 */
686
687 #if defined(_MSC_VER)
688 # pragma warning(disable : 4005)
689 #endif
690
691 #include "compiler/preprocessor/Tokenizer.h"
692
693 #include "compiler/preprocessor/DiagnosticsBase.h"
694 #include "compiler/preprocessor/Token.h"
695
696 #if defined(__GNUC__)
697 // Triggered by the auto-generated yy_fatal_error function.
698 # pragma GCC diagnostic ignored "-Wmissing-noreturn"
699 #elif defined(_MSC_VER)
700 # pragma warning(disable : 4244)
701 #endif
702 #if defined(__clang__)
703 // Flex uses `/*FALLTHROUGH*/` instead of dedicated statements.
704 # pragma clang diagnostic ignored "-Wimplicit-fallthrough"
705 # if defined(__APPLE__)
706 // Older clang versions don't have -Wextra-semi-stmt, and detecting Apple clang versions is
707 // difficult because they use different yet overlapping version numbers vs. regular clang.
708 # pragma clang diagnostic ignored "-Wunknown-warning-option"
709 # endif
710 // Flex isn't semi-colon clean.
711 # pragma clang diagnostic ignored "-Wextra-semi-stmt"
712 # pragma clang diagnostic ignored "-Wunreachable-code"
713 #endif
714
715 // Workaround for flex using the register keyword, deprecated in C++11.
716 #ifdef __cplusplus
717 # if __cplusplus > 199711L
718 # define register
719 # endif
720 #endif
721
722 typedef std::string YYSTYPE;
723 typedef angle::pp::SourceLocation YYLTYPE;
724
725 // Use the unused yycolumn variable to track file (string) number.
726 #define yyfileno yycolumn
727
728 #define YY_USER_INIT \
729 do \
730 { \
731 yyfileno = 0; \
732 yylineno = 1; \
733 yyextra->leadingSpace = false; \
734 yyextra->lineStart = true; \
735 } while (0);
736
737 #define YY_NO_INPUT
738 #define YY_USER_ACTION \
739 do \
740 { \
741 angle::pp::Input *input = &yyextra->input; \
742 angle::pp::Input::Location *scanLoc = &yyextra->scanLoc; \
743 while ((scanLoc->sIndex < input->count()) && \
744 (scanLoc->cIndex >= input->length(scanLoc->sIndex))) \
745 { \
746 scanLoc->cIndex -= input->length(scanLoc->sIndex++); \
747 ++yyfileno; \
748 yylineno = 1; \
749 } \
750 yylloc->file = yyfileno; \
751 yylloc->line = yylineno; \
752 scanLoc->cIndex += yyleng; \
753 } while (0);
754
755 #define YY_INPUT(buf, result, maxSize) result = yyextra->input.read(buf, maxSize, &yylineno);
756
757 #define INITIAL 0
758 #define COMMENT 1
759
760 #define YY_EXTRA_TYPE angle::pp::Tokenizer::Context *
761
762 /* Holds the entire state of the reentrant scanner. */
763 struct yyguts_t
764 {
765
766 /* User-defined. Not touched by flex. */
767 YY_EXTRA_TYPE yyextra_r;
768
769 /* The rest are the same as the globals declared in the non-reentrant scanner. */
770 FILE *yyin_r, *yyout_r;
771 size_t yy_buffer_stack_top; /**< index of top of stack. */
772 size_t yy_buffer_stack_max; /**< capacity of stack. */
773 YY_BUFFER_STATE *yy_buffer_stack; /**< Stack as an array. */
774 char yy_hold_char;
775 int yy_n_chars;
776 int yyleng_r;
777 char *yy_c_buf_p;
778 int yy_init;
779 int yy_start;
780 int yy_did_buffer_switch_on_eof;
781 int yy_start_stack_ptr;
782 int yy_start_stack_depth;
783 int *yy_start_stack;
784 yy_state_type yy_last_accepting_state;
785 char *yy_last_accepting_cpos;
786
787 int yylineno_r;
788 int yy_flex_debug_r;
789
790 char *yytext_r;
791 int yy_more_flag;
792 int yy_more_len;
793
794 YYSTYPE *yylval_r;
795
796 YYLTYPE *yylloc_r;
797
798 }; /* end struct yyguts_t */
799
800 static int yy_init_globals(yyscan_t yyscanner);
801
802 /* This must go here because YYSTYPE and YYLTYPE are included
803 * from bison output in section 1.*/
804 #define yylval yyg->yylval_r
805
806 #define yylloc yyg->yylloc_r
807
808 int yylex_init(yyscan_t *scanner);
809
810 int yylex_init_extra(YY_EXTRA_TYPE user_defined, yyscan_t *scanner);
811
812 /* Accessor methods to globals.
813 These are made visible to non-reentrant scanners for convenience. */
814
815 int yylex_destroy(yyscan_t yyscanner);
816
817 int yyget_debug(yyscan_t yyscanner);
818
819 void yyset_debug(int debug_flag, yyscan_t yyscanner);
820
821 YY_EXTRA_TYPE yyget_extra(yyscan_t yyscanner);
822
823 void yyset_extra(YY_EXTRA_TYPE user_defined, yyscan_t yyscanner);
824
825 FILE *yyget_in(yyscan_t yyscanner);
826
827 void yyset_in(FILE *_in_str, yyscan_t yyscanner);
828
829 FILE *yyget_out(yyscan_t yyscanner);
830
831 void yyset_out(FILE *_out_str, yyscan_t yyscanner);
832
833 int yyget_leng(yyscan_t yyscanner);
834
835 char *yyget_text(yyscan_t yyscanner);
836
837 int yyget_lineno(yyscan_t yyscanner);
838
839 void yyset_lineno(int _line_number, yyscan_t yyscanner);
840
841 int yyget_column(yyscan_t yyscanner);
842
843 void yyset_column(int _column_no, yyscan_t yyscanner);
844
845 YYSTYPE *yyget_lval(yyscan_t yyscanner);
846
847 void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner);
848
849 YYLTYPE *yyget_lloc(yyscan_t yyscanner);
850
851 void yyset_lloc(YYLTYPE *yylloc_param, yyscan_t yyscanner);
852
853 /* Macros after this point can all be overridden by user definitions in
854 * section 1.
855 */
856
857 #ifndef YY_SKIP_YYWRAP
858 # ifdef __cplusplus
859 extern "C" int yywrap(yyscan_t yyscanner);
860 # else
861 extern int yywrap(yyscan_t yyscanner);
862 # endif
863 #endif
864
865 #ifndef YY_NO_UNPUT
866
867 #endif
868
869 #ifndef yytext_ptr
870 static void yy_flex_strncpy(char *, const char *, int, yyscan_t yyscanner);
871 #endif
872
873 #ifdef YY_NEED_STRLEN
874 static int yy_flex_strlen(const char *, yyscan_t yyscanner);
875 #endif
876
877 #ifndef YY_NO_INPUT
878 # ifdef __cplusplus
879 static int yyinput(yyscan_t yyscanner);
880 # else
881 static int input(yyscan_t yyscanner);
882 # endif
883
884 #endif
885
886 /* Amount of stuff to slurp up with each read. */
887 #ifndef YY_READ_BUF_SIZE
888 # ifdef __ia64__
889 /* On IA-64, the buffer size is 16k, not 8k */
890 # define YY_READ_BUF_SIZE 16384
891 # else
892 # define YY_READ_BUF_SIZE 8192
893 # endif /* __ia64__ */
894 #endif
895
896 /* Copy whatever the last rule matched to the standard output. */
897 #ifndef ECHO
898 /* This used to be an fputs(), but since the string might contain NUL's,
899 * we now use fwrite().
900 */
901 # define ECHO \
902 do \
903 { \
904 if (fwrite(yytext, (size_t)yyleng, 1, yyout)) \
905 {} \
906 } while (0)
907 #endif
908
909 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
910 * is returned in "result".
911 */
912 #ifndef YY_INPUT
913 # define YY_INPUT(buf, result, max_size) \
914 if (YY_CURRENT_BUFFER_LVALUE->yy_is_interactive) \
915 { \
916 int c = '*'; \
917 int n; \
918 for (n = 0; n < max_size && (c = getc(yyin)) != EOF && c != '\n'; ++n) \
919 buf[n] = (char)c; \
920 if (c == '\n') \
921 buf[n++] = (char)c; \
922 if (c == EOF && ferror(yyin)) \
923 YY_FATAL_ERROR("input in flex scanner failed"); \
924 result = n; \
925 } \
926 else \
927 { \
928 errno = 0; \
929 while ((result = (int)fread(buf, 1, (yy_size_t)max_size, yyin)) == 0 && ferror(yyin)) \
930 { \
931 if (errno != EINTR) \
932 { \
933 YY_FATAL_ERROR("input in flex scanner failed"); \
934 break; \
935 } \
936 errno = 0; \
937 clearerr(yyin); \
938 } \
939 }
940
941 #endif
942
943 /* No semi-colon after return; correct usage is to write "yyterminate();" -
944 * we don't want an extra ';' after the "return" because that will cause
945 * some compilers to complain about unreachable statements.
946 */
947 #ifndef yyterminate
948 # define yyterminate() return YY_NULL
949 #endif
950
951 /* Number of entries by which start-condition stack grows. */
952 #ifndef YY_START_STACK_INCR
953 # define YY_START_STACK_INCR 25
954 #endif
955
956 /* Report a fatal error. */
957 #ifndef YY_FATAL_ERROR
958 # define YY_FATAL_ERROR(msg) yy_fatal_error(msg, yyscanner)
959 #endif
960
961 /* end tables serialization structures and prototypes */
962
963 /* Default declaration of generated scanner - a define so the user can
964 * easily add parameters.
965 */
966 #ifndef YY_DECL
967 # define YY_DECL_IS_OURS 1
968
969 extern int yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner);
970
971 # define YY_DECL int yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)
972 #endif /* !YY_DECL */
973
974 /* Code executed at the beginning of each rule, after yytext and yyleng
975 * have been set up.
976 */
977 #ifndef YY_USER_ACTION
978 # define YY_USER_ACTION
979 #endif
980
981 /* Code executed at the end of each rule. */
982 #ifndef YY_BREAK
983 # define YY_BREAK /*LINTED*/ break;
984 #endif
985
986 #define YY_RULE_SETUP YY_USER_ACTION
987
988 /** The main scanner function which does all the work.
989 */
990 YY_DECL
991 {
992 yy_state_type yy_current_state;
993 char *yy_cp, *yy_bp;
994 int yy_act;
995 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
996
997 yylval = yylval_param;
998
999 yylloc = yylloc_param;
1000
1001 if (!yyg->yy_init)
1002 {
1003 yyg->yy_init = 1;
1004
1005 #ifdef YY_USER_INIT
1006 YY_USER_INIT;
1007 #endif
1008
1009 if (!yyg->yy_start)
1010 yyg->yy_start = 1; /* first start state */
1011
1012 if (!yyin)
1013 yyin = stdin;
1014
1015 if (!yyout)
1016 yyout = stdout;
1017
1018 if (!YY_CURRENT_BUFFER)
1019 {
1020 yyensure_buffer_stack(yyscanner);
1021 YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner);
1022 }
1023
1024 yy_load_buffer_state(yyscanner);
1025 }
1026
1027 {
1028
1029 /* Line comment */
1030
1031 while (/*CONSTCOND*/ 1) /* loops until end-of-file is reached */
1032 {
1033 yy_cp = yyg->yy_c_buf_p;
1034
1035 /* Support of yytext. */
1036 *yy_cp = yyg->yy_hold_char;
1037
1038 /* yy_bp points to the position in yy_ch_buf of the start of
1039 * the current run.
1040 */
1041 yy_bp = yy_cp;
1042
1043 yy_current_state = yyg->yy_start;
1044 yy_match:
1045 do
1046 {
1047 YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
1048 if (yy_accept[yy_current_state])
1049 {
1050 yyg->yy_last_accepting_state = yy_current_state;
1051 yyg->yy_last_accepting_cpos = yy_cp;
1052 }
1053 while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)
1054 {
1055 yy_current_state = (int)yy_def[yy_current_state];
1056 if (yy_current_state >= 95)
1057 yy_c = yy_meta[yy_c];
1058 }
1059 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1060 ++yy_cp;
1061 } while (yy_current_state != 94);
1062 yy_cp = yyg->yy_last_accepting_cpos;
1063 yy_current_state = yyg->yy_last_accepting_state;
1064
1065 yy_find_action:
1066 yy_act = yy_accept[yy_current_state];
1067
1068 YY_DO_BEFORE_ACTION;
1069
1070 do_action: /* This label is used only to access EOF actions. */
1071
1072 switch (yy_act)
1073 { /* beginning of action switch */
1074 case 0: /* must back up */
1075 /* undo the effects of YY_DO_BEFORE_ACTION */
1076 *yy_cp = yyg->yy_hold_char;
1077 yy_cp = yyg->yy_last_accepting_cpos;
1078 yy_current_state = yyg->yy_last_accepting_state;
1079 goto yy_find_action;
1080
1081 case 1:
1082 YY_RULE_SETUP
1083
1084 YY_BREAK
1085 /* Block comment */
1086 /* Line breaks are just counted - not returned. */
1087 /* The comment is replaced by a single space. */
1088 case 2:
1089 YY_RULE_SETUP
1090 {
1091 BEGIN(COMMENT);
1092 }
1093 YY_BREAK
1094 case 3:
1095 YY_RULE_SETUP
1096
1097 YY_BREAK
1098 case 4:
1099 YY_RULE_SETUP
1100
1101 YY_BREAK
1102 case 5:
1103 /* rule 5 can match eol */
1104 YY_RULE_SETUP
1105 {
1106 if (yylineno == INT_MAX)
1107 {
1108 *yylval = "Integer overflow on line number";
1109 return angle::pp::Token::GOT_ERROR;
1110 }
1111 ++yylineno;
1112 }
1113 YY_BREAK
1114 case 6:
1115 YY_RULE_SETUP
1116 {
1117 yyextra->leadingSpace = true;
1118 BEGIN(INITIAL);
1119 }
1120 YY_BREAK
1121 case 7:
1122 YY_RULE_SETUP
1123 {
1124 // # is only valid at start of line for preprocessor directives.
1125 yylval->assign(1, yytext[0]);
1126 return yyextra->lineStart ? angle::pp::Token::PP_HASH
1127 : angle::pp::Token::PP_OTHER;
1128 }
1129 YY_BREAK
1130 case 8:
1131 YY_RULE_SETUP
1132 {
1133 yylval->assign(yytext, yyleng);
1134 return angle::pp::Token::IDENTIFIER;
1135 }
1136 YY_BREAK
1137 case 9:
1138 YY_RULE_SETUP
1139 {
1140 yylval->assign(yytext, yyleng);
1141 return angle::pp::Token::CONST_INT;
1142 }
1143 YY_BREAK
1144 case 10:
1145 YY_RULE_SETUP
1146 {
1147 yylval->assign(yytext, yyleng);
1148 return angle::pp::Token::CONST_FLOAT;
1149 }
1150 YY_BREAK
1151 /* Anything that starts with a {DIGIT} or .{DIGIT} must be a number. */
1152 /* Rule to catch all invalid integers and floats. */
1153 case 11:
1154 YY_RULE_SETUP
1155 {
1156 yylval->assign(yytext, yyleng);
1157 return angle::pp::Token::PP_NUMBER;
1158 }
1159 YY_BREAK
1160 case 12:
1161 YY_RULE_SETUP
1162 {
1163 yylval->assign(yytext, yyleng);
1164 return angle::pp::Token::OP_INC;
1165 }
1166 YY_BREAK
1167 case 13:
1168 YY_RULE_SETUP
1169 {
1170 yylval->assign(yytext, yyleng);
1171 return angle::pp::Token::OP_DEC;
1172 }
1173 YY_BREAK
1174 case 14:
1175 YY_RULE_SETUP
1176 {
1177 yylval->assign(yytext, yyleng);
1178 return angle::pp::Token::OP_LEFT;
1179 }
1180 YY_BREAK
1181 case 15:
1182 YY_RULE_SETUP
1183 {
1184 yylval->assign(yytext, yyleng);
1185 return angle::pp::Token::OP_RIGHT;
1186 }
1187 YY_BREAK
1188 case 16:
1189 YY_RULE_SETUP
1190 {
1191 yylval->assign(yytext, yyleng);
1192 return angle::pp::Token::OP_LE;
1193 }
1194 YY_BREAK
1195 case 17:
1196 YY_RULE_SETUP
1197 {
1198 yylval->assign(yytext, yyleng);
1199 return angle::pp::Token::OP_GE;
1200 }
1201 YY_BREAK
1202 case 18:
1203 YY_RULE_SETUP
1204 {
1205 yylval->assign(yytext, yyleng);
1206 return angle::pp::Token::OP_EQ;
1207 }
1208 YY_BREAK
1209 case 19:
1210 YY_RULE_SETUP
1211 {
1212 yylval->assign(yytext, yyleng);
1213 return angle::pp::Token::OP_NE;
1214 }
1215 YY_BREAK
1216 case 20:
1217 YY_RULE_SETUP
1218 {
1219 yylval->assign(yytext, yyleng);
1220 return angle::pp::Token::OP_AND;
1221 }
1222 YY_BREAK
1223 case 21:
1224 YY_RULE_SETUP
1225 {
1226 yylval->assign(yytext, yyleng);
1227 return angle::pp::Token::OP_XOR;
1228 }
1229 YY_BREAK
1230 case 22:
1231 YY_RULE_SETUP
1232 {
1233 yylval->assign(yytext, yyleng);
1234 return angle::pp::Token::OP_OR;
1235 }
1236 YY_BREAK
1237 case 23:
1238 YY_RULE_SETUP
1239 {
1240 yylval->assign(yytext, yyleng);
1241 return angle::pp::Token::OP_ADD_ASSIGN;
1242 }
1243 YY_BREAK
1244 case 24:
1245 YY_RULE_SETUP
1246 {
1247 yylval->assign(yytext, yyleng);
1248 return angle::pp::Token::OP_SUB_ASSIGN;
1249 }
1250 YY_BREAK
1251 case 25:
1252 YY_RULE_SETUP
1253 {
1254 yylval->assign(yytext, yyleng);
1255 return angle::pp::Token::OP_MUL_ASSIGN;
1256 }
1257 YY_BREAK
1258 case 26:
1259 YY_RULE_SETUP
1260 {
1261 yylval->assign(yytext, yyleng);
1262 return angle::pp::Token::OP_DIV_ASSIGN;
1263 }
1264 YY_BREAK
1265 case 27:
1266 YY_RULE_SETUP
1267 {
1268 yylval->assign(yytext, yyleng);
1269 return angle::pp::Token::OP_MOD_ASSIGN;
1270 }
1271 YY_BREAK
1272 case 28:
1273 YY_RULE_SETUP
1274 {
1275 yylval->assign(yytext, yyleng);
1276 return angle::pp::Token::OP_LEFT_ASSIGN;
1277 }
1278 YY_BREAK
1279 case 29:
1280 YY_RULE_SETUP
1281 {
1282 yylval->assign(yytext, yyleng);
1283 return angle::pp::Token::OP_RIGHT_ASSIGN;
1284 }
1285 YY_BREAK
1286 case 30:
1287 YY_RULE_SETUP
1288 {
1289 yylval->assign(yytext, yyleng);
1290 return angle::pp::Token::OP_AND_ASSIGN;
1291 }
1292 YY_BREAK
1293 case 31:
1294 YY_RULE_SETUP
1295 {
1296 yylval->assign(yytext, yyleng);
1297 return angle::pp::Token::OP_XOR_ASSIGN;
1298 }
1299 YY_BREAK
1300 case 32:
1301 YY_RULE_SETUP
1302 {
1303 yylval->assign(yytext, yyleng);
1304 return angle::pp::Token::OP_OR_ASSIGN;
1305 }
1306 YY_BREAK
1307 case 33:
1308 YY_RULE_SETUP
1309 {
1310 yylval->assign(1, yytext[0]);
1311 return yytext[0];
1312 }
1313 YY_BREAK
1314 case 34:
1315 YY_RULE_SETUP
1316 {
1317 yyextra->leadingSpace = true;
1318 }
1319 YY_BREAK
1320 case 35:
1321 /* rule 35 can match eol */
1322 YY_RULE_SETUP
1323 {
1324 if (yylineno == INT_MAX)
1325 {
1326 *yylval = "Integer overflow on line number";
1327 return angle::pp::Token::GOT_ERROR;
1328 }
1329 ++yylineno;
1330 yylval->assign(1, '\n');
1331 return '\n';
1332 }
1333 YY_BREAK
1334 case 36:
1335 YY_RULE_SETUP
1336 {
1337 yylval->assign(1, yytext[0]);
1338 return angle::pp::Token::PP_OTHER;
1339 }
1340 YY_BREAK
1341 case YY_STATE_EOF(INITIAL):
1342 case YY_STATE_EOF(COMMENT):
1343 {
1344 // YY_USER_ACTION is not invoked for handling EOF.
1345 // Set the location for EOF token manually.
1346 angle::pp::Input *input = &yyextra->input;
1347 angle::pp::Input::Location *scanLoc = &yyextra->scanLoc;
1348 yy_size_t sIndexMax = input->count() ? input->count() - 1 : 0;
1349 if (scanLoc->sIndex != sIndexMax)
1350 {
1351 // We can only reach here if there are empty strings at the
1352 // end of the input.
1353 scanLoc->sIndex = sIndexMax;
1354 scanLoc->cIndex = 0;
1355 // FIXME: this is not 64-bit clean.
1356 yyfileno = static_cast<int>(sIndexMax);
1357 yylineno = 1;
1358 }
1359 yylloc->file = yyfileno;
1360 yylloc->line = yylineno;
1361 yylval->clear();
1362
1363 // Line number overflows fake EOFs to exit early, check for this case.
1364 if (yylineno == INT_MAX)
1365 {
1366 yyextra->diagnostics->report(angle::pp::Diagnostics::PP_TOKENIZER_ERROR,
1367 angle::pp::SourceLocation(yyfileno, yylineno),
1368 "Integer overflow on line number");
1369 }
1370 else if (YY_START == COMMENT)
1371 {
1372 yyextra->diagnostics->report(angle::pp::Diagnostics::PP_EOF_IN_COMMENT,
1373 angle::pp::SourceLocation(yyfileno, yylineno),
1374 "EOF while in a comment");
1375 }
1376 yyterminate();
1377 }
1378 YY_BREAK
1379 case 37:
1380 YY_RULE_SETUP
1381 ECHO;
1382 YY_BREAK
1383
1384 case YY_END_OF_BUFFER:
1385 {
1386 /* Amount of text matched not including the EOB char. */
1387 int yy_amount_of_matched_text = (int)(yy_cp - yyg->yytext_ptr) - 1;
1388
1389 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1390 *yy_cp = yyg->yy_hold_char;
1391 YY_RESTORE_YY_MORE_OFFSET
1392
1393 if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW)
1394 {
1395 /* We're scanning a new file or input source. It's
1396 * possible that this happened because the user
1397 * just pointed yyin at a new source and called
1398 * yylex(). If so, then we have to assure
1399 * consistency between YY_CURRENT_BUFFER and our
1400 * globals. Here is the right place to do so, because
1401 * this is the first action (other than possibly a
1402 * back-up) that will match for the new input source.
1403 */
1404 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1405 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1406 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1407 }
1408
1409 /* Note that here we test for yy_c_buf_p "<=" to the position
1410 * of the first EOB in the buffer, since yy_c_buf_p will
1411 * already have been incremented past the NUL character
1412 * (since all states make transitions on EOB to the
1413 * end-of-buffer state). Contrast this with the test
1414 * in input().
1415 */
1416 if (yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars])
1417 { /* This was really a NUL. */
1418 yy_state_type yy_next_state;
1419
1420 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1421
1422 yy_current_state = yy_get_previous_state(yyscanner);
1423
1424 /* Okay, we're now positioned to make the NUL
1425 * transition. We couldn't have
1426 * yy_get_previous_state() go ahead and do it
1427 * for us because it doesn't know how to deal
1428 * with the possibility of jamming (and we don't
1429 * want to build jamming into it because then it
1430 * will run more slowly).
1431 */
1432
1433 yy_next_state = yy_try_NUL_trans(yy_current_state, yyscanner);
1434
1435 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1436
1437 if (yy_next_state)
1438 {
1439 /* Consume the NUL. */
1440 yy_cp = ++yyg->yy_c_buf_p;
1441 yy_current_state = yy_next_state;
1442 goto yy_match;
1443 }
1444
1445 else
1446 {
1447 yy_cp = yyg->yy_last_accepting_cpos;
1448 yy_current_state = yyg->yy_last_accepting_state;
1449 goto yy_find_action;
1450 }
1451 }
1452
1453 else
1454 switch (yy_get_next_buffer(yyscanner))
1455 {
1456 case EOB_ACT_END_OF_FILE:
1457 {
1458 yyg->yy_did_buffer_switch_on_eof = 0;
1459
1460 if (yywrap(yyscanner))
1461 {
1462 /* Note: because we've taken care in
1463 * yy_get_next_buffer() to have set up
1464 * yytext, we can now set up
1465 * yy_c_buf_p so that if some total
1466 * hoser (like flex itself) wants to
1467 * call the scanner after we return the
1468 * YY_NULL, it'll still work - another
1469 * YY_NULL will get returned.
1470 */
1471 yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1472
1473 yy_act = YY_STATE_EOF(YY_START);
1474 goto do_action;
1475 }
1476
1477 else
1478 {
1479 if (!yyg->yy_did_buffer_switch_on_eof)
1480 YY_NEW_FILE;
1481 }
1482 break;
1483 }
1484
1485 case EOB_ACT_CONTINUE_SCAN:
1486 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1487
1488 yy_current_state = yy_get_previous_state(yyscanner);
1489
1490 yy_cp = yyg->yy_c_buf_p;
1491 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1492 goto yy_match;
1493
1494 case EOB_ACT_LAST_MATCH:
1495 yyg->yy_c_buf_p =
1496 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1497
1498 yy_current_state = yy_get_previous_state(yyscanner);
1499
1500 yy_cp = yyg->yy_c_buf_p;
1501 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1502 goto yy_find_action;
1503 }
1504 break;
1505 }
1506
1507 default:
1508 YY_FATAL_ERROR("fatal flex scanner internal error--no action found");
1509 } /* end of action switch */
1510 } /* end of scanning one token */
1511 } /* end of user's declarations */
1512 } /* end of yylex */
1513
1514 /* yy_get_next_buffer - try to read in a new buffer
1515 *
1516 * Returns a code representing an action:
1517 * EOB_ACT_LAST_MATCH -
1518 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1519 * EOB_ACT_END_OF_FILE - end of file
1520 */
1521 static int yy_get_next_buffer(yyscan_t yyscanner)
1522 {
1523 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1524 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1525 char *source = yyg->yytext_ptr;
1526 int number_to_move, i;
1527 int ret_val;
1528
1529 if (yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1])
1530 YY_FATAL_ERROR("fatal flex scanner internal error--end of buffer missed");
1531
1532 if (YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0)
1533 { /* Don't try to fill the buffer, so this is an EOF. */
1534 if (yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1)
1535 {
1536 /* We matched a single character, the EOB, so
1537 * treat this as a final EOF.
1538 */
1539 return EOB_ACT_END_OF_FILE;
1540 }
1541
1542 else
1543 {
1544 /* We matched some text prior to the EOB, first
1545 * process it.
1546 */
1547 return EOB_ACT_LAST_MATCH;
1548 }
1549 }
1550
1551 /* Try to read more data. */
1552
1553 /* First move last chars to start of buffer. */
1554 number_to_move = (int)(yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
1555
1556 for (i = 0; i < number_to_move; ++i)
1557 *(dest++) = *(source++);
1558
1559 if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING)
1560 /* don't do the read, it's not guaranteed to return an EOF,
1561 * just force an EOF
1562 */
1563 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1564
1565 else
1566 {
1567 int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1568
1569 while (num_to_read <= 0)
1570 { /* Not enough room in the buffer - grow it. */
1571
1572 /* just a shorter name for the current buffer */
1573 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1574
1575 int yy_c_buf_p_offset = (int)(yyg->yy_c_buf_p - b->yy_ch_buf);
1576
1577 if (b->yy_is_our_buffer)
1578 {
1579 int new_size = b->yy_buf_size * 2;
1580
1581 if (new_size <= 0)
1582 b->yy_buf_size += b->yy_buf_size / 8;
1583 else
1584 b->yy_buf_size *= 2;
1585
1586 b->yy_ch_buf = (char *)
1587 /* Include room in for 2 EOB chars. */
1588 yyrealloc((void *)b->yy_ch_buf, (yy_size_t)(b->yy_buf_size + 2), yyscanner);
1589 }
1590 else
1591 /* Can't grow it, we don't own it. */
1592 b->yy_ch_buf = NULL;
1593
1594 if (!b->yy_ch_buf)
1595 YY_FATAL_ERROR("fatal error - scanner input buffer overflow");
1596
1597 yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1598
1599 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1600 }
1601
1602 if (num_to_read > YY_READ_BUF_SIZE)
1603 num_to_read = YY_READ_BUF_SIZE;
1604
1605 /* Read in more data. */
1606 yy_size_t ret = 0;
1607 YY_INPUT((&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), ret, num_to_read);
1608 yyg->yy_n_chars = static_cast<int>(ret);
1609
1610 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1611 }
1612
1613 if (yyg->yy_n_chars == 0)
1614 {
1615 if (number_to_move == YY_MORE_ADJ)
1616 {
1617 ret_val = EOB_ACT_END_OF_FILE;
1618 yyrestart(yyin, yyscanner);
1619 }
1620
1621 else
1622 {
1623 ret_val = EOB_ACT_LAST_MATCH;
1624 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING;
1625 }
1626 }
1627
1628 else
1629 ret_val = EOB_ACT_CONTINUE_SCAN;
1630
1631 if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size)
1632 {
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);
1641 }
1642
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;
1646
1647 yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1648
1649 return ret_val;
1650 }
1651
1652 /* yy_get_previous_state - get the state just before the EOB char was reached */
1653
yy_get_previous_state(yyscan_t yyscanner)1654 static yy_state_type yy_get_previous_state(yyscan_t yyscanner)
1655 {
1656 yy_state_type yy_current_state;
1657 char *yy_cp;
1658 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1659
1660 yy_current_state = yyg->yy_start;
1661
1662 for (yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp)
1663 {
1664 YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1665 if (yy_accept[yy_current_state])
1666 {
1667 yyg->yy_last_accepting_state = yy_current_state;
1668 yyg->yy_last_accepting_cpos = yy_cp;
1669 }
1670 while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)
1671 {
1672 yy_current_state = (int)yy_def[yy_current_state];
1673 if (yy_current_state >= 95)
1674 yy_c = yy_meta[yy_c];
1675 }
1676 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1677 }
1678
1679 return yy_current_state;
1680 }
1681
1682 /* yy_try_NUL_trans - try to make a transition on the NUL character
1683 *
1684 * synopsis
1685 * next_state = yy_try_NUL_trans( current_state );
1686 */
yy_try_NUL_trans(yy_state_type yy_current_state,yyscan_t yyscanner)1687 static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state, yyscan_t yyscanner)
1688 {
1689 int yy_is_jam;
1690 struct yyguts_t *yyg =
1691 (struct yyguts_t *)yyscanner; /* This var may be unused depending upon options. */
1692 char *yy_cp = yyg->yy_c_buf_p;
1693
1694 YY_CHAR yy_c = 1;
1695 if (yy_accept[yy_current_state])
1696 {
1697 yyg->yy_last_accepting_state = yy_current_state;
1698 yyg->yy_last_accepting_cpos = yy_cp;
1699 }
1700 while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)
1701 {
1702 yy_current_state = (int)yy_def[yy_current_state];
1703 if (yy_current_state >= 95)
1704 yy_c = yy_meta[yy_c];
1705 }
1706 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1707 yy_is_jam = (yy_current_state == 94);
1708
1709 (void)yyg;
1710 return yy_is_jam ? 0 : yy_current_state;
1711 }
1712
1713 #ifndef YY_NO_UNPUT
1714
1715 #endif
1716
1717 #ifndef YY_NO_INPUT
1718 # ifdef __cplusplus
yyinput(yyscan_t yyscanner)1719 static int yyinput(yyscan_t yyscanner)
1720 # else
1721 static int input(yyscan_t yyscanner)
1722 # endif
1723
1724 {
1725 int c;
1726 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1727
1728 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1729
1730 if (*yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR)
1731 {
1732 /* yy_c_buf_p now points to the character we want to return.
1733 * If this occurs *before* the EOB characters, then it's a
1734 * valid NUL; if not, then we've hit the end of the buffer.
1735 */
1736 if (yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars])
1737 /* This was really a NUL. */
1738 *yyg->yy_c_buf_p = '\0';
1739
1740 else
1741 { /* need more input */
1742 int offset = (int)(yyg->yy_c_buf_p - yyg->yytext_ptr);
1743 ++yyg->yy_c_buf_p;
1744
1745 switch (yy_get_next_buffer(yyscanner))
1746 {
1747 case EOB_ACT_LAST_MATCH:
1748 /* This happens because yy_g_n_b()
1749 * sees that we've accumulated a
1750 * token and flags that we need to
1751 * try matching the token before
1752 * proceeding. But for input(),
1753 * there's no matching to consider.
1754 * So convert the EOB_ACT_LAST_MATCH
1755 * to EOB_ACT_END_OF_FILE.
1756 */
1757
1758 /* Reset buffer status. */
1759 yyrestart(yyin, yyscanner);
1760
1761 /*FALLTHROUGH*/
1762
1763 case EOB_ACT_END_OF_FILE:
1764 {
1765 if (yywrap(yyscanner))
1766 return 0;
1767
1768 if (!yyg->yy_did_buffer_switch_on_eof)
1769 YY_NEW_FILE;
1770 # ifdef __cplusplus
1771 return yyinput(yyscanner);
1772 # else
1773 return input(yyscanner);
1774 # endif
1775 }
1776
1777 case EOB_ACT_CONTINUE_SCAN:
1778 yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1779 break;
1780 }
1781 }
1782 }
1783
1784 c = *(unsigned char *)yyg->yy_c_buf_p; /* cast for 8-bit char's */
1785 *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1786 yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1787
1788 return c;
1789 }
1790 #endif /* ifndef YY_NO_INPUT */
1791
1792 /** Immediately switch to a different input stream.
1793 * @param input_file A readable stream.
1794 * @param yyscanner The scanner object.
1795 * @note This function does not reset the start condition to @c INITIAL .
1796 */
yyrestart(FILE * input_file,yyscan_t yyscanner)1797 void yyrestart(FILE *input_file, yyscan_t yyscanner)
1798 {
1799 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1800
1801 if (!YY_CURRENT_BUFFER)
1802 {
1803 yyensure_buffer_stack(yyscanner);
1804 YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner);
1805 }
1806
1807 yy_init_buffer(YY_CURRENT_BUFFER, input_file, yyscanner);
1808 yy_load_buffer_state(yyscanner);
1809 }
1810
1811 /** Switch to a different input buffer.
1812 * @param new_buffer The new input buffer.
1813 * @param yyscanner The scanner object.
1814 */
yy_switch_to_buffer(YY_BUFFER_STATE new_buffer,yyscan_t yyscanner)1815 void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner)
1816 {
1817 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1818
1819 /* TODO. We should be able to replace this entire function body
1820 * with
1821 * yypop_buffer_state();
1822 * yypush_buffer_state(new_buffer);
1823 */
1824 yyensure_buffer_stack(yyscanner);
1825 if (YY_CURRENT_BUFFER == new_buffer)
1826 return;
1827
1828 if (YY_CURRENT_BUFFER)
1829 {
1830 /* Flush out information for old buffer. */
1831 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1832 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1833 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1834 }
1835
1836 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1837 yy_load_buffer_state(yyscanner);
1838
1839 /* We don't actually know whether we did this switch during
1840 * EOF (yywrap()) processing, but the only time this flag
1841 * is looked at is after yywrap() is called, so it's safe
1842 * to go ahead and always set it.
1843 */
1844 yyg->yy_did_buffer_switch_on_eof = 1;
1845 }
1846
yy_load_buffer_state(yyscan_t yyscanner)1847 static void yy_load_buffer_state(yyscan_t yyscanner)
1848 {
1849 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1850 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1851 yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1852 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1853 yyg->yy_hold_char = *yyg->yy_c_buf_p;
1854 }
1855
1856 /** Allocate and initialize an input buffer state.
1857 * @param file A readable stream.
1858 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1859 * @param yyscanner The scanner object.
1860 * @return the allocated buffer state.
1861 */
yy_create_buffer(FILE * file,int size,yyscan_t yyscanner)1862 YY_BUFFER_STATE yy_create_buffer(FILE *file, int size, yyscan_t yyscanner)
1863 {
1864 YY_BUFFER_STATE b;
1865
1866 b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state), yyscanner);
1867 if (!b)
1868 YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()");
1869
1870 b->yy_buf_size = size;
1871
1872 /* yy_ch_buf has to be 2 characters longer than the size given because
1873 * we need to put in 2 end-of-buffer characters.
1874 */
1875 b->yy_ch_buf = (char *)yyalloc((yy_size_t)(b->yy_buf_size + 2), yyscanner);
1876 if (!b->yy_ch_buf)
1877 YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()");
1878
1879 b->yy_is_our_buffer = 1;
1880
1881 yy_init_buffer(b, file, yyscanner);
1882
1883 return b;
1884 }
1885
1886 /** Destroy the buffer.
1887 * @param b a buffer created with yy_create_buffer()
1888 * @param yyscanner The scanner object.
1889 */
yy_delete_buffer(YY_BUFFER_STATE b,yyscan_t yyscanner)1890 void yy_delete_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner)
1891 {
1892 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1893
1894 if (!b)
1895 return;
1896
1897 if (b == YY_CURRENT_BUFFER) /* Not sure if we should pop here. */
1898 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE)0;
1899
1900 if (b->yy_is_our_buffer)
1901 yyfree((void *)b->yy_ch_buf, yyscanner);
1902
1903 yyfree((void *)b, yyscanner);
1904 }
1905
1906 /* Initializes or reinitializes a buffer.
1907 * This function is sometimes called more than once on the same buffer,
1908 * such as during a yyrestart() or at EOF.
1909 */
yy_init_buffer(YY_BUFFER_STATE b,FILE * file,yyscan_t yyscanner)1910 static void yy_init_buffer(YY_BUFFER_STATE b, FILE *file, yyscan_t yyscanner)
1911
1912 {
1913 int oerrno = errno;
1914 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1915
1916 yy_flush_buffer(b, yyscanner);
1917
1918 b->yy_input_file = file;
1919 b->yy_fill_buffer = 1;
1920
1921 /* If b is the current buffer, then yy_init_buffer was _probably_
1922 * called from yyrestart() or through yy_get_next_buffer.
1923 * In that case, we don't want to reset the lineno or column.
1924 */
1925 if (b != YY_CURRENT_BUFFER)
1926 {
1927 b->yy_bs_lineno = 1;
1928 b->yy_bs_column = 0;
1929 }
1930
1931 b->yy_is_interactive = 0;
1932
1933 errno = oerrno;
1934 }
1935
1936 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1937 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1938 * @param yyscanner The scanner object.
1939 */
yy_flush_buffer(YY_BUFFER_STATE b,yyscan_t yyscanner)1940 void yy_flush_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner)
1941 {
1942 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1943 if (!b)
1944 return;
1945
1946 b->yy_n_chars = 0;
1947
1948 /* We always need two end-of-buffer characters. The first causes
1949 * a transition to the end-of-buffer state. The second causes
1950 * a jam in that state.
1951 */
1952 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1953 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1954
1955 b->yy_buf_pos = &b->yy_ch_buf[0];
1956
1957 b->yy_at_bol = 1;
1958 b->yy_buffer_status = YY_BUFFER_NEW;
1959
1960 if (b == YY_CURRENT_BUFFER)
1961 yy_load_buffer_state(yyscanner);
1962 }
1963
1964 /** Pushes the new state onto the stack. The new state becomes
1965 * the current state. This function will allocate the stack
1966 * if necessary.
1967 * @param new_buffer The new state.
1968 * @param yyscanner The scanner object.
1969 */
yypush_buffer_state(YY_BUFFER_STATE new_buffer,yyscan_t yyscanner)1970 void yypush_buffer_state(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner)
1971 {
1972 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1973 if (new_buffer == NULL)
1974 return;
1975
1976 yyensure_buffer_stack(yyscanner);
1977
1978 /* This block is copied from yy_switch_to_buffer. */
1979 if (YY_CURRENT_BUFFER)
1980 {
1981 /* Flush out information for old buffer. */
1982 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1983 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1984 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1985 }
1986
1987 /* Only push if top exists. Otherwise, replace top. */
1988 if (YY_CURRENT_BUFFER)
1989 yyg->yy_buffer_stack_top++;
1990 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1991
1992 /* copied from yy_switch_to_buffer. */
1993 yy_load_buffer_state(yyscanner);
1994 yyg->yy_did_buffer_switch_on_eof = 1;
1995 }
1996
1997 /** Removes and deletes the top of the stack, if present.
1998 * The next element becomes the new top.
1999 * @param yyscanner The scanner object.
2000 */
yypop_buffer_state(yyscan_t yyscanner)2001 void yypop_buffer_state(yyscan_t yyscanner)
2002 {
2003 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2004 if (!YY_CURRENT_BUFFER)
2005 return;
2006
2007 yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner);
2008 YY_CURRENT_BUFFER_LVALUE = NULL;
2009 if (yyg->yy_buffer_stack_top > 0)
2010 --yyg->yy_buffer_stack_top;
2011
2012 if (YY_CURRENT_BUFFER)
2013 {
2014 yy_load_buffer_state(yyscanner);
2015 yyg->yy_did_buffer_switch_on_eof = 1;
2016 }
2017 }
2018
2019 /* Allocates the stack if it does not exist.
2020 * Guarantees space for at least one push.
2021 */
yyensure_buffer_stack(yyscan_t yyscanner)2022 static void yyensure_buffer_stack(yyscan_t yyscanner)
2023 {
2024 yy_size_t num_to_alloc;
2025 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2026
2027 if (!yyg->yy_buffer_stack)
2028 {
2029
2030 /* First allocation is just for 2 elements, since we don't know if this
2031 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2032 * immediate realloc on the next call.
2033 */
2034 num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
2035 yyg->yy_buffer_stack = (struct yy_buffer_state **)yyalloc(
2036 num_to_alloc * sizeof(struct yy_buffer_state *), yyscanner);
2037 if (!yyg->yy_buffer_stack)
2038 YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()");
2039
2040 memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state *));
2041
2042 yyg->yy_buffer_stack_max = num_to_alloc;
2043 yyg->yy_buffer_stack_top = 0;
2044 return;
2045 }
2046
2047 if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1)
2048 {
2049
2050 /* Increase the buffer to prepare for a possible push. */
2051 yy_size_t grow_size = 8 /* arbitrary grow size */;
2052
2053 num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
2054 yyg->yy_buffer_stack = (struct yy_buffer_state **)yyrealloc(
2055 yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state *), yyscanner);
2056 if (!yyg->yy_buffer_stack)
2057 YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()");
2058
2059 /* zero only the new slots.*/
2060 memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0,
2061 grow_size * sizeof(struct yy_buffer_state *));
2062 yyg->yy_buffer_stack_max = num_to_alloc;
2063 }
2064 }
2065
2066 /** Setup the input buffer state to scan directly from a user-specified character buffer.
2067 * @param base the character buffer
2068 * @param size the size in bytes of the character buffer
2069 * @param yyscanner The scanner object.
2070 * @return the newly allocated buffer state object.
2071 */
yy_scan_buffer(char * base,yy_size_t size,yyscan_t yyscanner)2072 YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size, yyscan_t yyscanner)
2073 {
2074 YY_BUFFER_STATE b;
2075
2076 if (size < 2 || base[size - 2] != YY_END_OF_BUFFER_CHAR ||
2077 base[size - 1] != YY_END_OF_BUFFER_CHAR)
2078 /* They forgot to leave room for the EOB's. */
2079 return NULL;
2080
2081 b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state), yyscanner);
2082 if (!b)
2083 YY_FATAL_ERROR("out of dynamic memory in yy_scan_buffer()");
2084
2085 b->yy_buf_size = (int)(size - 2); /* "- 2" to take care of EOB's */
2086 b->yy_buf_pos = b->yy_ch_buf = base;
2087 b->yy_is_our_buffer = 0;
2088 b->yy_input_file = NULL;
2089 b->yy_n_chars = b->yy_buf_size;
2090 b->yy_is_interactive = 0;
2091 b->yy_at_bol = 1;
2092 b->yy_fill_buffer = 0;
2093 b->yy_buffer_status = YY_BUFFER_NEW;
2094
2095 yy_switch_to_buffer(b, yyscanner);
2096
2097 return b;
2098 }
2099
2100 /** Setup the input buffer state to scan a string. The next call to yylex() will
2101 * scan from a @e copy of @a str.
2102 * @param yystr a NUL-terminated string to scan
2103 * @param yyscanner The scanner object.
2104 * @return the newly allocated buffer state object.
2105 * @note If you want to scan bytes that may contain NUL values, then use
2106 * yy_scan_bytes() instead.
2107 */
yy_scan_string(const char * yystr,yyscan_t yyscanner)2108 YY_BUFFER_STATE yy_scan_string(const char *yystr, yyscan_t yyscanner)
2109 {
2110
2111 return yy_scan_bytes(yystr, (int)strlen(yystr), yyscanner);
2112 }
2113
2114 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
2115 * scan from a @e copy of @a bytes.
2116 * @param yybytes the byte buffer to scan
2117 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2118 * @param yyscanner The scanner object.
2119 * @return the newly allocated buffer state object.
2120 */
yy_scan_bytes(const char * yybytes,int _yybytes_len,yyscan_t yyscanner)2121 YY_BUFFER_STATE yy_scan_bytes(const char *yybytes, int _yybytes_len, yyscan_t yyscanner)
2122 {
2123 YY_BUFFER_STATE b;
2124 char *buf;
2125 yy_size_t n;
2126 int i;
2127
2128 /* Get memory for full buffer, including space for trailing EOB's. */
2129 n = (yy_size_t)(_yybytes_len + 2);
2130 buf = (char *)yyalloc(n, yyscanner);
2131 if (!buf)
2132 YY_FATAL_ERROR("out of dynamic memory in yy_scan_bytes()");
2133
2134 for (i = 0; i < _yybytes_len; ++i)
2135 buf[i] = yybytes[i];
2136
2137 buf[_yybytes_len] = buf[_yybytes_len + 1] = YY_END_OF_BUFFER_CHAR;
2138
2139 b = yy_scan_buffer(buf, n, yyscanner);
2140 if (!b)
2141 YY_FATAL_ERROR("bad buffer in yy_scan_bytes()");
2142
2143 /* It's okay to grow etc. this buffer, and we should throw it
2144 * away when we're done.
2145 */
2146 b->yy_is_our_buffer = 1;
2147
2148 return b;
2149 }
2150
2151 #ifndef YY_EXIT_FAILURE
2152 # define YY_EXIT_FAILURE 2
2153 #endif
2154
yy_fatal_error(const char * msg,yyscan_t yyscanner)2155 static void yynoreturn yy_fatal_error(const char *msg, yyscan_t yyscanner)
2156 {
2157 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2158 (void)yyg;
2159 fprintf(stderr, "%s\n", msg);
2160 exit(YY_EXIT_FAILURE);
2161 }
2162
2163 /* Redefine yyless() so it works in section 3 code. */
2164
2165 #undef yyless
2166 #define yyless(n) \
2167 do \
2168 { \
2169 /* Undo effects of setting up yytext. */ \
2170 int yyless_macro_arg = (n); \
2171 YY_LESS_LINENO(yyless_macro_arg); \
2172 yytext[yyleng] = yyg->yy_hold_char; \
2173 yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2174 yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2175 *yyg->yy_c_buf_p = '\0'; \
2176 yyleng = yyless_macro_arg; \
2177 } while (0)
2178
2179 /* Accessor methods (get/set functions) to struct members. */
2180
2181 /** Get the user-defined data for this scanner.
2182 * @param yyscanner The scanner object.
2183 */
yyget_extra(yyscan_t yyscanner)2184 YY_EXTRA_TYPE yyget_extra(yyscan_t yyscanner)
2185 {
2186 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2187 return yyextra;
2188 }
2189
2190 /** Get the current line number.
2191 * @param yyscanner The scanner object.
2192 */
yyget_lineno(yyscan_t yyscanner)2193 int yyget_lineno(yyscan_t yyscanner)
2194 {
2195 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2196
2197 if (!YY_CURRENT_BUFFER)
2198 return 0;
2199
2200 return yylineno;
2201 }
2202
2203 /** Get the current column number.
2204 * @param yyscanner The scanner object.
2205 */
yyget_column(yyscan_t yyscanner)2206 int yyget_column(yyscan_t yyscanner)
2207 {
2208 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2209
2210 if (!YY_CURRENT_BUFFER)
2211 return 0;
2212
2213 return yycolumn;
2214 }
2215
2216 /** Get the input stream.
2217 * @param yyscanner The scanner object.
2218 */
yyget_in(yyscan_t yyscanner)2219 FILE *yyget_in(yyscan_t yyscanner)
2220 {
2221 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2222 return yyin;
2223 }
2224
2225 /** Get the output stream.
2226 * @param yyscanner The scanner object.
2227 */
yyget_out(yyscan_t yyscanner)2228 FILE *yyget_out(yyscan_t yyscanner)
2229 {
2230 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2231 return yyout;
2232 }
2233
2234 /** Get the length of the current token.
2235 * @param yyscanner The scanner object.
2236 */
yyget_leng(yyscan_t yyscanner)2237 int yyget_leng(yyscan_t yyscanner)
2238 {
2239 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2240 return yyleng;
2241 }
2242
2243 /** Get the current token.
2244 * @param yyscanner The scanner object.
2245 */
2246
yyget_text(yyscan_t yyscanner)2247 char *yyget_text(yyscan_t yyscanner)
2248 {
2249 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2250 return yytext;
2251 }
2252
2253 /** Set the user-defined data. This data is never touched by the scanner.
2254 * @param user_defined The data to be associated with this scanner.
2255 * @param yyscanner The scanner object.
2256 */
yyset_extra(YY_EXTRA_TYPE user_defined,yyscan_t yyscanner)2257 void yyset_extra(YY_EXTRA_TYPE user_defined, yyscan_t yyscanner)
2258 {
2259 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2260 yyextra = user_defined;
2261 }
2262
2263 /** Set the current line number.
2264 * @param _line_number line number
2265 * @param yyscanner The scanner object.
2266 */
yyset_lineno(int _line_number,yyscan_t yyscanner)2267 void yyset_lineno(int _line_number, yyscan_t yyscanner)
2268 {
2269 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2270
2271 /* lineno is only valid if an input buffer exists. */
2272 if (!YY_CURRENT_BUFFER)
2273 YY_FATAL_ERROR("yyset_lineno called with no buffer");
2274
2275 yylineno = _line_number;
2276 }
2277
2278 /** Set the current column.
2279 * @param _column_no column number
2280 * @param yyscanner The scanner object.
2281 */
yyset_column(int _column_no,yyscan_t yyscanner)2282 void yyset_column(int _column_no, yyscan_t yyscanner)
2283 {
2284 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2285
2286 /* column is only valid if an input buffer exists. */
2287 if (!YY_CURRENT_BUFFER)
2288 YY_FATAL_ERROR("yyset_column called with no buffer");
2289
2290 yycolumn = _column_no;
2291 }
2292
2293 /** Set the input stream. This does not discard the current
2294 * input buffer.
2295 * @param _in_str A readable stream.
2296 * @param yyscanner The scanner object.
2297 * @see yy_switch_to_buffer
2298 */
yyset_in(FILE * _in_str,yyscan_t yyscanner)2299 void yyset_in(FILE *_in_str, yyscan_t yyscanner)
2300 {
2301 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2302 yyin = _in_str;
2303 }
2304
yyset_out(FILE * _out_str,yyscan_t yyscanner)2305 void yyset_out(FILE *_out_str, yyscan_t yyscanner)
2306 {
2307 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2308 yyout = _out_str;
2309 }
2310
yyget_debug(yyscan_t yyscanner)2311 int yyget_debug(yyscan_t yyscanner)
2312 {
2313 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2314 return yy_flex_debug;
2315 }
2316
yyset_debug(int _bdebug,yyscan_t yyscanner)2317 void yyset_debug(int _bdebug, yyscan_t yyscanner)
2318 {
2319 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2320 yy_flex_debug = _bdebug;
2321 }
2322
2323 /* Accessor methods for yylval and yylloc */
2324
yyget_lval(yyscan_t yyscanner)2325 YYSTYPE *yyget_lval(yyscan_t yyscanner)
2326 {
2327 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2328 return yylval;
2329 }
2330
yyset_lval(YYSTYPE * yylval_param,yyscan_t yyscanner)2331 void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner)
2332 {
2333 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2334 yylval = yylval_param;
2335 }
2336
yyget_lloc(yyscan_t yyscanner)2337 YYLTYPE *yyget_lloc(yyscan_t yyscanner)
2338 {
2339 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2340 return yylloc;
2341 }
2342
yyset_lloc(YYLTYPE * yylloc_param,yyscan_t yyscanner)2343 void yyset_lloc(YYLTYPE *yylloc_param, yyscan_t yyscanner)
2344 {
2345 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2346 yylloc = yylloc_param;
2347 }
2348
2349 /* User-visible API */
2350
2351 /* yylex_init is special because it creates the scanner itself, so it is
2352 * the ONLY reentrant function that doesn't take the scanner as the last argument.
2353 * That's why we explicitly handle the declaration, instead of using our macros.
2354 */
yylex_init(yyscan_t * ptr_yy_globals)2355 int yylex_init(yyscan_t *ptr_yy_globals)
2356 {
2357 if (ptr_yy_globals == NULL)
2358 {
2359 errno = EINVAL;
2360 return 1;
2361 }
2362
2363 *ptr_yy_globals = (yyscan_t)yyalloc(sizeof(struct yyguts_t), NULL);
2364
2365 if (*ptr_yy_globals == NULL)
2366 {
2367 errno = ENOMEM;
2368 return 1;
2369 }
2370
2371 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2372 memset(*ptr_yy_globals, 0x00, sizeof(struct yyguts_t));
2373
2374 return yy_init_globals(*ptr_yy_globals);
2375 }
2376
2377 /* yylex_init_extra has the same functionality as yylex_init, but follows the
2378 * convention of taking the scanner as the last argument. Note however, that
2379 * this is a *pointer* to a scanner, as it will be allocated by this call (and
2380 * is the reason, too, why this function also must handle its own declaration).
2381 * The user defined value in the first argument will be available to yyalloc in
2382 * the yyextra field.
2383 */
yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t * ptr_yy_globals)2384 int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined, yyscan_t *ptr_yy_globals)
2385 {
2386 struct yyguts_t dummy_yyguts;
2387
2388 yyset_extra(yy_user_defined, &dummy_yyguts);
2389
2390 if (ptr_yy_globals == NULL)
2391 {
2392 errno = EINVAL;
2393 return 1;
2394 }
2395
2396 *ptr_yy_globals = (yyscan_t)yyalloc(sizeof(struct yyguts_t), &dummy_yyguts);
2397
2398 if (*ptr_yy_globals == NULL)
2399 {
2400 errno = ENOMEM;
2401 return 1;
2402 }
2403
2404 /* By setting to 0xAA, we expose bugs in
2405 yy_init_globals. Leave at 0x00 for releases. */
2406 memset(*ptr_yy_globals, 0x00, sizeof(struct yyguts_t));
2407
2408 yyset_extra(yy_user_defined, *ptr_yy_globals);
2409
2410 return yy_init_globals(*ptr_yy_globals);
2411 }
2412
yy_init_globals(yyscan_t yyscanner)2413 static int yy_init_globals(yyscan_t yyscanner)
2414 {
2415 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2416 /* Initialization is the same as for the non-reentrant scanner.
2417 * This function is called from yylex_destroy(), so don't allocate here.
2418 */
2419
2420 yyg->yy_buffer_stack = NULL;
2421 yyg->yy_buffer_stack_top = 0;
2422 yyg->yy_buffer_stack_max = 0;
2423 yyg->yy_c_buf_p = NULL;
2424 yyg->yy_init = 0;
2425 yyg->yy_start = 0;
2426
2427 yyg->yy_start_stack_ptr = 0;
2428 yyg->yy_start_stack_depth = 0;
2429 yyg->yy_start_stack = NULL;
2430
2431 /* Defined in main.c */
2432 #ifdef YY_STDINIT
2433 yyin = stdin;
2434 yyout = stdout;
2435 #else
2436 yyin = NULL;
2437 yyout = NULL;
2438 #endif
2439
2440 /* For future reference: Set errno on error, since we are called by
2441 * yylex_init()
2442 */
2443 return 0;
2444 }
2445
2446 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
yylex_destroy(yyscan_t yyscanner)2447 int yylex_destroy(yyscan_t yyscanner)
2448 {
2449 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2450
2451 /* Pop the buffer stack, destroying each element. */
2452 while (YY_CURRENT_BUFFER)
2453 {
2454 yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner);
2455 YY_CURRENT_BUFFER_LVALUE = NULL;
2456 yypop_buffer_state(yyscanner);
2457 }
2458
2459 /* Destroy the stack itself. */
2460 yyfree(yyg->yy_buffer_stack, yyscanner);
2461 yyg->yy_buffer_stack = NULL;
2462
2463 /* Destroy the start condition stack. */
2464 yyfree(yyg->yy_start_stack, yyscanner);
2465 yyg->yy_start_stack = NULL;
2466
2467 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2468 * yylex() is called, initialization will occur. */
2469 yy_init_globals(yyscanner);
2470
2471 /* Destroy the main struct (reentrant only). */
2472 yyfree(yyscanner, yyscanner);
2473 yyscanner = NULL;
2474 return 0;
2475 }
2476
2477 /*
2478 * Internal utility routines.
2479 */
2480
2481 #ifndef yytext_ptr
yy_flex_strncpy(char * s1,const char * s2,int n,yyscan_t yyscanner)2482 static void yy_flex_strncpy(char *s1, const char *s2, int n, yyscan_t yyscanner)
2483 {
2484 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2485 (void)yyg;
2486
2487 int i;
2488 for (i = 0; i < n; ++i)
2489 s1[i] = s2[i];
2490 }
2491 #endif
2492
2493 #ifdef YY_NEED_STRLEN
yy_flex_strlen(const char * s,yyscan_t yyscanner)2494 static int yy_flex_strlen(const char *s, yyscan_t yyscanner)
2495 {
2496 int n;
2497 for (n = 0; s[n]; ++n)
2498 ;
2499
2500 return n;
2501 }
2502 #endif
2503
yyalloc(yy_size_t size,yyscan_t yyscanner)2504 void *yyalloc(yy_size_t size, yyscan_t yyscanner)
2505 {
2506 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2507 (void)yyg;
2508 return malloc(size);
2509 }
2510
yyrealloc(void * ptr,yy_size_t size,yyscan_t yyscanner)2511 void *yyrealloc(void *ptr, yy_size_t size, yyscan_t yyscanner)
2512 {
2513 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2514 (void)yyg;
2515
2516 /* The cast to (char *) in the following accommodates both
2517 * implementations that use char* generic pointers, and those
2518 * that use void* generic pointers. It works with the latter
2519 * because both ANSI C and C++ allow castless assignment from
2520 * any pointer type to void*, and deal with argument conversions
2521 * as though doing an assignment.
2522 */
2523 return realloc(ptr, size);
2524 }
2525
yyfree(void * ptr,yyscan_t yyscanner)2526 void yyfree(void *ptr, yyscan_t yyscanner)
2527 {
2528 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2529 (void)yyg;
2530 free((char *)ptr); /* see yyrealloc() for (char *) cast */
2531 }
2532
2533 #define YYTABLES_NAME "yytables"
2534
2535 namespace angle
2536 {
2537
2538 namespace pp
2539 {
2540
Tokenizer(Diagnostics * diagnostics)2541 Tokenizer::Tokenizer(Diagnostics *diagnostics) : mHandle(nullptr), mMaxTokenSize(256)
2542 {
2543 mContext.diagnostics = diagnostics;
2544 }
2545
~Tokenizer()2546 Tokenizer::~Tokenizer()
2547 {
2548 destroyScanner();
2549 }
2550
init(size_t count,const char * const string[],const int length[])2551 bool Tokenizer::init(size_t count, const char *const string[], const int length[])
2552 {
2553 if ((count > 0) && (string == 0))
2554 return false;
2555
2556 mContext.input = Input(count, string, length);
2557 return initScanner();
2558 }
2559
setFileNumber(int file)2560 void Tokenizer::setFileNumber(int file)
2561 {
2562 // We use column number as file number.
2563 // See macro yyfileno.
2564 yyset_column(file, mHandle);
2565 }
2566
setLineNumber(int line)2567 void Tokenizer::setLineNumber(int line)
2568 {
2569 yyset_lineno(line, mHandle);
2570 }
2571
setMaxTokenSize(size_t maxTokenSize)2572 void Tokenizer::setMaxTokenSize(size_t maxTokenSize)
2573 {
2574 mMaxTokenSize = maxTokenSize;
2575 }
2576
lex(Token * token)2577 void Tokenizer::lex(Token *token)
2578 {
2579 int tokenType = yylex(&token->text, &token->location, mHandle);
2580
2581 if (tokenType == Token::GOT_ERROR)
2582 {
2583 mContext.diagnostics->report(Diagnostics::PP_TOKENIZER_ERROR, token->location, token->text);
2584 token->type = Token::LAST;
2585 }
2586 else
2587 {
2588 token->type = tokenType;
2589 }
2590
2591 if (token->text.size() > mMaxTokenSize)
2592 {
2593 mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG, token->location, token->text);
2594 token->text.erase(mMaxTokenSize);
2595 }
2596
2597 token->flags = 0;
2598
2599 token->setAtStartOfLine(mContext.lineStart);
2600 mContext.lineStart = token->type == '\n';
2601
2602 token->setHasLeadingSpace(mContext.leadingSpace);
2603 mContext.leadingSpace = false;
2604 }
2605
initScanner()2606 bool Tokenizer::initScanner()
2607 {
2608 if ((mHandle == nullptr) && yylex_init_extra(&mContext, &mHandle))
2609 return false;
2610
2611 yyrestart(0, mHandle);
2612 return true;
2613 }
2614
destroyScanner()2615 void Tokenizer::destroyScanner()
2616 {
2617 if (mHandle == nullptr)
2618 return;
2619
2620 yylex_destroy(mHandle);
2621 mHandle = nullptr;
2622 }
2623
2624 } // namespace pp
2625
2626 } // namespace angle
2627