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