Path: blob/main_old/src/compiler/preprocessor/preprocessor_lex_autogen.cpp
1693 views
#line 16 "preprocessor.l"1// GENERATED FILE - DO NOT EDIT.2// Generated by generate_parser.py from preprocessor.l3//4// Copyright 2019 The ANGLE Project Authors. All rights reserved.5// Use of this source code is governed by a BSD-style license that can be6// found in the LICENSE file.7//8// preprocessor.l:9// Lexer for the OpenGL shading language preprocessor.1011#define YY_INT_ALIGNED short int1213/* A lexical scanner generated by flex */1415#define FLEX_SCANNER16#define YY_FLEX_MAJOR_VERSION 217#define YY_FLEX_MINOR_VERSION 618#define YY_FLEX_SUBMINOR_VERSION 419#if YY_FLEX_SUBMINOR_VERSION > 020# define FLEX_BETA21#endif2223#ifdef yy_create_buffer24# define pp_create_buffer_ALREADY_DEFINED25#else26# define yy_create_buffer pp_create_buffer27#endif2829#ifdef yy_delete_buffer30# define pp_delete_buffer_ALREADY_DEFINED31#else32# define yy_delete_buffer pp_delete_buffer33#endif3435#ifdef yy_scan_buffer36# define pp_scan_buffer_ALREADY_DEFINED37#else38# define yy_scan_buffer pp_scan_buffer39#endif4041#ifdef yy_scan_string42# define pp_scan_string_ALREADY_DEFINED43#else44# define yy_scan_string pp_scan_string45#endif4647#ifdef yy_scan_bytes48# define pp_scan_bytes_ALREADY_DEFINED49#else50# define yy_scan_bytes pp_scan_bytes51#endif5253#ifdef yy_init_buffer54# define pp_init_buffer_ALREADY_DEFINED55#else56# define yy_init_buffer pp_init_buffer57#endif5859#ifdef yy_flush_buffer60# define pp_flush_buffer_ALREADY_DEFINED61#else62# define yy_flush_buffer pp_flush_buffer63#endif6465#ifdef yy_load_buffer_state66# define pp_load_buffer_state_ALREADY_DEFINED67#else68# define yy_load_buffer_state pp_load_buffer_state69#endif7071#ifdef yy_switch_to_buffer72# define pp_switch_to_buffer_ALREADY_DEFINED73#else74# define yy_switch_to_buffer pp_switch_to_buffer75#endif7677#ifdef yypush_buffer_state78# define pppush_buffer_state_ALREADY_DEFINED79#else80# define yypush_buffer_state pppush_buffer_state81#endif8283#ifdef yypop_buffer_state84# define pppop_buffer_state_ALREADY_DEFINED85#else86# define yypop_buffer_state pppop_buffer_state87#endif8889#ifdef yyensure_buffer_stack90# define ppensure_buffer_stack_ALREADY_DEFINED91#else92# define yyensure_buffer_stack ppensure_buffer_stack93#endif9495#ifdef yylex96# define pplex_ALREADY_DEFINED97#else98# define yylex pplex99#endif100101#ifdef yyrestart102# define pprestart_ALREADY_DEFINED103#else104# define yyrestart pprestart105#endif106107#ifdef yylex_init108# define pplex_init_ALREADY_DEFINED109#else110# define yylex_init pplex_init111#endif112113#ifdef yylex_init_extra114# define pplex_init_extra_ALREADY_DEFINED115#else116# define yylex_init_extra pplex_init_extra117#endif118119#ifdef yylex_destroy120# define pplex_destroy_ALREADY_DEFINED121#else122# define yylex_destroy pplex_destroy123#endif124125#ifdef yyget_debug126# define ppget_debug_ALREADY_DEFINED127#else128# define yyget_debug ppget_debug129#endif130131#ifdef yyset_debug132# define ppset_debug_ALREADY_DEFINED133#else134# define yyset_debug ppset_debug135#endif136137#ifdef yyget_extra138# define ppget_extra_ALREADY_DEFINED139#else140# define yyget_extra ppget_extra141#endif142143#ifdef yyset_extra144# define ppset_extra_ALREADY_DEFINED145#else146# define yyset_extra ppset_extra147#endif148149#ifdef yyget_in150# define ppget_in_ALREADY_DEFINED151#else152# define yyget_in ppget_in153#endif154155#ifdef yyset_in156# define ppset_in_ALREADY_DEFINED157#else158# define yyset_in ppset_in159#endif160161#ifdef yyget_out162# define ppget_out_ALREADY_DEFINED163#else164# define yyget_out ppget_out165#endif166167#ifdef yyset_out168# define ppset_out_ALREADY_DEFINED169#else170# define yyset_out ppset_out171#endif172173#ifdef yyget_leng174# define ppget_leng_ALREADY_DEFINED175#else176# define yyget_leng ppget_leng177#endif178179#ifdef yyget_text180# define ppget_text_ALREADY_DEFINED181#else182# define yyget_text ppget_text183#endif184185#ifdef yyget_lineno186# define ppget_lineno_ALREADY_DEFINED187#else188# define yyget_lineno ppget_lineno189#endif190191#ifdef yyset_lineno192# define ppset_lineno_ALREADY_DEFINED193#else194# define yyset_lineno ppset_lineno195#endif196197#ifdef yyget_column198# define ppget_column_ALREADY_DEFINED199#else200# define yyget_column ppget_column201#endif202203#ifdef yyset_column204# define ppset_column_ALREADY_DEFINED205#else206# define yyset_column ppset_column207#endif208209#ifdef yywrap210# define ppwrap_ALREADY_DEFINED211#else212# define yywrap ppwrap213#endif214215#ifdef yyget_lval216# define ppget_lval_ALREADY_DEFINED217#else218# define yyget_lval ppget_lval219#endif220221#ifdef yyset_lval222# define ppset_lval_ALREADY_DEFINED223#else224# define yyset_lval ppset_lval225#endif226227#ifdef yyget_lloc228# define ppget_lloc_ALREADY_DEFINED229#else230# define yyget_lloc ppget_lloc231#endif232233#ifdef yyset_lloc234# define ppset_lloc_ALREADY_DEFINED235#else236# define yyset_lloc ppset_lloc237#endif238239#ifdef yyalloc240# define ppalloc_ALREADY_DEFINED241#else242# define yyalloc ppalloc243#endif244245#ifdef yyrealloc246# define pprealloc_ALREADY_DEFINED247#else248# define yyrealloc pprealloc249#endif250251#ifdef yyfree252# define ppfree_ALREADY_DEFINED253#else254# define yyfree ppfree255#endif256257/* First, we deal with platform-specific or compiler-specific issues. */258259/* begin standard C headers. */260#include <errno.h>261#include <stdio.h>262#include <stdlib.h>263#include <string.h>264265/* end standard C headers. */266267/* flex integer type definitions */268269#ifndef FLEXINT_H270# define FLEXINT_H271272/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */273274# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L275276/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,277* if you want the limit (max/min) macros for int types.278*/279# ifndef __STDC_LIMIT_MACROS280# define __STDC_LIMIT_MACROS 1281# endif282283# include <inttypes.h>284typedef int8_t flex_int8_t;285typedef uint8_t flex_uint8_t;286typedef int16_t flex_int16_t;287typedef uint16_t flex_uint16_t;288typedef int32_t flex_int32_t;289typedef uint32_t flex_uint32_t;290# else291typedef signed char flex_int8_t;292typedef short int flex_int16_t;293typedef int flex_int32_t;294typedef unsigned char flex_uint8_t;295typedef unsigned short int flex_uint16_t;296typedef unsigned int flex_uint32_t;297298/* Limits of integral types. */299# ifndef INT8_MIN300# define INT8_MIN (-128)301# endif302# ifndef INT16_MIN303# define INT16_MIN (-32767 - 1)304# endif305# ifndef INT32_MIN306# define INT32_MIN (-2147483647 - 1)307# endif308# ifndef INT8_MAX309# define INT8_MAX (127)310# endif311# ifndef INT16_MAX312# define INT16_MAX (32767)313# endif314# ifndef INT32_MAX315# define INT32_MAX (2147483647)316# endif317# ifndef UINT8_MAX318# define UINT8_MAX (255U)319# endif320# ifndef UINT16_MAX321# define UINT16_MAX (65535U)322# endif323# ifndef UINT32_MAX324# define UINT32_MAX (4294967295U)325# endif326327# ifndef SIZE_MAX328# define SIZE_MAX (~(size_t)0)329# endif330331# endif /* ! C99 */332333#endif /* ! FLEXINT_H */334335/* begin standard C++ headers. */336337/* TODO: this is always defined, so inline it */338#define yyconst const339340#if defined(__GNUC__) && __GNUC__ >= 3341# define yynoreturn __attribute__((__noreturn__))342#else343# define yynoreturn344#endif345346/* Returned upon end-of-file. */347#define YY_NULL 0348349/* Promotes a possibly negative, possibly signed char to an350* integer in range [0..255] for use as an array index.351*/352#define YY_SC_TO_UI(c) ((YY_CHAR)(c))353354/* An opaque pointer. */355#ifndef YY_TYPEDEF_YY_SCANNER_T356# define YY_TYPEDEF_YY_SCANNER_T357typedef void *yyscan_t;358#endif359360/* For convenience, these vars (plus the bison vars far below)361are macros in the reentrant scanner. */362#define yyin yyg->yyin_r363#define yyout yyg->yyout_r364#define yyextra yyg->yyextra_r365#define yyleng yyg->yyleng_r366#define yytext yyg->yytext_r367#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)368#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)369#define yy_flex_debug yyg->yy_flex_debug_r370371/* Enter a start condition. This macro really ought to take a parameter,372* but we do it the disgusting crufty way forced on us by the ()-less373* definition of BEGIN.374*/375#define BEGIN yyg->yy_start = 1 + 2 *376/* Translate the current start state into a value that can be later handed377* to BEGIN to return to the state. The YYSTATE alias is for lex378* compatibility.379*/380#define YY_START ((yyg->yy_start - 1) / 2)381#define YYSTATE YY_START382/* Action number for EOF rule of a given start state. */383#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)384/* Special action meaning "start processing a new file". */385#define YY_NEW_FILE yyrestart(yyin, yyscanner)386#define YY_END_OF_BUFFER_CHAR 0387388/* Size of default input buffer. */389#ifndef YY_BUF_SIZE390# ifdef __ia64__391/* On IA-64, the buffer size is 16k, not 8k.392* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.393* Ditto for the __ia64__ case accordingly.394*/395# define YY_BUF_SIZE 32768396# else397# define YY_BUF_SIZE 16384398# endif /* __ia64__ */399#endif400401/* The state buf must be large enough to hold one state per character in the main buffer.402*/403#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))404405#ifndef YY_TYPEDEF_YY_BUFFER_STATE406# define YY_TYPEDEF_YY_BUFFER_STATE407typedef struct yy_buffer_state *YY_BUFFER_STATE;408#endif409410#ifndef YY_TYPEDEF_YY_SIZE_T411# define YY_TYPEDEF_YY_SIZE_T412typedef size_t yy_size_t;413#endif414415#define EOB_ACT_CONTINUE_SCAN 0416#define EOB_ACT_END_OF_FILE 1417#define EOB_ACT_LAST_MATCH 2418419#define YY_LESS_LINENO(n)420#define YY_LINENO_REWIND_TO(ptr)421422/* Return all but the first "n" matched characters back to the input stream. */423#define yyless(n) \424do \425{ \426/* Undo effects of setting up yytext. */ \427int yyless_macro_arg = (n); \428YY_LESS_LINENO(yyless_macro_arg); \429*yy_cp = yyg->yy_hold_char; \430YY_RESTORE_YY_MORE_OFFSET \431yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \432YY_DO_BEFORE_ACTION; /* set up yytext again */ \433} while (0)434#define unput(c) yyunput(c, yyg->yytext_ptr, yyscanner)435436#ifndef YY_STRUCT_YY_BUFFER_STATE437# define YY_STRUCT_YY_BUFFER_STATE438struct yy_buffer_state439{440FILE *yy_input_file;441442char *yy_ch_buf; /* input buffer */443char *yy_buf_pos; /* current position in input buffer */444445/* Size of input buffer in bytes, not including room for EOB446* characters.447*/448int yy_buf_size;449450/* Number of characters read into yy_ch_buf, not including EOB451* characters.452*/453int yy_n_chars;454455/* Whether we "own" the buffer - i.e., we know we created it,456* and can realloc() it to grow it, and should free() it to457* delete it.458*/459int yy_is_our_buffer;460461/* Whether this is an "interactive" input source; if so, and462* if we're using stdio for input, then we want to use getc()463* instead of fread(), to make sure we stop fetching input after464* each newline.465*/466int yy_is_interactive;467468/* Whether we're considered to be at the beginning of a line.469* If so, '^' rules will be active on the next match, otherwise470* not.471*/472int yy_at_bol;473474int yy_bs_lineno; /**< The line count. */475int yy_bs_column; /**< The column count. */476477/* Whether to try to fill the input buffer when we reach the478* end of it.479*/480int yy_fill_buffer;481482int yy_buffer_status;483484# define YY_BUFFER_NEW 0485# define YY_BUFFER_NORMAL 1486/* When an EOF's been seen but there's still some text to process487* then we mark the buffer as YY_EOF_PENDING, to indicate that we488* shouldn't try reading from the input source any more. We might489* still have a bunch of tokens to match, though, because of490* possible backing-up.491*492* When we actually see the EOF, we change the status to "new"493* (via yyrestart()), so that the user can continue scanning by494* just pointing yyin at a new input file.495*/496# define YY_BUFFER_EOF_PENDING 2497};498#endif /* !YY_STRUCT_YY_BUFFER_STATE */499500/* We provide macros for accessing buffer states in case in the501* future we want to put the buffer states in a more general502* "scanner state".503*504* Returns the top of the stack, or NULL.505*/506#define YY_CURRENT_BUFFER \507(yyg->yy_buffer_stack ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] : NULL)508/* Same as previous macro, but useful when we know that the buffer stack is not509* NULL or when we need an lvalue. For internal use only.510*/511#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]512513void yyrestart(FILE *input_file, yyscan_t yyscanner);514void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner);515YY_BUFFER_STATE yy_create_buffer(FILE *file, int size, yyscan_t yyscanner);516void yy_delete_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner);517void yy_flush_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner);518void yypush_buffer_state(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner);519void yypop_buffer_state(yyscan_t yyscanner);520521static void yyensure_buffer_stack(yyscan_t yyscanner);522static void yy_load_buffer_state(yyscan_t yyscanner);523static void yy_init_buffer(YY_BUFFER_STATE b, FILE *file, yyscan_t yyscanner);524#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER, yyscanner)525526YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size, yyscan_t yyscanner);527YY_BUFFER_STATE yy_scan_string(const char *yy_str, yyscan_t yyscanner);528YY_BUFFER_STATE yy_scan_bytes(const char *bytes, int len, yyscan_t yyscanner);529530void *yyalloc(yy_size_t, yyscan_t yyscanner);531void *yyrealloc(void *, yy_size_t, yyscan_t yyscanner);532void yyfree(void *, yyscan_t yyscanner);533534#define yy_new_buffer yy_create_buffer535#define yy_set_interactive(is_interactive) \536{ \537if (!YY_CURRENT_BUFFER) \538{ \539yyensure_buffer_stack(yyscanner); \540YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner); \541} \542YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \543}544#define yy_set_bol(at_bol) \545{ \546if (!YY_CURRENT_BUFFER) \547{ \548yyensure_buffer_stack(yyscanner); \549YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner); \550} \551YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \552}553#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)554555/* Begin user sect3 */556557#define ppwrap(yyscanner) (/*CONSTCOND*/ 1)558#define YY_SKIP_YYWRAP559typedef flex_uint8_t YY_CHAR;560561typedef int yy_state_type;562563#define yytext_ptr yytext_r564565static yy_state_type yy_get_previous_state(yyscan_t yyscanner);566static yy_state_type yy_try_NUL_trans(yy_state_type current_state, yyscan_t yyscanner);567static int yy_get_next_buffer(yyscan_t yyscanner);568static void yynoreturn yy_fatal_error(const char *msg, yyscan_t yyscanner);569570/* Done after the current pattern has been matched and before the571* corresponding action - sets up yytext.572*/573#define YY_DO_BEFORE_ACTION \574yyg->yytext_ptr = yy_bp; \575yyleng = (int)(yy_cp - yy_bp); \576yyg->yy_hold_char = *yy_cp; \577*yy_cp = '\0'; \578yyg->yy_c_buf_p = yy_cp;579#define YY_NUM_RULES 37580#define YY_END_OF_BUFFER 38581/* This struct is not used in this scanner,582but its presence is necessary. */583struct yy_trans_info584{585flex_int32_t yy_verify;586flex_int32_t yy_nxt;587};588static const flex_int16_t yy_accept[95] = {5890, 0, 0, 0, 0, 38, 36, 34, 35, 35, 33, 7, 33, 33, 33, 33, 33, 33, 33, 33, 9, 9, 33, 33,59033, 8, 33, 33, 3, 5, 5, 4, 34, 35, 19, 27, 20, 30, 25, 12, 23, 13, 24, 10, 2, 1, 26, 10,5919, 11, 11, 11, 9, 11, 9, 9, 14, 16, 18, 17, 15, 8, 31, 21, 32, 22, 3, 5, 6, 11, 10, 11,59210, 1, 10, 11, 10, 0, 10, 9, 9, 9, 28, 29, 0, 10, 10, 10, 10, 9, 10, 10, 9, 10, 0593594};595596static const YY_CHAR yy_ec[256] = {5970, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 4, 1, 1, 1, 1, 1, 1, 1,5981, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, 9,59910, 11, 9, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 17, 17, 9, 9, 18, 19, 20,6009, 1, 21, 21, 21, 21, 22, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,60124, 25, 24, 24, 26, 24, 24, 9, 1, 9, 27, 24, 1, 21, 21, 21, 21,60260322, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 24, 24, 26, 24,60424, 9, 28, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,6051, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,6061, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,6071, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,6086091, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,6101, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,6111, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};612613static const YY_CHAR yy_meta[29] = {0, 1, 1, 2, 2, 1, 1, 1, 1, 1, 3, 1, 1, 4, 1,6145, 5, 5, 1, 1, 1, 5, 5, 5, 5, 5, 5, 1, 1};615616static const flex_int16_t yy_base[100] = {6170, 0, 0, 26, 28, 133, 195, 130, 195, 128, 105, 195, 104, 25, 195, 100, 23,61827, 32, 31, 38, 50, 38, 93, 49, 0, 16, 51, 0, 195, 105, 87, 93, 195,619195, 195, 195, 195, 195, 195, 195, 195, 195, 67, 195, 0, 195, 81, 55, 84, 98,620110, 53, 61, 0, 52, 39, 195, 195, 195, 33, 0, 195, 195, 195, 195, 0, 195,621195, 113, 0, 126, 0, 0, 0, 133, 0, 56, 128, 0, 133, 0, 195, 195, 101,622141, 143, 145, 0, 15, 154, 195, 0, 195, 195, 177, 32, 182, 187, 189623624};625626static const flex_int16_t yy_def[100] = {6270, 94, 1, 95, 95, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,62820, 94, 94, 94, 96, 94, 94, 97, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,62994, 94, 94, 98, 94, 94, 20, 20, 49, 50, 50, 99, 21, 50, 94, 94, 94, 94, 94, 96, 94,63094, 94, 94, 97, 94, 94, 43, 43, 69, 69, 98, 47, 50, 50, 94, 51, 50, 99, 50, 94, 94,63194, 71, 75, 94, 50, 50, 94, 94, 50, 94, 0, 94, 94, 94, 94, 94632633};634635static const flex_int16_t yy_nxt[224] = {6360, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, 22, 23, 24, 25, 25,63725, 25, 25, 25, 26, 27, 29, 30, 29, 30, 36, 39, 62, 31, 61, 31, 41, 92, 44, 40, 63, 37, 45,63842, 43, 43, 43, 46, 47, 83, 48, 48, 49, 56, 57, 82, 50, 51, 50, 50, 52, 53, 54, 54, 54, 59,63960, 64, 87, 87, 87, 50, 55, 50, 81, 79, 65, 69, 50, 70, 70, 70, 50, 50, 50, 69, 71, 72, 69,64069, 69, 50, 32, 74, 74, 74, 49, 49,64164268, 50, 75, 76, 50, 50, 50, 67, 50, 50, 50, 58, 50, 50, 50, 90, 90, 90, 38, 50, 77, 77, 35,64334, 78, 78, 78, 69, 69, 69, 33, 32, 94, 94, 69, 69, 84, 84, 94, 94, 85, 85, 85, 84, 84, 50,64494, 86, 86, 86, 88, 94, 94, 94, 94, 94, 50, 89, 50, 87, 87, 87, 94, 72, 94, 76, 94, 91, 90,64590, 90, 94, 94, 94, 94, 94, 93, 28, 28, 28, 28, 28, 66, 94, 94, 66, 66, 73, 94, 73, 73, 73,64680, 80, 5, 94, 94, 94, 94, 94,64764894, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94};649650static const flex_int16_t yy_chk[224] = {6510, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,6521, 1, 1, 1, 1, 1, 3, 3, 4, 4, 13, 16, 26, 3, 96, 4, 17, 89, 19, 16, 26, 13, 19,65317, 18, 18, 18, 19, 20, 60, 20, 20, 20, 22, 22, 56, 20, 20, 20, 20, 20, 20, 21, 21, 21, 24,65424, 27, 77, 77, 77, 53, 21, 21, 55, 52, 27, 43, 48, 43, 43, 43, 53, 53, 53, 43, 43, 43, 43,65543, 43, 47, 32, 47, 47, 47, 49, 49,65665731, 47, 47, 47, 47, 47, 47, 30, 49, 49, 50, 23, 50, 50, 50, 84, 84, 84, 15, 50, 51, 51, 12,65810, 51, 51, 51, 69, 69, 69, 9, 7, 5, 0, 69, 69, 71, 71, 78, 78, 71, 71, 71, 75, 75, 80,6590, 75, 75, 75, 78, 85, 85, 86, 86, 0, 80, 80, 80, 87, 87, 87, 0, 85, 0, 86, 0, 87, 90,66090, 90, 0, 0, 0, 0, 0, 90, 95, 95, 95, 95, 95, 97, 0, 0, 97, 97, 98, 0, 98, 98, 98,66199, 99, 94, 94, 94, 94, 94, 94,66266394, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94};664665/* The intent behind this definition is that it'll catch666* any uses of REJECT which flex missed.667*/668#define REJECT reject_used_but_not_detected669#define yymore() yymore_used_but_not_detected670#define YY_MORE_ADJ 0671#define YY_RESTORE_YY_MORE_OFFSET672/*673//674// Copyright 2002 The ANGLE Project Authors. All rights reserved.675// Use of this source code is governed by a BSD-style license that can be676// found in the LICENSE file.677//678679This file contains the Lex specification for GLSL ES preprocessor.680Based on Microsoft Visual Studio 2010 Preprocessor Grammar:681http://msdn.microsoft.com/en-us/library/2scxys89.aspx682683IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN scripts/run_code_generation.py684*/685686#if defined(_MSC_VER)687# pragma warning(disable : 4005)688#endif689690#include "compiler/preprocessor/Tokenizer.h"691692#include "compiler/preprocessor/DiagnosticsBase.h"693#include "compiler/preprocessor/Token.h"694695#if defined(__GNUC__)696// Triggered by the auto-generated yy_fatal_error function.697# pragma GCC diagnostic ignored "-Wmissing-noreturn"698#elif defined(_MSC_VER)699# pragma warning(disable : 4244)700#endif701#if defined(__clang__)702// Flex uses `/*FALLTHROUGH*/` instead of dedicated statements.703# pragma clang diagnostic ignored "-Wimplicit-fallthrough"704# if defined(__APPLE__)705// Older clang versions don't have -Wextra-semi-stmt, and detecting Apple clang versions is706// difficult because they use different yet overlapping version numbers vs. regular clang.707# pragma clang diagnostic ignored "-Wunknown-warning-option"708# endif709// Flex isn't semi-colon clean.710# pragma clang diagnostic ignored "-Wextra-semi-stmt"711# pragma clang diagnostic ignored "-Wunreachable-code"712#endif713714// Workaround for flex using the register keyword, deprecated in C++11.715#ifdef __cplusplus716# if __cplusplus > 199711L717# define register718# endif719#endif720721typedef std::string YYSTYPE;722typedef angle::pp::SourceLocation YYLTYPE;723724// Use the unused yycolumn variable to track file (string) number.725#define yyfileno yycolumn726727#define YY_USER_INIT \728do \729{ \730yyfileno = 0; \731yylineno = 1; \732yyextra->leadingSpace = false; \733yyextra->lineStart = true; \734} while (0);735736#define YY_NO_INPUT737#define YY_USER_ACTION \738do \739{ \740angle::pp::Input *input = &yyextra->input; \741angle::pp::Input::Location *scanLoc = &yyextra->scanLoc; \742while ((scanLoc->sIndex < input->count()) && \743(scanLoc->cIndex >= input->length(scanLoc->sIndex))) \744{ \745scanLoc->cIndex -= input->length(scanLoc->sIndex++); \746++yyfileno; \747yylineno = 1; \748} \749yylloc->file = yyfileno; \750yylloc->line = yylineno; \751scanLoc->cIndex += yyleng; \752} while (0);753754#define YY_INPUT(buf, result, maxSize) result = yyextra->input.read(buf, maxSize, &yylineno);755756#define INITIAL 0757#define COMMENT 1758759#define YY_EXTRA_TYPE angle::pp::Tokenizer::Context *760761/* Holds the entire state of the reentrant scanner. */762struct yyguts_t763{764765/* User-defined. Not touched by flex. */766YY_EXTRA_TYPE yyextra_r;767768/* The rest are the same as the globals declared in the non-reentrant scanner. */769FILE *yyin_r, *yyout_r;770size_t yy_buffer_stack_top; /**< index of top of stack. */771size_t yy_buffer_stack_max; /**< capacity of stack. */772YY_BUFFER_STATE *yy_buffer_stack; /**< Stack as an array. */773char yy_hold_char;774int yy_n_chars;775int yyleng_r;776char *yy_c_buf_p;777int yy_init;778int yy_start;779int yy_did_buffer_switch_on_eof;780int yy_start_stack_ptr;781int yy_start_stack_depth;782int *yy_start_stack;783yy_state_type yy_last_accepting_state;784char *yy_last_accepting_cpos;785786int yylineno_r;787int yy_flex_debug_r;788789char *yytext_r;790int yy_more_flag;791int yy_more_len;792793YYSTYPE *yylval_r;794795YYLTYPE *yylloc_r;796797}; /* end struct yyguts_t */798799static int yy_init_globals(yyscan_t yyscanner);800801/* This must go here because YYSTYPE and YYLTYPE are included802* from bison output in section 1.*/803#define yylval yyg->yylval_r804805#define yylloc yyg->yylloc_r806807int yylex_init(yyscan_t *scanner);808809int yylex_init_extra(YY_EXTRA_TYPE user_defined, yyscan_t *scanner);810811/* Accessor methods to globals.812These are made visible to non-reentrant scanners for convenience. */813814int yylex_destroy(yyscan_t yyscanner);815816int yyget_debug(yyscan_t yyscanner);817818void yyset_debug(int debug_flag, yyscan_t yyscanner);819820YY_EXTRA_TYPE yyget_extra(yyscan_t yyscanner);821822void yyset_extra(YY_EXTRA_TYPE user_defined, yyscan_t yyscanner);823824FILE *yyget_in(yyscan_t yyscanner);825826void yyset_in(FILE *_in_str, yyscan_t yyscanner);827828FILE *yyget_out(yyscan_t yyscanner);829830void yyset_out(FILE *_out_str, yyscan_t yyscanner);831832int yyget_leng(yyscan_t yyscanner);833834char *yyget_text(yyscan_t yyscanner);835836int yyget_lineno(yyscan_t yyscanner);837838void yyset_lineno(int _line_number, yyscan_t yyscanner);839840int yyget_column(yyscan_t yyscanner);841842void yyset_column(int _column_no, yyscan_t yyscanner);843844YYSTYPE *yyget_lval(yyscan_t yyscanner);845846void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner);847848YYLTYPE *yyget_lloc(yyscan_t yyscanner);849850void yyset_lloc(YYLTYPE *yylloc_param, yyscan_t yyscanner);851852/* Macros after this point can all be overridden by user definitions in853* section 1.854*/855856#ifndef YY_SKIP_YYWRAP857# ifdef __cplusplus858extern "C" int yywrap(yyscan_t yyscanner);859# else860extern int yywrap(yyscan_t yyscanner);861# endif862#endif863864#ifndef YY_NO_UNPUT865866#endif867868#ifndef yytext_ptr869static void yy_flex_strncpy(char *, const char *, int, yyscan_t yyscanner);870#endif871872#ifdef YY_NEED_STRLEN873static int yy_flex_strlen(const char *, yyscan_t yyscanner);874#endif875876#ifndef YY_NO_INPUT877# ifdef __cplusplus878static int yyinput(yyscan_t yyscanner);879# else880static int input(yyscan_t yyscanner);881# endif882883#endif884885/* Amount of stuff to slurp up with each read. */886#ifndef YY_READ_BUF_SIZE887# ifdef __ia64__888/* On IA-64, the buffer size is 16k, not 8k */889# define YY_READ_BUF_SIZE 16384890# else891# define YY_READ_BUF_SIZE 8192892# endif /* __ia64__ */893#endif894895/* Copy whatever the last rule matched to the standard output. */896#ifndef ECHO897/* This used to be an fputs(), but since the string might contain NUL's,898* we now use fwrite().899*/900# define ECHO \901do \902{ \903if (fwrite(yytext, (size_t)yyleng, 1, yyout)) \904{ \905} \906} while (0)907#endif908909/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,910* is returned in "result".911*/912#ifndef YY_INPUT913# define YY_INPUT(buf, result, max_size) \914if (YY_CURRENT_BUFFER_LVALUE->yy_is_interactive) \915{ \916int c = '*'; \917int n; \918for (n = 0; n < max_size && (c = getc(yyin)) != EOF && c != '\n'; ++n) \919buf[n] = (char)c; \920if (c == '\n') \921buf[n++] = (char)c; \922if (c == EOF && ferror(yyin)) \923YY_FATAL_ERROR("input in flex scanner failed"); \924result = n; \925} \926else \927{ \928errno = 0; \929while ((result = (int)fread(buf, 1, (yy_size_t)max_size, yyin)) == 0 && ferror(yyin)) \930{ \931if (errno != EINTR) \932{ \933YY_FATAL_ERROR("input in flex scanner failed"); \934break; \935} \936errno = 0; \937clearerr(yyin); \938} \939}940941#endif942943/* No semi-colon after return; correct usage is to write "yyterminate();" -944* we don't want an extra ';' after the "return" because that will cause945* some compilers to complain about unreachable statements.946*/947#ifndef yyterminate948# define yyterminate() return YY_NULL949#endif950951/* Number of entries by which start-condition stack grows. */952#ifndef YY_START_STACK_INCR953# define YY_START_STACK_INCR 25954#endif955956/* Report a fatal error. */957#ifndef YY_FATAL_ERROR958# define YY_FATAL_ERROR(msg) yy_fatal_error(msg, yyscanner)959#endif960961/* end tables serialization structures and prototypes */962963/* Default declaration of generated scanner - a define so the user can964* easily add parameters.965*/966#ifndef YY_DECL967# define YY_DECL_IS_OURS 1968969extern int yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner);970971# define YY_DECL int yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)972#endif /* !YY_DECL */973974/* Code executed at the beginning of each rule, after yytext and yyleng975* have been set up.976*/977#ifndef YY_USER_ACTION978# define YY_USER_ACTION979#endif980981/* Code executed at the end of each rule. */982#ifndef YY_BREAK983# define YY_BREAK /*LINTED*/ break;984#endif985986#define YY_RULE_SETUP YY_USER_ACTION987988/** The main scanner function which does all the work.989*/990YY_DECL991{992yy_state_type yy_current_state;993char *yy_cp, *yy_bp;994int yy_act;995struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;996997yylval = yylval_param;998999yylloc = yylloc_param;10001001if (!yyg->yy_init)1002{1003yyg->yy_init = 1;10041005#ifdef YY_USER_INIT1006YY_USER_INIT;1007#endif10081009if (!yyg->yy_start)1010yyg->yy_start = 1; /* first start state */10111012if (!yyin)1013yyin = stdin;10141015if (!yyout)1016yyout = stdout;10171018if (!YY_CURRENT_BUFFER)1019{1020yyensure_buffer_stack(yyscanner);1021YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner);1022}10231024yy_load_buffer_state(yyscanner);1025}10261027{10281029/* Line comment */10301031while (/*CONSTCOND*/ 1) /* loops until end-of-file is reached */1032{1033yy_cp = yyg->yy_c_buf_p;10341035/* Support of yytext. */1036*yy_cp = yyg->yy_hold_char;10371038/* yy_bp points to the position in yy_ch_buf of the start of1039* the current run.1040*/1041yy_bp = yy_cp;10421043yy_current_state = yyg->yy_start;1044yy_match:1045do1046{1047YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];1048if (yy_accept[yy_current_state])1049{1050yyg->yy_last_accepting_state = yy_current_state;1051yyg->yy_last_accepting_cpos = yy_cp;1052}1053while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)1054{1055yy_current_state = (int)yy_def[yy_current_state];1056if (yy_current_state >= 95)1057yy_c = yy_meta[yy_c];1058}1059yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];1060++yy_cp;1061} while (yy_current_state != 94);1062yy_cp = yyg->yy_last_accepting_cpos;1063yy_current_state = yyg->yy_last_accepting_state;10641065yy_find_action:1066yy_act = yy_accept[yy_current_state];10671068YY_DO_BEFORE_ACTION;10691070do_action: /* This label is used only to access EOF actions. */10711072switch (yy_act)1073{ /* beginning of action switch */1074case 0: /* must back up */1075/* undo the effects of YY_DO_BEFORE_ACTION */1076*yy_cp = yyg->yy_hold_char;1077yy_cp = yyg->yy_last_accepting_cpos;1078yy_current_state = yyg->yy_last_accepting_state;1079goto yy_find_action;10801081case 1:1082YY_RULE_SETUP10831084YY_BREAK1085/* Block comment */1086/* Line breaks are just counted - not returned. */1087/* The comment is replaced by a single space. */1088case 2:1089YY_RULE_SETUP { BEGIN(COMMENT); }1090YY_BREAK1091case 3:1092YY_RULE_SETUP10931094YY_BREAK1095case 4:1096YY_RULE_SETUP10971098YY_BREAK1099case 5:1100/* rule 5 can match eol */1101YY_RULE_SETUP1102{1103if (yylineno == INT_MAX)1104{1105*yylval = "Integer overflow on line number";1106return angle::pp::Token::GOT_ERROR;1107}1108++yylineno;1109}1110YY_BREAK1111case 6:1112YY_RULE_SETUP1113{1114yyextra->leadingSpace = true;1115BEGIN(INITIAL);1116}1117YY_BREAK1118case 7:1119YY_RULE_SETUP1120{1121// # is only valid at start of line for preprocessor directives.1122yylval->assign(1, yytext[0]);1123return yyextra->lineStart ? angle::pp::Token::PP_HASH1124: angle::pp::Token::PP_OTHER;1125}1126YY_BREAK1127case 8:1128YY_RULE_SETUP1129{1130yylval->assign(yytext, yyleng);1131return angle::pp::Token::IDENTIFIER;1132}1133YY_BREAK1134case 9:1135YY_RULE_SETUP1136{1137yylval->assign(yytext, yyleng);1138return angle::pp::Token::CONST_INT;1139}1140YY_BREAK1141case 10:1142YY_RULE_SETUP1143{1144yylval->assign(yytext, yyleng);1145return angle::pp::Token::CONST_FLOAT;1146}1147YY_BREAK1148/* Anything that starts with a {DIGIT} or .{DIGIT} must be a number. */1149/* Rule to catch all invalid integers and floats. */1150case 11:1151YY_RULE_SETUP1152{1153yylval->assign(yytext, yyleng);1154return angle::pp::Token::PP_NUMBER;1155}1156YY_BREAK1157case 12:1158YY_RULE_SETUP1159{1160yylval->assign(yytext, yyleng);1161return angle::pp::Token::OP_INC;1162}1163YY_BREAK1164case 13:1165YY_RULE_SETUP1166{1167yylval->assign(yytext, yyleng);1168return angle::pp::Token::OP_DEC;1169}1170YY_BREAK1171case 14:1172YY_RULE_SETUP1173{1174yylval->assign(yytext, yyleng);1175return angle::pp::Token::OP_LEFT;1176}1177YY_BREAK1178case 15:1179YY_RULE_SETUP1180{1181yylval->assign(yytext, yyleng);1182return angle::pp::Token::OP_RIGHT;1183}1184YY_BREAK1185case 16:1186YY_RULE_SETUP1187{1188yylval->assign(yytext, yyleng);1189return angle::pp::Token::OP_LE;1190}1191YY_BREAK1192case 17:1193YY_RULE_SETUP1194{1195yylval->assign(yytext, yyleng);1196return angle::pp::Token::OP_GE;1197}1198YY_BREAK1199case 18:1200YY_RULE_SETUP1201{1202yylval->assign(yytext, yyleng);1203return angle::pp::Token::OP_EQ;1204}1205YY_BREAK1206case 19:1207YY_RULE_SETUP1208{1209yylval->assign(yytext, yyleng);1210return angle::pp::Token::OP_NE;1211}1212YY_BREAK1213case 20:1214YY_RULE_SETUP1215{1216yylval->assign(yytext, yyleng);1217return angle::pp::Token::OP_AND;1218}1219YY_BREAK1220case 21:1221YY_RULE_SETUP1222{1223yylval->assign(yytext, yyleng);1224return angle::pp::Token::OP_XOR;1225}1226YY_BREAK1227case 22:1228YY_RULE_SETUP1229{1230yylval->assign(yytext, yyleng);1231return angle::pp::Token::OP_OR;1232}1233YY_BREAK1234case 23:1235YY_RULE_SETUP1236{1237yylval->assign(yytext, yyleng);1238return angle::pp::Token::OP_ADD_ASSIGN;1239}1240YY_BREAK1241case 24:1242YY_RULE_SETUP1243{1244yylval->assign(yytext, yyleng);1245return angle::pp::Token::OP_SUB_ASSIGN;1246}1247YY_BREAK1248case 25:1249YY_RULE_SETUP1250{1251yylval->assign(yytext, yyleng);1252return angle::pp::Token::OP_MUL_ASSIGN;1253}1254YY_BREAK1255case 26:1256YY_RULE_SETUP1257{1258yylval->assign(yytext, yyleng);1259return angle::pp::Token::OP_DIV_ASSIGN;1260}1261YY_BREAK1262case 27:1263YY_RULE_SETUP1264{1265yylval->assign(yytext, yyleng);1266return angle::pp::Token::OP_MOD_ASSIGN;1267}1268YY_BREAK1269case 28:1270YY_RULE_SETUP1271{1272yylval->assign(yytext, yyleng);1273return angle::pp::Token::OP_LEFT_ASSIGN;1274}1275YY_BREAK1276case 29:1277YY_RULE_SETUP1278{1279yylval->assign(yytext, yyleng);1280return angle::pp::Token::OP_RIGHT_ASSIGN;1281}1282YY_BREAK1283case 30:1284YY_RULE_SETUP1285{1286yylval->assign(yytext, yyleng);1287return angle::pp::Token::OP_AND_ASSIGN;1288}1289YY_BREAK1290case 31:1291YY_RULE_SETUP1292{1293yylval->assign(yytext, yyleng);1294return angle::pp::Token::OP_XOR_ASSIGN;1295}1296YY_BREAK1297case 32:1298YY_RULE_SETUP1299{1300yylval->assign(yytext, yyleng);1301return angle::pp::Token::OP_OR_ASSIGN;1302}1303YY_BREAK1304case 33:1305YY_RULE_SETUP1306{1307yylval->assign(1, yytext[0]);1308return yytext[0];1309}1310YY_BREAK1311case 34:1312YY_RULE_SETUP { yyextra->leadingSpace = true; }1313YY_BREAK1314case 35:1315/* rule 35 can match eol */1316YY_RULE_SETUP1317{1318if (yylineno == INT_MAX)1319{1320*yylval = "Integer overflow on line number";1321return angle::pp::Token::GOT_ERROR;1322}1323++yylineno;1324yylval->assign(1, '\n');1325return '\n';1326}1327YY_BREAK1328case 36:1329YY_RULE_SETUP1330{1331yylval->assign(1, yytext[0]);1332return angle::pp::Token::PP_OTHER;1333}1334YY_BREAK1335case YY_STATE_EOF(INITIAL):1336case YY_STATE_EOF(COMMENT):1337{1338// YY_USER_ACTION is not invoked for handling EOF.1339// Set the location for EOF token manually.1340angle::pp::Input *input = &yyextra->input;1341angle::pp::Input::Location *scanLoc = &yyextra->scanLoc;1342yy_size_t sIndexMax = input->count() ? input->count() - 1 : 0;1343if (scanLoc->sIndex != sIndexMax)1344{1345// We can only reach here if there are empty strings at the1346// end of the input.1347scanLoc->sIndex = sIndexMax;1348scanLoc->cIndex = 0;1349// FIXME: this is not 64-bit clean.1350yyfileno = static_cast<int>(sIndexMax);1351yylineno = 1;1352}1353yylloc->file = yyfileno;1354yylloc->line = yylineno;1355yylval->clear();13561357// Line number overflows fake EOFs to exit early, check for this case.1358if (yylineno == INT_MAX)1359{1360yyextra->diagnostics->report(angle::pp::Diagnostics::PP_TOKENIZER_ERROR,1361angle::pp::SourceLocation(yyfileno, yylineno),1362"Integer overflow on line number");1363}1364else if (YY_START == COMMENT)1365{1366yyextra->diagnostics->report(angle::pp::Diagnostics::PP_EOF_IN_COMMENT,1367angle::pp::SourceLocation(yyfileno, yylineno),1368"EOF while in a comment");1369}1370yyterminate();1371}1372YY_BREAK1373case 37:1374YY_RULE_SETUP1375ECHO;1376YY_BREAK13771378case YY_END_OF_BUFFER:1379{1380/* Amount of text matched not including the EOB char. */1381int yy_amount_of_matched_text = (int)(yy_cp - yyg->yytext_ptr) - 1;13821383/* Undo the effects of YY_DO_BEFORE_ACTION. */1384*yy_cp = yyg->yy_hold_char;1385YY_RESTORE_YY_MORE_OFFSET13861387if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW)1388{1389/* We're scanning a new file or input source. It's1390* possible that this happened because the user1391* just pointed yyin at a new source and called1392* yylex(). If so, then we have to assure1393* consistency between YY_CURRENT_BUFFER and our1394* globals. Here is the right place to do so, because1395* this is the first action (other than possibly a1396* back-up) that will match for the new input source.1397*/1398yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;1399YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;1400YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;1401}14021403/* Note that here we test for yy_c_buf_p "<=" to the position1404* of the first EOB in the buffer, since yy_c_buf_p will1405* already have been incremented past the NUL character1406* (since all states make transitions on EOB to the1407* end-of-buffer state). Contrast this with the test1408* in input().1409*/1410if (yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars])1411{ /* This was really a NUL. */1412yy_state_type yy_next_state;14131414yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;14151416yy_current_state = yy_get_previous_state(yyscanner);14171418/* Okay, we're now positioned to make the NUL1419* transition. We couldn't have1420* yy_get_previous_state() go ahead and do it1421* for us because it doesn't know how to deal1422* with the possibility of jamming (and we don't1423* want to build jamming into it because then it1424* will run more slowly).1425*/14261427yy_next_state = yy_try_NUL_trans(yy_current_state, yyscanner);14281429yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;14301431if (yy_next_state)1432{1433/* Consume the NUL. */1434yy_cp = ++yyg->yy_c_buf_p;1435yy_current_state = yy_next_state;1436goto yy_match;1437}14381439else1440{1441yy_cp = yyg->yy_last_accepting_cpos;1442yy_current_state = yyg->yy_last_accepting_state;1443goto yy_find_action;1444}1445}14461447else1448switch (yy_get_next_buffer(yyscanner))1449{1450case EOB_ACT_END_OF_FILE:1451{1452yyg->yy_did_buffer_switch_on_eof = 0;14531454if (yywrap(yyscanner))1455{1456/* Note: because we've taken care in1457* yy_get_next_buffer() to have set up1458* yytext, we can now set up1459* yy_c_buf_p so that if some total1460* hoser (like flex itself) wants to1461* call the scanner after we return the1462* YY_NULL, it'll still work - another1463* YY_NULL will get returned.1464*/1465yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;14661467yy_act = YY_STATE_EOF(YY_START);1468goto do_action;1469}14701471else1472{1473if (!yyg->yy_did_buffer_switch_on_eof)1474YY_NEW_FILE;1475}1476break;1477}14781479case EOB_ACT_CONTINUE_SCAN:1480yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;14811482yy_current_state = yy_get_previous_state(yyscanner);14831484yy_cp = yyg->yy_c_buf_p;1485yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;1486goto yy_match;14871488case EOB_ACT_LAST_MATCH:1489yyg->yy_c_buf_p =1490&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];14911492yy_current_state = yy_get_previous_state(yyscanner);14931494yy_cp = yyg->yy_c_buf_p;1495yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;1496goto yy_find_action;1497}1498break;1499}15001501default:1502YY_FATAL_ERROR("fatal flex scanner internal error--no action found");1503} /* end of action switch */1504} /* end of scanning one token */1505} /* end of user's declarations */1506} /* end of yylex */15071508/* yy_get_next_buffer - try to read in a new buffer1509*1510* Returns a code representing an action:1511* EOB_ACT_LAST_MATCH -1512* EOB_ACT_CONTINUE_SCAN - continue scanning from current position1513* EOB_ACT_END_OF_FILE - end of file1514*/1515static int yy_get_next_buffer(yyscan_t yyscanner)1516{1517struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;1518char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;1519char *source = yyg->yytext_ptr;1520int number_to_move, i;1521int ret_val;15221523if (yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1])1524YY_FATAL_ERROR("fatal flex scanner internal error--end of buffer missed");15251526if (YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0)1527{ /* Don't try to fill the buffer, so this is an EOF. */1528if (yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1)1529{1530/* We matched a single character, the EOB, so1531* treat this as a final EOF.1532*/1533return EOB_ACT_END_OF_FILE;1534}15351536else1537{1538/* We matched some text prior to the EOB, first1539* process it.1540*/1541return EOB_ACT_LAST_MATCH;1542}1543}15441545/* Try to read more data. */15461547/* First move last chars to start of buffer. */1548number_to_move = (int)(yyg->yy_c_buf_p - yyg->yytext_ptr - 1);15491550for (i = 0; i < number_to_move; ++i)1551*(dest++) = *(source++);15521553if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING)1554/* don't do the read, it's not guaranteed to return an EOF,1555* just force an EOF1556*/1557YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;15581559else1560{1561int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;15621563while (num_to_read <= 0)1564{ /* Not enough room in the buffer - grow it. */15651566/* just a shorter name for the current buffer */1567YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;15681569int yy_c_buf_p_offset = (int)(yyg->yy_c_buf_p - b->yy_ch_buf);15701571if (b->yy_is_our_buffer)1572{1573int new_size = b->yy_buf_size * 2;15741575if (new_size <= 0)1576b->yy_buf_size += b->yy_buf_size / 8;1577else1578b->yy_buf_size *= 2;15791580b->yy_ch_buf = (char *)1581/* Include room in for 2 EOB chars. */1582yyrealloc((void *)b->yy_ch_buf, (yy_size_t)(b->yy_buf_size + 2), yyscanner);1583}1584else1585/* Can't grow it, we don't own it. */1586b->yy_ch_buf = NULL;15871588if (!b->yy_ch_buf)1589YY_FATAL_ERROR("fatal error - scanner input buffer overflow");15901591yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];15921593num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;1594}15951596if (num_to_read > YY_READ_BUF_SIZE)1597num_to_read = YY_READ_BUF_SIZE;15981599/* Read in more data. */1600yy_size_t ret = 0;1601YY_INPUT((&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), ret, num_to_read);1602yyg->yy_n_chars = static_cast<int>(ret);16031604YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;1605}16061607if (yyg->yy_n_chars == 0)1608{1609if (number_to_move == YY_MORE_ADJ)1610{1611ret_val = EOB_ACT_END_OF_FILE;1612yyrestart(yyin, yyscanner);1613}16141615else1616{1617ret_val = EOB_ACT_LAST_MATCH;1618YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING;1619}1620}16211622else1623ret_val = EOB_ACT_CONTINUE_SCAN;16241625if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size)1626{1627/* Extend the array by 50%, plus the number we really need. */1628int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);1629YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *)yyrealloc(1630(void *)YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t)new_size, yyscanner);1631if (!YY_CURRENT_BUFFER_LVALUE->yy_ch_buf)1632YY_FATAL_ERROR("out of dynamic memory in yy_get_next_buffer()");1633/* "- 2" to take care of EOB's */1634YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int)(new_size - 2);1635}16361637yyg->yy_n_chars += number_to_move;1638YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;1639YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;16401641yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];16421643return ret_val;1644}16451646/* yy_get_previous_state - get the state just before the EOB char was reached */16471648static yy_state_type yy_get_previous_state(yyscan_t yyscanner)1649{1650yy_state_type yy_current_state;1651char *yy_cp;1652struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;16531654yy_current_state = yyg->yy_start;16551656for (yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp)1657{1658YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);1659if (yy_accept[yy_current_state])1660{1661yyg->yy_last_accepting_state = yy_current_state;1662yyg->yy_last_accepting_cpos = yy_cp;1663}1664while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)1665{1666yy_current_state = (int)yy_def[yy_current_state];1667if (yy_current_state >= 95)1668yy_c = yy_meta[yy_c];1669}1670yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];1671}16721673return yy_current_state;1674}16751676/* yy_try_NUL_trans - try to make a transition on the NUL character1677*1678* synopsis1679* next_state = yy_try_NUL_trans( current_state );1680*/1681static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state, yyscan_t yyscanner)1682{1683int yy_is_jam;1684struct yyguts_t *yyg =1685(struct yyguts_t *)yyscanner; /* This var may be unused depending upon options. */1686char *yy_cp = yyg->yy_c_buf_p;16871688YY_CHAR yy_c = 1;1689if (yy_accept[yy_current_state])1690{1691yyg->yy_last_accepting_state = yy_current_state;1692yyg->yy_last_accepting_cpos = yy_cp;1693}1694while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state)1695{1696yy_current_state = (int)yy_def[yy_current_state];1697if (yy_current_state >= 95)1698yy_c = yy_meta[yy_c];1699}1700yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];1701yy_is_jam = (yy_current_state == 94);17021703(void)yyg;1704return yy_is_jam ? 0 : yy_current_state;1705}17061707#ifndef YY_NO_UNPUT17081709#endif17101711#ifndef YY_NO_INPUT1712# ifdef __cplusplus1713static int yyinput(yyscan_t yyscanner)1714# else1715static int input(yyscan_t yyscanner)1716# endif17171718{1719int c;1720struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;17211722*yyg->yy_c_buf_p = yyg->yy_hold_char;17231724if (*yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR)1725{1726/* yy_c_buf_p now points to the character we want to return.1727* If this occurs *before* the EOB characters, then it's a1728* valid NUL; if not, then we've hit the end of the buffer.1729*/1730if (yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars])1731/* This was really a NUL. */1732*yyg->yy_c_buf_p = '\0';17331734else1735{ /* need more input */1736int offset = (int)(yyg->yy_c_buf_p - yyg->yytext_ptr);1737++yyg->yy_c_buf_p;17381739switch (yy_get_next_buffer(yyscanner))1740{1741case EOB_ACT_LAST_MATCH:1742/* This happens because yy_g_n_b()1743* sees that we've accumulated a1744* token and flags that we need to1745* try matching the token before1746* proceeding. But for input(),1747* there's no matching to consider.1748* So convert the EOB_ACT_LAST_MATCH1749* to EOB_ACT_END_OF_FILE.1750*/17511752/* Reset buffer status. */1753yyrestart(yyin, yyscanner);17541755/*FALLTHROUGH*/17561757case EOB_ACT_END_OF_FILE:1758{1759if (yywrap(yyscanner))1760return 0;17611762if (!yyg->yy_did_buffer_switch_on_eof)1763YY_NEW_FILE;1764# ifdef __cplusplus1765return yyinput(yyscanner);1766# else1767return input(yyscanner);1768# endif1769}17701771case EOB_ACT_CONTINUE_SCAN:1772yyg->yy_c_buf_p = yyg->yytext_ptr + offset;1773break;1774}1775}1776}17771778c = *(unsigned char *)yyg->yy_c_buf_p; /* cast for 8-bit char's */1779*yyg->yy_c_buf_p = '\0'; /* preserve yytext */1780yyg->yy_hold_char = *++yyg->yy_c_buf_p;17811782return c;1783}1784#endif /* ifndef YY_NO_INPUT */17851786/** Immediately switch to a different input stream.1787* @param input_file A readable stream.1788* @param yyscanner The scanner object.1789* @note This function does not reset the start condition to @c INITIAL .1790*/1791void yyrestart(FILE *input_file, yyscan_t yyscanner)1792{1793struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;17941795if (!YY_CURRENT_BUFFER)1796{1797yyensure_buffer_stack(yyscanner);1798YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner);1799}18001801yy_init_buffer(YY_CURRENT_BUFFER, input_file, yyscanner);1802yy_load_buffer_state(yyscanner);1803}18041805/** Switch to a different input buffer.1806* @param new_buffer The new input buffer.1807* @param yyscanner The scanner object.1808*/1809void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner)1810{1811struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;18121813/* TODO. We should be able to replace this entire function body1814* with1815* yypop_buffer_state();1816* yypush_buffer_state(new_buffer);1817*/1818yyensure_buffer_stack(yyscanner);1819if (YY_CURRENT_BUFFER == new_buffer)1820return;18211822if (YY_CURRENT_BUFFER)1823{1824/* Flush out information for old buffer. */1825*yyg->yy_c_buf_p = yyg->yy_hold_char;1826YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;1827YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;1828}18291830YY_CURRENT_BUFFER_LVALUE = new_buffer;1831yy_load_buffer_state(yyscanner);18321833/* We don't actually know whether we did this switch during1834* EOF (yywrap()) processing, but the only time this flag1835* is looked at is after yywrap() is called, so it's safe1836* to go ahead and always set it.1837*/1838yyg->yy_did_buffer_switch_on_eof = 1;1839}18401841static void yy_load_buffer_state(yyscan_t yyscanner)1842{1843struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;1844yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;1845yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;1846yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;1847yyg->yy_hold_char = *yyg->yy_c_buf_p;1848}18491850/** Allocate and initialize an input buffer state.1851* @param file A readable stream.1852* @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.1853* @param yyscanner The scanner object.1854* @return the allocated buffer state.1855*/1856YY_BUFFER_STATE yy_create_buffer(FILE *file, int size, yyscan_t yyscanner)1857{1858YY_BUFFER_STATE b;18591860b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state), yyscanner);1861if (!b)1862YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()");18631864b->yy_buf_size = size;18651866/* yy_ch_buf has to be 2 characters longer than the size given because1867* we need to put in 2 end-of-buffer characters.1868*/1869b->yy_ch_buf = (char *)yyalloc((yy_size_t)(b->yy_buf_size + 2), yyscanner);1870if (!b->yy_ch_buf)1871YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()");18721873b->yy_is_our_buffer = 1;18741875yy_init_buffer(b, file, yyscanner);18761877return b;1878}18791880/** Destroy the buffer.1881* @param b a buffer created with yy_create_buffer()1882* @param yyscanner The scanner object.1883*/1884void yy_delete_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner)1885{1886struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;18871888if (!b)1889return;18901891if (b == YY_CURRENT_BUFFER) /* Not sure if we should pop here. */1892YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE)0;18931894if (b->yy_is_our_buffer)1895yyfree((void *)b->yy_ch_buf, yyscanner);18961897yyfree((void *)b, yyscanner);1898}18991900/* Initializes or reinitializes a buffer.1901* This function is sometimes called more than once on the same buffer,1902* such as during a yyrestart() or at EOF.1903*/1904static void yy_init_buffer(YY_BUFFER_STATE b, FILE *file, yyscan_t yyscanner)19051906{1907int oerrno = errno;1908struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;19091910yy_flush_buffer(b, yyscanner);19111912b->yy_input_file = file;1913b->yy_fill_buffer = 1;19141915/* If b is the current buffer, then yy_init_buffer was _probably_1916* called from yyrestart() or through yy_get_next_buffer.1917* In that case, we don't want to reset the lineno or column.1918*/1919if (b != YY_CURRENT_BUFFER)1920{1921b->yy_bs_lineno = 1;1922b->yy_bs_column = 0;1923}19241925b->yy_is_interactive = 0;19261927errno = oerrno;1928}19291930/** Discard all buffered characters. On the next scan, YY_INPUT will be called.1931* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.1932* @param yyscanner The scanner object.1933*/1934void yy_flush_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner)1935{1936struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;1937if (!b)1938return;19391940b->yy_n_chars = 0;19411942/* We always need two end-of-buffer characters. The first causes1943* a transition to the end-of-buffer state. The second causes1944* a jam in that state.1945*/1946b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;1947b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;19481949b->yy_buf_pos = &b->yy_ch_buf[0];19501951b->yy_at_bol = 1;1952b->yy_buffer_status = YY_BUFFER_NEW;19531954if (b == YY_CURRENT_BUFFER)1955yy_load_buffer_state(yyscanner);1956}19571958/** Pushes the new state onto the stack. The new state becomes1959* the current state. This function will allocate the stack1960* if necessary.1961* @param new_buffer The new state.1962* @param yyscanner The scanner object.1963*/1964void yypush_buffer_state(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner)1965{1966struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;1967if (new_buffer == NULL)1968return;19691970yyensure_buffer_stack(yyscanner);19711972/* This block is copied from yy_switch_to_buffer. */1973if (YY_CURRENT_BUFFER)1974{1975/* Flush out information for old buffer. */1976*yyg->yy_c_buf_p = yyg->yy_hold_char;1977YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;1978YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;1979}19801981/* Only push if top exists. Otherwise, replace top. */1982if (YY_CURRENT_BUFFER)1983yyg->yy_buffer_stack_top++;1984YY_CURRENT_BUFFER_LVALUE = new_buffer;19851986/* copied from yy_switch_to_buffer. */1987yy_load_buffer_state(yyscanner);1988yyg->yy_did_buffer_switch_on_eof = 1;1989}19901991/** Removes and deletes the top of the stack, if present.1992* The next element becomes the new top.1993* @param yyscanner The scanner object.1994*/1995void yypop_buffer_state(yyscan_t yyscanner)1996{1997struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;1998if (!YY_CURRENT_BUFFER)1999return;20002001yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner);2002YY_CURRENT_BUFFER_LVALUE = NULL;2003if (yyg->yy_buffer_stack_top > 0)2004--yyg->yy_buffer_stack_top;20052006if (YY_CURRENT_BUFFER)2007{2008yy_load_buffer_state(yyscanner);2009yyg->yy_did_buffer_switch_on_eof = 1;2010}2011}20122013/* Allocates the stack if it does not exist.2014* Guarantees space for at least one push.2015*/2016static void yyensure_buffer_stack(yyscan_t yyscanner)2017{2018yy_size_t num_to_alloc;2019struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;20202021if (!yyg->yy_buffer_stack)2022{20232024/* First allocation is just for 2 elements, since we don't know if this2025* scanner will even need a stack. We use 2 instead of 1 to avoid an2026* immediate realloc on the next call.2027*/2028num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */2029yyg->yy_buffer_stack = (struct yy_buffer_state **)yyalloc(2030num_to_alloc * sizeof(struct yy_buffer_state *), yyscanner);2031if (!yyg->yy_buffer_stack)2032YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()");20332034memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state *));20352036yyg->yy_buffer_stack_max = num_to_alloc;2037yyg->yy_buffer_stack_top = 0;2038return;2039}20402041if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1)2042{20432044/* Increase the buffer to prepare for a possible push. */2045yy_size_t grow_size = 8 /* arbitrary grow size */;20462047num_to_alloc = yyg->yy_buffer_stack_max + grow_size;2048yyg->yy_buffer_stack = (struct yy_buffer_state **)yyrealloc(2049yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state *), yyscanner);2050if (!yyg->yy_buffer_stack)2051YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()");20522053/* zero only the new slots.*/2054memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0,2055grow_size * sizeof(struct yy_buffer_state *));2056yyg->yy_buffer_stack_max = num_to_alloc;2057}2058}20592060/** Setup the input buffer state to scan directly from a user-specified character buffer.2061* @param base the character buffer2062* @param size the size in bytes of the character buffer2063* @param yyscanner The scanner object.2064* @return the newly allocated buffer state object.2065*/2066YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size, yyscan_t yyscanner)2067{2068YY_BUFFER_STATE b;20692070if (size < 2 || base[size - 2] != YY_END_OF_BUFFER_CHAR ||2071base[size - 1] != YY_END_OF_BUFFER_CHAR)2072/* They forgot to leave room for the EOB's. */2073return NULL;20742075b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state), yyscanner);2076if (!b)2077YY_FATAL_ERROR("out of dynamic memory in yy_scan_buffer()");20782079b->yy_buf_size = (int)(size - 2); /* "- 2" to take care of EOB's */2080b->yy_buf_pos = b->yy_ch_buf = base;2081b->yy_is_our_buffer = 0;2082b->yy_input_file = NULL;2083b->yy_n_chars = b->yy_buf_size;2084b->yy_is_interactive = 0;2085b->yy_at_bol = 1;2086b->yy_fill_buffer = 0;2087b->yy_buffer_status = YY_BUFFER_NEW;20882089yy_switch_to_buffer(b, yyscanner);20902091return b;2092}20932094/** Setup the input buffer state to scan a string. The next call to yylex() will2095* scan from a @e copy of @a str.2096* @param yystr a NUL-terminated string to scan2097* @param yyscanner The scanner object.2098* @return the newly allocated buffer state object.2099* @note If you want to scan bytes that may contain NUL values, then use2100* yy_scan_bytes() instead.2101*/2102YY_BUFFER_STATE yy_scan_string(const char *yystr, yyscan_t yyscanner)2103{21042105return yy_scan_bytes(yystr, (int)strlen(yystr), yyscanner);2106}21072108/** Setup the input buffer state to scan the given bytes. The next call to yylex() will2109* scan from a @e copy of @a bytes.2110* @param yybytes the byte buffer to scan2111* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.2112* @param yyscanner The scanner object.2113* @return the newly allocated buffer state object.2114*/2115YY_BUFFER_STATE yy_scan_bytes(const char *yybytes, int _yybytes_len, yyscan_t yyscanner)2116{2117YY_BUFFER_STATE b;2118char *buf;2119yy_size_t n;2120int i;21212122/* Get memory for full buffer, including space for trailing EOB's. */2123n = (yy_size_t)(_yybytes_len + 2);2124buf = (char *)yyalloc(n, yyscanner);2125if (!buf)2126YY_FATAL_ERROR("out of dynamic memory in yy_scan_bytes()");21272128for (i = 0; i < _yybytes_len; ++i)2129buf[i] = yybytes[i];21302131buf[_yybytes_len] = buf[_yybytes_len + 1] = YY_END_OF_BUFFER_CHAR;21322133b = yy_scan_buffer(buf, n, yyscanner);2134if (!b)2135YY_FATAL_ERROR("bad buffer in yy_scan_bytes()");21362137/* It's okay to grow etc. this buffer, and we should throw it2138* away when we're done.2139*/2140b->yy_is_our_buffer = 1;21412142return b;2143}21442145#ifndef YY_EXIT_FAILURE2146# define YY_EXIT_FAILURE 22147#endif21482149static void yynoreturn yy_fatal_error(const char *msg, yyscan_t yyscanner)2150{2151struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2152(void)yyg;2153fprintf(stderr, "%s\n", msg);2154exit(YY_EXIT_FAILURE);2155}21562157/* Redefine yyless() so it works in section 3 code. */21582159#undef yyless2160#define yyless(n) \2161do \2162{ \2163/* Undo effects of setting up yytext. */ \2164int yyless_macro_arg = (n); \2165YY_LESS_LINENO(yyless_macro_arg); \2166yytext[yyleng] = yyg->yy_hold_char; \2167yyg->yy_c_buf_p = yytext + yyless_macro_arg; \2168yyg->yy_hold_char = *yyg->yy_c_buf_p; \2169*yyg->yy_c_buf_p = '\0'; \2170yyleng = yyless_macro_arg; \2171} while (0)21722173/* Accessor methods (get/set functions) to struct members. */21742175/** Get the user-defined data for this scanner.2176* @param yyscanner The scanner object.2177*/2178YY_EXTRA_TYPE yyget_extra(yyscan_t yyscanner)2179{2180struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2181return yyextra;2182}21832184/** Get the current line number.2185* @param yyscanner The scanner object.2186*/2187int yyget_lineno(yyscan_t yyscanner)2188{2189struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;21902191if (!YY_CURRENT_BUFFER)2192return 0;21932194return yylineno;2195}21962197/** Get the current column number.2198* @param yyscanner The scanner object.2199*/2200int yyget_column(yyscan_t yyscanner)2201{2202struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;22032204if (!YY_CURRENT_BUFFER)2205return 0;22062207return yycolumn;2208}22092210/** Get the input stream.2211* @param yyscanner The scanner object.2212*/2213FILE *yyget_in(yyscan_t yyscanner)2214{2215struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2216return yyin;2217}22182219/** Get the output stream.2220* @param yyscanner The scanner object.2221*/2222FILE *yyget_out(yyscan_t yyscanner)2223{2224struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2225return yyout;2226}22272228/** Get the length of the current token.2229* @param yyscanner The scanner object.2230*/2231int yyget_leng(yyscan_t yyscanner)2232{2233struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2234return yyleng;2235}22362237/** Get the current token.2238* @param yyscanner The scanner object.2239*/22402241char *yyget_text(yyscan_t yyscanner)2242{2243struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2244return yytext;2245}22462247/** Set the user-defined data. This data is never touched by the scanner.2248* @param user_defined The data to be associated with this scanner.2249* @param yyscanner The scanner object.2250*/2251void yyset_extra(YY_EXTRA_TYPE user_defined, yyscan_t yyscanner)2252{2253struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2254yyextra = user_defined;2255}22562257/** Set the current line number.2258* @param _line_number line number2259* @param yyscanner The scanner object.2260*/2261void yyset_lineno(int _line_number, yyscan_t yyscanner)2262{2263struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;22642265/* lineno is only valid if an input buffer exists. */2266if (!YY_CURRENT_BUFFER)2267YY_FATAL_ERROR("yyset_lineno called with no buffer");22682269yylineno = _line_number;2270}22712272/** Set the current column.2273* @param _column_no column number2274* @param yyscanner The scanner object.2275*/2276void yyset_column(int _column_no, yyscan_t yyscanner)2277{2278struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;22792280/* column is only valid if an input buffer exists. */2281if (!YY_CURRENT_BUFFER)2282YY_FATAL_ERROR("yyset_column called with no buffer");22832284yycolumn = _column_no;2285}22862287/** Set the input stream. This does not discard the current2288* input buffer.2289* @param _in_str A readable stream.2290* @param yyscanner The scanner object.2291* @see yy_switch_to_buffer2292*/2293void yyset_in(FILE *_in_str, yyscan_t yyscanner)2294{2295struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2296yyin = _in_str;2297}22982299void yyset_out(FILE *_out_str, yyscan_t yyscanner)2300{2301struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2302yyout = _out_str;2303}23042305int yyget_debug(yyscan_t yyscanner)2306{2307struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2308return yy_flex_debug;2309}23102311void yyset_debug(int _bdebug, yyscan_t yyscanner)2312{2313struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2314yy_flex_debug = _bdebug;2315}23162317/* Accessor methods for yylval and yylloc */23182319YYSTYPE *yyget_lval(yyscan_t yyscanner)2320{2321struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2322return yylval;2323}23242325void yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner)2326{2327struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2328yylval = yylval_param;2329}23302331YYLTYPE *yyget_lloc(yyscan_t yyscanner)2332{2333struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2334return yylloc;2335}23362337void yyset_lloc(YYLTYPE *yylloc_param, yyscan_t yyscanner)2338{2339struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2340yylloc = yylloc_param;2341}23422343/* User-visible API */23442345/* yylex_init is special because it creates the scanner itself, so it is2346* the ONLY reentrant function that doesn't take the scanner as the last argument.2347* That's why we explicitly handle the declaration, instead of using our macros.2348*/2349int yylex_init(yyscan_t *ptr_yy_globals)2350{2351if (ptr_yy_globals == NULL)2352{2353errno = EINVAL;2354return 1;2355}23562357*ptr_yy_globals = (yyscan_t)yyalloc(sizeof(struct yyguts_t), NULL);23582359if (*ptr_yy_globals == NULL)2360{2361errno = ENOMEM;2362return 1;2363}23642365/* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */2366memset(*ptr_yy_globals, 0x00, sizeof(struct yyguts_t));23672368return yy_init_globals(*ptr_yy_globals);2369}23702371/* yylex_init_extra has the same functionality as yylex_init, but follows the2372* convention of taking the scanner as the last argument. Note however, that2373* this is a *pointer* to a scanner, as it will be allocated by this call (and2374* is the reason, too, why this function also must handle its own declaration).2375* The user defined value in the first argument will be available to yyalloc in2376* the yyextra field.2377*/2378int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined, yyscan_t *ptr_yy_globals)2379{2380struct yyguts_t dummy_yyguts;23812382yyset_extra(yy_user_defined, &dummy_yyguts);23832384if (ptr_yy_globals == NULL)2385{2386errno = EINVAL;2387return 1;2388}23892390*ptr_yy_globals = (yyscan_t)yyalloc(sizeof(struct yyguts_t), &dummy_yyguts);23912392if (*ptr_yy_globals == NULL)2393{2394errno = ENOMEM;2395return 1;2396}23972398/* By setting to 0xAA, we expose bugs in2399yy_init_globals. Leave at 0x00 for releases. */2400memset(*ptr_yy_globals, 0x00, sizeof(struct yyguts_t));24012402yyset_extra(yy_user_defined, *ptr_yy_globals);24032404return yy_init_globals(*ptr_yy_globals);2405}24062407static int yy_init_globals(yyscan_t yyscanner)2408{2409struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2410/* Initialization is the same as for the non-reentrant scanner.2411* This function is called from yylex_destroy(), so don't allocate here.2412*/24132414yyg->yy_buffer_stack = NULL;2415yyg->yy_buffer_stack_top = 0;2416yyg->yy_buffer_stack_max = 0;2417yyg->yy_c_buf_p = NULL;2418yyg->yy_init = 0;2419yyg->yy_start = 0;24202421yyg->yy_start_stack_ptr = 0;2422yyg->yy_start_stack_depth = 0;2423yyg->yy_start_stack = NULL;24242425/* Defined in main.c */2426#ifdef YY_STDINIT2427yyin = stdin;2428yyout = stdout;2429#else2430yyin = NULL;2431yyout = NULL;2432#endif24332434/* For future reference: Set errno on error, since we are called by2435* yylex_init()2436*/2437return 0;2438}24392440/* yylex_destroy is for both reentrant and non-reentrant scanners. */2441int yylex_destroy(yyscan_t yyscanner)2442{2443struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;24442445/* Pop the buffer stack, destroying each element. */2446while (YY_CURRENT_BUFFER)2447{2448yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner);2449YY_CURRENT_BUFFER_LVALUE = NULL;2450yypop_buffer_state(yyscanner);2451}24522453/* Destroy the stack itself. */2454yyfree(yyg->yy_buffer_stack, yyscanner);2455yyg->yy_buffer_stack = NULL;24562457/* Destroy the start condition stack. */2458yyfree(yyg->yy_start_stack, yyscanner);2459yyg->yy_start_stack = NULL;24602461/* Reset the globals. This is important in a non-reentrant scanner so the next time2462* yylex() is called, initialization will occur. */2463yy_init_globals(yyscanner);24642465/* Destroy the main struct (reentrant only). */2466yyfree(yyscanner, yyscanner);2467yyscanner = NULL;2468return 0;2469}24702471/*2472* Internal utility routines.2473*/24742475#ifndef yytext_ptr2476static void yy_flex_strncpy(char *s1, const char *s2, int n, yyscan_t yyscanner)2477{2478struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2479(void)yyg;24802481int i;2482for (i = 0; i < n; ++i)2483s1[i] = s2[i];2484}2485#endif24862487#ifdef YY_NEED_STRLEN2488static int yy_flex_strlen(const char *s, yyscan_t yyscanner)2489{2490int n;2491for (n = 0; s[n]; ++n)2492;24932494return n;2495}2496#endif24972498void *yyalloc(yy_size_t size, yyscan_t yyscanner)2499{2500struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2501(void)yyg;2502return malloc(size);2503}25042505void *yyrealloc(void *ptr, yy_size_t size, yyscan_t yyscanner)2506{2507struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2508(void)yyg;25092510/* The cast to (char *) in the following accommodates both2511* implementations that use char* generic pointers, and those2512* that use void* generic pointers. It works with the latter2513* because both ANSI C and C++ allow castless assignment from2514* any pointer type to void*, and deal with argument conversions2515* as though doing an assignment.2516*/2517return realloc(ptr, size);2518}25192520void yyfree(void *ptr, yyscan_t yyscanner)2521{2522struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;2523(void)yyg;2524free((char *)ptr); /* see yyrealloc() for (char *) cast */2525}25262527#define YYTABLES_NAME "yytables"25282529namespace angle2530{25312532namespace pp2533{25342535Tokenizer::Tokenizer(Diagnostics *diagnostics) : mHandle(nullptr), mMaxTokenSize(256)2536{2537mContext.diagnostics = diagnostics;2538}25392540Tokenizer::~Tokenizer()2541{2542destroyScanner();2543}25442545bool Tokenizer::init(size_t count, const char *const string[], const int length[])2546{2547if ((count > 0) && (string == 0))2548return false;25492550mContext.input = Input(count, string, length);2551return initScanner();2552}25532554void Tokenizer::setFileNumber(int file)2555{2556// We use column number as file number.2557// See macro yyfileno.2558yyset_column(file, mHandle);2559}25602561void Tokenizer::setLineNumber(int line)2562{2563yyset_lineno(line, mHandle);2564}25652566void Tokenizer::setMaxTokenSize(size_t maxTokenSize)2567{2568mMaxTokenSize = maxTokenSize;2569}25702571void Tokenizer::lex(Token *token)2572{2573int tokenType = yylex(&token->text, &token->location, mHandle);25742575if (tokenType == Token::GOT_ERROR)2576{2577mContext.diagnostics->report(Diagnostics::PP_TOKENIZER_ERROR, token->location, token->text);2578token->type = Token::LAST;2579}2580else2581{2582token->type = tokenType;2583}25842585if (token->text.size() > mMaxTokenSize)2586{2587mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG, token->location, token->text);2588token->text.erase(mMaxTokenSize);2589}25902591token->flags = 0;25922593token->setAtStartOfLine(mContext.lineStart);2594mContext.lineStart = token->type == '\n';25952596token->setHasLeadingSpace(mContext.leadingSpace);2597mContext.leadingSpace = false;2598}25992600bool Tokenizer::initScanner()2601{2602if ((mHandle == nullptr) && yylex_init_extra(&mContext, &mHandle))2603return false;26042605yyrestart(0, mHandle);2606return true;2607}26082609void Tokenizer::destroyScanner()2610{2611if (mHandle == nullptr)2612return;26132614yylex_destroy(mHandle);2615mHandle = nullptr;2616}26172618} // namespace pp26192620} // namespace angle262126222623