#line 1 "libs/vkd3d-shader/preproc.yy.c"

#line 3 "libs/vkd3d-shader/preproc.yy.c"

#define  YY_INT_ALIGNED short int

/* A lexical scanner generated by flex */

#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
#define YY_FLEX_SUBMINOR_VERSION 4
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif

#ifdef yy_create_buffer
#define preproc_yy_create_buffer_ALREADY_DEFINED
#else
#define yy_create_buffer preproc_yy_create_buffer
#endif

#ifdef yy_delete_buffer
#define preproc_yy_delete_buffer_ALREADY_DEFINED
#else
#define yy_delete_buffer preproc_yy_delete_buffer
#endif

#ifdef yy_scan_buffer
#define preproc_yy_scan_buffer_ALREADY_DEFINED
#else
#define yy_scan_buffer preproc_yy_scan_buffer
#endif

#ifdef yy_scan_string
#define preproc_yy_scan_string_ALREADY_DEFINED
#else
#define yy_scan_string preproc_yy_scan_string
#endif

#ifdef yy_scan_bytes
#define preproc_yy_scan_bytes_ALREADY_DEFINED
#else
#define yy_scan_bytes preproc_yy_scan_bytes
#endif

#ifdef yy_init_buffer
#define preproc_yy_init_buffer_ALREADY_DEFINED
#else
#define yy_init_buffer preproc_yy_init_buffer
#endif

#ifdef yy_flush_buffer
#define preproc_yy_flush_buffer_ALREADY_DEFINED
#else
#define yy_flush_buffer preproc_yy_flush_buffer
#endif

#ifdef yy_load_buffer_state
#define preproc_yy_load_buffer_state_ALREADY_DEFINED
#else
#define yy_load_buffer_state preproc_yy_load_buffer_state
#endif

#ifdef yy_switch_to_buffer
#define preproc_yy_switch_to_buffer_ALREADY_DEFINED
#else
#define yy_switch_to_buffer preproc_yy_switch_to_buffer
#endif

#ifdef yypush_buffer_state
#define preproc_yypush_buffer_state_ALREADY_DEFINED
#else
#define yypush_buffer_state preproc_yypush_buffer_state
#endif

#ifdef yypop_buffer_state
#define preproc_yypop_buffer_state_ALREADY_DEFINED
#else
#define yypop_buffer_state preproc_yypop_buffer_state
#endif

#ifdef yyensure_buffer_stack
#define preproc_yyensure_buffer_stack_ALREADY_DEFINED
#else
#define yyensure_buffer_stack preproc_yyensure_buffer_stack
#endif

#ifdef yylex
#define preproc_yylex_ALREADY_DEFINED
#else
#define yylex preproc_yylex
#endif

#ifdef yyrestart
#define preproc_yyrestart_ALREADY_DEFINED
#else
#define yyrestart preproc_yyrestart
#endif

#ifdef yylex_init
#define preproc_yylex_init_ALREADY_DEFINED
#else
#define yylex_init preproc_yylex_init
#endif

#ifdef yylex_init_extra
#define preproc_yylex_init_extra_ALREADY_DEFINED
#else
#define yylex_init_extra preproc_yylex_init_extra
#endif

#ifdef yylex_destroy
#define preproc_yylex_destroy_ALREADY_DEFINED
#else
#define yylex_destroy preproc_yylex_destroy
#endif

#ifdef yyget_debug
#define preproc_yyget_debug_ALREADY_DEFINED
#else
#define yyget_debug preproc_yyget_debug
#endif

#ifdef yyset_debug
#define preproc_yyset_debug_ALREADY_DEFINED
#else
#define yyset_debug preproc_yyset_debug
#endif

#ifdef yyget_extra
#define preproc_yyget_extra_ALREADY_DEFINED
#else
#define yyget_extra preproc_yyget_extra
#endif

#ifdef yyset_extra
#define preproc_yyset_extra_ALREADY_DEFINED
#else
#define yyset_extra preproc_yyset_extra
#endif

#ifdef yyget_in
#define preproc_yyget_in_ALREADY_DEFINED
#else
#define yyget_in preproc_yyget_in
#endif

#ifdef yyset_in
#define preproc_yyset_in_ALREADY_DEFINED
#else
#define yyset_in preproc_yyset_in
#endif

#ifdef yyget_out
#define preproc_yyget_out_ALREADY_DEFINED
#else
#define yyget_out preproc_yyget_out
#endif

#ifdef yyset_out
#define preproc_yyset_out_ALREADY_DEFINED
#else
#define yyset_out preproc_yyset_out
#endif

#ifdef yyget_leng
#define preproc_yyget_leng_ALREADY_DEFINED
#else
#define yyget_leng preproc_yyget_leng
#endif

#ifdef yyget_text
#define preproc_yyget_text_ALREADY_DEFINED
#else
#define yyget_text preproc_yyget_text
#endif

#ifdef yyget_lineno
#define preproc_yyget_lineno_ALREADY_DEFINED
#else
#define yyget_lineno preproc_yyget_lineno
#endif

#ifdef yyset_lineno
#define preproc_yyset_lineno_ALREADY_DEFINED
#else
#define yyset_lineno preproc_yyset_lineno
#endif

#ifdef yyget_column
#define preproc_yyget_column_ALREADY_DEFINED
#else
#define yyget_column preproc_yyget_column
#endif

#ifdef yyset_column
#define preproc_yyset_column_ALREADY_DEFINED
#else
#define yyset_column preproc_yyset_column
#endif

#ifdef yywrap
#define preproc_yywrap_ALREADY_DEFINED
#else
#define yywrap preproc_yywrap
#endif

#ifdef yyget_lval
#define preproc_yyget_lval_ALREADY_DEFINED
#else
#define yyget_lval preproc_yyget_lval
#endif

#ifdef yyset_lval
#define preproc_yyset_lval_ALREADY_DEFINED
#else
#define yyset_lval preproc_yyset_lval
#endif

#ifdef yyget_lloc
#define preproc_yyget_lloc_ALREADY_DEFINED
#else
#define yyget_lloc preproc_yyget_lloc
#endif

#ifdef yyset_lloc
#define preproc_yyset_lloc_ALREADY_DEFINED
#else
#define yyset_lloc preproc_yyset_lloc
#endif

#ifdef yyalloc
#define preproc_yyalloc_ALREADY_DEFINED
#else
#define yyalloc preproc_yyalloc
#endif

#ifdef yyrealloc
#define preproc_yyrealloc_ALREADY_DEFINED
#else
#define yyrealloc preproc_yyrealloc
#endif

#ifdef yyfree
#define preproc_yyfree_ALREADY_DEFINED
#else
#define yyfree preproc_yyfree
#endif

/* First, we deal with  platform-specific or compiler-specific issues. */

/* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>

/* end standard C headers. */

/* flex integer type definitions */

#ifndef FLEXINT_H
#define FLEXINT_H

/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */

#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L

/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
 * if you want the limit (max/min) macros for int types. 
 */
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif

#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t; 
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;

/* Limits of integral types. */
#ifndef INT8_MIN
#define INT8_MIN               (-128)
#endif
#ifndef INT16_MIN
#define INT16_MIN              (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN              (-2147483647-1)
#endif
#ifndef INT8_MAX
#define INT8_MAX               (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX              (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX              (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX              (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX             (65535U)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX             (4294967295U)
#endif

#ifndef SIZE_MAX
#define SIZE_MAX               (~(size_t)0)
#endif

#endif /* ! C99 */

#endif /* ! FLEXINT_H */

/* begin standard C++ headers. */

/* TODO: this is always defined, so inline it */
#define yyconst const

#if defined(__GNUC__) && __GNUC__ >= 3
#define yynoreturn __attribute__((__noreturn__))
#else
#define yynoreturn
#endif

/* Returned upon end-of-file. */
#define YY_NULL 0

/* Promotes a possibly negative, possibly signed char to an
 *   integer in range [0..255] for use as an array index.
 */
#define YY_SC_TO_UI(c) ((YY_CHAR) (c))

/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void* yyscan_t;
#endif

/* For convenience, these vars (plus the bison vars far below)
   are macros in the reentrant scanner. */
#define yyin yyg->yyin_r
#define yyout yyg->yyout_r
#define yyextra yyg->yyextra_r
#define yyleng yyg->yyleng_r
#define yytext yyg->yytext_r
#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r

/* Enter a start condition.  This macro really ought to take a parameter,
 * but we do it the disgusting crufty way forced on us by the ()-less
 * definition of BEGIN.
 */
#define BEGIN yyg->yy_start = 1 + 2 *
/* Translate the current start state into a value that can be later handed
 * to BEGIN to return to the state.  The YYSTATE alias is for lex
 * compatibility.
 */
#define YY_START ((yyg->yy_start - 1) / 2)
#define YYSTATE YY_START
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* Special action meaning "start processing a new file". */
#define YY_NEW_FILE yyrestart( yyin , yyscanner )
#define YY_END_OF_BUFFER_CHAR 0

/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
 * Ditto for the __ia64__ case accordingly.
 */
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif

/* The state buf must be large enough to hold one state per character in the main buffer.
 */
#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))

#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif

#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif

#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
    
    #define YY_LESS_LINENO(n)
    #define YY_LINENO_REWIND_TO(ptr)
    
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
	do \
		{ \
		/* Undo effects of setting up yytext. */ \
        int yyless_macro_arg = (n); \
        YY_LESS_LINENO(yyless_macro_arg);\
		*yy_cp = yyg->yy_hold_char; \
		YY_RESTORE_YY_MORE_OFFSET \
		yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
		} \
	while ( 0 )
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )

#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
	{
	FILE *yy_input_file;

	char *yy_ch_buf;		/* input buffer */
	char *yy_buf_pos;		/* current position in input buffer */

	/* Size of input buffer in bytes, not including room for EOB
	 * characters.
	 */
	int yy_buf_size;

	/* Number of characters read into yy_ch_buf, not including EOB
	 * characters.
	 */
	int yy_n_chars;

	/* Whether we "own" the buffer - i.e., we know we created it,
	 * and can realloc() it to grow it, and should free() it to
	 * delete it.
	 */
	int yy_is_our_buffer;

	/* Whether this is an "interactive" input source; if so, and
	 * if we're using stdio for input, then we want to use getc()
	 * instead of fread(), to make sure we stop fetching input after
	 * each newline.
	 */
	int yy_is_interactive;

	/* Whether we're considered to be at the beginning of a line.
	 * If so, '^' rules will be active on the next match, otherwise
	 * not.
	 */
	int yy_at_bol;

    int yy_bs_lineno; /**< The line count. */
    int yy_bs_column; /**< The column count. */

	/* Whether to try to fill the input buffer when we reach the
	 * end of it.
	 */
	int yy_fill_buffer;

	int yy_buffer_status;

#define YY_BUFFER_NEW 0
#define YY_BUFFER_NORMAL 1
	/* When an EOF's been seen but there's still some text to process
	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
	 * shouldn't try reading from the input source any more.  We might
	 * still have a bunch of tokens to match, though, because of
	 * possible backing-up.
	 *
	 * When we actually see the EOF, we change the status to "new"
	 * (via yyrestart()), so that the user can continue scanning by
	 * just pointing yyin at a new input file.
	 */
#define YY_BUFFER_EOF_PENDING 2

	};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */

/* We provide macros for accessing buffer states in case in the
 * future we want to put the buffer states in a more general
 * "scanner state".
 *
 * Returns the top of the stack, or NULL.
 */
#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
                          ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
                          : NULL)
/* Same as previous macro, but useful when we know that the buffer stack is not
 * NULL or when we need an lvalue. For internal use only.
 */
#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]

void yyrestart ( FILE *input_file , yyscan_t yyscanner );
void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
void yypop_buffer_state ( yyscan_t yyscanner );

