xref: /aosp_15_r20/external/angle/src/compiler/preprocessor/preprocessor_lex_autogen.cpp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
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             }                                             \
907         } while (0)
908 #endif
909 
910 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
911  * is returned in "result".
912  */
913 #ifndef YY_INPUT
914 #    define YY_INPUT(buf, result, max_size)                                                       \
915         if (YY_CURRENT_BUFFER_LVALUE->yy_is_interactive)                                          \
916         {                                                                                         \
917             int c = '*';                                                                          \
918             int n;                                                                                \
919             for (n = 0; n < max_size && (c = getc(yyin)) != EOF && c != '\n'; ++n)                \
920                 buf[n] = (char)c;                                                                 \
921             if (c == '\n')                                                                        \
922                 buf[n++] = (char)c;                                                               \
923             if (c == EOF && ferror(yyin))                                                         \
924                 YY_FATAL_ERROR("input in flex scanner failed");                                   \
925             result = n;                                                                           \
926         }                                                                                         \
927         else                                                                                      \
928         {                                                                                         \
929             errno = 0;                                                                            \
930             while ((result = (int)fread(buf, 1, (yy_size_t)max_size, yyin)) == 0 && ferror(yyin)) \
931             {                                                                                     \
932                 if (errno != EINTR)                                                               \
933                 {                                                                                 \
934                     YY_FATAL_ERROR("input in flex scanner failed");                               \
935                     break;                                                                        \
936                 }                                                                                 \
937                 errno = 0;                                                                        \
938                 clearerr(yyin);                                                                   \
939             }                                                                                     \
940         }
941 
942 #endif
943 
944 /* No semi-colon after return; correct usage is to write "yyterminate();" -
945  * we don't want an extra ';' after the "return" because that will cause
946  * some compilers to complain about unreachable statements.
947  */
948 #ifndef yyterminate
949 #    define yyterminate() return YY_NULL
950 #endif
951 
952 /* Number of entries by which start-condition stack grows. */
953 #ifndef YY_START_STACK_INCR
954 #    define YY_START_STACK_INCR 25
955 #endif
956 
957 /* Report a fatal error. */
958 #ifndef YY_FATAL_ERROR
959 #    define YY_FATAL_ERROR(msg) yy_fatal_error(msg, yyscanner)
960 #endif
961 
962 /* end tables serialization structures and prototypes */
963 
964 /* Default declaration of generated scanner - a define so the user can
965  * easily add parameters.
966  */
967 #ifndef YY_DECL
968 #    define YY_DECL_IS_OURS 1
969 
970 extern int yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner);
971 
972 #    define YY_DECL int yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)
973 #endif /* !YY_DECL */
974 
975 /* Code executed at the beginning of each rule, after yytext and yyleng
976  * have been set up.
977  */
978 #ifndef YY_USER_ACTION
979 #    define YY_USER_ACTION
980 #endif
981 
982 /* Code executed at the end of each rule. */
983 #ifndef YY_BREAK
984 #    define YY_BREAK /*LINTED*/ break;
985 #endif
986 
987 #define YY_RULE_SETUP YY_USER_ACTION
988 
989 /** The main scanner function which does all the work.
990  */
991 YY_DECL
992 {
993     yy_state_type yy_current_state;
994     char *yy_cp, *yy_bp;
995     int yy_act;
996     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
997 
998     yylval = yylval_param;
999 
1000     yylloc = yylloc_param;
1001 
1002     if (!yyg->yy_init)
1003     {
1004         yyg->yy_init = 1;
1005 
1006 #ifdef YY_USER_INIT
1007         YY_USER_INIT;
1008 #endif
1009 
1010         if (!yyg->yy_start)
1011             yyg->yy_start = 1; /* first start state */
1012 
1013         if (!yyin)
1014             yyin = stdin;
1015 
1016         if (!yyout)
1017             yyout = stdout;
1018 
1019         if (!YY_CURRENT_BUFFER)
1020         {
1021             yyensure_buffer_stack(yyscanner);
1022             YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner);
1023         }
1024 
1025         yy_load_buffer_state(yyscanner);
1026     }
1027 
1028     {
1029 
1030         /* Line comment */
1031 
1032         while (/*CONSTCOND*/ 1) /* loops until end-of-file is reached */
1033         {
1034             yy_cp = yyg->yy_c_buf_p;
1035 
1036             /* Support of yytext. */
1037             *yy_cp = yyg->yy_hold_char;
1038 
1039             /* yy_bp points to the position in yy_ch_buf of the start of
1040              * the current run.
1041              */
1042             yy_bp = yy_cp;
1043 
1044             yy_current_state = yyg->yy_start;
1045         yy_match:
1046             do
1047             {
1048                 YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
1049                 if (yy_accept[yy_current_state])
1050                 {
1051                     yyg->yy_last_accepting_state = yy_current_state;
1052                     yyg->yy_last_accepting_cpos  = yy_cp;
1053                 }
1054                 while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)
1055                 {
1056                     yy_current_state = (int)yy_def[yy_current_state];
1057                     if (yy_current_state >= 95)
1058                         yy_c = yy_meta[yy_c];
1059                 }
1060                 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1061                 ++yy_cp;
1062             } while (yy_current_state != 94);
1063             yy_cp            = yyg->yy_last_accepting_cpos;
1064             yy_current_state = yyg->yy_last_accepting_state;
1065 
1066         yy_find_action:
1067             yy_act = yy_accept[yy_current_state];
1068 
1069             YY_DO_BEFORE_ACTION;
1070 
1071         do_action: /* This label is used only to access EOF actions. */
1072 
1073             switch (yy_act)
1074             {           /* beginning of action switch */
1075                 case 0: /* must back up */
1076                     /* undo the effects of YY_DO_BEFORE_ACTION */
1077                     *yy_cp           = yyg->yy_hold_char;
1078                     yy_cp            = yyg->yy_last_accepting_cpos;
1079                     yy_current_state = yyg->yy_last_accepting_state;
1080                     goto yy_find_action;
1081 
1082                 case 1:
1083                     YY_RULE_SETUP
1084 
1085                     YY_BREAK
1086                 /* Block comment */
1087                 /* Line breaks are just counted - not returned. */
1088                 /* The comment is replaced by a single space. */
1089                 case 2:
1090                     YY_RULE_SETUP
1091                     {
1092                         BEGIN(COMMENT);
1093                     }
1094                     YY_BREAK
1095                 case 3:
1096                     YY_RULE_SETUP
1097 
1098                     YY_BREAK
1099                 case 4:
1100                     YY_RULE_SETUP
1101 
1102                     YY_BREAK
1103                 case 5:
1104                     /* rule 5 can match eol */
1105                     YY_RULE_SETUP
1106                     {
1107                         if (yylineno == INT_MAX)
1108                         {
1109                             *yylval = "Integer overflow on line number";
1110                             return angle::pp::Token::GOT_ERROR;
1111                         }
1112                         ++yylineno;
1113                     }
1114                     YY_BREAK
1115                 case 6:
1116                     YY_RULE_SETUP
1117                     {
1118                         yyextra->leadingSpace = true;
1119                         BEGIN(INITIAL);
1120                     }
1121                     YY_BREAK
1122                 case 7:
1123                     YY_RULE_SETUP
1124                     {
1125                         // # is only valid at start of line for preprocessor directives.
1126                         yylval->assign(1, yytext[0]);
1127                         return yyextra->lineStart ? angle::pp::Token::PP_HASH
1128                                                   : angle::pp::Token::PP_OTHER;
1129                     }
1130                     YY_BREAK
1131                 case 8:
1132                     YY_RULE_SETUP
1133                     {
1134                         yylval->assign(yytext, yyleng);
1135                         return angle::pp::Token::IDENTIFIER;
1136                     }
1137                     YY_BREAK
1138                 case 9:
1139                     YY_RULE_SETUP
1140                     {
1141                         yylval->assign(yytext, yyleng);
1142                         return angle::pp::Token::CONST_INT;
1143                     }
1144                     YY_BREAK
1145                 case 10:
1146                     YY_RULE_SETUP
1147                     {
1148                         yylval->assign(yytext, yyleng);
1149                         return angle::pp::Token::CONST_FLOAT;
1150                     }
1151                     YY_BREAK
1152                 /* Anything that starts with a {DIGIT} or .{DIGIT} must be a number. */
1153                 /* Rule to catch all invalid integers and floats. */
1154                 case 11:
1155                     YY_RULE_SETUP
1156                     {
1157                         yylval->assign(yytext, yyleng);
1158                         return angle::pp::Token::PP_NUMBER;
1159                     }
1160                     YY_BREAK
1161                 case 12:
1162                     YY_RULE_SETUP
1163                     {
1164                         yylval->assign(yytext, yyleng);
1165                         return angle::pp::Token::OP_INC;
1166                     }
1167                     YY_BREAK
1168                 case 13:
1169                     YY_RULE_SETUP
1170                     {
1171                         yylval->assign(yytext, yyleng);
1172                         return angle::pp::Token::OP_DEC;
1173                     }
1174                     YY_BREAK
1175                 case 14:
1176                     YY_RULE_SETUP
1177                     {
1178                         yylval->assign(yytext, yyleng);
1179                         return angle::pp::Token::OP_LEFT;
1180                     }
1181                     YY_BREAK
1182                 case 15:
1183                     YY_RULE_SETUP
1184                     {
1185                         yylval->assign(yytext, yyleng);
1186                         return angle::pp::Token::OP_RIGHT;
1187                     }
1188                     YY_BREAK
1189                 case 16:
1190                     YY_RULE_SETUP
1191                     {
1192                         yylval->assign(yytext, yyleng);
1193                         return angle::pp::Token::OP_LE;
1194                     }
1195                     YY_BREAK
1196                 case 17:
1197                     YY_RULE_SETUP
1198                     {
1199                         yylval->assign(yytext, yyleng);
1200                         return angle::pp::Token::OP_GE;
1201                     }
1202                     YY_BREAK
1203                 case 18:
1204                     YY_RULE_SETUP
1205                     {
1206                         yylval->assign(yytext, yyleng);
1207                         return angle::pp::Token::OP_EQ;
1208                     }
1209                     YY_BREAK
1210                 case 19:
1211                     YY_RULE_SETUP
1212                     {
1213                         yylval->assign(yytext, yyleng);
1214                         return angle::pp::Token::OP_NE;
1215                     }
1216                     YY_BREAK
1217                 case 20:
1218                     YY_RULE_SETUP
1219                     {
1220                         yylval->assign(yytext, yyleng);
1221                         return angle::pp::Token::OP_AND;
1222                     }
1223                     YY_BREAK
1224                 case 21:
1225                     YY_RULE_SETUP
1226                     {
1227                         yylval->assign(yytext, yyleng);
1228                         return angle::pp::Token::OP_XOR;
1229                     }
1230                     YY_BREAK
1231                 case 22:
1232                     YY_RULE_SETUP
1233                     {
1234                         yylval->assign(yytext, yyleng);
1235                         return angle::pp::Token::OP_OR;
1236                     }
1237                     YY_BREAK
1238                 case 23:
1239                     YY_RULE_SETUP
1240                     {
1241                         yylval->assign(yytext, yyleng);
1242                         return angle::pp::Token::OP_ADD_ASSIGN;
1243                     }
1244                     YY_BREAK
1245                 case 24:
1246                     YY_RULE_SETUP
1247                     {
1248                         yylval->assign(yytext, yyleng);
1249                         return angle::pp::Token::OP_SUB_ASSIGN;
1250                     }
1251                     YY_BREAK
1252                 case 25:
1253                     YY_RULE_SETUP
1254                     {
1255                         yylval->assign(yytext, yyleng);
1256                         return angle::pp::Token::OP_MUL_ASSIGN;
1257                     }
1258                     YY_BREAK
1259                 case 26:
1260                     YY_RULE_SETUP
1261                     {
1262                         yylval->assign(yytext, yyleng);
1263                         return angle::pp::Token::OP_DIV_ASSIGN;
1264                     }
1265                     YY_BREAK
1266                 case 27:
1267                     YY_RULE_SETUP
1268                     {
1269                         yylval->assign(yytext, yyleng);
1270                         return angle::pp::Token::OP_MOD_ASSIGN;
1271                     }
1272                     YY_BREAK
1273                 case 28:
1274                     YY_RULE_SETUP
1275                     {
1276                         yylval->assign(yytext, yyleng);
1277                         return angle::pp::Token::OP_LEFT_ASSIGN;
1278                     }
1279                     YY_BREAK
1280                 case 29:
1281                     YY_RULE_SETUP
1282                     {
1283                         yylval->assign(yytext, yyleng);
1284                         return angle::pp::Token::OP_RIGHT_ASSIGN;
1285                     }
1286                     YY_BREAK
1287                 case 30:
1288                     YY_RULE_SETUP
1289                     {
1290                         yylval->assign(yytext, yyleng);
1291                         return angle::pp::Token::OP_AND_ASSIGN;
1292                     }
1293                     YY_BREAK
1294                 case 31:
1295                     YY_RULE_SETUP
1296                     {
1297                         yylval->assign(yytext, yyleng);
1298                         return angle::pp::Token::OP_XOR_ASSIGN;
1299                     }
1300                     YY_BREAK
1301                 case 32:
1302                     YY_RULE_SETUP
1303                     {
1304                         yylval->assign(yytext, yyleng);
1305                         return angle::pp::Token::OP_OR_ASSIGN;
1306                     }
1307                     YY_BREAK
1308                 case 33:
1309                     YY_RULE_SETUP
1310                     {
1311                         yylval->assign(1, yytext[0]);
1312                         return yytext[0];
1313                     }
1314                     YY_BREAK
1315                 case 34:
1316                     YY_RULE_SETUP
1317                     {
1318                         yyextra->leadingSpace = true;
1319                     }
1320                     YY_BREAK
1321                 case 35:
1322                     /* rule 35 can match eol */
1323                     YY_RULE_SETUP
1324                     {
1325                         if (yylineno == INT_MAX)
1326                         {
1327                             *yylval = "Integer overflow on line number";
1328                             return angle::pp::Token::GOT_ERROR;
1329                         }
1330                         ++yylineno;
1331                         yylval->assign(1, '\n');
1332                         return '\n';
1333                     }
1334                     YY_BREAK
1335                 case 36:
1336                     YY_RULE_SETUP
1337                     {
1338                         yylval->assign(1, yytext[0]);
1339                         return angle::pp::Token::PP_OTHER;
1340                     }
1341                     YY_BREAK
1342                 case YY_STATE_EOF(INITIAL):
1343                 case YY_STATE_EOF(COMMENT):
1344                 {
1345                     // YY_USER_ACTION is not invoked for handling EOF.
1346                     // Set the location for EOF token manually.
1347                     angle::pp::Input *input             = &yyextra->input;
1348                     angle::pp::Input::Location *scanLoc = &yyextra->scanLoc;
1349                     yy_size_t sIndexMax                 = input->count() ? input->count() - 1 : 0;
1350                     if (scanLoc->sIndex != sIndexMax)
1351                     {
1352                         // We can only reach here if there are empty strings at the
1353                         // end of the input.
1354                         scanLoc->sIndex = sIndexMax;
1355                         scanLoc->cIndex = 0;
1356                         // FIXME: this is not 64-bit clean.
1357                         yyfileno = static_cast<int>(sIndexMax);
1358                         yylineno = 1;
1359                     }
1360                     yylloc->file = yyfileno;
1361                     yylloc->line = yylineno;
1362                     yylval->clear();
1363 
1364                     // Line number overflows fake EOFs to exit early, check for this case.
1365                     if (yylineno == INT_MAX)
1366                     {
1367                         yyextra->diagnostics->report(angle::pp::Diagnostics::PP_TOKENIZER_ERROR,
1368                                                      angle::pp::SourceLocation(yyfileno, yylineno),
1369                                                      "Integer overflow on line number");
1370                     }
1371                     else if (YY_START == COMMENT)
1372                     {
1373                         yyextra->diagnostics->report(angle::pp::Diagnostics::PP_EOF_IN_COMMENT,
1374                                                      angle::pp::SourceLocation(yyfileno, yylineno),
1375                                                      "EOF while in a comment");
1376                     }
1377                     yyterminate();
1378                 }
1379                     YY_BREAK
1380                 case 37:
1381                     YY_RULE_SETUP
1382                     ECHO;
1383                     YY_BREAK
1384 
1385                 case YY_END_OF_BUFFER:
1386                 {
1387                     /* Amount of text matched not including the EOB char. */
1388                     int yy_amount_of_matched_text = (int)(yy_cp - yyg->yytext_ptr) - 1;
1389 
1390                     /* Undo the effects of YY_DO_BEFORE_ACTION. */
1391                     *yy_cp = yyg->yy_hold_char;
1392                     YY_RESTORE_YY_MORE_OFFSET
1393 
1394                     if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW)
1395                     {
1396                         /* We're scanning a new file or input source.  It's
1397                          * possible that this happened because the user
1398                          * just pointed yyin at a new source and called
1399                          * yylex().  If so, then we have to assure
1400                          * consistency between YY_CURRENT_BUFFER and our
1401                          * globals.  Here is the right place to do so, because
1402                          * this is the first action (other than possibly a
1403                          * back-up) that will match for the new input source.
1404                          */
1405                         yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1406                         YY_CURRENT_BUFFER_LVALUE->yy_input_file    = yyin;
1407                         YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1408                     }
1409 
1410                     /* Note that here we test for yy_c_buf_p "<=" to the position
1411                      * of the first EOB in the buffer, since yy_c_buf_p will
1412                      * already have been incremented past the NUL character
1413                      * (since all states make transitions on EOB to the
1414                      * end-of-buffer state).  Contrast this with the test
1415                      * in input().
1416                      */
1417                     if (yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars])
1418                     { /* This was really a NUL. */
1419                         yy_state_type yy_next_state;
1420 
1421                         yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1422 
1423                         yy_current_state = yy_get_previous_state(yyscanner);
1424 
1425                         /* Okay, we're now positioned to make the NUL
1426                          * transition.  We couldn't have
1427                          * yy_get_previous_state() go ahead and do it
1428                          * for us because it doesn't know how to deal
1429                          * with the possibility of jamming (and we don't
1430                          * want to build jamming into it because then it
1431                          * will run more slowly).
1432                          */
1433 
1434                         yy_next_state = yy_try_NUL_trans(yy_current_state, yyscanner);
1435 
1436                         yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1437 
1438                         if (yy_next_state)
1439                         {
1440                             /* Consume the NUL. */
1441                             yy_cp            = ++yyg->yy_c_buf_p;
1442                             yy_current_state = yy_next_state;
1443                             goto yy_match;
1444                         }
1445 
1446                         else
1447                         {
1448                             yy_cp            = yyg->yy_last_accepting_cpos;
1449                             yy_current_state = yyg->yy_last_accepting_state;
1450                             goto yy_find_action;
1451                         }
1452                     }
1453 
1454                     else
1455                         switch (yy_get_next_buffer(yyscanner))
1456                         {
1457                             case EOB_ACT_END_OF_FILE:
1458                             {
1459                                 yyg->yy_did_buffer_switch_on_eof = 0;
1460 
1461                                 if (yywrap(yyscanner))
1462                                 {
1463                                     /* Note: because we've taken care in
1464                                      * yy_get_next_buffer() to have set up
1465                                      * yytext, we can now set up
1466                                      * yy_c_buf_p so that if some total
1467                                      * hoser (like flex itself) wants to
1468                                      * call the scanner after we return the
1469                                      * YY_NULL, it'll still work - another
1470                                      * YY_NULL will get returned.
1471                                      */
1472                                     yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1473 
1474                                     yy_act = YY_STATE_EOF(YY_START);
1475                                     goto do_action;
1476                                 }
1477 
1478                                 else
1479                                 {
1480                                     if (!yyg->yy_did_buffer_switch_on_eof)
1481                                         YY_NEW_FILE;
1482                                 }
1483                                 break;
1484                             }
1485 
1486                             case EOB_ACT_CONTINUE_SCAN:
1487                                 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1488 
1489                                 yy_current_state = yy_get_previous_state(yyscanner);
1490 
1491                                 yy_cp = yyg->yy_c_buf_p;
1492                                 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1493                                 goto yy_match;
1494 
1495                             case EOB_ACT_LAST_MATCH:
1496                                 yyg->yy_c_buf_p =
1497                                     &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1498 
1499                                 yy_current_state = yy_get_previous_state(yyscanner);
1500 
1501                                 yy_cp = yyg->yy_c_buf_p;
1502                                 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1503                                 goto yy_find_action;
1504                         }
1505                     break;
1506                 }
1507 
1508                 default:
1509                     YY_FATAL_ERROR("fatal flex scanner internal error--no action found");
1510             } /* end of action switch */
1511         }     /* end of scanning one token */
1512     }         /* end of user's declarations */
1513 } /* end of yylex */
1514 
1515 /* yy_get_next_buffer - try to read in a new buffer
1516  *
1517  * Returns a code representing an action:
1518  *    EOB_ACT_LAST_MATCH -
1519  *    EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1520  *    EOB_ACT_END_OF_FILE - end of file
1521  */
1522 static int yy_get_next_buffer(yyscan_t yyscanner)
1523 {
1524     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1525     char *dest           = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1526     char *source         = yyg->yytext_ptr;
1527     int number_to_move, i;
1528     int ret_val;
1529 
1530     if (yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1])
1531         YY_FATAL_ERROR("fatal flex scanner internal error--end of buffer missed");
1532 
1533     if (YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0)
1534     { /* Don't try to fill the buffer, so this is an EOF. */
1535         if (yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1)
1536         {
1537             /* We matched a single character, the EOB, so
1538              * treat this as a final EOF.
1539              */
1540             return EOB_ACT_END_OF_FILE;
1541         }
1542 
1543         else
1544         {
1545             /* We matched some text prior to the EOB, first
1546              * process it.
1547              */
1548             return EOB_ACT_LAST_MATCH;
1549         }
1550     }
1551 
1552     /* Try to read more data. */
1553 
1554     /* First move last chars to start of buffer. */
1555     number_to_move = (int)(yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
1556 
1557     for (i = 0; i < number_to_move; ++i)
1558         *(dest++) = *(source++);
1559 
1560     if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING)
1561         /* don't do the read, it's not guaranteed to return an EOF,
1562          * just force an EOF
1563          */
1564         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1565 
1566     else
1567     {
1568         int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1569 
1570         while (num_to_read <= 0)
1571         { /* Not enough room in the buffer - grow it. */
1572 
1573             /* just a shorter name for the current buffer */
1574             YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1575 
1576             int yy_c_buf_p_offset = (int)(yyg->yy_c_buf_p - b->yy_ch_buf);
1577 
1578             if (b->yy_is_our_buffer)
1579             {
1580                 int new_size = b->yy_buf_size * 2;
1581 
1582                 if (new_size <= 0)
1583                     b->yy_buf_size += b->yy_buf_size / 8;
1584                 else
1585                     b->yy_buf_size *= 2;
1586 
1587                 b->yy_ch_buf = (char *)
1588                     /* Include room in for 2 EOB chars. */
1589                     yyrealloc((void *)b->yy_ch_buf, (yy_size_t)(b->yy_buf_size + 2), yyscanner);
1590             }
1591             else
1592                 /* Can't grow it, we don't own it. */
1593                 b->yy_ch_buf = NULL;
1594 
1595             if (!b->yy_ch_buf)
1596                 YY_FATAL_ERROR("fatal error - scanner input buffer overflow");
1597 
1598             yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1599 
1600             num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1601         }
1602 
1603         if (num_to_read > YY_READ_BUF_SIZE)
1604             num_to_read = YY_READ_BUF_SIZE;
1605 
1606         /* Read in more data. */
1607         yy_size_t ret = 0;
1608         YY_INPUT((&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), ret, num_to_read);
1609         yyg->yy_n_chars = static_cast<int>(ret);
1610 
1611         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1612     }
1613 
1614     if (yyg->yy_n_chars == 0)
1615     {
1616         if (number_to_move == YY_MORE_ADJ)
1617         {
1618             ret_val = EOB_ACT_END_OF_FILE;
1619             yyrestart(yyin, yyscanner);
1620         }
1621 
1622         else
1623         {
1624             ret_val                                    = EOB_ACT_LAST_MATCH;
1625             YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING;
1626         }
1627     }
1628 
1629     else
1630         ret_val = EOB_ACT_CONTINUE_SCAN;
1631 
1632     if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size)
1633     {
1634         /* Extend the array by 50%, plus the number we really need. */
1635         int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1636         YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *)yyrealloc(
1637             (void *)YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t)new_size, yyscanner);
1638         if (!YY_CURRENT_BUFFER_LVALUE->yy_ch_buf)
1639             YY_FATAL_ERROR("out of dynamic memory in yy_get_next_buffer()");
1640         /* "- 2" to take care of EOB's */
1641         YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int)(new_size - 2);
1642     }
1643 
1644     yyg->yy_n_chars += number_to_move;
1645     YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]     = YY_END_OF_BUFFER_CHAR;
1646     YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1647 
1648     yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1649 
1650     return ret_val;
1651 }
1652 
1653 /* yy_get_previous_state - get the state just before the EOB char was reached */
1654 
yy_get_previous_state(yyscan_t yyscanner)1655 static yy_state_type yy_get_previous_state(yyscan_t yyscanner)
1656 {
1657     yy_state_type yy_current_state;
1658     char *yy_cp;
1659     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1660 
1661     yy_current_state = yyg->yy_start;
1662 
1663     for (yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp)
1664     {
1665         YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1666         if (yy_accept[yy_current_state])
1667         {
1668             yyg->yy_last_accepting_state = yy_current_state;
1669             yyg->yy_last_accepting_cpos  = yy_cp;
1670         }
1671         while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)
1672         {
1673             yy_current_state = (int)yy_def[yy_current_state];
1674             if (yy_current_state >= 95)
1675                 yy_c = yy_meta[yy_c];
1676         }
1677         yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1678     }
1679 
1680     return yy_current_state;
1681 }
1682 
1683 /* yy_try_NUL_trans - try to make a transition on the NUL character
1684  *
1685  * synopsis
1686  *    next_state = yy_try_NUL_trans( current_state );
1687  */
yy_try_NUL_trans(yy_state_type yy_current_state,yyscan_t yyscanner)1688 static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state, yyscan_t yyscanner)
1689 {
1690     int yy_is_jam;
1691     struct yyguts_t *yyg =
1692         (struct yyguts_t *)yyscanner; /* This var may be unused depending upon options. */
1693     char *yy_cp = yyg->yy_c_buf_p;
1694 
1695     YY_CHAR yy_c = 1;
1696     if (yy_accept[yy_current_state])
1697     {
1698         yyg->yy_last_accepting_state = yy_current_state;
1699         yyg->yy_last_accepting_cpos  = yy_cp;
1700     }
1701     while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)
1702     {
1703         yy_current_state = (int)yy_def[yy_current_state];
1704         if (yy_current_state >= 95)
1705             yy_c = yy_meta[yy_c];
1706     }
1707     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1708     yy_is_jam        = (yy_current_state == 94);
1709 
1710     (void)yyg;
1711     return yy_is_jam ? 0 : yy_current_state;
1712 }
1713 
1714 #ifndef YY_NO_UNPUT
1715 
1716 #endif
1717 
1718 #ifndef YY_NO_INPUT
1719 #    ifdef __cplusplus
yyinput(yyscan_t yyscanner)1720 static int yyinput(yyscan_t yyscanner)
1721 #    else
1722 static int input(yyscan_t yyscanner)
1723 #    endif
1724 
1725 {
1726     int c;
1727     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1728 
1729     *yyg->yy_c_buf_p = yyg->yy_hold_char;
1730 
1731     if (*yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR)
1732     {
1733         /* yy_c_buf_p now points to the character we want to return.
1734          * If this occurs *before* the EOB characters, then it's a
1735          * valid NUL; if not, then we've hit the end of the buffer.
1736          */
1737         if (yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars])
1738             /* This was really a NUL. */
1739             *yyg->yy_c_buf_p = '\0';
1740 
1741         else
1742         { /* need more input */
1743             int offset = (int)(yyg->yy_c_buf_p - yyg->yytext_ptr);
1744             ++yyg->yy_c_buf_p;
1745 
1746             switch (yy_get_next_buffer(yyscanner))
1747             {
1748                 case EOB_ACT_LAST_MATCH:
1749                     /* This happens because yy_g_n_b()
1750                      * sees that we've accumulated a
1751                      * token and flags that we need to
1752                      * try matching the token before
1753                      * proceeding.  But for input(),
1754                      * there's no matching to consider.
1755                      * So convert the EOB_ACT_LAST_MATCH
1756                      * to EOB_ACT_END_OF_FILE.
1757                      */
1758 
1759                     /* Reset buffer status. */
1760                     yyrestart(yyin, yyscanner);
1761 
1762                     /*FALLTHROUGH*/
1763 
1764                 case EOB_ACT_END_OF_FILE:
1765                 {
1766                     if (yywrap(yyscanner))
1767                         return 0;
1768 
1769                     if (!yyg->yy_did_buffer_switch_on_eof)
1770                         YY_NEW_FILE;
1771 #    ifdef __cplusplus
1772                     return yyinput(yyscanner);
1773 #    else
1774                     return input(yyscanner);
1775 #    endif
1776                 }
1777 
1778                 case EOB_ACT_CONTINUE_SCAN:
1779                     yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1780                     break;
1781             }
1782         }
1783     }
1784 
1785     c                 = *(unsigned char *)yyg->yy_c_buf_p; /* cast for 8-bit char's */
1786     *yyg->yy_c_buf_p  = '\0';                              /* preserve yytext */
1787     yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1788 
1789     return c;
1790 }
1791 #endif /* ifndef YY_NO_INPUT */
1792 
1793 /** Immediately switch to a different input stream.
1794  * @param input_file A readable stream.
1795  * @param yyscanner The scanner object.
1796  * @note This function does not reset the start condition to @c INITIAL .
1797  */
yyrestart(FILE * input_file,yyscan_t yyscanner)1798 void yyrestart(FILE *input_file, yyscan_t yyscanner)
1799 {
1800     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1801 
1802     if (!YY_CURRENT_BUFFER)
1803     {
1804         yyensure_buffer_stack(yyscanner);
1805         YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner);
1806     }
1807 
1808     yy_init_buffer(YY_CURRENT_BUFFER, input_file, yyscanner);
1809     yy_load_buffer_state(yyscanner);
1810 }
1811 
1812 /** Switch to a different input buffer.
1813  * @param new_buffer The new input buffer.
1814  * @param yyscanner The scanner object.
1815  */
yy_switch_to_buffer(YY_BUFFER_STATE new_buffer,yyscan_t yyscanner)1816 void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner)
1817 {
1818     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1819 
1820     /* TODO. We should be able to replace this entire function body
1821      * with
1822      *        yypop_buffer_state();
1823      *        yypush_buffer_state(new_buffer);
1824      */
1825     yyensure_buffer_stack(yyscanner);
1826     if (YY_CURRENT_BUFFER == new_buffer)
1827         return;
1828 
1829     if (YY_CURRENT_BUFFER)
1830     {
1831         /* Flush out information for old buffer. */
1832         *yyg->yy_c_buf_p                     = yyg->yy_hold_char;
1833         YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1834         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1835     }
1836 
1837     YY_CURRENT_BUFFER_LVALUE = new_buffer;
1838     yy_load_buffer_state(yyscanner);
1839 
1840     /* We don't actually know whether we did this switch during
1841      * EOF (yywrap()) processing, but the only time this flag
1842      * is looked at is after yywrap() is called, so it's safe
1843      * to go ahead and always set it.
1844      */
1845     yyg->yy_did_buffer_switch_on_eof = 1;
1846 }
1847 
yy_load_buffer_state(yyscan_t yyscanner)1848 static void yy_load_buffer_state(yyscan_t yyscanner)
1849 {
1850     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1851     yyg->yy_n_chars      = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1852     yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1853     yyin                              = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1854     yyg->yy_hold_char                 = *yyg->yy_c_buf_p;
1855 }
1856 
1857 /** Allocate and initialize an input buffer state.
1858  * @param file A readable stream.
1859  * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1860  * @param yyscanner The scanner object.
1861  * @return the allocated buffer state.
1862  */
yy_create_buffer(FILE * file,int size,yyscan_t yyscanner)1863 YY_BUFFER_STATE yy_create_buffer(FILE *file, int size, yyscan_t yyscanner)
1864 {
1865     YY_BUFFER_STATE b;
1866 
1867     b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state), yyscanner);
1868     if (!b)
1869         YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()");
1870 
1871     b->yy_buf_size = size;
1872 
1873     /* yy_ch_buf has to be 2 characters longer than the size given because
1874      * we need to put in 2 end-of-buffer characters.
1875      */
1876     b->yy_ch_buf = (char *)yyalloc((yy_size_t)(b->yy_buf_size + 2), yyscanner);
1877     if (!b->yy_ch_buf)
1878         YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()");
1879 
1880     b->yy_is_our_buffer = 1;
1881 
1882     yy_init_buffer(b, file, yyscanner);
1883 
1884     return b;
1885 }
1886 
1887 /** Destroy the buffer.
1888  * @param b a buffer created with yy_create_buffer()
1889  * @param yyscanner The scanner object.
1890  */
yy_delete_buffer(YY_BUFFER_STATE b,yyscan_t yyscanner)1891 void yy_delete_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner)
1892 {
1893     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1894 
1895     if (!b)
1896         return;
1897 
1898     if (b == YY_CURRENT_BUFFER) /* Not sure if we should pop here. */
1899         YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE)0;
1900 
1901     if (b->yy_is_our_buffer)
1902         yyfree((void *)b->yy_ch_buf, yyscanner);
1903 
1904     yyfree((void *)b, yyscanner);
1905 }
1906 
1907 /* Initializes or reinitializes a buffer.
1908  * This function is sometimes called more than once on the same buffer,
1909  * such as during a yyrestart() or at EOF.
1910  */
yy_init_buffer(YY_BUFFER_STATE b,FILE * file,yyscan_t yyscanner)1911 static void yy_init_buffer(YY_BUFFER_STATE b, FILE *file, yyscan_t yyscanner)
1912 
1913 {
1914     int oerrno           = errno;
1915     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1916 
1917     yy_flush_buffer(b, yyscanner);
1918 
1919     b->yy_input_file  = file;
1920     b->yy_fill_buffer = 1;
1921 
1922     /* If b is the current buffer, then yy_init_buffer was _probably_
1923      * called from yyrestart() or through yy_get_next_buffer.
1924      * In that case, we don't want to reset the lineno or column.
1925      */
1926     if (b != YY_CURRENT_BUFFER)
1927     {
1928         b->yy_bs_lineno = 1;
1929         b->yy_bs_column = 0;
1930     }
1931 
1932     b->yy_is_interactive = 0;
1933 
1934     errno = oerrno;
1935 }
1936 
1937 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1938  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1939  * @param yyscanner The scanner object.
1940  */
yy_flush_buffer(YY_BUFFER_STATE b,yyscan_t yyscanner)1941 void yy_flush_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner)
1942 {
1943     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1944     if (!b)
1945         return;
1946 
1947     b->yy_n_chars = 0;
1948 
1949     /* We always need two end-of-buffer characters.  The first causes
1950      * a transition to the end-of-buffer state.  The second causes
1951      * a jam in that state.
1952      */
1953     b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1954     b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1955 
1956     b->yy_buf_pos = &b->yy_ch_buf[0];
1957 
1958     b->yy_at_bol        = 1;
1959     b->yy_buffer_status = YY_BUFFER_NEW;
1960 
1961     if (b == YY_CURRENT_BUFFER)
1962         yy_load_buffer_state(yyscanner);
1963 }
1964 
1965 /** Pushes the new state onto the stack. The new state becomes
1966  *  the current state. This function will allocate the stack
1967  *  if necessary.
1968  *  @param new_buffer The new state.
1969  *  @param yyscanner The scanner object.
1970  */
yypush_buffer_state(YY_BUFFER_STATE new_buffer,yyscan_t yyscanner)1971 void yypush_buffer_state(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner)
1972 {
1973     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1974     if (new_buffer == NULL)
1975         return;
1976 
1977     yyensure_buffer_stack(yyscanner);
1978 
1979     /* This block is copied from yy_switch_to_buffer. */
1980     if (YY_CURRENT_BUFFER)
1981     {
1982         /* Flush out information for old buffer. */
1983         *yyg->yy_c_buf_p                     = yyg->yy_hold_char;
1984         YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1985         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1986     }
1987 
1988     /* Only push if top exists. Otherwise, replace top. */
1989     if (YY_CURRENT_BUFFER)
1990         yyg->yy_buffer_stack_top++;
1991     YY_CURRENT_BUFFER_LVALUE = new_buffer;
1992 
1993     /* copied from yy_switch_to_buffer. */
1994     yy_load_buffer_state(yyscanner);
1995     yyg->yy_did_buffer_switch_on_eof = 1;
1996 }
1997 
1998 /** Removes and deletes the top of the stack, if present.
1999  *  The next element becomes the new top.
2000  *  @param yyscanner The scanner object.
2001  */
yypop_buffer_state(yyscan_t yyscanner)2002 void yypop_buffer_state(yyscan_t yyscanner)
2003 {
2004     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2005     if (!YY_CURRENT_BUFFER)
2006         return;
2007 
2008     yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner);
2009     YY_CURRENT_BUFFER_LVALUE = NULL;
2010     if (yyg->yy_buffer_stack_top > 0)
2011         --yyg->yy_buffer_stack_top;
2012 
2013     if (YY_CURRENT_BUFFER)
2014     {
2015         yy_load_buffer_state(yyscanner);
2016         yyg->yy_did_buffer_switch_on_eof = 1;
2017     }
2018 }
2019 
2020 /* Allocates the stack if it does not exist.
2021  *  Guarantees space for at least one push.
2022  */
yyensure_buffer_stack(yyscan_t yyscanner)2023 static void yyensure_buffer_stack(yyscan_t yyscanner)
2024 {
2025     yy_size_t num_to_alloc;
2026     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2027 
2028     if (!yyg->yy_buffer_stack)
2029     {
2030 
2031         /* First allocation is just for 2 elements, since we don't know if this
2032          * scanner will even need a stack. We use 2 instead of 1 to avoid an
2033          * immediate realloc on the next call.
2034          */
2035         num_to_alloc         = 1; /* After all that talk, this was set to 1 anyways... */
2036         yyg->yy_buffer_stack = (struct yy_buffer_state **)yyalloc(
2037             num_to_alloc * sizeof(struct yy_buffer_state *), yyscanner);
2038         if (!yyg->yy_buffer_stack)
2039             YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()");
2040 
2041         memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state *));
2042 
2043         yyg->yy_buffer_stack_max = num_to_alloc;
2044         yyg->yy_buffer_stack_top = 0;
2045         return;
2046     }
2047 
2048     if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1)
2049     {
2050 
2051         /* Increase the buffer to prepare for a possible push. */
2052         yy_size_t grow_size = 8 /* arbitrary grow size */;
2053 
2054         num_to_alloc         = yyg->yy_buffer_stack_max + grow_size;
2055         yyg->yy_buffer_stack = (struct yy_buffer_state **)yyrealloc(
2056             yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state *), yyscanner);
2057         if (!yyg->yy_buffer_stack)
2058             YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()");
2059 
2060         /* zero only the new slots.*/
2061         memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0,
2062                grow_size * sizeof(struct yy_buffer_state *));
2063         yyg->yy_buffer_stack_max = num_to_alloc;
2064     }
2065 }
2066 
2067 /** Setup the input buffer state to scan directly from a user-specified character buffer.
2068  * @param base the character buffer
2069  * @param size the size in bytes of the character buffer
2070  * @param yyscanner The scanner object.
2071  * @return the newly allocated buffer state object.
2072  */
yy_scan_buffer(char * base,yy_size_t size,yyscan_t yyscanner)2073 YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size, yyscan_t yyscanner)
2074 {
2075     YY_BUFFER_STATE b;
2076 
2077     if (size < 2 || base[size - 2] != YY_END_OF_BUFFER_CHAR ||
2078         base[size - 1] != YY_END_OF_BUFFER_CHAR)
2079         /* They forgot to leave room for the EOB's. */
2080         return NULL;
2081 
2082     b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state), yyscanner);
2083     if (!b)
2084         YY_FATAL_ERROR("out of dynamic memory in yy_scan_buffer()");
2085 
2086     b->yy_buf_size = (int)(size - 2); /* "- 2" to take care of EOB's */
2087     b->yy_buf_pos = b->yy_ch_buf = base;
2088     b->yy_is_our_buffer          = 0;
2089     b->yy_input_file             = NULL;
2090     b->yy_n_chars                = b->yy_buf_size;
2091     b->yy_is_interactive         = 0;
2092     b->yy_at_bol                 = 1;
2093     b->yy_fill_buffer            = 0;
2094     b->yy_buffer_status          = YY_BUFFER_NEW;
2095 
2096     yy_switch_to_buffer(b, yyscanner);
2097 
2098     return b;
2099 }
2100 
2101 /** Setup the input buffer state to scan a string. The next call to yylex() will
2102  * scan from a @e copy of @a str.
2103  * @param yystr a NUL-terminated string to scan
2104  * @param yyscanner The scanner object.
2105  * @return the newly allocated buffer state object.
2106  * @note If you want to scan bytes that may contain NUL values, then use
2107  *       yy_scan_bytes() instead.
2108  */
yy_scan_string(const char * yystr,yyscan_t yyscanner)2109 YY_BUFFER_STATE yy_scan_string(const char *yystr, yyscan_t yyscanner)
2110 {
2111 
2112     return yy_scan_bytes(yystr, (int)strlen(yystr), yyscanner);
2113 }
2114 
2115 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
2116  * scan from a @e copy of @a bytes.
2117  * @param yybytes the byte buffer to scan
2118  * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2119  * @param yyscanner The scanner object.
2120  * @return the newly allocated buffer state object.
2121  */
yy_scan_bytes(const char * yybytes,int _yybytes_len,yyscan_t yyscanner)2122 YY_BUFFER_STATE yy_scan_bytes(const char *yybytes, int _yybytes_len, yyscan_t yyscanner)
2123 {
2124     YY_BUFFER_STATE b;
2125     char *buf;
2126     yy_size_t n;
2127     int i;
2128 
2129     /* Get memory for full buffer, including space for trailing EOB's. */
2130     n   = (yy_size_t)(_yybytes_len + 2);
2131     buf = (char *)yyalloc(n, yyscanner);
2132     if (!buf)
2133         YY_FATAL_ERROR("out of dynamic memory in yy_scan_bytes()");
2134 
2135     for (i = 0; i < _yybytes_len; ++i)
2136         buf[i] = yybytes[i];
2137 
2138     buf[_yybytes_len] = buf[_yybytes_len + 1] = YY_END_OF_BUFFER_CHAR;
2139 
2140     b = yy_scan_buffer(buf, n, yyscanner);
2141     if (!b)
2142         YY_FATAL_ERROR("bad buffer in yy_scan_bytes()");
2143 
2144     /* It's okay to grow etc. this buffer, and we should throw it
2145      * away when we're done.
2146      */
2147     b->yy_is_our_buffer = 1;
2148 
2149     return b;
2150 }
2151 
2152 #ifndef YY_EXIT_FAILURE
2153 #    define YY_EXIT_FAILURE 2
2154 #endif
2155 
yy_fatal_error(const char * msg,yyscan_t yyscanner)2156 static void yynoreturn yy_fatal_error(const char *msg, yyscan_t yyscanner)
2157 {
2158     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2159     (void)yyg;
2160     fprintf(stderr, "%s\n", msg);
2161     exit(YY_EXIT_FAILURE);
2162 }
2163 
2164 /* Redefine yyless() so it works in section 3 code. */
2165 
2166 #undef yyless
2167 #define yyless(n)                                      \
2168     do                                                 \
2169     {                                                  \
2170         /* Undo effects of setting up yytext. */       \
2171         int yyless_macro_arg = (n);                    \
2172         YY_LESS_LINENO(yyless_macro_arg);              \
2173         yytext[yyleng]    = yyg->yy_hold_char;         \
2174         yyg->yy_c_buf_p   = yytext + yyless_macro_arg; \
2175         yyg->yy_hold_char = *yyg->yy_c_buf_p;          \
2176         *yyg->yy_c_buf_p  = '\0';                      \
2177         yyleng            = yyless_macro_arg;          \
2178     } while (0)
2179 
2180 /* Accessor  methods (get/set functions) to struct members. */
2181 
2182 /** Get the user-defined data for this scanner.
2183  * @param yyscanner The scanner object.
2184  */
yyget_extra(yyscan_t yyscanner)2185 YY_EXTRA_TYPE yyget_extra(yyscan_t yyscanner)
2186 {
2187     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2188     return yyextra;
2189 }
2190 
2191 /** Get the current line number.
2192  * @param yyscanner The scanner object.
2193  */
yyget_lineno(yyscan_t yyscanner)2194 int yyget_lineno(yyscan_t yyscanner)
2195 {
2196     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2197 
2198     if (!YY_CURRENT_BUFFER)
2199         return 0;
2200 
2201     return yylineno;
2202 }
2203 
2204 /** Get the current column number.
2205  * @param yyscanner The scanner object.
2206  */
yyget_column(yyscan_t yyscanner)2207 int yyget_column(yyscan_t yyscanner)
2208 {
2209     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2210 
2211     if (!YY_CURRENT_BUFFER)
2212         return 0;
2213 
2214     return yycolumn;
2215 }
2216 
2217 /** Get the input stream.
2218  * @param yyscanner The scanner object.
2219  */
yyget_in(yyscan_t yyscanner)2220 FILE *yyget_in(yyscan_t yyscanner)
2221 {
2222     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2223     return yyin;
2224 }
2225 
2226 /** Get the output stream.
2227  * @param yyscanner The scanner object.
2228  */
yyget_out(yyscan_t yyscanner)2229 FILE *yyget_out(yyscan_t yyscanner)
2230 {
2231     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2232     return yyout;
2233 }
2234 
2235 /** Get the length of the current token.
2236  * @param yyscanner The scanner object.
2237  */
yyget_leng(yyscan_t yyscanner)2238 int yyget_leng(yyscan_t yyscanner)
2239 {
2240     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2241     return yyleng;
2242 }
2243 
2244 /** Get the current token.
2245  * @param yyscanner The scanner object.
2246  */
2247 
yyget_text(yyscan_t yyscanner)2248 char *yyget_text(yyscan_t yyscanner)
2249 {
2250     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2251     return yytext;
2252 }
2253 
2254 /** Set the user-defined data. This data is never touched by the scanner.
2255  * @param user_defined The data to be associated with this scanner.
2256  * @param yyscanner The scanner object.
2257  */
yyset_extra(YY_EXTRA_TYPE user_defined,yyscan_t yyscanner)2258 void yyset_extra(YY_EXTRA_TYPE user_defined, yyscan_t yyscanner)
2259 {
2260     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2261     yyextra              = user_defined;
2262 }
2263 
2264 /** Set the current line number.
2265  * @param _line_number line number
2266  * @param yyscanner The scanner object.
2267  */
yyset_lineno(int _line_number,yyscan_t yyscanner)2268 void yyset_lineno(int _line_number, yyscan_t yyscanner)
2269 {
2270     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2271 
2272     /* lineno is only valid if an input buffer exists. */
2273     if (!YY_CURRENT_BUFFER)
2274         YY_FATAL_ERROR("yyset_lineno called with no buffer");
2275 
2276     yylineno = _line_number;
2277 }
2278 
2279 /** Set the current column.
2280  * @param _column_no column number
2281  * @param yyscanner The scanner object.
2282  */
yyset_column(int _column_no,yyscan_t yyscanner)2283 void yyset_column(int _column_no, yyscan_t yyscanner)
2284 {
2285     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2286 
2287     /* column is only valid if an input buffer exists. */
2288     if (!YY_CURRENT_BUFFER)
2289         YY_FATAL_ERROR("yyset_column called with no buffer");
2290 
2291     yycolumn = _column_no;
2292 }
2293 
2294 /** Set the input stream. This does not discard the current
2295  * input buffer.
2296  * @param _in_str A readable stream.
2297  * @param yyscanner The scanner object.
2298  * @see yy_switch_to_buffer
2299  */
yyset_in(FILE * _in_str,yyscan_t yyscanner)2300 void yyset_in(FILE *_in_str, yyscan_t yyscanner)
2301 {
2302     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2303     yyin                 = _in_str;
2304 }
2305 
yyset_out(FILE * _out_str,yyscan_t yyscanner)2306 void yyset_out(FILE *_out_str, yyscan_t yyscanner)
2307 {
2308     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2309     yyout                = _out_str;
2310 }
2311 
yyget_debug(yyscan_t yyscanner)2312 int yyget_debug(yyscan_t yyscanner)
2313 {
2314     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2315     return yy_flex_debug;
2316 }
2317 
yyset_debug(int _bdebug,yyscan_t yyscanner)2318 void yyset_debug(int _bdebug, yyscan_t yyscanner)
2319 {
2320     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2321     yy_flex_debug        = _bdebug;
2322 }
2323 
2324 /* Accessor methods for yylval and yylloc */
2325 
yyget_lval(yyscan_t yyscanner)2326 YYSTYPE *yyget_lval(yyscan_t yyscanner)
2327 {
2328     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2329     return yylval;
2330 }
2331 
yyset_lval(YYSTYPE * yylval_param,yyscan_t yyscanner)2332 void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner)
2333 {
2334     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2335     yylval               = yylval_param;
2336 }
2337 
yyget_lloc(yyscan_t yyscanner)2338 YYLTYPE *yyget_lloc(yyscan_t yyscanner)
2339 {
2340     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2341     return yylloc;
2342 }
2343 
yyset_lloc(YYLTYPE * yylloc_param,yyscan_t yyscanner)2344 void yyset_lloc(YYLTYPE *yylloc_param, yyscan_t yyscanner)
2345 {
2346     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2347     yylloc               = yylloc_param;
2348 }
2349 
2350 /* User-visible API */
2351 
2352 /* yylex_init is special because it creates the scanner itself, so it is
2353  * the ONLY reentrant function that doesn't take the scanner as the last argument.
2354  * That's why we explicitly handle the declaration, instead of using our macros.
2355  */
yylex_init(yyscan_t * ptr_yy_globals)2356 int yylex_init(yyscan_t *ptr_yy_globals)
2357 {
2358     if (ptr_yy_globals == NULL)
2359     {
2360         errno = EINVAL;
2361         return 1;
2362     }
2363 
2364     *ptr_yy_globals = (yyscan_t)yyalloc(sizeof(struct yyguts_t), NULL);
2365 
2366     if (*ptr_yy_globals == NULL)
2367     {
2368         errno = ENOMEM;
2369         return 1;
2370     }
2371 
2372     /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2373     memset(*ptr_yy_globals, 0x00, sizeof(struct yyguts_t));
2374 
2375     return yy_init_globals(*ptr_yy_globals);
2376 }
2377 
2378 /* yylex_init_extra has the same functionality as yylex_init, but follows the
2379  * convention of taking the scanner as the last argument. Note however, that
2380  * this is a *pointer* to a scanner, as it will be allocated by this call (and
2381  * is the reason, too, why this function also must handle its own declaration).
2382  * The user defined value in the first argument will be available to yyalloc in
2383  * the yyextra field.
2384  */
yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t * ptr_yy_globals)2385 int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined, yyscan_t *ptr_yy_globals)
2386 {
2387     struct yyguts_t dummy_yyguts;
2388 
2389     yyset_extra(yy_user_defined, &dummy_yyguts);
2390 
2391     if (ptr_yy_globals == NULL)
2392     {
2393         errno = EINVAL;
2394         return 1;
2395     }
2396 
2397     *ptr_yy_globals = (yyscan_t)yyalloc(sizeof(struct yyguts_t), &dummy_yyguts);
2398 
2399     if (*ptr_yy_globals == NULL)
2400     {
2401         errno = ENOMEM;
2402         return 1;
2403     }
2404 
2405     /* By setting to 0xAA, we expose bugs in
2406     yy_init_globals. Leave at 0x00 for releases. */
2407     memset(*ptr_yy_globals, 0x00, sizeof(struct yyguts_t));
2408 
2409     yyset_extra(yy_user_defined, *ptr_yy_globals);
2410 
2411     return yy_init_globals(*ptr_yy_globals);
2412 }
2413 
yy_init_globals(yyscan_t yyscanner)2414 static int yy_init_globals(yyscan_t yyscanner)
2415 {
2416     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2417     /* Initialization is the same as for the non-reentrant scanner.
2418      * This function is called from yylex_destroy(), so don't allocate here.
2419      */
2420 
2421     yyg->yy_buffer_stack     = NULL;
2422     yyg->yy_buffer_stack_top = 0;
2423     yyg->yy_buffer_stack_max = 0;
2424     yyg->yy_c_buf_p          = NULL;
2425     yyg->yy_init             = 0;
2426     yyg->yy_start            = 0;
2427 
2428     yyg->yy_start_stack_ptr   = 0;
2429     yyg->yy_start_stack_depth = 0;
2430     yyg->yy_start_stack       = NULL;
2431 
2432 /* Defined in main.c */
2433 #ifdef YY_STDINIT
2434     yyin  = stdin;
2435     yyout = stdout;
2436 #else
2437     yyin  = NULL;
2438     yyout = NULL;
2439 #endif
2440 
2441     /* For future reference: Set errno on error, since we are called by
2442      * yylex_init()
2443      */
2444     return 0;
2445 }
2446 
2447 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
yylex_destroy(yyscan_t yyscanner)2448 int yylex_destroy(yyscan_t yyscanner)
2449 {
2450     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2451 
2452     /* Pop the buffer stack, destroying each element. */
2453     while (YY_CURRENT_BUFFER)
2454     {
2455         yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner);
2456         YY_CURRENT_BUFFER_LVALUE = NULL;
2457         yypop_buffer_state(yyscanner);
2458     }
2459 
2460     /* Destroy the stack itself. */
2461     yyfree(yyg->yy_buffer_stack, yyscanner);
2462     yyg->yy_buffer_stack = NULL;
2463 
2464     /* Destroy the start condition stack. */
2465     yyfree(yyg->yy_start_stack, yyscanner);
2466     yyg->yy_start_stack = NULL;
2467 
2468     /* Reset the globals. This is important in a non-reentrant scanner so the next time
2469      * yylex() is called, initialization will occur. */
2470     yy_init_globals(yyscanner);
2471 
2472     /* Destroy the main struct (reentrant only). */
2473     yyfree(yyscanner, yyscanner);
2474     yyscanner = NULL;
2475     return 0;
2476 }
2477 
2478 /*
2479  * Internal utility routines.
2480  */
2481 
2482 #ifndef yytext_ptr
yy_flex_strncpy(char * s1,const char * s2,int n,yyscan_t yyscanner)2483 static void yy_flex_strncpy(char *s1, const char *s2, int n, yyscan_t yyscanner)
2484 {
2485     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2486     (void)yyg;
2487 
2488     int i;
2489     for (i = 0; i < n; ++i)
2490         s1[i] = s2[i];
2491 }
2492 #endif
2493 
2494 #ifdef YY_NEED_STRLEN
yy_flex_strlen(const char * s,yyscan_t yyscanner)2495 static int yy_flex_strlen(const char *s, yyscan_t yyscanner)
2496 {
2497     int n;
2498     for (n = 0; s[n]; ++n)
2499         ;
2500 
2501     return n;
2502 }
2503 #endif
2504 
yyalloc(yy_size_t size,yyscan_t yyscanner)2505 void *yyalloc(yy_size_t size, yyscan_t yyscanner)
2506 {
2507     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2508     (void)yyg;
2509     return malloc(size);
2510 }
2511 
yyrealloc(void * ptr,yy_size_t size,yyscan_t yyscanner)2512 void *yyrealloc(void *ptr, yy_size_t size, yyscan_t yyscanner)
2513 {
2514     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2515     (void)yyg;
2516 
2517     /* The cast to (char *) in the following accommodates both
2518      * implementations that use char* generic pointers, and those
2519      * that use void* generic pointers.  It works with the latter
2520      * because both ANSI C and C++ allow castless assignment from
2521      * any pointer type to void*, and deal with argument conversions
2522      * as though doing an assignment.
2523      */
2524     return realloc(ptr, size);
2525 }
2526 
yyfree(void * ptr,yyscan_t yyscanner)2527 void yyfree(void *ptr, yyscan_t yyscanner)
2528 {
2529     struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
2530     (void)yyg;
2531     free((char *)ptr); /* see yyrealloc() for (char *) cast */
2532 }
2533 
2534 #define YYTABLES_NAME "yytables"
2535 
2536 namespace angle
2537 {
2538 
2539 namespace pp
2540 {
2541 
Tokenizer(Diagnostics * diagnostics)2542 Tokenizer::Tokenizer(Diagnostics *diagnostics) : mHandle(nullptr), mMaxTokenSize(256)
2543 {
2544     mContext.diagnostics = diagnostics;
2545 }
2546 
~Tokenizer()2547 Tokenizer::~Tokenizer()
2548 {
2549     destroyScanner();
2550 }
2551 
init(size_t count,const char * const string[],const int length[])2552 bool Tokenizer::init(size_t count, const char *const string[], const int length[])
2553 {
2554     if ((count > 0) && (string == 0))
2555         return false;
2556 
2557     mContext.input = Input(count, string, length);
2558     return initScanner();
2559 }
2560 
setFileNumber(int file)2561 void Tokenizer::setFileNumber(int file)
2562 {
2563     // We use column number as file number.
2564     // See macro yyfileno.
2565     yyset_column(file, mHandle);
2566 }
2567 
setLineNumber(int line)2568 void Tokenizer::setLineNumber(int line)
2569 {
2570     yyset_lineno(line, mHandle);
2571 }
2572 
setMaxTokenSize(size_t maxTokenSize)2573 void Tokenizer::setMaxTokenSize(size_t maxTokenSize)
2574 {
2575     mMaxTokenSize = maxTokenSize;
2576 }
2577 
lex(Token * token)2578 void Tokenizer::lex(Token *token)
2579 {
2580     int tokenType = yylex(&token->text, &token->location, mHandle);
2581 
2582     if (tokenType == Token::GOT_ERROR)
2583     {
2584         mContext.diagnostics->report(Diagnostics::PP_TOKENIZER_ERROR, token->location, token->text);
2585         token->type = Token::LAST;
2586     }
2587     else
2588     {
2589         token->type = tokenType;
2590     }
2591 
2592     if (token->text.size() > mMaxTokenSize)
2593     {
2594         mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG, token->location, token->text);
2595         token->text.erase(mMaxTokenSize);
2596     }
2597 
2598     token->flags = 0;
2599 
2600     token->setAtStartOfLine(mContext.lineStart);
2601     mContext.lineStart = token->type == '\n';
2602 
2603     token->setHasLeadingSpace(mContext.leadingSpace);
2604     mContext.leadingSpace = false;
2605 }
2606 
initScanner()2607 bool Tokenizer::initScanner()
2608 {
2609     if ((mHandle == nullptr) && yylex_init_extra(&mContext, &mHandle))
2610         return false;
2611 
2612     yyrestart(0, mHandle);
2613     return true;
2614 }
2615 
destroyScanner()2616 void Tokenizer::destroyScanner()
2617 {
2618     if (mHandle == nullptr)
2619         return;
2620 
2621     yylex_destroy(mHandle);
2622     mHandle = nullptr;
2623 }
2624 
2625 }  // namespace pp
2626 
2627 }  // namespace angle
2628