static void yyensure_buffer_stack ( yyscan_t yyscanner );
static void yy_load_buffer_state ( yyscan_t yyscanner );
static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)

YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );

void *yyalloc ( yy_size_t , yyscan_t yyscanner );
void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
void yyfree ( void * , yyscan_t yyscanner );

#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
	{ \
	if ( ! YY_CURRENT_BUFFER ){ \
        yyensure_buffer_stack (yyscanner); \
		YY_CURRENT_BUFFER_LVALUE =    \
            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
	} \
	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
	}
#define yy_set_bol(at_bol) \
	{ \
	if ( ! YY_CURRENT_BUFFER ){\
        yyensure_buffer_stack (yyscanner); \
		YY_CURRENT_BUFFER_LVALUE =    \
            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
	} \
	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
	}
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)

/* Begin user sect3 */

#define preproc_yywrap(yyscanner) (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
typedef flex_uint8_t YY_CHAR;

typedef int yy_state_type;

#define yytext_ptr yytext_r

static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
static yy_state_type yy_try_NUL_trans ( yy_state_type current_state  , yyscan_t yyscanner);
static int yy_get_next_buffer ( yyscan_t yyscanner );
static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );

/* Done after the current pattern has been matched and before the
 * corresponding action - sets up yytext.
 */
#define YY_DO_BEFORE_ACTION \
	yyg->yytext_ptr = yy_bp; \
	yyleng = (int) (yy_cp - yy_bp); \
	yyg->yy_hold_char = *yy_cp; \
	*yy_cp = '\0'; \
	yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 42
#define YY_END_OF_BUFFER 43
/* This struct is not used in this scanner,
   but its presence is necessary. */
struct yy_trans_info
	{
	flex_int32_t yy_verify;
	flex_int32_t yy_nxt;
	};
static const flex_int16_t yy_accept[140] =
    {   0,
        0,    0,    0,    0,    0,    0,    8,    8,    0,    0,
        0,    0,   43,   41,   39,   38,   39,   40,   41,   41,
       41,   40,   40,   40,   40,   40,   41,   40,   24,   25,
       40,   40,   41,   40,   12,   41,   12,   12,   40,    6,
        7,    6,    4,    6,    8,    8,    8,   41,   41,   41,
       24,   25,   39,   38,   16,    0,   35,    0,    0,   26,
        0,   36,   31,   17,   27,   28,   19,    2,    1,   20,
       24,    0,    0,   21,   24,    0,   25,   25,    0,   29,
       13,   15,   14,   30,   11,   12,    0,   37,    0,   12,
       12,   18,    5,    3,    0,    8,    8,    8,    0,   33,

        0,   34,   24,   25,    0,   36,    0,    0,   19,    0,
       20,    0,   22,   24,   23,   25,   12,   29,   30,    0,
       12,    0,    0,    0,   19,    0,   20,   23,   23,   12,
        0,   23,   12,    0,   12,   32,   10,    9,    0
    } ;

static const YY_CHAR yy_ec[256] =
    {   0,
        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
        1,    1,    4,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    2,    5,    6,    7,    1,    8,    9,    1,   10,
       11,   12,   13,   11,   14,   15,   16,   17,   18,   18,
       18,   19,   20,   20,   20,   21,   21,   22,    1,   23,
       24,   25,   11,    1,   26,   26,   26,   26,   27,   28,
       26,   28,   26,   26,   26,   29,   26,   26,   26,   26,
       26,   26,   26,   26,   29,   26,   26,   30,   26,   26,
       31,   32,   31,   33,   26,   34,   26,   26,   26,   35,

       36,   37,   38,   39,   40,   38,   38,   41,   38,   42,
       38,   43,   38,   38,   44,   38,   41,   43,   38,   45,
       38,   38,   11,   46,   11,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,

        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1
    } ;

static const YY_CHAR yy_meta[47] =
    {   0,
        1,    2,    3,    2,    1,    1,    2,    1,    1,    4,
        1,    1,    5,    5,    1,    1,    6,    6,    6,    6,
        6,    7,    1,    1,    1,    8,    8,    9,   10,    8,
       11,   11,   11,   11,    8,    8,    9,   12,   13,   12,
       14,   12,   12,   12,   12,    1
    } ;

static const flex_int16_t yy_base[159] =
    {   0,
        0,    0,   44,   45,   46,   47,   48,   50,   81,  112,
      143,    0,  384,  503,   56,  503,   59,  359,   49,   64,
      300,   50,  503,  298,   51,   53,   71,   82,  161,  192,
      299,   46,  295,   48,   83,   92,   89,   90,   77,  503,
      503,  302,  503,   99,  285,  104,  105,  305,  105,  284,
      217,   81,  122,  503,  503,  121,  503,  302,  136,  503,
      279,  265,  503,  503,  503,  503,  246,  503,  503,  129,
      103,  271,  106,  503,  100,    0,    0,  101,    0,  256,
      503,  503,  503,  246,  503,  129,  234,  503,  242,  162,
      186,  503,  503,  503,  237,  186,  151,  171,  208,  503,

      152,  503,  175,  144,  148,  149,  147,  118,  503,  173,
      503,  205,  202,  503,  176,  503,  205,  503,  503,  222,
      228,  149,   54,  234,  220,  258,  232,  220,  243,  271,
       50,  503,  284,  278,  290,  503,  292,  503,  503,  325,
      339,  353,  367,  380,  391,  405,  419,  433,  442,  451,
      237,  460,  464,  298,  310,  473,  481,  489
    } ;

static const flex_int16_t yy_def[159] =
    {   0,
      139,    1,  140,  140,  140,  140,  141,  141,  142,  142,
      142,   11,  139,  139,  139,  139,  139,  139,  143,  144,
      139,  139,  139,  139,  139,  139,  139,  139,  139,  139,
      139,  139,  139,  139,  145,  139,  145,  145,  139,  139,
      139,  139,  139,  139,  146,  146,  146,  147,  139,  148,
      139,  149,  139,  139,  139,  143,  139,  143,  144,  139,
      139,  150,  139,  139,  139,  139,  139,  139,  139,   67,
       29,  139,  151,  139,  139,  152,   30,  139,  153,  139,
      139,  139,  139,  139,  139,  145,  139,  139,  139,  145,
      145,  139,  139,  139,  139,  146,  146,  146,  147,  139,

      148,  139,  139,  149,   59,  150,  139,  154,  139,  155,
      139,  139,  156,  139,  152,  139,  145,  139,  139,  145,
      145,  139,  150,  139,  157,  139,  158,  152,  139,  145,
      139,  139,  145,  139,  145,  139,  145,  139,    0,  139,
      139,  139,  139,  139,  139,  139,  139,  139,  139,  139,
      139,  139,  139,  139,  139,  139,  139,  139
    } ;

static const flex_int16_t yy_nxt[550] =
    {   0,
       14,   15,   16,   17,   18,   19,   20,   21,   22,   23,
       23,   24,   25,   26,   27,   28,   29,   30,   30,   30,
       30,   31,   32,   33,   34,   35,   35,   35,   35,   35,
       23,   36,   24,   14,   37,   35,   35,   35,   35,   35,
       35,   35,   38,   35,   35,   39,   41,   41,   43,   43,
       16,   46,   16,   46,   57,   42,   42,   53,   64,   53,
       53,   54,   53,   65,  134,   59,   66,   59,   80,   81,
       60,   83,   84,   63,   63,  139,   63,   44,   44,   47,
       58,   47,   15,   16,   17,   61,   48,   67,   67,   67,
       67,   67,   85,   68,   88,   89,   49,   69,   85,   85,

       63,   94,   95,   50,   87,   63,   54,   96,   98,   78,
       87,   87,   36,   15,   16,   17,   68,   48,  112,  112,
       69,   78,   92,   53,   90,   53,   57,   49,  114,  116,
      124,  124,  139,   91,   50,   97,   97,   59,   85,   59,
      114,  116,  139,   36,   15,   16,   17,  139,   48,  139,
       87,  139,   58,   96,   98,  110,  111,   61,   49,   51,
       52,   52,   52,   52,  110,  111,  131,  111,  123,  139,
      107,   85,   78,   96,   36,   70,  102,   71,   71,   71,
       71,   72,   97,   87,   78,  126,  126,   73,   74,   75,
       76,  103,  103,  103,  103,   85,   73,   74,  121,   74,

      122,   75,   97,   75,  128,   76,   70,   87,   77,   77,
       77,   77,   77,  100,   85,   75,  129,   97,   73,   74,
       78,  113,  113,  113,  113,  113,   87,   73,   74,   74,
       74,  139,   78,  103,  103,  103,  103,   85,   74,   94,
       74,  113,  113,  139,   88,   75,   76,  109,  128,   87,
      125,  125,  125,  125,  125,  120,  109,   75,  109,  111,
      129,   76,   67,   67,   67,   67,   67,  130,  111,  119,
      111,  132,  108,  109,  127,  127,  127,  127,  127,  118,
       85,  108,  109,  132,  109,   70,  107,   72,   72,   72,
       72,   72,   87,   85,  136,  136,  136,   73,   74,   85,

      105,  138,  125,  125,  139,   87,   73,   74,  102,   74,
      100,   87,  133,   87,  127,  127,   97,   93,   82,  135,
       79,   63,  136,   63,  137,   40,   40,   40,   40,   40,
       40,   40,   40,   40,   40,   40,   40,   40,   40,   45,
       45,   45,   45,   45,   45,   45,   45,   45,   45,   45,
       45,   45,   45,   14,   14,   14,   14,   14,   14,   14,
       14,   14,   14,   14,   14,   14,   14,   56,   56,   56,
       56,   56,   56,   56,   56,   56,   56,   56,   56,   56,
       56,   62,   55,  139,  139,  139,   62,   62,   62,   62,
      139,   62,   62,   62,   86,  139,   86,   86,   86,   86,

       86,  139,   86,   86,   86,   96,   96,  139,   96,   96,
       96,   96,   96,   96,   96,   96,   96,   96,   96,   99,
       99,   99,   99,   99,   99,   99,   99,   99,   99,   99,
       99,   99,   99,  101,  101,  101,  101,  101,  101,  101,
      101,  101,  101,  101,  101,  101,  101,  104,  139,  139,
      139,  104,  139,  139,  139,  104,  106,  106,  106,  106,
      106,  139,  106,  106,  106,  115,  139,  115,  115,  115,
      115,  117,  117,  117,  139,  117,  117,  117,  113,  139,
      139,  113,  139,  139,  139,  113,  125,  139,  139,  125,
      139,  139,  139,  125,  127,  139,  139,  127,  139,  139,

      139,  127,   13,  139,  139,  139,  139,  139,  139,  139,
      139,  139,  139,  139,  139,  139,  139,  139,  139,  139,
      139,  139,  139,  139,  139,  139,  139,  139,  139,  139,
      139,  139,  139,  139,  139,  139,  139,  139,  139,  139,
      139,  139,  139,  139,  139,  139,  139,  139,  139
    } ;

static const flex_int16_t yy_chk[550] =
    {   0,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    3,    4,    5,    6,
        7,    7,    8,    8,   19,    3,    4,   15,   22,   15,
       17,   17,   17,   25,  131,   20,   26,   20,   32,   32,
       20,   34,   34,   22,   25,  123,   26,    5,    6,    7,
       19,    8,    9,    9,    9,   20,    9,   27,   27,   27,
       27,   27,   35,   28,   36,   36,    9,   28,   37,   38,

       39,   44,   44,    9,   35,   28,   46,   47,   47,   52,
       37,   38,    9,   10,   10,   10,   49,   10,   73,   73,
       49,   52,   39,   53,   37,   53,   56,   10,   75,   78,
      108,  108,   71,   38,   10,   46,   47,   59,   86,   59,
       75,   78,   59,   10,   11,   11,   11,   71,   11,  105,
       86,  105,   56,   97,   97,   70,   70,   59,   11,   11,
       11,   11,   11,   11,   70,   70,  122,   70,  107,  105,
      106,   90,  104,   98,   11,   29,  101,   29,   29,   29,
       29,   29,   97,   90,  104,  110,  110,   29,   29,   29,
       29,  103,  103,  103,  103,   91,   29,   29,   90,   29,

       91,   29,   98,  103,  115,   29,   30,   91,   30,   30,
       30,   30,   30,   99,  117,  103,  115,   96,   30,   30,
       30,  112,  112,  112,  112,  112,  117,   30,   30,  113,
       30,  120,   30,   51,   51,   51,   51,  121,  113,   95,
      113,  151,  151,  120,   89,   51,   51,  125,  128,  121,
      124,  124,  124,  124,  124,   87,  125,   51,  125,  127,
      128,   51,   67,   67,   67,   67,   67,  121,  127,   84,
      127,  129,   67,   67,  126,  126,  126,  126,  126,   80,
      130,   67,   67,  129,   67,   72,   62,   72,   72,   72,
       72,   72,  130,  133,  134,  134,  134,   72,   72,  135,

       61,  137,  154,  154,   58,  133,   72,   72,   50,   72,
       48,  135,  130,  137,  155,  155,   45,   42,   33,  133,
       31,   24,  134,   21,  135,  140,  140,  140,  140,  140,
      140,  140,  140,  140,  140,  140,  140,  140,  140,  141,
      141,  141,  141,  141,  141,  141,  141,  141,  141,  141,
      141,  141,  141,  142,  142,  142,  142,  142,  142,  142,
      142,  142,  142,  142,  142,  142,  142,  143,  143,  143,
      143,  143,  143,  143,  143,  143,  143,  143,  143,  143,
      143,  144,   18,   13,    0,    0,  144,  144,  144,  144,
        0,  144,  144,  144,  145,    0,  145,  145,  145,  145,

      145,    0,  145,  145,  145,  146,  146,    0,  146,  146,
      146,  146,  146,  146,  146,  146,  146,  146,  146,  147,
      147,  147,  147,  147,  147,  147,  147,  147,  147,  147,
      147,  147,  147,  148,  148,  148,  148,  148,  148,  148,
      148,  148,  148,  148,  148,  148,  148,  149,    0,    0,
        0,  149,    0,    0,    0,  149,  150,  150,  150,  150,
      150,    0,  150,  150,  150,  152,    0,  152,  152,  152,
      152,  153,  153,  153,    0,  153,  153,  153,  156,    0,
        0,  156,    0,    0,    0,  156,  157,    0,    0,  157,
        0,    0,    0,  157,  158,    0,    0,  158,    0,    0,

        0,  158,  139,  139,  139,  139,  139,  139,  139,  139,
      139,  139,  139,  139,  139,  139,  139,  139,  139,  139,
      139,  139,  139,  139,  139,  139,  139,  139,  139,  139,
      139,  139,  139,  139,  139,  139,  139,  139,  139,  139,
      139,  139,  139,  139,  139,  139,  139,  139,  139
    } ;

/* The intent behind this definition is that it'll catch
 * any uses of REJECT which flex missed.
 */
#define REJECT reject_used_but_not_detected
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
#line 1 "libs/vkd3d-shader/preproc.l"
/*
 * HLSL preprocessor
 *
 * Copyright 2020 Zebediah Figura for CodeWeavers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
#line 22 "libs/vkd3d-shader/preproc.l"

#include "preproc.tab.h"

#undef ERROR  /* defined in wingdi.h */

#define YYSTYPE PREPROC_YYSTYPE
#define YYLTYPE PREPROC_YYLTYPE

#define YY_DECL static int preproc_lexer_lex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)

static struct preproc_expansion *preproc_get_top_expansion(struct preproc_ctx *ctx)
{
    if (!ctx->expansion_count)
        return NULL;
    return &ctx->expansion_stack[ctx->expansion_count - 1];
}

static void update_location(struct preproc_ctx *ctx);

#define YY_USER_ACTION update_location(yyget_extra(yyscanner));

#line 864 "libs/vkd3d-shader/preproc.yy.c"
#define YY_NO_INPUT 1
#line 60 "libs/vkd3d-shader/preproc.l"
    /* Because these can both be terminated by EOF, we need states for them. */





#line 873 "libs/vkd3d-shader/preproc.yy.c"

#define INITIAL 0
#define C_COMMENT 1
#define CXX_COMMENT 2
#define ERROR 3
#define INCLUDE 4
#define LINE 5

#ifndef YY_NO_UNISTD_H
/* Special case for "unistd.h", since it is non-ANSI. We include it way
 * down here because we want the user's section 1 to have been scanned first.
 * The user has a chance to override it with an option.
 */
#include <unistd.h>
#endif

#define YY_EXTRA_TYPE struct preproc_ctx *

/* Holds the entire state of the reentrant scanner. */
struct yyguts_t
    {

    /* User-defined. Not touched by flex. */
    YY_EXTRA_TYPE yyextra_r;

    /* The rest are the same as the globals declared in the non-reentrant scanner. */
    FILE *yyin_r, *yyout_r;
    size_t yy_buffer_stack_top; /**< index of top of stack. */
    size_t yy_buffer_stack_max; /**< capacity of stack. */
    YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
    char yy_hold_char;
    int yy_n_chars;
    int yyleng_r;
    char *yy_c_buf_p;
    int yy_init;
    int yy_start;
    int yy_did_buffer_switch_on_eof;
    int yy_start_stack_ptr;
    int yy_start_stack_depth;
    int *yy_start_stack;
    yy_state_type yy_last_accepting_state;
    char* yy_last_accepting_cpos;

    int yylineno_r;
    int yy_flex_debug_r;

    char *yytext_r;
    int yy_more_flag;
    int yy_more_len;

    YYSTYPE * yylval_r;

    YYLTYPE * yylloc_r;

    }; /* end struct yyguts_t */

static int yy_init_globals ( yyscan_t yyscanner );

    /* This must go here because YYSTYPE and YYLTYPE are included
     * from bison output in section 1.*/
    #    define yylval yyg->yylval_r
    
    #    define yylloc yyg->yylloc_r
    
int yylex_init (yyscan_t* scanner);

int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);

/* Accessor methods to globals.
   These are made visible to non-reentrant scanners for convenience. */

int yylex_destroy ( yyscan_t yyscanner );

int yyget_debug ( yyscan_t yyscanner );

void yyset_debug ( int debug_flag , yyscan_t yyscanner );

YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );

void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );

FILE *yyget_in ( yyscan_t yyscanner );

void yyset_in  ( FILE * _in_str , yyscan_t yyscanner );

FILE *yyget_out ( yyscan_t yyscanner );

void yyset_out  ( FILE * _out_str , yyscan_t yyscanner );

			int yyget_leng ( yyscan_t yyscanner );

char *yyget_text ( yyscan_t yyscanner );

int yyget_lineno ( yyscan_t yyscanner );

void yyset_lineno ( int _line_number , yyscan_t yyscanner );

int yyget_column  ( yyscan_t yyscanner );

void yyset_column ( int _column_no , yyscan_t yyscanner );

YYSTYPE * yyget_lval ( yyscan_t yyscanner );

void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );

       YYLTYPE *yyget_lloc ( yyscan_t yyscanner );
    
        void yyset_lloc ( YYLTYPE * yylloc_param , yyscan_t yyscanner );
    
/* Macros after this point can all be overridden by user definitions in
 * section 1.
 */

#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap ( yyscan_t yyscanner );
#else
extern int yywrap ( yyscan_t yyscanner );
#endif
#endif

#ifndef YY_NO_UNPUT
    
#endif

#ifndef yytext_ptr
static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
#endif

#ifdef YY_NEED_STRLEN
static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
#endif

#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput ( yyscan_t yyscanner );
#else
static int input ( yyscan_t yyscanner );
#endif

#endif

    static void yy_push_state ( int _new_state , yyscan_t yyscanner);
    
    static void yy_pop_state ( yyscan_t yyscanner );
    
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif

/* Copy whatever the last rule matched to the standard output. */
#ifndef ECHO
/* This used to be an fputs(), but since the string might contain NUL's,
 * we now use fwrite().
 */
#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
#endif

/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
 * is returned in "result".
 */
#ifndef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
		{ \
		int c = '*'; \
		int n; \
		for ( n = 0; n < max_size && \
			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
			buf[n] = (char) c; \
		if ( c == '\n' ) \
			buf[n++] = (char) c; \
		if ( c == EOF && ferror( yyin ) ) \
			YY_FATAL_ERROR( "input in flex scanner failed" ); \
		result = n; \
		} \
	else \
		{ \
		errno=0; \
		while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
			{ \
			if( errno != EINTR) \
				{ \
				YY_FATAL_ERROR( "input in flex scanner failed" ); \
				break; \
				} \
			errno=0; \
			clearerr(yyin); \
			} \
		}\
\

#endif

/* No semi-colon after return; correct usage is to write "yyterminate();" -
 * we don't want an extra ';' after the "return" because that will cause
 * some compilers to complain about unreachable statements.
 */
#ifndef yyterminate
#define yyterminate() return YY_NULL
#endif

/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif

/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
#endif

/* end tables serialization structures and prototypes */

/* Default declaration of generated scanner - a define so the user can
 * easily add parameters.
 */
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1

extern int yylex \
               (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner);

#define YY_DECL int yylex \
               (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
#endif /* !YY_DECL */

/* Code executed at the beginning of each rule, after yytext and yyleng
 * have been set up.
 */
#ifndef YY_USER_ACTION
#define YY_USER_ACTION
#endif

/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK /*LINTED*/break;
#endif

#define YY_RULE_SETUP \
	YY_USER_ACTION

/** The main scanner function which does all the work.
 */
YY_DECL
{
	yy_state_type yy_current_state;
	char *yy_cp, *yy_bp;
	int yy_act;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

    yylval = yylval_param;

    yylloc = yylloc_param;

	if ( !yyg->yy_init )
		{
		yyg->yy_init = 1;

#ifdef YY_USER_INIT
		YY_USER_INIT;
#endif

		if ( ! yyg->yy_start )
			yyg->yy_start = 1;	/* first start state */

		if ( ! yyin )
			yyin = stdin;

		if ( ! yyout )
			yyout = stdout;

		if ( ! YY_CURRENT_BUFFER ) {
			yyensure_buffer_stack (yyscanner);
			YY_CURRENT_BUFFER_LVALUE =
				yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
		}

		yy_load_buffer_state( yyscanner );
		}

	{
#line 73 "libs/vkd3d-shader/preproc.l"


#line 1165 "libs/vkd3d-shader/preproc.yy.c"

	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
		{
		yy_cp = yyg->yy_c_buf_p;

		/* Support of yytext. */
		*yy_cp = yyg->yy_hold_char;

		/* yy_bp points to the position in yy_ch_buf of the start of
		 * the current run.
		 */
		yy_bp = yy_cp;

		yy_current_state = yyg->yy_start;
yy_match:
		do
			{
			YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
			if ( yy_accept[yy_current_state] )
				{
				yyg->yy_last_accepting_state = yy_current_state;
				yyg->yy_last_accepting_cpos = yy_cp;
				}
			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
				{
				yy_current_state = (int) yy_def[yy_current_state];
				if ( yy_current_state >= 140 )
					yy_c = yy_meta[yy_c];
				}
			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
			++yy_cp;
			}
		while ( yy_current_state != 139 );
		yy_cp = yyg->yy_last_accepting_cpos;
		yy_current_state = yyg->yy_last_accepting_state;

yy_find_action:
		yy_act = yy_accept[yy_current_state];

		YY_DO_BEFORE_ACTION;

do_action:	/* This label is used only to access EOF actions. */

		switch ( yy_act )
	{ /* beginning of action switch */
			case 0: /* must back up */
			/* undo the effects of YY_DO_BEFORE_ACTION */
			*yy_cp = yyg->yy_hold_char;
			yy_cp = yyg->yy_last_accepting_cpos;
			yy_current_state = yyg->yy_last_accepting_state;
			goto yy_find_action;

case 1:
YY_RULE_SETUP
#line 75 "libs/vkd3d-shader/preproc.l"
{yy_push_state(CXX_COMMENT, yyscanner);}
	YY_BREAK
case 2:
YY_RULE_SETUP
#line 76 "libs/vkd3d-shader/preproc.l"
{yy_push_state(C_COMMENT, yyscanner);}
	YY_BREAK
case 3:
/* rule 3 can match eol */
YY_RULE_SETUP
#line 77 "libs/vkd3d-shader/preproc.l"
{}
	YY_BREAK
case 4:
/* rule 4 can match eol */
YY_RULE_SETUP
#line 78 "libs/vkd3d-shader/preproc.l"
{
        yy_pop_state(yyscanner);
        BEGIN(INITIAL);
        return T_NEWLINE;
    }
	YY_BREAK
case 5:
YY_RULE_SETUP
#line 83 "libs/vkd3d-shader/preproc.l"
{yy_pop_state(yyscanner);}
	YY_BREAK
case YY_STATE_EOF(C_COMMENT):
case YY_STATE_EOF(CXX_COMMENT):
#line 84 "libs/vkd3d-shader/preproc.l"
{
        yy_pop_state(yyscanner);
        BEGIN(INITIAL);
        yyterminate();
    }
	YY_BREAK
case 6:
YY_RULE_SETUP
#line 89 "libs/vkd3d-shader/preproc.l"
{}
	YY_BREAK
case 7:
/* rule 7 can match eol */
YY_RULE_SETUP
#line 90 "libs/vkd3d-shader/preproc.l"
{}
	YY_BREAK
case 8:
/* rule 8 can match eol */
YY_RULE_SETUP
#line 92 "libs/vkd3d-shader/preproc.l"
{return T_STRING;}
	YY_BREAK
case 9:
*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
yyg->yy_c_buf_p = yy_cp = yy_bp + 7;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
#line 94 "libs/vkd3d-shader/preproc.l"
{return T_DEFINED;}
	YY_BREAK
case 10:
YY_RULE_SETUP
#line 95 "libs/vkd3d-shader/preproc.l"
{return T_DEFINED;}
	YY_BREAK
case 11:
*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
yyg->yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
#line 96 "libs/vkd3d-shader/preproc.l"
{return T_IDENTIFIER_PAREN;}
	YY_BREAK
case 12:
YY_RULE_SETUP
#line 97 "libs/vkd3d-shader/preproc.l"
{return T_IDENTIFIER;}
	YY_BREAK
case 13:
YY_RULE_SETUP
#line 99 "libs/vkd3d-shader/preproc.l"
{return T_LE;}
	YY_BREAK
case 14:
YY_RULE_SETUP
#line 100 "libs/vkd3d-shader/preproc.l"
{return T_GE;}
	YY_BREAK
case 15:
YY_RULE_SETUP
#line 101 "libs/vkd3d-shader/preproc.l"
{return T_EQ;}
	YY_BREAK
case 16:
YY_RULE_SETUP
#line 102 "libs/vkd3d-shader/preproc.l"
{return T_NE;}
	YY_BREAK
case 17:
YY_RULE_SETUP
#line 103 "libs/vkd3d-shader/preproc.l"
{return T_AND;}
	YY_BREAK
case 18:
YY_RULE_SETUP
#line 104 "libs/vkd3d-shader/preproc.l"
{return T_OR;}
	YY_BREAK
/* We have no use for floats, but shouldn't parse them as integers. */
case 19:
YY_RULE_SETUP
#line 108 "libs/vkd3d-shader/preproc.l"
{return T_TEXT;}
	YY_BREAK
case 20:
YY_RULE_SETUP
#line 109 "libs/vkd3d-shader/preproc.l"
{return T_TEXT;}
	YY_BREAK
case 21:
YY_RULE_SETUP
#line 110 "libs/vkd3d-shader/preproc.l"
{return T_TEXT;}
	YY_BREAK
case 22:
YY_RULE_SETUP
#line 111 "libs/vkd3d-shader/preproc.l"
{return T_TEXT;}
	YY_BREAK
case 23:
YY_RULE_SETUP
#line 112 "libs/vkd3d-shader/preproc.l"
{return T_INTEGER;}
	YY_BREAK
case 24:
YY_RULE_SETUP
#line 113 "libs/vkd3d-shader/preproc.l"
{return T_INTEGER;}
	YY_BREAK
case 25:
YY_RULE_SETUP
#line 114 "libs/vkd3d-shader/preproc.l"
{return T_INTEGER;}
	YY_BREAK
case 26:
YY_RULE_SETUP
#line 116 "libs/vkd3d-shader/preproc.l"
{return T_CONCAT;}
	YY_BREAK
case 27:
YY_RULE_SETUP
#line 118 "libs/vkd3d-shader/preproc.l"
{return T_TEXT;}
	YY_BREAK
case 28:
YY_RULE_SETUP
#line 119 "libs/vkd3d-shader/preproc.l"
{return T_TEXT;}
	YY_BREAK
case 29:
YY_RULE_SETUP
#line 120 "libs/vkd3d-shader/preproc.l"
{return T_TEXT;}
	YY_BREAK
case 30:
YY_RULE_SETUP
#line 121 "libs/vkd3d-shader/preproc.l"
{return T_TEXT;}
	YY_BREAK
case 31:
YY_RULE_SETUP
#line 122 "libs/vkd3d-shader/preproc.l"
{return T_TEXT;}
	YY_BREAK
/* Native doesn't preserve these tokens when running the preprocessor on its
     * own, but there's no good reason to emulate that difference yet. */
case 32:
YY_RULE_SETUP
#line 126 "libs/vkd3d-shader/preproc.l"
{return T_TEXT;}
	YY_BREAK
case 33:
/* rule 33 can match eol */
YY_RULE_SETUP
#line 128 "libs/vkd3d-shader/preproc.l"
{return T_STRING;}
	YY_BREAK
case 34:
/* rule 34 can match eol */
YY_RULE_SETUP
#line 129 "libs/vkd3d-shader/preproc.l"
{return T_STRING;}
	YY_BREAK
/* C strings (including escaped quotes). */
case 35:
/* rule 35 can match eol */
YY_RULE_SETUP
#line 132 "libs/vkd3d-shader/preproc.l"
{return T_TEXT;}
	YY_BREAK
case 36:
YY_RULE_SETUP
#line 134 "libs/vkd3d-shader/preproc.l"
{
        struct preproc_ctx *ctx = yyget_extra(yyscanner);
        const char *p;

        if (!ctx->last_was_newline)
        {
            struct preproc_expansion *exp;

            /* Stringification is only done for function-like macro bodies.
             * Anywhere else, we need to parse it as two separate tokens.
             * We could use a state for this, but yyless() is easier and cheap.
             */

            if ((exp = preproc_get_top_expansion(ctx)) && exp->macro && exp->macro->arg_count)
                return T_HASHSTRING;

            yyless(1);
            return T_TEXT;
        }

        for (p = yytext + 1; strchr(" \t", *p); ++p)
            ;

        if (!strcmp(p, "error"))
        {
            BEGIN(ERROR);
            return T_ERROR;
        }

        if (!strcmp(p, "include"))
        {
            BEGIN(INCLUDE);
            return T_INCLUDE;
        }

        if (!strcmp(p, "line"))
        {
            BEGIN(LINE);
            return T_LINE;
        }

        if (!strcmp(p, "define"))
            return T_DEFINE;
        if (!strcmp(p, "elif"))
            return T_ELIF;
        if (!strcmp(p, "else"))
            return T_ELSE;
        if (!strcmp(p, "endif"))
            return T_ENDIF;
        if (!strcmp(p, "if"))
            return T_IF;
        if (!strcmp(p, "ifdef"))
            return T_IFDEF;
        if (!strcmp(p, "ifndef"))
            return T_IFNDEF;
        if (!strcmp(p, "pragma"))
            return T_PRAGMA;
        if (!strcmp(p, "undef"))
            return T_UNDEF;

        preproc_warning(ctx, yyget_lloc(yyscanner), VKD3D_SHADER_WARNING_PP_UNKNOWN_DIRECTIVE,
                "Ignoring unknown directive \"%s\".", yytext);
        return T_TEXT;
    }
	YY_BREAK
case 37:
/* rule 37 can match eol */
YY_RULE_SETUP
#line 199 "libs/vkd3d-shader/preproc.l"
{}
	YY_BREAK
case 38:
/* rule 38 can match eol */
YY_RULE_SETUP
#line 200 "libs/vkd3d-shader/preproc.l"
{
        BEGIN(INITIAL);
        return T_NEWLINE;
    }
	YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(INCLUDE):
case YY_STATE_EOF(ERROR):
case YY_STATE_EOF(LINE):
#line 204 "libs/vkd3d-shader/preproc.l"
{
        BEGIN(INITIAL);
        yyterminate();
    }
	YY_BREAK
case 39:
YY_RULE_SETUP
#line 209 "libs/vkd3d-shader/preproc.l"
{}
	YY_BREAK
case 40:
YY_RULE_SETUP
#line 210 "libs/vkd3d-shader/preproc.l"
{return yytext[0];}
	YY_BREAK
case 41:
YY_RULE_SETUP
#line 211 "libs/vkd3d-shader/preproc.l"
{return T_TEXT;}
	YY_BREAK
case 42:
YY_RULE_SETUP
#line 213 "libs/vkd3d-shader/preproc.l"
YY_FATAL_ERROR( "flex scanner jammed" );
	YY_BREAK
#line 1536 "libs/vkd3d-shader/preproc.yy.c"

	case YY_END_OF_BUFFER:
		{
		/* Amount of text matched not including the EOB char. */
		int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;

		/* Undo the effects of YY_DO_BEFORE_ACTION. */
		*yy_cp = yyg->yy_hold_char;
		YY_RESTORE_YY_MORE_OFFSET

		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
			{
			/* We're scanning a new file or input source.  It's
			 * possible that this happened because the user
			 * just pointed yyin at a new source and called
			 * yylex().  If so, then we have to assure
			 * consistency between YY_CURRENT_BUFFER and our
			 * globals.  Here is the right place to do so, because
			 * this is the first action (other than possibly a
			 * back-up) that will match for the new input source.
			 */
			yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
			YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
			}

		/* Note that here we test for yy_c_buf_p "<=" to the position
		 * of the first EOB in the buffer, since yy_c_buf_p will
		 * already have been incremented past the NUL character
		 * (since all states make transitions on EOB to the
		 * end-of-buffer state).  Contrast this with the test
		 * in input().
		 */
		if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
			{ /* This was really a NUL. */
			yy_state_type yy_next_state;

			yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;

			yy_current_state = yy_get_previous_state( yyscanner );

			/* Okay, we're now positioned to make the NUL
			 * transition.  We couldn't have
			 * yy_get_previous_state() go ahead and do it
			 * for us because it doesn't know how to deal
			 * with the possibility of jamming (and we don't
			 * want to build jamming into it because then it
			 * will run more slowly).
			 */

			yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);

			yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;

			if ( yy_next_state )
				{
				/* Consume the NUL. */
				yy_cp = ++yyg->yy_c_buf_p;
				yy_current_state = yy_next_state;
				goto yy_match;
				}

			else
				{
				yy_cp = yyg->yy_last_accepting_cpos;
				yy_current_state = yyg->yy_last_accepting_state;
				goto yy_find_action;
				}
			}

		else switch ( yy_get_next_buffer( yyscanner ) )
			{
			case EOB_ACT_END_OF_FILE:
				{
				yyg->yy_did_buffer_switch_on_eof = 0;

				if ( yywrap( yyscanner ) )
					{
					/* Note: because we've taken care in
					 * yy_get_next_buffer() to have set up
					 * yytext, we can now set up
					 * yy_c_buf_p so that if some total
					 * hoser (like flex itself) wants to
					 * call the scanner after we return the
					 * YY_NULL, it'll still work - another
					 * YY_NULL will get returned.
					 */
					yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;

					yy_act = YY_STATE_EOF(YY_START);
					goto do_action;
					}

				else
					{
					if ( ! yyg->yy_did_buffer_switch_on_eof )
						YY_NEW_FILE;
					}
				break;
				}

			case EOB_ACT_CONTINUE_SCAN:
				yyg->yy_c_buf_p =
					yyg->yytext_ptr + yy_amount_of_matched_text;

				yy_current_state = yy_get_previous_state( yyscanner );

				yy_cp = yyg->yy_c_buf_p;
				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
				goto yy_match;

			case EOB_ACT_LAST_MATCH:
				yyg->yy_c_buf_p =
				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];

				yy_current_state = yy_get_previous_state( yyscanner );

				yy_cp = yyg->yy_c_buf_p;
				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
				goto yy_find_action;
			}
		break;
		}

	default:
		YY_FATAL_ERROR(
			"fatal flex scanner internal error--no action found" );
	} /* end of action switch */
		} /* end of scanning one token */
	} /* end of user's declarations */
} /* end of yylex */

/* yy_get_next_buffer - try to read in a new buffer
 *
 * Returns a code representing an action:
 *	EOB_ACT_LAST_MATCH -
 *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
 *	EOB_ACT_END_OF_FILE - end of file
 */
static int yy_get_next_buffer (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
	char *source = yyg->yytext_ptr;
	int number_to_move, i;
	int ret_val;

	if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
		YY_FATAL_ERROR(
		"fatal flex scanner internal error--end of buffer missed" );

	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
		{ /* Don't try to fill the buffer, so this is an EOF. */
		if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
			{
			/* We matched a single character, the EOB, so
			 * treat this as a final EOF.
			 */
			return EOB_ACT_END_OF_FILE;
			}

		else
			{
			/* We matched some text prior to the EOB, first
			 * process it.
			 */
			return EOB_ACT_LAST_MATCH;
			}
		}

	/* Try to read more data. */

	/* First move last chars to start of buffer. */
	number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);

	for ( i = 0; i < number_to_move; ++i )
		*(dest++) = *(source++);

	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
		/* don't do the read, it's not guaranteed to return an EOF,
		 * just force an EOF
		 */
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;

	else
		{
			int num_to_read =
			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;

		while ( num_to_read <= 0 )
			{ /* Not enough room in the buffer - grow it. */

			/* just a shorter name for the current buffer */
			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;

			int yy_c_buf_p_offset =
				(int) (yyg->yy_c_buf_p - b->yy_ch_buf);

			if ( b->yy_is_our_buffer )
				{
				int new_size = b->yy_buf_size * 2;

				if ( new_size <= 0 )
					b->yy_buf_size += b->yy_buf_size / 8;
				else
					b->yy_buf_size *= 2;

				b->yy_ch_buf = (char *)
					/* Include room in for 2 EOB chars. */
					yyrealloc( (void *) b->yy_ch_buf,
							 (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
				}
			else
				/* Can't grow it, we don't own it. */
				b->yy_ch_buf = NULL;

			if ( ! b->yy_ch_buf )
				YY_FATAL_ERROR(
				"fatal error - scanner input buffer overflow" );

			yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];

			num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
						number_to_move - 1;

			}

		if ( num_to_read > YY_READ_BUF_SIZE )
			num_to_read = YY_READ_BUF_SIZE;

		/* Read in more data. */
		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
			yyg->yy_n_chars, num_to_read );

		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
		}

	if ( yyg->yy_n_chars == 0 )
		{
		if ( number_to_move == YY_MORE_ADJ )
			{
			ret_val = EOB_ACT_END_OF_FILE;
			yyrestart( yyin  , yyscanner);
			}

		else
			{
			ret_val = EOB_ACT_LAST_MATCH;
			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
				YY_BUFFER_EOF_PENDING;
			}
		}

	else
		ret_val = EOB_ACT_CONTINUE_SCAN;

	if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
		/* Extend the array by 50%, plus the number we really need. */
		int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
			(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
		/* "- 2" to take care of EOB's */
		YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
	}

	yyg->yy_n_chars += number_to_move;
	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;

	yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];

	return ret_val;
}

/* yy_get_previous_state - get the state just before the EOB char was reached */

    static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
{
	yy_state_type yy_current_state;
	char *yy_cp;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	yy_current_state = yyg->yy_start;

	for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
		{
		YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
		if ( yy_accept[yy_current_state] )
			{
			yyg->yy_last_accepting_state = yy_current_state;
			yyg->yy_last_accepting_cpos = yy_cp;
			}
		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
			{
			yy_current_state = (int) yy_def[yy_current_state];
			if ( yy_current_state >= 140 )
				yy_c = yy_meta[yy_c];
			}
		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
		}

	return yy_current_state;
}

/* yy_try_NUL_trans - try to make a transition on the NUL character
 *
 * synopsis
 *	next_state = yy_try_NUL_trans( current_state );
 */
    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
{
	int yy_is_jam;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
	char *yy_cp = yyg->yy_c_buf_p;

	YY_CHAR yy_c = 1;
	if ( yy_accept[yy_current_state] )
		{
		yyg->yy_last_accepting_state = yy_current_state;
		yyg->yy_last_accepting_cpos = yy_cp;
		}
	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
		{
		yy_current_state = (int) yy_def[yy_current_state];
		if ( yy_current_state >= 140 )
			yy_c = yy_meta[yy_c];
		}
	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
	yy_is_jam = (yy_current_state == 139);

	(void)yyg;
	return yy_is_jam ? 0 : yy_current_state;
}

#ifndef YY_NO_UNPUT

#endif

#ifndef YY_NO_INPUT
#ifdef __cplusplus
    static int yyinput (yyscan_t yyscanner)
#else
    static int input  (yyscan_t yyscanner)
#endif

{
	int c;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	*yyg->yy_c_buf_p = yyg->yy_hold_char;

	if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
		{
		/* yy_c_buf_p now points to the character we want to return.
		 * If this occurs *before* the EOB characters, then it's a
		 * valid NUL; if not, then we've hit the end of the buffer.
		 */
		if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
			/* This was really a NUL. */
			*yyg->yy_c_buf_p = '\0';

		else
			{ /* need more input */
			int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
			++yyg->yy_c_buf_p;

			switch ( yy_get_next_buffer( yyscanner ) )
				{
				case EOB_ACT_LAST_MATCH:
					/* This happens because yy_g_n_b()
					 * sees that we've accumulated a
					 * token and flags that we need to
					 * try matching the token before
					 * proceeding.  But for input(),
					 * there's no matching to consider.
					 * So convert the EOB_ACT_LAST_MATCH
					 * to EOB_ACT_END_OF_FILE.
					 */

					/* Reset buffer status. */
					yyrestart( yyin , yyscanner);

					/*FALLTHROUGH*/

				case EOB_ACT_END_OF_FILE:
					{
					if ( yywrap( yyscanner ) )
						return 0;

					if ( ! yyg->yy_did_buffer_switch_on_eof )
						YY_NEW_FILE;
#ifdef __cplusplus
					return yyinput(yyscanner);
#else
					return input(yyscanner);
#endif
					}

				case EOB_ACT_CONTINUE_SCAN:
					yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
					break;
				}
			}
		}

	c = *(unsigned char *) yyg->yy_c_buf_p;	/* cast for 8-bit char's */
	*yyg->yy_c_buf_p = '\0';	/* preserve yytext */
	yyg->yy_hold_char = *++yyg->yy_c_buf_p;

	return c;
}
#endif	/* ifndef YY_NO_INPUT */

/** Immediately switch to a different input stream.
 * @param input_file A readable stream.
 * @param yyscanner The scanner object.
 * @note This function does not reset the start condition to @c INITIAL .
 */
    void yyrestart  (FILE * input_file , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	if ( ! YY_CURRENT_BUFFER ){
        yyensure_buffer_stack (yyscanner);
		YY_CURRENT_BUFFER_LVALUE =
            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
	}

	yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
	yy_load_buffer_state( yyscanner );
}

/** Switch to a different input buffer.
 * @param new_buffer The new input buffer.
 * @param yyscanner The scanner object.
 */
    void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	/* TODO. We should be able to replace this entire function body
	 * with
	 *		yypop_buffer_state();
	 *		yypush_buffer_state(new_buffer);
     */
	yyensure_buffer_stack (yyscanner);
	if ( YY_CURRENT_BUFFER == new_buffer )
		return;

	if ( YY_CURRENT_BUFFER )
		{
		/* Flush out information for old buffer. */
		*yyg->yy_c_buf_p = yyg->yy_hold_char;
		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
		}

	YY_CURRENT_BUFFER_LVALUE = new_buffer;
	yy_load_buffer_state( yyscanner );

	/* We don't actually know whether we did this switch during
	 * EOF (yywrap()) processing, but the only time this flag
	 * is looked at is after yywrap() is called, so it's safe
	 * to go ahead and always set it.
	 */
	yyg->yy_did_buffer_switch_on_eof = 1;
}

static void yy_load_buffer_state  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
	yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
	yyg->yy_hold_char = *yyg->yy_c_buf_p;
}

/** Allocate and initialize an input buffer state.
 * @param file A readable stream.
 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
 * @param yyscanner The scanner object.
 * @return the allocated buffer state.
 */
    YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
{
	YY_BUFFER_STATE b;
    
	b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
	if ( ! b )
		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );

	b->yy_buf_size = size;

	/* yy_ch_buf has to be 2 characters longer than the size given because
	 * we need to put in 2 end-of-buffer characters.
	 */
	b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
	if ( ! b->yy_ch_buf )
		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );

	b->yy_is_our_buffer = 1;

	yy_init_buffer( b, file , yyscanner);

	return b;
}

/** Destroy the buffer.
 * @param b a buffer created with yy_create_buffer()
 * @param yyscanner The scanner object.
 */
    void yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	if ( ! b )
		return;

	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;

	if ( b->yy_is_our_buffer )
		yyfree( (void *) b->yy_ch_buf , yyscanner );

	yyfree( (void *) b , yyscanner );
}

/* Initializes or reinitializes a buffer.
 * This function is sometimes called more than once on the same buffer,
 * such as during a yyrestart() or at EOF.
 */
    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)

{
	int oerrno = errno;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	yy_flush_buffer( b , yyscanner);

	b->yy_input_file = file;
	b->yy_fill_buffer = 1;

    /* If b is the current buffer, then yy_init_buffer was _probably_
     * called from yyrestart() or through yy_get_next_buffer.
     * In that case, we don't want to reset the lineno or column.
     */
    if (b != YY_CURRENT_BUFFER){
        b->yy_bs_lineno = 1;
        b->yy_bs_column = 0;
    }

        b->yy_is_interactive = 0;
    
	errno = oerrno;
}

/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
 * @param yyscanner The scanner object.
 */
    void yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	if ( ! b )
		return;

	b->yy_n_chars = 0;

	/* We always need two end-of-buffer characters.  The first causes
	 * a transition to the end-of-buffer state.  The second causes
	 * a jam in that state.
	 */
	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;

	b->yy_buf_pos = &b->yy_ch_buf[0];

	b->yy_at_bol = 1;
	b->yy_buffer_status = YY_BUFFER_NEW;

	if ( b == YY_CURRENT_BUFFER )
		yy_load_buffer_state( yyscanner );
}

/** Pushes the new state onto the stack. The new state becomes
 *  the current state. This function will allocate the stack
 *  if necessary.
 *  @param new_buffer The new state.
 *  @param yyscanner The scanner object.
 */
void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	if (new_buffer == NULL)
		return;

	yyensure_buffer_stack(yyscanner);

	/* This block is copied from yy_switch_to_buffer. */
	if ( YY_CURRENT_BUFFER )
		{
		/* Flush out information for old buffer. */
		*yyg->yy_c_buf_p = yyg->yy_hold_char;
		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
		}

	/* Only push if top exists. Otherwise, replace top. */
	if (YY_CURRENT_BUFFER)
		yyg->yy_buffer_stack_top++;
	YY_CURRENT_BUFFER_LVALUE = new_buffer;

	/* copied from yy_switch_to_buffer. */
	yy_load_buffer_state( yyscanner );
	yyg->yy_did_buffer_switch_on_eof = 1;
}

/** Removes and deletes the top of the stack, if present.
 *  The next element becomes the new top.
 *  @param yyscanner The scanner object.
 */
void yypop_buffer_state (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	if (!YY_CURRENT_BUFFER)
		return;

	yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
	YY_CURRENT_BUFFER_LVALUE = NULL;
	if (yyg->yy_buffer_stack_top > 0)
		--yyg->yy_buffer_stack_top;

	if (YY_CURRENT_BUFFER) {
		yy_load_buffer_state( yyscanner );
		yyg->yy_did_buffer_switch_on_eof = 1;
	}
}

/* Allocates the stack if it does not exist.
 *  Guarantees space for at least one push.
 */
static void yyensure_buffer_stack (yyscan_t yyscanner)
{
	yy_size_t num_to_alloc;
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

	if (!yyg->yy_buffer_stack) {

		/* First allocation is just for 2 elements, since we don't know if this
		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
		 * immediate realloc on the next call.
         */
      num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
		yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
								(num_to_alloc * sizeof(struct yy_buffer_state*)
								, yyscanner);
		if ( ! yyg->yy_buffer_stack )
			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );

		memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));

		yyg->yy_buffer_stack_max = num_to_alloc;
		yyg->yy_buffer_stack_top = 0;
		return;
	}

	if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){

		/* Increase the buffer to prepare for a possible push. */
		yy_size_t grow_size = 8 /* arbitrary grow size */;

		num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
		yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
								(yyg->yy_buffer_stack,
								num_to_alloc * sizeof(struct yy_buffer_state*)
								, yyscanner);
		if ( ! yyg->yy_buffer_stack )
			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );

		/* zero only the new slots.*/
		memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
		yyg->yy_buffer_stack_max = num_to_alloc;
	}
}

/** Setup the input buffer state to scan directly from a user-specified character buffer.
 * @param base the character buffer
 * @param size the size in bytes of the character buffer
 * @param yyscanner The scanner object.
 * @return the newly allocated buffer state object.
 */
YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
{
	YY_BUFFER_STATE b;
    
	if ( size < 2 ||
	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
	     base[size-1] != YY_END_OF_BUFFER_CHAR )
		/* They forgot to leave room for the EOB's. */
		return NULL;

	b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
	if ( ! b )
		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );

	b->yy_buf_size = (int) (size - 2);	/* "- 2" to take care of EOB's */
	b->yy_buf_pos = b->yy_ch_buf = base;
	b->yy_is_our_buffer = 0;
	b->yy_input_file = NULL;
	b->yy_n_chars = b->yy_buf_size;
	b->yy_is_interactive = 0;
	b->yy_at_bol = 1;
	b->yy_fill_buffer = 0;
	b->yy_buffer_status = YY_BUFFER_NEW;

	yy_switch_to_buffer( b , yyscanner );

	return b;
}

/** Setup the input buffer state to scan a string. The next call to yylex() will
 * scan from a @e copy of @a str.
 * @param yystr a NUL-terminated string to scan
 * @param yyscanner The scanner object.
 * @return the newly allocated buffer state object.
 * @note If you want to scan bytes that may contain NUL values, then use
 *       yy_scan_bytes() instead.
 */
YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
{
    
	return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
}

/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
 * scan from a @e copy of @a bytes.
 * @param yybytes the byte buffer to scan
 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
 * @param yyscanner The scanner object.
 * @return the newly allocated buffer state object.
 */
YY_BUFFER_STATE yy_scan_bytes  (const char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
{
	YY_BUFFER_STATE b;
	char *buf;
	yy_size_t n;
	int i;
    
	/* Get memory for full buffer, including space for trailing EOB's. */
	n = (yy_size_t) (_yybytes_len + 2);
	buf = (char *) yyalloc( n , yyscanner );
	if ( ! buf )
		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );

	for ( i = 0; i < _yybytes_len; ++i )
		buf[i] = yybytes[i];

	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;

	b = yy_scan_buffer( buf, n , yyscanner);
	if ( ! b )
		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );

	/* It's okay to grow etc. this buffer, and we should throw it
	 * away when we're done.
	 */
	b->yy_is_our_buffer = 1;

	return b;
}

    static void yy_push_state (int  _new_state , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth )
		{
		yy_size_t new_size;

		yyg->yy_start_stack_depth += YY_START_STACK_INCR;
		new_size = (yy_size_t) yyg->yy_start_stack_depth * sizeof( int );

		if ( ! yyg->yy_start_stack )
			yyg->yy_start_stack = (int *) yyalloc( new_size , yyscanner );

		else
			yyg->yy_start_stack = (int *) yyrealloc(
					(void *) yyg->yy_start_stack, new_size , yyscanner );

		if ( ! yyg->yy_start_stack )
			YY_FATAL_ERROR( "out of memory expanding start-condition stack" );
		}

	yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START;

	BEGIN(_new_state);
}

    static void yy_pop_state  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	if ( --yyg->yy_start_stack_ptr < 0 )
		YY_FATAL_ERROR( "start-condition stack underflow" );

	BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]);
}

#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif

static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
{
	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	(void)yyg;
	fprintf( stderr, "%s\n", msg );
	exit( YY_EXIT_FAILURE );
}

/* Redefine yyless() so it works in section 3 code. */

#undef yyless
#define yyless(n) \
	do \
		{ \
		/* Undo effects of setting up yytext. */ \
        int yyless_macro_arg = (n); \
        YY_LESS_LINENO(yyless_macro_arg);\
		yytext[yyleng] = yyg->yy_hold_char; \
		yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
		yyg->yy_hold_char = *yyg->yy_c_buf_p; \
		*yyg->yy_c_buf_p = '\0'; \
		yyleng = yyless_macro_arg; \
		} \
	while ( 0 )

/* Accessor  methods (get/set functions) to struct members. */

/** Get the user-defined data for this scanner.
 * @param yyscanner The scanner object.
 */
YY_EXTRA_TYPE yyget_extra  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yyextra;
}

/** Get the current line number.
 * @param yyscanner The scanner object.
 */
int yyget_lineno  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

        if (! YY_CURRENT_BUFFER)
            return 0;
    
    return yylineno;
}

/** Get the current column number.
 * @param yyscanner The scanner object.
 */
int yyget_column  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

        if (! YY_CURRENT_BUFFER)
            return 0;
    
    return yycolumn;
}

/** Get the input stream.
 * @param yyscanner The scanner object.
 */
FILE *yyget_in  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yyin;
}

/** Get the output stream.
 * @param yyscanner The scanner object.
 */
FILE *yyget_out  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yyout;
}

/** Get the length of the current token.
 * @param yyscanner The scanner object.
 */
int yyget_leng  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yyleng;
}

/** Get the current token.
 * @param yyscanner The scanner object.
 */

char *yyget_text  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yytext;
}

/** Set the user-defined data. This data is never touched by the scanner.
 * @param user_defined The data to be associated with this scanner.
 * @param yyscanner The scanner object.
 */
void yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yyextra = user_defined ;
}

/** Set the current line number.
 * @param _line_number line number
 * @param yyscanner The scanner object.
 */
void yyset_lineno (int  _line_number , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

        /* lineno is only valid if an input buffer exists. */
        if (! YY_CURRENT_BUFFER )
           YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
    
    yylineno = _line_number;
}

/** Set the current column.
 * @param _column_no column number
 * @param yyscanner The scanner object.
 */
void yyset_column (int  _column_no , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

        /* column is only valid if an input buffer exists. */
        if (! YY_CURRENT_BUFFER )
           YY_FATAL_ERROR( "yyset_column called with no buffer" );
    
    yycolumn = _column_no;
}

/** Set the input stream. This does not discard the current
 * input buffer.
 * @param _in_str A readable stream.
 * @param yyscanner The scanner object.
 * @see yy_switch_to_buffer
 */
void yyset_in (FILE *  _in_str , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yyin = _in_str ;
}

void yyset_out (FILE *  _out_str , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yyout = _out_str ;
}

int yyget_debug  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yy_flex_debug;
}

void yyset_debug (int  _bdebug , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yy_flex_debug = _bdebug ;
}

/* Accessor methods for yylval and yylloc */

YYSTYPE * yyget_lval  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yylval;
}

void yyset_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yylval = yylval_param;
}

YYLTYPE *yyget_lloc  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    return yylloc;
}
    
void yyset_lloc (YYLTYPE *  yylloc_param , yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    yylloc = yylloc_param;
}
    
/* User-visible API */

/* yylex_init is special because it creates the scanner itself, so it is
 * the ONLY reentrant function that doesn't take the scanner as the last argument.
 * That's why we explicitly handle the declaration, instead of using our macros.
 */
int yylex_init(yyscan_t* ptr_yy_globals)
{
    if (ptr_yy_globals == NULL){
        errno = EINVAL;
        return 1;
    }

    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );

    if (*ptr_yy_globals == NULL){
        errno = ENOMEM;
        return 1;
    }

    /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));

    return yy_init_globals ( *ptr_yy_globals );
}

/* yylex_init_extra has the same functionality as yylex_init, but follows the
 * convention of taking the scanner as the last argument. Note however, that
 * this is a *pointer* to a scanner, as it will be allocated by this call (and
 * is the reason, too, why this function also must handle its own declaration).
 * The user defined value in the first argument will be available to yyalloc in
 * the yyextra field.
 */
int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
{
    struct yyguts_t dummy_yyguts;

    yyset_extra (yy_user_defined, &dummy_yyguts);

    if (ptr_yy_globals == NULL){
        errno = EINVAL;
        return 1;
    }

    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );

    if (*ptr_yy_globals == NULL){
        errno = ENOMEM;
        return 1;
    }

    /* By setting to 0xAA, we expose bugs in
    yy_init_globals. Leave at 0x00 for releases. */
    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));

    yyset_extra (yy_user_defined, *ptr_yy_globals);

    return yy_init_globals ( *ptr_yy_globals );
}

static int yy_init_globals (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    /* Initialization is the same as for the non-reentrant scanner.
     * This function is called from yylex_destroy(), so don't allocate here.
     */

    yyg->yy_buffer_stack = NULL;
    yyg->yy_buffer_stack_top = 0;
    yyg->yy_buffer_stack_max = 0;
    yyg->yy_c_buf_p = NULL;
    yyg->yy_init = 0;
    yyg->yy_start = 0;

    yyg->yy_start_stack_ptr = 0;
    yyg->yy_start_stack_depth = 0;
    yyg->yy_start_stack =  NULL;

/* Defined in main.c */
#ifdef YY_STDINIT
    yyin = stdin;
    yyout = stdout;
#else
    yyin = NULL;
    yyout = NULL;
#endif

    /* For future reference: Set errno on error, since we are called by
     * yylex_init()
     */
    return 0;
}

/* yylex_destroy is for both reentrant and non-reentrant scanners. */
int yylex_destroy  (yyscan_t yyscanner)
{
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

    /* Pop the buffer stack, destroying each element. */
	while(YY_CURRENT_BUFFER){
		yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
		YY_CURRENT_BUFFER_LVALUE = NULL;
		yypop_buffer_state(yyscanner);
	}

	/* Destroy the stack itself. */
	yyfree(yyg->yy_buffer_stack , yyscanner);
	yyg->yy_buffer_stack = NULL;

    /* Destroy the start condition stack. */
        yyfree( yyg->yy_start_stack , yyscanner );
        yyg->yy_start_stack = NULL;

    /* Reset the globals. This is important in a non-reentrant scanner so the next time
     * yylex() is called, initialization will occur. */
    yy_init_globals( yyscanner);

    /* Destroy the main struct (reentrant only). */
    yyfree ( yyscanner , yyscanner );
    yyscanner = NULL;
    return 0;
}

/*
 * Internal utility routines.
 */

#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
{
	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	(void)yyg;

	int i;
	for ( i = 0; i < n; ++i )
		s1[i] = s2[i];
}
#endif

#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
{
	int n;
	for ( n = 0; s[n]; ++n )
		;

	return n;
}
#endif

void *yyalloc (yy_size_t  size , yyscan_t yyscanner)
{
	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	(void)yyg;
	return malloc(size);
}

void *yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
{
	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	(void)yyg;

	/* The cast to (char *) in the following accommodates both
	 * implementations that use char* generic pointers, and those
	 * that use void* generic pointers.  It works with the latter
	 * because both ANSI C and C++ allow castless assignment from
	 * any pointer type to void*, and deal with argument conversions
	 * as though doing an assignment.
	 */
	return realloc(ptr, size);
}

void yyfree (void * ptr , yyscan_t yyscanner)
{
	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
	(void)yyg;
	free( (char *) ptr );	/* see yyrealloc() for (char *) cast */
}

#define YYTABLES_NAME "yytables"

#line 213 "libs/vkd3d-shader/preproc.l"


static void preproc_func_state_cleanup_arg_values(struct preproc_func_state *f)
{
    const struct preproc_macro *m;
    size_t i;

    if (!(m = f->macro))
        return;

    for (i = 0; i < m->arg_count; ++i)
    {
        vkd3d_string_buffer_cleanup(&f->arg_values[i].text);
    }
    free(f->arg_values);
}

static void update_location(struct preproc_ctx *ctx)
{
    struct preproc_buffer *buffer = &preproc_get_top_file(ctx)->buffer;
    unsigned int i, leng = yyget_leng(ctx->scanner);
    const char *text = yyget_text(ctx->scanner);

    /* We want to do this here, rather than before calling yylex(), because
     * some tokens are skipped by the lexer. */

    *yyget_lloc(ctx->scanner) = buffer->location;

    for (i = 0; i < leng; ++i)
    {
        ++buffer->location.column;
        if (text[i] == '\n')
        {
            buffer->location.column = 1;
            ++buffer->location.line;
        }
    }
}

static bool preproc_is_writing(struct preproc_ctx *ctx)
{
    const struct preproc_file *file;

    /* This can happen while checking for unterminated macro invocation. */
    if (!ctx->file_count)
        return true;
    file = preproc_get_top_file(ctx);
    if (!file->if_count)
        return true;
    return file->if_stack[file->if_count - 1].current_true;
}

/* Concatenation is not done for object-like macros, but is done for both
 * function-like macro bodies and their arguments. */
static bool should_concat(struct preproc_ctx *ctx)
{
    struct preproc_macro *macro;

    if (!ctx->expansion_count)
        return false;
    macro = ctx->expansion_stack[ctx->expansion_count - 1].macro;
    return !macro || macro->arg_count;
}

static struct preproc_buffer *preproc_get_top_buffer(struct preproc_ctx *ctx)
{
    if (ctx->expansion_count)
        return &ctx->expansion_stack[ctx->expansion_count - 1].buffer;
    if (ctx->file_count)
        return &ctx->file_stack[ctx->file_count - 1].buffer;
    return NULL;
}

static void preproc_pop_buffer(struct preproc_ctx *ctx)
{
    struct preproc_buffer *buffer;

    if (ctx->expansion_count)
    {
        struct preproc_expansion *exp = &ctx->expansion_stack[ctx->expansion_count - 1];

        yy_delete_buffer(exp->buffer.lexer_buffer, ctx->scanner);

        if (exp->macro)
        {
            for (unsigned int i = 0; i < exp->macro->arg_count; ++i)
                vkd3d_string_buffer_cleanup(&exp->arg_values[i].text);
            free(exp->arg_values);
        }
        --ctx->expansion_count;
        TRACE("Expansion stack size is now %zu.\n", ctx->expansion_count);
    }
    else
    {
        struct preproc_file *file = preproc_get_top_file(ctx);

        if (ctx->file_count > 1)
            preproc_close_include(ctx, &file->code);

        if (file->if_count)
        {
            const struct vkd3d_shader_location loc = {.source_name = file->filename};

            preproc_warning(ctx, &loc, VKD3D_SHADER_WARNING_PP_UNTERMINATED_IF, "Unterminated #if block.");
        }
        vkd3d_free(file->if_stack);

        vkd3d_free(file->filename);

        yy_delete_buffer(file->buffer.lexer_buffer, ctx->scanner);

        --ctx->file_count;
        TRACE("File stack size is now %zu.\n", ctx->file_count);
    }

    if ((buffer = preproc_get_top_buffer(ctx)))
        yy_switch_to_buffer(buffer->lexer_buffer, ctx->scanner);
}

static int return_token(int token, YYSTYPE *lval, const char *text)
{
    switch (token)
    {
        case T_HASHSTRING:
        case T_IDENTIFIER:
        case T_IDENTIFIER_PAREN:
        case T_INTEGER:
        case T_STRING:
        case T_TEXT:
            if (!(lval->string = vkd3d_strdup(text)))
                return 0;
            break;
    }

    return token;
}

static const struct preproc_text *find_arg_expansion(struct preproc_ctx *ctx, const char *s)
{
    struct preproc_expansion *exp;
    unsigned int i;

    if ((exp = preproc_get_top_expansion(ctx)) && exp->macro)
    {
        for (i = 0; i < exp->macro->arg_count; ++i)
        {
            if (!strcmp(s, exp->macro->arg_names[i]))
                return &exp->arg_values[i];
        }
    }
    return NULL;
}

static void preproc_text_add(struct preproc_text *text, const char *string)
{
    vkd3d_string_buffer_printf(&text->text, "%s", string);
}

static bool preproc_push_expansion(struct preproc_ctx *ctx,
        const struct preproc_text *text, struct preproc_macro *macro, struct preproc_text *arg_values)
{
    struct preproc_expansion *exp;

    if (!vkd3d_array_reserve((void **)&ctx->expansion_stack, &ctx->expansion_stack_size,
            ctx->expansion_count + 1, sizeof(*ctx->expansion_stack)))
        return false;
    exp = &ctx->expansion_stack[ctx->expansion_count++];
    exp->text = text;
    exp->buffer.lexer_buffer = yy_scan_bytes(text->text.buffer, text->text.content_size, ctx->scanner);
    exp->buffer.location = text->location;
    exp->buffer.eof = false;
    exp->macro = macro;
    exp->arg_values = arg_values;
    TRACE("Expansion stack size is now %zu.\n", ctx->expansion_count);
    return true;
}

static void preproc_stringify(struct preproc_ctx *ctx, struct vkd3d_string_buffer *buffer, const char *text)
{
    const struct preproc_text *expansion;
    const char *p = text + 1;
    unsigned int i;

    while (*p == ' ' || *p == '\t')
        ++p;

    vkd3d_string_buffer_printf(buffer, "\"");
    if ((expansion = find_arg_expansion(ctx, p)))
    {
        size_t len = expansion->text.content_size;
        size_t start = 0;

        while (len && strchr(" \t\r\n", expansion->text.buffer[len - 1]))
            --len;

        while (start < len && strchr(" \t\r\n", expansion->text.buffer[start]))
            ++start;

        for (i = start; i < len; ++i)
        {
            char c = expansion->text.buffer[i];

            if (c == '\\' || c == '"')
                vkd3d_string_buffer_printf(buffer, "\\");
            vkd3d_string_buffer_printf(buffer, "%c", c);
        }
    }
    else
    {
        vkd3d_string_buffer_printf(buffer, "%s", p);
    }
    vkd3d_string_buffer_printf(buffer, "\"");
}

int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
{
    struct preproc_ctx *ctx = yyget_extra(scanner);

    for (;;)
    {
        struct preproc_func_state *func_state;
        const char *text;
        int token;

        if (ctx->lookahead_token)
        {
            token = ctx->lookahead_token;
            text = yyget_text(scanner);
        }
        else
        {
            if (preproc_get_top_buffer(ctx)->eof)
            {
                preproc_pop_buffer(ctx);
                if (!ctx->file_count)
                    return 0;
            }

            VKD3D_ASSERT(ctx->file_count);
            if (!(token = preproc_lexer_lex(lval, lloc, scanner)))
            {
                preproc_get_top_buffer(ctx)->eof = true;

                /* If we have reached the end of an included file, inject a newline. */
                if (ctx->expansion_count)
                    continue;
                token = T_NEWLINE;
                text = "\n";
            }
            else
            {
                text = yyget_text(scanner);
            }

            if (ctx->last_was_newline)
            {
                switch (token)
                {
                    case T_DEFINE:
                    case T_ELIF:
                    case T_ELSE:
                    case T_ENDIF:
                    case T_ERROR:
                    case T_IF:
                    case T_IFDEF:
                    case T_IFNDEF:
                    case T_INCLUDE:
                    case T_LINE:
                    case T_PRAGMA:
                    case T_UNDEF:
                        ctx->current_directive = token;
                        break;

                    default:
                        ctx->current_directive = 0;
                }
            }

            ctx->last_was_newline = (token == T_NEWLINE);
        }

        if (ctx->current_directive && token == T_DEFINED)
            ctx->last_was_defined = true;

        func_state = ctx->current_directive ? &ctx->directive_func : &ctx->text_func;

        TRACE("Parsing token %d%s, line %d, in directive %d, state %#x, string %s.\n",
                token, ctx->lookahead_token ? " (lookahead)" : "", lloc->line,
                ctx->current_directive, func_state->state, debugstr_a(text));

        ctx->lookahead_token = 0;

        switch (ctx->current_directive)
        {
            case T_ELIF:
            case T_ELSE:
            case T_ENDIF:
            case T_IF:
            case T_IFDEF:
            case T_IFNDEF:
                break;

            default:
                if (!preproc_is_writing(ctx))
                    continue;
        }

        if (ctx->current_directive == T_PRAGMA)
        {
            /* Print all tokens verbatim. */
            if (token == T_PRAGMA)
                vkd3d_string_buffer_printf(&ctx->buffer, "#pragma ");
            else
                vkd3d_string_buffer_printf(&ctx->buffer, "%s", text);
            continue;
        }

        switch (func_state->state)
        {
            case STATE_NONE:
                if (token == T_CONCAT && should_concat(ctx))
                {
                    while (ctx->buffer.content_size
                            && strchr(" \t\r\n", ctx->buffer.buffer[ctx->buffer.content_size - 1]))
                        --ctx->buffer.content_size;
                    break;
                }

                if (token == T_HASHSTRING)
                {
                    struct vkd3d_string_buffer buffer;

                    if (ctx->current_directive)
                        return return_token(token, lval, text);

                    vkd3d_string_buffer_init(&buffer);
                    preproc_stringify(ctx, &buffer, text);
                    vkd3d_string_buffer_printf(&ctx->buffer, "%s", buffer.buffer);
                    vkd3d_string_buffer_cleanup(&buffer);
                    break;
                }

                if (token == T_IDENTIFIER || token == T_IDENTIFIER_PAREN)
                {
                    const struct preproc_text *expansion;
                    struct preproc_macro *macro;

                    switch (ctx->current_directive)
                    {
                        case T_DEFINE:
                        case T_IFDEF:
                        case T_IFNDEF:
                        case T_UNDEF:
                            /* Return identifiers verbatim. */
                            return return_token(token, lval, text);

                        case T_IF:
                        case T_ELIF:
                            /* Return identifiers verbatim only if they're the
                             * argument to "defined". */
                            if (ctx->last_was_defined)
                            {
                                ctx->last_was_defined = false;
                                return return_token(token, lval, text);
                            }
                            break;
                    }

                    /* Otherwise, expand a macro if there is one. */

                    if ((expansion = find_arg_expansion(ctx, text)))
                    {
                        preproc_push_expansion(ctx, expansion, NULL, NULL);
                        continue;
                    }

                    if ((macro = preproc_find_macro(ctx, text)))
                    {
                        if (!macro->arg_count)
                        {
                            preproc_push_expansion(ctx, &macro->body, macro, NULL);
                        }
                        else
                        {
                            func_state->state = STATE_IDENTIFIER;
                            func_state->macro = macro;
                        }
                        continue;
                    }

                    if (!strcmp(text, "__FILE__"))
                    {
                        const struct preproc_file *file = preproc_get_top_file(ctx);

                        /* Not the current file name, but rather the file name
                         * before invoking any macros. */

                        if (ctx->current_directive)
                        {
                            char *string;

                            if (!(string = vkd3d_malloc(strlen(file->filename) + 3)))
                                return 0;
                            sprintf(string, "\"%s\"", file->filename);
                            lval->string = string;
                            return T_STRING;
                        }

                        if (preproc_is_writing(ctx))
                            vkd3d_string_buffer_printf(&ctx->buffer, "\"%s\" ", file->filename);
                        continue;
                    }

                    if (!strcmp(text, "__LINE__"))
                    {
                        const struct preproc_file *file = preproc_get_top_file(ctx);

                        /* Not the current line number, but rather the line
                         * number before invoking any macros. */

                        if (ctx->current_directive)
                        {
                            char string[13];

                            sprintf(string, "%d", file->buffer.location.line);
                            return return_token(T_INTEGER, lval, string);
                        }

                        if (preproc_is_writing(ctx))
                            vkd3d_string_buffer_printf(&ctx->buffer, "%d ", file->buffer.location.line);
                        continue;
                    }
                }

                if (ctx->current_directive)
                    return return_token(token, lval, text);

                if (isspace(text[0]))
                    vkd3d_string_buffer_printf(&ctx->buffer, "%s", text);
                else
                    vkd3d_string_buffer_printf(&ctx->buffer, "%s ", text);
                break;

            case STATE_IDENTIFIER:
                if (token == '(')
                {
                    struct preproc_text *arg_values;

                    if (!(arg_values = calloc(func_state->macro->arg_count, sizeof(*arg_values))))
                        return 0;

                    for (unsigned int i = 0; i < func_state->macro->arg_count; ++i)
                        vkd3d_string_buffer_init(&arg_values[i].text);
                    arg_values[0].location = *lloc;

                    func_state->arg_count = 0;
                    func_state->paren_depth = 1;
                    func_state->state = STATE_ARGS;
                    func_state->arg_values = arg_values;
                }
                else
                {
                    const char *name = func_state->macro->name;

                    ctx->lookahead_token = token;
                    func_state->macro = NULL;
                    func_state->state = STATE_NONE;

                    if (ctx->current_directive)
                        return return_token(T_IDENTIFIER, lval, name);

                    vkd3d_string_buffer_printf(&ctx->buffer, "%s ", name);
                }
                break;

            case STATE_ARGS:
            {
                struct preproc_text *current_arg = NULL;

                VKD3D_ASSERT(func_state->macro->arg_count);

                if (func_state->arg_count < func_state->macro->arg_count)
                    current_arg = &func_state->arg_values[func_state->arg_count];

                switch (token)
                {
                    /* Most text gets left alone (e.g. if it contains macros,
                     * the macros should be evaluated later).
                     * Arguments are a special case, and are replaced with
                     * their values immediately. */
                    case T_IDENTIFIER:
                    case T_IDENTIFIER_PAREN:
                    {
                        const struct preproc_text *expansion;

                        if ((expansion = find_arg_expansion(ctx, text)))
                        {
                            preproc_push_expansion(ctx, expansion, NULL, NULL);
                            continue;
                        }

                        if (current_arg)
                            preproc_text_add(current_arg, text);
                        break;
                    }

                    /* Stringification is another special case. Unsurprisingly,
                     * we need to stringify if this is an argument. More
                     * surprisingly, we need to stringify even if it's not. */
                    case T_HASHSTRING:
                    {
                        struct vkd3d_string_buffer buffer;

                        vkd3d_string_buffer_init(&buffer);
                        preproc_stringify(ctx, &buffer, text);
                        if (current_arg)
                            preproc_text_add(current_arg, buffer.buffer);
                        vkd3d_string_buffer_cleanup(&buffer);
                        break;
                    }

                    case T_NEWLINE:
                        if (current_arg)
                            preproc_text_add(current_arg, " ");
                        break;

                    case ')':
                    case ']':
                    case '}':
                        if (!--func_state->paren_depth)
                        {
                            /* Not only can you end a macro with ] or }, if
                             * you do, it's treated as part of the last
                             * argument. */
                            if (token != ')' && current_arg)
                                preproc_text_add(current_arg, text);

                            if (++func_state->arg_count == func_state->macro->arg_count)
                            {
                                preproc_push_expansion(ctx, &func_state->macro->body,
                                        func_state->macro, func_state->arg_values);
                            }
                            else
                            {
                                preproc_warning(ctx, lloc, VKD3D_SHADER_WARNING_PP_ARGUMENT_COUNT_MISMATCH,
                                        "Wrong number of arguments to macro \"%s\": expected %zu, got %zu.",
                                        func_state->macro->name, func_state->macro->arg_count, func_state->arg_count);

                                if (ctx->current_directive)
                                    return return_token(T_IDENTIFIER, lval, func_state->macro->name);

                                vkd3d_string_buffer_printf(&ctx->buffer, "%s ", func_state->macro->name);
                                preproc_func_state_cleanup_arg_values(func_state);
                            }
                            func_state->macro = NULL;
                            func_state->state = STATE_NONE;
                        }
                        else
                        {
                            if (current_arg)
                                preproc_text_add(current_arg, text);
                        }
                        break;

                    case ',':
                        if (func_state->paren_depth == 1)
                        {
                            ++func_state->arg_count;
                            if (current_arg)
                                current_arg->location = *lloc;
                        }
                        else if (current_arg)
                        {
                            preproc_text_add(current_arg, text);
                        }
                        break;

                    case '(':
                    case '[':
                    case '{':
                        ++func_state->paren_depth;
                        /* fall through */

                    default:
                        if (current_arg)
                            preproc_text_add(current_arg, text);
                }

                if (current_arg)
                    preproc_text_add(current_arg, " ");
                break;
            }
        }
    }
}

bool preproc_push_include(struct preproc_ctx *ctx, char *filename, const struct vkd3d_shader_code *code)
{
    struct preproc_file *file;

    if (!vkd3d_array_reserve((void **)&ctx->file_stack, &ctx->file_stack_size,
            ctx->file_count + 1, sizeof(*ctx->file_stack)))
        return false;
    file = &ctx->file_stack[ctx->file_count++];
    memset(file, 0, sizeof(*file));
    file->code = *code;
    file->filename = filename;
    file->buffer.lexer_buffer = yy_scan_bytes(code->code, code->size, ctx->scanner);
    file->buffer.location.source_name = file->filename;
    file->buffer.location.line = 1;
    file->buffer.location.column = 1;
    file->buffer.eof = false;
    TRACE("File stack size is now %zu.\n", ctx->file_count);
    ctx->last_was_newline = true;
    return true;
}

static int preproc_macro_compare(const void *key, const struct rb_entry *entry)
{
    const struct preproc_macro *macro = RB_ENTRY_VALUE(entry, struct preproc_macro, entry);
    const char *name = key;

    return strcmp(name, macro->name);
}

static void preproc_macro_rb_free(struct rb_entry *entry, void *ctx)
{
    preproc_free_macro(RB_ENTRY_VALUE(entry, struct preproc_macro, entry));
}

int preproc_lexer_parse(const struct vkd3d_shader_compile_info *compile_info,
        struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
{
    static const struct vkd3d_shader_preprocess_info default_preprocess_info = {0};
    struct vkd3d_shader_location loc = {0};
    struct preproc_ctx ctx = {0};
    char *source_name = NULL;
    unsigned int i;

    vkd3d_string_buffer_init(&ctx.buffer);
    rb_init(&ctx.macros, preproc_macro_compare);
    if (!(ctx.preprocess_info = vkd3d_find_struct(compile_info->next, PREPROCESS_INFO)))
        ctx.preprocess_info = &default_preprocess_info;
    ctx.message_context = message_context;

    loc.source_name = compile_info->source_name ? compile_info->source_name : "<anonymous>";
    if (!(source_name = vkd3d_strdup(loc.source_name)))
        goto fail;

    for (i = 0; i < ctx.preprocess_info->macro_count; ++i)
    {
        struct vkd3d_string_buffer body;
        char *name;

        vkd3d_string_buffer_init(&body);
        vkd3d_string_buffer_printf(&body, "%s", ctx.preprocess_info->macros[i].value);
        if (!(name = vkd3d_strdup(ctx.preprocess_info->macros[i].name)))
        {
            vkd3d_string_buffer_cleanup(&body);
            goto fail;
        }
        if (!preproc_add_macro(&ctx, &loc, name, NULL, 0, &loc, &body))
        {
            vkd3d_free(name);
            vkd3d_string_buffer_cleanup(&body);
            goto fail;
        }
    }

    yylex_init_extra(&ctx, &ctx.scanner);
    if (!preproc_push_include(&ctx, source_name, &compile_info->source))
    {
        yylex_destroy(ctx.scanner);
        goto fail;
    }

    preproc_yyparse(ctx.scanner, &ctx);

    switch (ctx.text_func.state)
    {
        case STATE_NONE:
            break;

        case STATE_ARGS:
            preproc_warning(&ctx, &loc, VKD3D_SHADER_WARNING_PP_UNTERMINATED_MACRO,
                    "Unterminated macro invocation.");
        /* fall through */
        case STATE_IDENTIFIER:
            if (preproc_is_writing(&ctx))
                vkd3d_string_buffer_printf(&ctx.buffer, "%s ", ctx.text_func.macro->name);
            break;
    }

    preproc_func_state_cleanup_arg_values(&ctx.text_func);
    while (ctx.file_count)
        preproc_pop_buffer(&ctx);
    yylex_destroy(ctx.scanner);

    rb_destroy(&ctx.macros, preproc_macro_rb_free, NULL);
    vkd3d_free(ctx.file_stack);
    vkd3d_free(ctx.expansion_stack);

    if (ctx.error)
    {
        WARN("Failed to preprocess.\n");
        vkd3d_string_buffer_cleanup(&ctx.buffer);
        return VKD3D_ERROR_INVALID_SHADER;
    }

    vkd3d_string_buffer_trace(&ctx.buffer);

    vkd3d_shader_code_from_string_buffer(out, &ctx.buffer);
    return VKD3D_OK;

fail:
    rb_destroy(&ctx.macros, preproc_macro_rb_free, NULL);
    vkd3d_free(source_name);
    vkd3d_string_buffer_cleanup(&ctx.buffer);
    return VKD3D_ERROR_OUT_OF_MEMORY;
}

