From 91380e8718fe817952a71890111eb5d8c2f99147 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 2 Jan 2021 20:08:15 +0100 Subject: [PATCH] egg: Make egg parser and lexer reentrant This avoids the need for the global mutex lock and allows two egg files to be read simultaneously. Error reporting has also been improved by specifically pinpointing the offending token when an error occurs. --- makepanda/makepanda.py | 2 +- panda/src/egg/eggData.cxx | 13 +- panda/src/egg/eggGroup.cxx | 4 +- panda/src/egg/eggGroup.h | 2 +- panda/src/egg/eggNode.cxx | 16 +- panda/src/egg/eggNode.h | 4 +- panda/src/egg/eggPrimitive.cxx | 4 +- panda/src/egg/eggPrimitive.h | 2 +- panda/src/egg/eggTexture.cxx | 4 +- panda/src/egg/eggTexture.h | 2 +- panda/src/egg/lexer.cxx.prebuilt | 2109 ++++++++++------- panda/src/egg/lexer.lxx | 349 ++- panda/src/egg/lexerDefs.h | 56 +- panda/src/egg/parser.cxx.prebuilt | 3649 ++++++++++++++--------------- panda/src/egg/parser.h.prebuilt | 217 +- panda/src/egg/parser.yxx | 769 +++--- panda/src/egg/parserDefs.h | 20 +- 17 files changed, 3823 insertions(+), 3399 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index fe7558c049..48b02846a8 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -4396,7 +4396,7 @@ if GetTarget() == 'windows' and not PkgSkip("DX9"): # if not PkgSkip("EGG"): - OPTS=['DIR:panda/src/egg', 'BUILDING:PANDAEGG', 'ZLIB', 'BISONPREFIX_eggyy', 'FLEXDASHI', 'FLEXVERSION:2.5.9'] + OPTS=['DIR:panda/src/egg', 'BUILDING:PANDAEGG', 'ZLIB', 'BISONPREFIX_eggyy', 'FLEXDASHI', 'FLEXVERSION:2.5.6'] CreateFile(GetOutputDir()+"/include/parser.h") TargetAdd('p3egg_parser.obj', opts=OPTS, input='parser.yxx') TargetAdd('parser.h', input='p3egg_parser.obj', opts=['DEPENDENCYONLY']) diff --git a/panda/src/egg/eggData.cxx b/panda/src/egg/eggData.cxx index 75c9ad68d0..a8776ae629 100644 --- a/panda/src/egg/eggData.cxx +++ b/panda/src/egg/eggData.cxx @@ -114,13 +114,12 @@ read(istream &in) { // set it. PT(EggData) data = new EggData(*this); - int error_count; + bool success; { - LightMutexHolder holder(egg_lock); - egg_init_parser(in, get_egg_filename(), data, data); - eggyyparse(); - egg_cleanup_parser(); - error_count = egg_error_count(); + EggLexerState lexer_state; + egg_init_lexer_state(lexer_state, in, get_egg_filename()); + success = egg_parse(lexer_state, data, data); + egg_cleanup_lexer_state(lexer_state); } data->post_read(); @@ -128,7 +127,7 @@ read(istream &in) { steal_children(*data); (*this) = *data; - return (error_count == 0); + return success; } /** diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index fe36f2b123..cce47550f2 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -1094,8 +1094,8 @@ write_vertex_ref(ostream &out, int indent_level) const { * return false. */ bool EggGroup:: -egg_start_parse_body() { - egg_start_group_body(); +egg_start_parse_body(EggLexerState &state) { + egg_start_group_body(state); return true; } diff --git a/panda/src/egg/eggGroup.h b/panda/src/egg/eggGroup.h index 14485dcc24..639d5eb202 100644 --- a/panda/src/egg/eggGroup.h +++ b/panda/src/egg/eggGroup.h @@ -369,7 +369,7 @@ public: protected: void write_vertex_ref(std::ostream &out, int indent_level) const; - virtual bool egg_start_parse_body(); + virtual bool egg_start_parse_body(EggLexerState &state); virtual void adjust_under(); virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv, CoordinateSystem to_cs); diff --git a/panda/src/egg/eggNode.cxx b/panda/src/egg/eggNode.cxx index efca0825c7..c4c8641526 100644 --- a/panda/src/egg/eggNode.cxx +++ b/panda/src/egg/eggNode.cxx @@ -229,19 +229,13 @@ parse_egg(const std::string &egg_syntax) { std::istringstream in(egg_syntax); - LightMutexHolder holder(egg_lock); - - egg_init_parser(in, "", this, group); - - if (!egg_start_parse_body()) { - egg_cleanup_parser(); + EggLexerState lexer_state; + egg_init_lexer_state(lexer_state, in, ""); + if (!egg_start_parse_body(lexer_state)) { return false; } - eggyyparse(); - egg_cleanup_parser(); - - return (egg_error_count() == 0); + return egg_parse(lexer_state, this, group); } #ifdef _DEBUG @@ -287,7 +281,7 @@ test_under_integrity() const { * return false. */ bool EggNode:: -egg_start_parse_body() { +egg_start_parse_body(EggLexerState &state) { return false; } diff --git a/panda/src/egg/eggNode.h b/panda/src/egg/eggNode.h index 48f4443ed4..8a741b600a 100644 --- a/panda/src/egg/eggNode.h +++ b/panda/src/egg/eggNode.h @@ -28,6 +28,8 @@ class EggGroupNode; class EggRenderMode; class EggTextureCollection; +struct EggLexerState; + /** * A base class for things that may be directly added into the egg hierarchy. * This includes groups, joints, polygons, vertex pools, etc., but does not @@ -100,7 +102,7 @@ protected: UF_local_coord = 0x004, }; - virtual bool egg_start_parse_body(); + virtual bool egg_start_parse_body(EggLexerState &state); virtual void update_under(int depth_offset); virtual void adjust_under(); diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index 158866855f..a16c29c373 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/panda/src/egg/eggPrimitive.cxx @@ -905,8 +905,8 @@ write_body(std::ostream &out, int indent_level) const { * return false. */ bool EggPrimitive:: -egg_start_parse_body() { - egg_start_primitive_body(); +egg_start_parse_body(EggLexerState &state) { + egg_start_primitive_body(state); return true; } diff --git a/panda/src/egg/eggPrimitive.h b/panda/src/egg/eggPrimitive.h index b20c81ba73..1e280a8175 100644 --- a/panda/src/egg/eggPrimitive.h +++ b/panda/src/egg/eggPrimitive.h @@ -211,7 +211,7 @@ protected: protected: void write_body(std::ostream &out, int indent_level) const; - virtual bool egg_start_parse_body(); + virtual bool egg_start_parse_body(EggLexerState &state); virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv, CoordinateSystem to_cs); virtual void r_flatten_transforms(); diff --git a/panda/src/egg/eggTexture.cxx b/panda/src/egg/eggTexture.cxx index 899438276e..27bc23d392 100644 --- a/panda/src/egg/eggTexture.cxx +++ b/panda/src/egg/eggTexture.cxx @@ -1063,8 +1063,8 @@ as_transform() { * return false. */ bool EggTexture:: -egg_start_parse_body() { - egg_start_texture_body(); +egg_start_parse_body(EggLexerState &state) { + egg_start_texture_body(state); return true; } diff --git a/panda/src/egg/eggTexture.h b/panda/src/egg/eggTexture.h index 5d602e26f8..11dabbceda 100644 --- a/panda/src/egg/eggTexture.h +++ b/panda/src/egg/eggTexture.h @@ -365,7 +365,7 @@ public: virtual EggTransform *as_transform(); protected: - virtual bool egg_start_parse_body(); + virtual bool egg_start_parse_body(EggLexerState &state); private: typedef pset MultiTextures; diff --git a/panda/src/egg/lexer.cxx.prebuilt b/panda/src/egg/lexer.cxx.prebuilt index 16ca6eff9d..f17e5acf94 100644 --- a/panda/src/egg/lexer.cxx.prebuilt +++ b/panda/src/egg/lexer.cxx.prebuilt @@ -1,38 +1,253 @@ -#line 2 "lex.yy.c" +#line 1 "panda/src/egg/lexer.cxx.prebuilt" -#line 4 "lex.yy.c" +#line 3 "panda/src/egg/lexer.cxx.prebuilt" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ -#define yy_create_buffer eggyy_create_buffer -#define yy_delete_buffer eggyy_delete_buffer -#define yy_flex_debug eggyy_flex_debug -#define yy_init_buffer eggyy_init_buffer -#define yy_flush_buffer eggyy_flush_buffer -#define yy_load_buffer_state eggyy_load_buffer_state -#define yy_switch_to_buffer eggyy_switch_to_buffer -#define yyin eggyyin -#define yyleng eggyyleng -#define yylex eggyylex -#define yylineno eggyylineno -#define yyout eggyyout -#define yyrestart eggyyrestart -#define yytext eggyytext -#define yywrap eggyywrap -#define yyalloc eggyyalloc -#define yyrealloc eggyyrealloc -#define yyfree eggyyfree - #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 +#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 eggyy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer eggyy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define eggyy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer eggyy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define eggyy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer eggyy_scan_buffer +#endif + +#ifdef yy_scan_string +#define eggyy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string eggyy_scan_string +#endif + +#ifdef yy_scan_bytes +#define eggyy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes eggyy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define eggyy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer eggyy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define eggyy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer eggyy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define eggyy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state eggyy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define eggyy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer eggyy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define eggyypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state eggyypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define eggyypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state eggyypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define eggyyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack eggyyensure_buffer_stack +#endif + +#ifdef yylex +#define eggyylex_ALREADY_DEFINED +#else +#define yylex eggyylex +#endif + +#ifdef yyrestart +#define eggyyrestart_ALREADY_DEFINED +#else +#define yyrestart eggyyrestart +#endif + +#ifdef yylex_init +#define eggyylex_init_ALREADY_DEFINED +#else +#define yylex_init eggyylex_init +#endif + +#ifdef yylex_init_extra +#define eggyylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra eggyylex_init_extra +#endif + +#ifdef yylex_destroy +#define eggyylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy eggyylex_destroy +#endif + +#ifdef yyget_debug +#define eggyyget_debug_ALREADY_DEFINED +#else +#define yyget_debug eggyyget_debug +#endif + +#ifdef yyset_debug +#define eggyyset_debug_ALREADY_DEFINED +#else +#define yyset_debug eggyyset_debug +#endif + +#ifdef yyget_extra +#define eggyyget_extra_ALREADY_DEFINED +#else +#define yyget_extra eggyyget_extra +#endif + +#ifdef yyset_extra +#define eggyyset_extra_ALREADY_DEFINED +#else +#define yyset_extra eggyyset_extra +#endif + +#ifdef yyget_in +#define eggyyget_in_ALREADY_DEFINED +#else +#define yyget_in eggyyget_in +#endif + +#ifdef yyset_in +#define eggyyset_in_ALREADY_DEFINED +#else +#define yyset_in eggyyset_in +#endif + +#ifdef yyget_out +#define eggyyget_out_ALREADY_DEFINED +#else +#define yyget_out eggyyget_out +#endif + +#ifdef yyset_out +#define eggyyset_out_ALREADY_DEFINED +#else +#define yyset_out eggyyset_out +#endif + +#ifdef yyget_leng +#define eggyyget_leng_ALREADY_DEFINED +#else +#define yyget_leng eggyyget_leng +#endif + +#ifdef yyget_text +#define eggyyget_text_ALREADY_DEFINED +#else +#define yyget_text eggyyget_text +#endif + +#ifdef yyget_lineno +#define eggyyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno eggyyget_lineno +#endif + +#ifdef yyset_lineno +#define eggyyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno eggyyset_lineno +#endif + +#ifdef yyget_column +#define eggyyget_column_ALREADY_DEFINED +#else +#define yyget_column eggyyget_column +#endif + +#ifdef yyset_column +#define eggyyset_column_ALREADY_DEFINED +#else +#define yyset_column eggyyset_column +#endif + +#ifdef yywrap +#define eggyywrap_ALREADY_DEFINED +#else +#define yywrap eggyywrap +#endif + +#ifdef yyget_lval +#define eggyyget_lval_ALREADY_DEFINED +#else +#define yyget_lval eggyyget_lval +#endif + +#ifdef yyset_lval +#define eggyyset_lval_ALREADY_DEFINED +#else +#define yyset_lval eggyyset_lval +#endif + +#ifdef yyget_lloc +#define eggyyget_lloc_ALREADY_DEFINED +#else +#define yyget_lloc eggyyget_lloc +#endif + +#ifdef yyset_lloc +#define eggyyset_lloc_ALREADY_DEFINED +#else +#define yyset_lloc eggyyset_lloc +#endif + +#ifdef yyalloc +#define eggyyalloc_ALREADY_DEFINED +#else +#define yyalloc eggyyalloc +#endif + +#ifdef yyrealloc +#define eggyyrealloc_ALREADY_DEFINED +#else +#define yyrealloc eggyyrealloc +#endif + +#ifdef yyfree +#define eggyyfree_ALREADY_DEFINED +#else +#define yyfree eggyyfree +#endif + /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ @@ -53,7 +268,7 @@ #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. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -70,10 +285,9 @@ typedef uint32_t flex_uint32_t; 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 char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -104,63 +318,78 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ -#ifdef __cplusplus +/* begin standard C++ headers. */ -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST +/* TODO: this is always defined, so inline it */ #define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) #else -#define yyconst +#define yynoreturn #endif /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* 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) ((unsigned int) (unsigned char) c) +#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 (yy_start) = 1 + 2 * - +#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 (((yy_start) - 1) / 2) +#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 eggyyrestart(eggyyin ) - +#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. @@ -172,36 +401,32 @@ typedef unsigned int flex_uint32_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif -extern int eggyyleng; - -extern FILE *eggyyin, *eggyyout; +#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 eggyytext. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ + *yy_cp = yyg->yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up eggyytext again */ \ + 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, (yytext_ptr) ) - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE @@ -215,7 +440,7 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - yy_size_t yy_buf_size; + int yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. @@ -243,7 +468,7 @@ struct yy_buffer_state 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. */ @@ -260,123 +485,92 @@ struct yy_buffer_state * possible backing-up. * * When we actually see the EOF, we change the status to "new" - * (via eggyyrestart()), so that the user can continue scanning by - * just pointing eggyyin at a new input file. + * (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 */ -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - /* 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 ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ +#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 (yy_buffer_stack)[(yy_buffer_stack_top)] +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] -/* yy_hold_char holds the character lost when eggyytext is formed. */ -static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int eggyyleng; +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 ); -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ +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) -/* Flag which is used to allow eggyywrap()'s to do buffer switches - * instead of setting up a fresh eggyyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; +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 eggyyrestart (FILE *input_file ); -void eggyy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE eggyy_create_buffer (FILE *file,int size ); -void eggyy_delete_buffer (YY_BUFFER_STATE b ); -void eggyy_flush_buffer (YY_BUFFER_STATE b ); -void eggyypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void eggyypop_buffer_state (void ); - -static void eggyyensure_buffer_stack (void ); -static void eggyy_load_buffer_state (void ); -static void eggyy_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER eggyy_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE eggyy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE eggyy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE eggyy_scan_bytes (yyconst char *bytes,int len ); - -void *eggyyalloc (yy_size_t ); -void *eggyyrealloc (void *,yy_size_t ); -void eggyyfree (void * ); - -#define yy_new_buffer eggyy_create_buffer +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 ){ \ - eggyyensure_buffer_stack (); \ + yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - eggyy_create_buffer(eggyyin,YY_BUF_SIZE ); \ + 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 ){\ - eggyyensure_buffer_stack (); \ + yyensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - eggyy_create_buffer(eggyyin,YY_BUF_SIZE ); \ + 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) -typedef unsigned char YY_CHAR; - -FILE *eggyyin = (FILE *) 0, *eggyyout = (FILE *) 0; +#define eggyywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; typedef int yy_state_type; -extern int eggyylineno; +#define yytext_ptr yytext_r -int eggyylineno = 1; - -extern char *eggyytext; -#define yytext_ptr eggyytext - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); +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 eggyytext. + * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - eggyyleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - + yyg->yy_c_buf_p = yy_cp; #define YY_NUM_RULES 101 #define YY_END_OF_BUFFER 102 /* This struct is not used in this scanner, @@ -386,7 +580,7 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[585] = +static const flex_int16_t yy_accept[585] = { 0, 0, 0, 102, 100, 2, 1, 99, 100, 100, 100, 100, 91, 91, 91, 100, 100, 100, 5, 100, 1, @@ -454,7 +648,7 @@ static yyconst flex_int16_t yy_accept[585] = 19, 100, 29, 0 } ; -static yyconst flex_int32_t yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, @@ -486,7 +680,7 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[73] = +static const YY_CHAR yy_meta[73] = { 0, 1, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -498,7 +692,7 @@ static yyconst flex_int32_t yy_meta[73] = 1, 2 } ; -static yyconst flex_int16_t yy_base[590] = +static const flex_int16_t yy_base[590] = { 0, 0, 71, 1224, 0, 1225, 0, 1225, 8, 23, 28, 18, 134, 55, 79, 203, 2, 0, 1225, 0, 0, @@ -566,7 +760,7 @@ static yyconst flex_int16_t yy_base[590] = 0, 27, 0, 1225, 1199, 0, 1202, 1204, 1206 } ; -static yyconst flex_int16_t yy_def[590] = +static const flex_int16_t yy_def[590] = { 0, 585, 585, 584, 586, 584, 587, 584, 586, 586, 586, 586, 586, 586, 586, 584, 586, 586, 584, 586, 587, @@ -634,7 +828,7 @@ static yyconst flex_int16_t yy_def[590] = 586, 586, 586, 0, 584, 584, 584, 584, 584 } ; -static yyconst flex_int16_t yy_nxt[1298] = +static const flex_int16_t yy_nxt[1298] = { 0, 19, 5, 6, 7, 584, 584, 584, 8, 9, 10, 11, 12, 13, 14, 14, 14, 15, 21, 54, 22, @@ -781,7 +975,7 @@ static yyconst flex_int16_t yy_nxt[1298] = } ; -static yyconst flex_int16_t yy_chk[1298] = +static const flex_int16_t yy_chk[1298] = { 0, 586, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 17, 8, @@ -928,12 +1122,6 @@ static yyconst flex_int16_t yy_chk[1298] = } ; -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -extern int eggyy_flex_debug; -int eggyy_flex_debug = 0; - /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ @@ -941,15 +1129,13 @@ int eggyy_flex_debug = 0; #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -char *eggyytext; -#line 1 "lexer.lxx" -/* -// Filename: lexer.l -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -*/ -#line 9 "lexer.lxx" +#line 1 "panda/src/egg/lexer.lxx" +/** + * @file lexer.lxx + * @author drose + * @date 1999-01-16 + */ +#line 12 "panda/src/egg/lexer.lxx" #include "pandabase.h" #include "lexerDefs.h" #include "parserDefs.h" @@ -963,183 +1149,157 @@ char *eggyytext; #include -using std::istream; -using std::ostream; -using std::string; - -extern "C" int eggyywrap(void); // declared below. - -static int yyinput(void); // declared by flex. - -int eggyylex_destroy(void); - -//////////////////////////////////////////////////////////////////// -// Static variables -//////////////////////////////////////////////////////////////////// - -// This mutex protects all of these global variables. -LightMutex egg_lock; - -// We'll increment line_number and col_number as we parse the file, so -// that we can report the position of an error. -static int line_number = 0; -static int col_number = 0; - -// current_line holds as much of the current line as will fit. Its -// only purpose is for printing it out to report an error to the user. -static const int max_error_width = 1024; -static char current_line[max_error_width + 1]; - -static int error_count = 0; -static int warning_count = 0; - -// This is the pointer to the current input stream. -static istream *input_p = NULL; - -// This is the name of the egg file we're parsing. We keep it so we -// can print it out for error messages. -static string egg_filename; - -// This is the initial token state returned by the lexer. It allows -// the yacc grammar to start from initial points. -static int initial_token; +// These are declared by flex. +static int yyinput(yyscan_t yyscanner); +static EggLexerState *eggyyget_extra(yyscan_t scanner); //////////////////////////////////////////////////////////////////// // Defining the interface to the lexer. //////////////////////////////////////////////////////////////////// void -egg_init_lexer(istream &in, const string &filename) { - input_p = ∈ - egg_filename = filename; - line_number = 0; - col_number = 0; - error_count = 0; - warning_count = 0; - initial_token = START_EGG; +egg_init_lexer_state(EggLexerState &state, std::istream &in, const std::string &filename) { + state._error_count = 0; + state._warning_count = 0; + state._input_p = ∈ + state._egg_filename = filename; + state._initial_token = START_EGG; } void -egg_cleanup_lexer() { - // Reset the lexer state. - eggyylex_destroy(); - - input_p = nullptr; - egg_filename.clear(); +egg_cleanup_lexer_state(EggLexerState &state) { + state._input_p = nullptr; + state._egg_filename.clear(); } void -egg_start_group_body() { +egg_start_group_body(EggLexerState &state) { /* Set the initial state to begin within a group_body context, instead of at the beginning of the egg file. */ - initial_token = START_GROUP_BODY; + state._initial_token = START_GROUP_BODY; } void -egg_start_texture_body() { - initial_token = START_TEXTURE_BODY; +egg_start_texture_body(EggLexerState &state) { + state._initial_token = START_TEXTURE_BODY; } void -egg_start_primitive_body() { - initial_token = START_PRIMITIVE_BODY; +egg_start_primitive_body(EggLexerState &state) { + state._initial_token = START_PRIMITIVE_BODY; } -int -egg_error_count() { - return error_count; -} - -int -egg_warning_count() { - return warning_count; -} - - //////////////////////////////////////////////////////////////////// // Internal support functions. //////////////////////////////////////////////////////////////////// -int -eggyywrap(void) { - return 1; -} - void -eggyyerror(const string &msg) { +eggyyerror(YYLTYPE *loc, yyscan_t scanner, const std::string &msg) { + EggLexerState *lexer_state = eggyyget_extra(scanner); + if (egg_cat.is_error()) { - ostream &out = egg_cat.error(false); + std::ostream &out = egg_cat.error(false); out << "\nError"; - if (!egg_filename.empty()) { - out << " in " << egg_filename; + if (!lexer_state->_egg_filename.empty()) { + out << " in " << lexer_state->_egg_filename; + } + if (loc != nullptr) { + out + << " at line " << loc->first_line << ", column " << loc->first_column << ":\n" + << std::setiosflags(Notify::get_literal_flag()) + << lexer_state->_current_line << "\n"; + indent(out, loc->first_column - 1) + << "^"; + + int last_column; + if (loc->first_line == loc->last_line) { + last_column = loc->last_column; + } else { + last_column = strlen(lexer_state->_current_line); + } + for (int i = loc->first_column; i < last_column; ++i) { + out.put('~'); + } + + out + << "\n" << msg << "\n\n" + << std::resetiosflags(Notify::get_literal_flag()) << std::flush; + } + else { + out << ":\n" << msg << "\n\n" << std::flush; } - out - << " at line " << line_number << ", column " << col_number << ":\n" - << std::setiosflags(Notify::get_literal_flag()) - << current_line << "\n"; - indent(out, col_number-1) - << "^\n" << msg << "\n\n" - << std::resetiosflags(Notify::get_literal_flag()) << std::flush; } - error_count++; + lexer_state->_error_count++; } void -eggyyerror(std::ostringstream &strm) { - string s = strm.str(); - eggyyerror(s); -} +eggyywarning(YYLTYPE *loc, yyscan_t scanner, const std::string &msg) { + EggLexerState *lexer_state = eggyyget_extra(scanner); -void -eggyywarning(const string &msg) { if (egg_cat.is_warning()) { - ostream &out = egg_cat.warning(false); + std::ostream &out = egg_cat.warning(false); out << "\nWarning"; - if (!egg_filename.empty()) { - out << " in " << egg_filename; + if (!lexer_state->_egg_filename.empty()) { + out << " in " << lexer_state->_egg_filename; } - out - << " at line " << line_number << ", column " << col_number << ":\n" - << std::setiosflags(Notify::get_literal_flag()) - << current_line << "\n"; - indent(out, col_number-1) - << "^\n" << msg << "\n\n" - << std::resetiosflags(Notify::get_literal_flag()) << std::flush; - } - warning_count++; -} + if (loc != nullptr) { + out + << " at line " << loc->first_line << ", column " << loc->first_column << ":\n" + << std::setiosflags(Notify::get_literal_flag()) + << lexer_state->_current_line << "\n"; + indent(out, loc->first_column - 1) + << "^"; -void -eggyywarning(std::ostringstream &strm) { - std::string s = strm.str(); - eggyywarning(s); + int last_column; + if (loc->first_line == loc->last_line) { + last_column = loc->last_column; + } else { + last_column = strlen(lexer_state->_current_line); + } + for (int i = loc->first_column; i < last_column; ++i) { + out.put('~'); + } + + out + << "\n" << msg << "\n\n" + << std::resetiosflags(Notify::get_literal_flag()) << std::flush; + } + else { + out << ":\n" << msg << "\n\n" << std::flush; + } + } + lexer_state->_warning_count++; } // Now define a function to take input from an istream instead of a // stdio FILE pointer. This is flex-specific. static void -input_chars(char *buffer, int &result, int max_size) { - nassertv(input_p != NULL); - if (*input_p) { - input_p->read(buffer, max_size); - result = input_p->gcount(); +input_chars(YYLTYPE *yylloc, yyscan_t yyscanner, char *buffer, int &result, int max_size) { + EggLexerState &state = *yyget_extra(yyscanner); - if (line_number == 0) { + nassertv(state._input_p != nullptr); + if (*state._input_p) { + state._input_p->read(buffer, max_size); + result = state._input_p->gcount(); + + if (yylloc->last_line == 0) { // This is a special case. If we are reading the very first bit - // from the stream, copy it into the current_line array. This - // is because the \n.* rule below, which fills current_line + // from the stream, copy it into the _current_line array. This + // is because the \n.* rule below, which fills _current_line // normally, doesn't catch the first line. - int length = std::min(max_error_width, result); - strncpy(current_line, buffer, length); - current_line[length] = '\0'; - line_number++; - col_number = 0; + size_t length = std::min(egg_max_error_width, (size_t)result); + strncpy(state._current_line, buffer, length); + state._current_line[length] = '\0'; + yylloc->first_line = 1; + yylloc->last_line = 1; + yylloc->first_column = 0; + yylloc->last_column = 0; // Truncate it at the newline. - char *end = strchr(current_line, '\n'); - if (end != NULL) { + char *end = strchr(state._current_line, '\n'); + if (end != nullptr) { *end = '\0'; } } @@ -1156,7 +1316,7 @@ input_chars(char *buffer, int &result, int max_size) { // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ int int_result = 0; \ - input_chars((buffer), int_result, (max_size)); \ + input_chars(yylloc, yyscanner, (buffer), int_result, (max_size)); \ (result) = int_result; \ } @@ -1164,8 +1324,8 @@ input_chars(char *buffer, int &result, int max_size) { // supplied line and column numbers as appropriate. A convenience // function for the scanning functions below. static int -read_char(int &line, int &col) { - int c = yyinput(); +read_char(yyscan_t yyscanner, int &line, int &col) { + int c = yyinput(yyscanner); if (c == '\n') { line++; col = 0; @@ -1177,81 +1337,60 @@ read_char(int &line, int &col) { // scan_quoted_string reads a string delimited by quotation marks and // returns it. -static string -scan_quoted_string() { - string result; - - // We don't touch the current line number and column number during - // scanning, so that if we detect an error while scanning the string - // (e.g. an unterminated string), we'll report the error as - // occurring at the start of the string, not at the end--somewhat - // more convenient for the user. - - // Instead of adjusting the global line_number and col_number - // variables, we'll operate on our own local variables for the - // interim. - int line = line_number; - int col = col_number; +static std::string +scan_quoted_string(YYLTYPE *yylloc, yyscan_t yyscanner) { + std::string result; int c; - c = read_char(line, col); + c = read_char(yyscanner, yylloc->last_line, yylloc->last_column); while (c != '"' && c != 0 && c != EOF) { result += c; - c = read_char(line, col); + c = read_char(yyscanner, yylloc->last_line, yylloc->last_column); } if (c == 0 || c == EOF) { - eggyyerror("This quotation mark is unterminated."); + eggyyerror(yylloc, yyscanner, "This quotation mark is unterminated."); } - line_number = line; - col_number = col; - return result; } // eat_c_comment scans past all characters up until the first */ // encountered. static void -eat_c_comment() { - // As above, we'll operate on our own local copies of line_number - // and col_number within this function. - - int line = line_number; - int col = col_number; - +eat_c_comment(YYLTYPE *yylloc, yyscan_t yyscanner) { int c, last_c; - + last_c = '\0'; - c = read_char(line, col); + c = read_char(yyscanner, yylloc->last_line, yylloc->last_column); while (c != 0 && c != EOF && !(last_c == '*' && c == '/')) { if (last_c == '/' && c == '*') { std::ostringstream errmsg; errmsg << "This comment contains a nested /* symbol at line " - << line << ", column " << col-1 << "--possibly unclosed?" - << std::ends; - eggyywarning(errmsg); + << yylloc->last_line << ", column " << yylloc->last_column - 1 + << "--possibly unclosed?" << std::ends; + eggyywarning(yylloc, yyscanner, errmsg.str()); } last_c = c; - c = read_char(line, col); + c = read_char(yyscanner, yylloc->last_line, yylloc->last_column); } if (c == 0 || c == EOF) { - eggyyerror("This comment marker is unclosed."); + eggyyerror(yylloc, yyscanner, "This comment marker is unclosed."); } - - line_number = line; - col_number = col; } // accept() is called below as each piece is pulled off and // accepted by the lexer; it increments the current column number. -INLINE void accept() { - col_number += eggyyleng; +#define accept() { \ + yylloc->first_line = yylloc->last_line; \ + yylloc->first_column = yylloc->last_column + 1; \ + yylloc->last_column += yyleng; \ } -#line 1241 "lex.yy.c" +#line 1392 "panda/src/egg/lexer.cxx.prebuilt" +#line 1393 "panda/src/egg/lexer.cxx.prebuilt" #define INITIAL 0 @@ -1260,42 +1399,103 @@ INLINE void accept() { * 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 #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif -static int yy_init_globals (void ); +/* 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 eggyylex_destroy (void ); +int yylex_destroy ( yyscan_t yyscanner ); -int eggyyget_debug (void ); +int yyget_debug ( yyscan_t yyscanner ); -void eggyyset_debug (int debug_flag ); +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); -YY_EXTRA_TYPE eggyyget_extra (void ); +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); -void eggyyset_extra (YY_EXTRA_TYPE user_defined ); +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); -FILE *eggyyget_in (void ); +FILE *yyget_in ( yyscan_t yyscanner ); -void eggyyset_in (FILE * in_str ); +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); -FILE *eggyyget_out (void ); +FILE *yyget_out ( yyscan_t yyscanner ); -void eggyyset_out (FILE * out_str ); +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); -int eggyyget_leng (void ); + int yyget_leng ( yyscan_t yyscanner ); -char *eggyyget_text (void ); +char *yyget_text ( yyscan_t yyscanner ); -int eggyyget_lineno (void ); +int yyget_lineno ( yyscan_t yyscanner ); -void eggyyset_lineno (int line_number ); +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. @@ -1303,35 +1503,43 @@ void eggyyset_lineno (int line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int eggyywrap (void ); +extern "C" int yywrap ( yyscan_t yyscanner ); #else -extern int eggyywrap (void ); +extern int yywrap ( yyscan_t yyscanner ); #endif #endif - static void yyunput (int c,char *buf_ptr ); - +#ifndef YY_NO_UNPUT + + static void yyunput ( int c, char *buf_ptr , yyscan_t yyscanner); + +#endif + #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (void ); +static int yyinput ( yyscan_t yyscanner ); #else -static int input (void ); +static int input ( yyscan_t yyscanner ); #endif #endif /* 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. */ @@ -1339,7 +1547,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO fwrite( eggyytext, eggyyleng, 1, eggyyout ) +#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, @@ -1352,18 +1560,18 @@ static int input (void ); int c = '*'; \ int n; \ for ( n = 0; n < max_size && \ - (c = getc( eggyyin )) != EOF && c != '\n'; ++n ) \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ - if ( c == EOF && ferror( eggyyin ) ) \ + if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ - while ( (result = fread(buf, 1, max_size, eggyyin))==0 && ferror(eggyyin)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -1371,7 +1579,7 @@ static int input (void ); break; \ } \ errno=0; \ - clearerr(eggyyin); \ + clearerr(yyin); \ } \ }\ \ @@ -1393,7 +1601,7 @@ static int input (void ); /* Report a fatal error. */ #ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) #endif /* end tables serialization structures and prototypes */ @@ -1404,12 +1612,14 @@ static int input (void ); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int eggyylex (void); +extern int yylex \ + (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner); -#define YY_DECL int eggyylex (void) +#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 eggyytext and eggyyleng +/* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION @@ -1418,7 +1628,7 @@ extern int eggyylex (void); /* Code executed at the end of each rule. */ #ifndef YY_BREAK -#define YY_BREAK break; +#define YY_BREAK /*LINTED*/break; #endif #define YY_RULE_SETUP \ @@ -1431,75 +1641,82 @@ YY_DECL yy_state_type yy_current_state; char *yy_cp, *yy_bp; int yy_act; - -#line 302 "lexer.lxx" + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; + yylloc = yylloc_param; - if (initial_token != 0) { - int t = initial_token; - initial_token = 0; - return t; - } - - -#line 1434 "lex.yy.c" - - if ( !(yy_init) ) + if ( !yyg->yy_init ) { - (yy_init) = 1; + yyg->yy_init = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ - if ( ! eggyyin ) - eggyyin = stdin; + if ( ! yyin ) + yyin = stdin; - if ( ! eggyyout ) - eggyyout = stdout; + if ( ! yyout ) + yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { - eggyyensure_buffer_stack (); + yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - eggyy_create_buffer(eggyyin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); } - eggyy_load_buffer_state( ); + yy_load_buffer_state( yyscanner ); } - while ( 1 ) /* loops until end-of-file is reached */ + { +#line 271 "panda/src/egg/lexer.lxx" + + + +#line 275 "panda/src/egg/lexer.lxx" + if (yyextra->_initial_token != 0) { + int t = yyextra->_initial_token; + yyextra->_initial_token = 0; + return t; + } + + +#line 1689 "panda/src/egg/lexer.cxx.prebuilt" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { - yy_cp = (yy_c_buf_p); + yy_cp = yyg->yy_c_buf_p; - /* Support of eggyytext. */ - *yy_cp = (yy_hold_char); + /* 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 = (yy_start); + yy_current_state = yyg->yy_start; yy_match: do { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; if ( yy_accept[yy_current_state] ) { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; + 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 >= 585 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 1225 ); @@ -1508,8 +1725,8 @@ yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; yy_act = yy_accept[yy_current_state]; } @@ -1521,23 +1738,26 @@ do_action: /* This label is used only to access EOF actions. */ { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); + *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: /* rule 1 can match eol */ YY_RULE_SETUP -#line 312 "lexer.lxx" +#line 282 "panda/src/egg/lexer.lxx" { // New line. Save a copy of the line so we can print it out for the // benefit of the user in case we get an error. - strncpy(current_line, eggyytext+1, max_error_width); - current_line[max_error_width] = '\0'; - line_number++; - col_number=0; + strncpy(yyextra->_current_line, yytext+1, egg_max_error_width); + yyextra->_current_line[egg_max_error_width] = '\0'; + + yylloc->first_line++; + yylloc->last_line++; + yylloc->first_column = 0; + yylloc->last_column = 0; // Return the whole line to the lexer, except the newline character, // which we eat. @@ -1546,41 +1766,41 @@ YY_RULE_SETUP YY_BREAK case 2: YY_RULE_SETUP -#line 326 "lexer.lxx" -{ +#line 299 "panda/src/egg/lexer.lxx" +{ // Eat whitespace. accept(); } YY_BREAK case 3: YY_RULE_SETUP -#line 331 "lexer.lxx" -{ +#line 304 "panda/src/egg/lexer.lxx" +{ // Eat C++-style comments. accept(); } YY_BREAK case 4: YY_RULE_SETUP -#line 336 "lexer.lxx" +#line 309 "panda/src/egg/lexer.lxx" { // Eat C-style comments. accept(); - eat_c_comment(); + eat_c_comment(yylloc, yyscanner); } YY_BREAK case 5: YY_RULE_SETUP -#line 342 "lexer.lxx" +#line 315 "panda/src/egg/lexer.lxx" { // Send curly braces as themselves. - accept(); - return eggyytext[0]; + accept(); + return yytext[0]; } YY_BREAK case 6: YY_RULE_SETUP -#line 350 "lexer.lxx" +#line 323 "panda/src/egg/lexer.lxx" { accept(); return ANIMPRELOAD; @@ -1588,7 +1808,7 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 354 "lexer.lxx" +#line 327 "panda/src/egg/lexer.lxx" { accept(); return AUX; @@ -1596,7 +1816,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 358 "lexer.lxx" +#line 331 "panda/src/egg/lexer.lxx" { accept(); return BEZIERCURVE; @@ -1604,7 +1824,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 362 "lexer.lxx" +#line 335 "panda/src/egg/lexer.lxx" { accept(); return BFACE; @@ -1612,7 +1832,7 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 366 "lexer.lxx" +#line 339 "panda/src/egg/lexer.lxx" { accept(); return BILLBOARD; @@ -1620,7 +1840,7 @@ YY_RULE_SETUP YY_BREAK case 11: YY_RULE_SETUP -#line 370 "lexer.lxx" +#line 343 "panda/src/egg/lexer.lxx" { accept(); return BILLBOARDCENTER; @@ -1628,7 +1848,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 374 "lexer.lxx" +#line 347 "panda/src/egg/lexer.lxx" { accept(); return BINORMAL; @@ -1636,7 +1856,7 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 378 "lexer.lxx" +#line 351 "panda/src/egg/lexer.lxx" { accept(); return BUNDLE; @@ -1644,7 +1864,7 @@ YY_RULE_SETUP YY_BREAK case 14: YY_RULE_SETUP -#line 382 "lexer.lxx" +#line 355 "panda/src/egg/lexer.lxx" { accept(); return SCALAR; @@ -1652,7 +1872,7 @@ YY_RULE_SETUP YY_BREAK case 15: YY_RULE_SETUP -#line 386 "lexer.lxx" +#line 359 "panda/src/egg/lexer.lxx" { accept(); return CLOSED; @@ -1660,7 +1880,7 @@ YY_RULE_SETUP YY_BREAK case 16: YY_RULE_SETUP -#line 390 "lexer.lxx" +#line 363 "panda/src/egg/lexer.lxx" { accept(); return COLLIDE; @@ -1668,7 +1888,7 @@ YY_RULE_SETUP YY_BREAK case 17: YY_RULE_SETUP -#line 394 "lexer.lxx" +#line 367 "panda/src/egg/lexer.lxx" { accept(); return COMMENT; @@ -1676,7 +1896,7 @@ YY_RULE_SETUP YY_BREAK case 18: YY_RULE_SETUP -#line 398 "lexer.lxx" +#line 371 "panda/src/egg/lexer.lxx" { accept(); return COMPONENT; @@ -1684,7 +1904,7 @@ YY_RULE_SETUP YY_BREAK case 19: YY_RULE_SETUP -#line 402 "lexer.lxx" +#line 375 "panda/src/egg/lexer.lxx" { accept(); return COORDSYSTEM; @@ -1692,7 +1912,7 @@ YY_RULE_SETUP YY_BREAK case 20: YY_RULE_SETUP -#line 406 "lexer.lxx" +#line 379 "panda/src/egg/lexer.lxx" { accept(); return CV; @@ -1700,7 +1920,7 @@ YY_RULE_SETUP YY_BREAK case 21: YY_RULE_SETUP -#line 410 "lexer.lxx" +#line 383 "panda/src/egg/lexer.lxx" { accept(); return DART; @@ -1708,7 +1928,7 @@ YY_RULE_SETUP YY_BREAK case 22: YY_RULE_SETUP -#line 414 "lexer.lxx" +#line 387 "panda/src/egg/lexer.lxx" { accept(); return DNORMAL; @@ -1716,7 +1936,7 @@ YY_RULE_SETUP YY_BREAK case 23: YY_RULE_SETUP -#line 418 "lexer.lxx" +#line 391 "panda/src/egg/lexer.lxx" { accept(); return DRGBA; @@ -1724,7 +1944,7 @@ YY_RULE_SETUP YY_BREAK case 24: YY_RULE_SETUP -#line 422 "lexer.lxx" +#line 395 "panda/src/egg/lexer.lxx" { accept(); return DUV; @@ -1732,7 +1952,7 @@ YY_RULE_SETUP YY_BREAK case 25: YY_RULE_SETUP -#line 426 "lexer.lxx" +#line 399 "panda/src/egg/lexer.lxx" { accept(); return DXYZ; @@ -1740,7 +1960,7 @@ YY_RULE_SETUP YY_BREAK case 26: YY_RULE_SETUP -#line 430 "lexer.lxx" +#line 403 "panda/src/egg/lexer.lxx" { accept(); return DCS; @@ -1748,7 +1968,7 @@ YY_RULE_SETUP YY_BREAK case 27: YY_RULE_SETUP -#line 434 "lexer.lxx" +#line 407 "panda/src/egg/lexer.lxx" { accept(); return DISTANCE; @@ -1756,7 +1976,7 @@ YY_RULE_SETUP YY_BREAK case 28: YY_RULE_SETUP -#line 438 "lexer.lxx" +#line 411 "panda/src/egg/lexer.lxx" { accept(); return DTREF; @@ -1764,7 +1984,7 @@ YY_RULE_SETUP YY_BREAK case 29: YY_RULE_SETUP -#line 442 "lexer.lxx" +#line 415 "panda/src/egg/lexer.lxx" { accept(); return DYNAMICVERTEXPOOL; @@ -1772,7 +1992,7 @@ YY_RULE_SETUP YY_BREAK case 30: YY_RULE_SETUP -#line 446 "lexer.lxx" +#line 419 "panda/src/egg/lexer.lxx" { accept(); return EXTERNAL_FILE; @@ -1780,7 +2000,7 @@ YY_RULE_SETUP YY_BREAK case 31: YY_RULE_SETUP -#line 450 "lexer.lxx" +#line 423 "panda/src/egg/lexer.lxx" { accept(); return GROUP; @@ -1788,7 +2008,7 @@ YY_RULE_SETUP YY_BREAK case 32: YY_RULE_SETUP -#line 454 "lexer.lxx" +#line 427 "panda/src/egg/lexer.lxx" { accept(); return DEFAULTPOSE; @@ -1796,7 +2016,7 @@ YY_RULE_SETUP YY_BREAK case 33: YY_RULE_SETUP -#line 458 "lexer.lxx" +#line 431 "panda/src/egg/lexer.lxx" { accept(); return JOINT; @@ -1804,7 +2024,7 @@ YY_RULE_SETUP YY_BREAK case 34: YY_RULE_SETUP -#line 462 "lexer.lxx" +#line 435 "panda/src/egg/lexer.lxx" { accept(); return KNOTS; @@ -1812,7 +2032,7 @@ YY_RULE_SETUP YY_BREAK case 35: YY_RULE_SETUP -#line 466 "lexer.lxx" +#line 439 "panda/src/egg/lexer.lxx" { accept(); return INCLUDE; @@ -1820,7 +2040,7 @@ YY_RULE_SETUP YY_BREAK case 36: YY_RULE_SETUP -#line 470 "lexer.lxx" +#line 443 "panda/src/egg/lexer.lxx" { accept(); return INSTANCE; @@ -1828,7 +2048,7 @@ YY_RULE_SETUP YY_BREAK case 37: YY_RULE_SETUP -#line 474 "lexer.lxx" +#line 447 "panda/src/egg/lexer.lxx" { accept(); return LINE; @@ -1836,7 +2056,7 @@ YY_RULE_SETUP YY_BREAK case 38: YY_RULE_SETUP -#line 478 "lexer.lxx" +#line 451 "panda/src/egg/lexer.lxx" { accept(); return LOOP; @@ -1844,7 +2064,7 @@ YY_RULE_SETUP YY_BREAK case 39: YY_RULE_SETUP -#line 482 "lexer.lxx" +#line 455 "panda/src/egg/lexer.lxx" { accept(); return MATERIAL; @@ -1852,7 +2072,7 @@ YY_RULE_SETUP YY_BREAK case 40: YY_RULE_SETUP -#line 486 "lexer.lxx" +#line 459 "panda/src/egg/lexer.lxx" { accept(); return MATRIX3; @@ -1860,7 +2080,7 @@ YY_RULE_SETUP YY_BREAK case 41: YY_RULE_SETUP -#line 490 "lexer.lxx" +#line 463 "panda/src/egg/lexer.lxx" { accept(); return MATRIX4; @@ -1868,7 +2088,7 @@ YY_RULE_SETUP YY_BREAK case 42: YY_RULE_SETUP -#line 494 "lexer.lxx" +#line 467 "panda/src/egg/lexer.lxx" { accept(); return MODEL; @@ -1876,7 +2096,7 @@ YY_RULE_SETUP YY_BREAK case 43: YY_RULE_SETUP -#line 498 "lexer.lxx" +#line 471 "panda/src/egg/lexer.lxx" { accept(); return MREF; @@ -1884,7 +2104,7 @@ YY_RULE_SETUP YY_BREAK case 44: YY_RULE_SETUP -#line 502 "lexer.lxx" +#line 475 "panda/src/egg/lexer.lxx" { accept(); return NORMAL; @@ -1892,7 +2112,7 @@ YY_RULE_SETUP YY_BREAK case 45: YY_RULE_SETUP -#line 506 "lexer.lxx" +#line 479 "panda/src/egg/lexer.lxx" { accept(); return NURBSCURVE; @@ -1900,7 +2120,7 @@ YY_RULE_SETUP YY_BREAK case 46: YY_RULE_SETUP -#line 510 "lexer.lxx" +#line 483 "panda/src/egg/lexer.lxx" { accept(); return NURBSSURFACE; @@ -1908,7 +2128,7 @@ YY_RULE_SETUP YY_BREAK case 47: YY_RULE_SETUP -#line 514 "lexer.lxx" +#line 487 "panda/src/egg/lexer.lxx" { accept(); return OBJECTTYPE; @@ -1916,7 +2136,7 @@ YY_RULE_SETUP YY_BREAK case 48: YY_RULE_SETUP -#line 518 "lexer.lxx" +#line 491 "panda/src/egg/lexer.lxx" { accept(); return ORDER; @@ -1924,7 +2144,7 @@ YY_RULE_SETUP YY_BREAK case 49: YY_RULE_SETUP -#line 522 "lexer.lxx" +#line 495 "panda/src/egg/lexer.lxx" { accept(); return OUTTANGENT; @@ -1932,7 +2152,7 @@ YY_RULE_SETUP YY_BREAK case 50: YY_RULE_SETUP -#line 526 "lexer.lxx" +#line 499 "panda/src/egg/lexer.lxx" { accept(); return PATCH; @@ -1940,7 +2160,7 @@ YY_RULE_SETUP YY_BREAK case 51: YY_RULE_SETUP -#line 530 "lexer.lxx" +#line 503 "panda/src/egg/lexer.lxx" { accept(); return POINTLIGHT; @@ -1948,7 +2168,7 @@ YY_RULE_SETUP YY_BREAK case 52: YY_RULE_SETUP -#line 534 "lexer.lxx" +#line 507 "panda/src/egg/lexer.lxx" { accept(); return POLYGON; @@ -1956,7 +2176,7 @@ YY_RULE_SETUP YY_BREAK case 53: YY_RULE_SETUP -#line 538 "lexer.lxx" +#line 511 "panda/src/egg/lexer.lxx" { accept(); return REF; @@ -1964,7 +2184,7 @@ YY_RULE_SETUP YY_BREAK case 54: YY_RULE_SETUP -#line 542 "lexer.lxx" +#line 515 "panda/src/egg/lexer.lxx" { accept(); return RGBA; @@ -1972,7 +2192,7 @@ YY_RULE_SETUP YY_BREAK case 55: YY_RULE_SETUP -#line 546 "lexer.lxx" +#line 519 "panda/src/egg/lexer.lxx" { accept(); return ROTATE; @@ -1980,7 +2200,7 @@ YY_RULE_SETUP YY_BREAK case 56: YY_RULE_SETUP -#line 550 "lexer.lxx" +#line 523 "panda/src/egg/lexer.lxx" { accept(); return ROTX; @@ -1988,7 +2208,7 @@ YY_RULE_SETUP YY_BREAK case 57: YY_RULE_SETUP -#line 554 "lexer.lxx" +#line 527 "panda/src/egg/lexer.lxx" { accept(); return ROTY; @@ -1996,7 +2216,7 @@ YY_RULE_SETUP YY_BREAK case 58: YY_RULE_SETUP -#line 558 "lexer.lxx" +#line 531 "panda/src/egg/lexer.lxx" { accept(); return ROTZ; @@ -2004,7 +2224,7 @@ YY_RULE_SETUP YY_BREAK case 59: YY_RULE_SETUP -#line 562 "lexer.lxx" +#line 535 "panda/src/egg/lexer.lxx" { accept(); return SANIM; @@ -2012,7 +2232,7 @@ YY_RULE_SETUP YY_BREAK case 60: YY_RULE_SETUP -#line 566 "lexer.lxx" +#line 539 "panda/src/egg/lexer.lxx" { accept(); return SCALAR; @@ -2020,7 +2240,7 @@ YY_RULE_SETUP YY_BREAK case 61: YY_RULE_SETUP -#line 570 "lexer.lxx" +#line 543 "panda/src/egg/lexer.lxx" { accept(); return SCALE; @@ -2028,7 +2248,7 @@ YY_RULE_SETUP YY_BREAK case 62: YY_RULE_SETUP -#line 574 "lexer.lxx" +#line 547 "panda/src/egg/lexer.lxx" { accept(); return SEQUENCE; @@ -2036,7 +2256,7 @@ YY_RULE_SETUP YY_BREAK case 63: YY_RULE_SETUP -#line 578 "lexer.lxx" +#line 551 "panda/src/egg/lexer.lxx" { accept(); return SHADING; @@ -2044,7 +2264,7 @@ YY_RULE_SETUP YY_BREAK case 64: YY_RULE_SETUP -#line 582 "lexer.lxx" +#line 555 "panda/src/egg/lexer.lxx" { accept(); return SWITCH; @@ -2052,7 +2272,7 @@ YY_RULE_SETUP YY_BREAK case 65: YY_RULE_SETUP -#line 586 "lexer.lxx" +#line 559 "panda/src/egg/lexer.lxx" { accept(); return SWITCHCONDITION; @@ -2060,7 +2280,7 @@ YY_RULE_SETUP YY_BREAK case 66: YY_RULE_SETUP -#line 590 "lexer.lxx" +#line 563 "panda/src/egg/lexer.lxx" { accept(); return TABLE; @@ -2068,7 +2288,7 @@ YY_RULE_SETUP YY_BREAK case 67: YY_RULE_SETUP -#line 594 "lexer.lxx" +#line 567 "panda/src/egg/lexer.lxx" { accept(); return TABLE_V; @@ -2076,7 +2296,7 @@ YY_RULE_SETUP YY_BREAK case 68: YY_RULE_SETUP -#line 598 "lexer.lxx" +#line 571 "panda/src/egg/lexer.lxx" { accept(); return TAG; @@ -2084,7 +2304,7 @@ YY_RULE_SETUP YY_BREAK case 69: YY_RULE_SETUP -#line 602 "lexer.lxx" +#line 575 "panda/src/egg/lexer.lxx" { accept(); return TANGENT; @@ -2092,7 +2312,7 @@ YY_RULE_SETUP YY_BREAK case 70: YY_RULE_SETUP -#line 606 "lexer.lxx" +#line 579 "panda/src/egg/lexer.lxx" { accept(); return TEXLIST; @@ -2100,7 +2320,7 @@ YY_RULE_SETUP YY_BREAK case 71: YY_RULE_SETUP -#line 610 "lexer.lxx" +#line 583 "panda/src/egg/lexer.lxx" { accept(); return TEXTURE; @@ -2108,7 +2328,7 @@ YY_RULE_SETUP YY_BREAK case 72: YY_RULE_SETUP -#line 614 "lexer.lxx" +#line 587 "panda/src/egg/lexer.lxx" { accept(); return TLENGTHS; @@ -2116,7 +2336,7 @@ YY_RULE_SETUP YY_BREAK case 73: YY_RULE_SETUP -#line 618 "lexer.lxx" +#line 591 "panda/src/egg/lexer.lxx" { accept(); return TRANSFORM; @@ -2124,7 +2344,7 @@ YY_RULE_SETUP YY_BREAK case 74: YY_RULE_SETUP -#line 622 "lexer.lxx" +#line 595 "panda/src/egg/lexer.lxx" { accept(); return TRANSLATE; @@ -2132,7 +2352,7 @@ YY_RULE_SETUP YY_BREAK case 75: YY_RULE_SETUP -#line 626 "lexer.lxx" +#line 599 "panda/src/egg/lexer.lxx" { accept(); return TREF; @@ -2140,7 +2360,7 @@ YY_RULE_SETUP YY_BREAK case 76: YY_RULE_SETUP -#line 630 "lexer.lxx" +#line 603 "panda/src/egg/lexer.lxx" { accept(); return TRIANGLEFAN; @@ -2148,7 +2368,7 @@ YY_RULE_SETUP YY_BREAK case 77: YY_RULE_SETUP -#line 634 "lexer.lxx" +#line 607 "panda/src/egg/lexer.lxx" { accept(); return TRIANGLESTRIP; @@ -2156,7 +2376,7 @@ YY_RULE_SETUP YY_BREAK case 78: YY_RULE_SETUP -#line 638 "lexer.lxx" +#line 611 "panda/src/egg/lexer.lxx" { accept(); return TRIM; @@ -2164,7 +2384,7 @@ YY_RULE_SETUP YY_BREAK case 79: YY_RULE_SETUP -#line 642 "lexer.lxx" +#line 615 "panda/src/egg/lexer.lxx" { accept(); return TXT; @@ -2172,7 +2392,7 @@ YY_RULE_SETUP YY_BREAK case 80: YY_RULE_SETUP -#line 646 "lexer.lxx" +#line 619 "panda/src/egg/lexer.lxx" { accept(); return UKNOTS; @@ -2180,7 +2400,7 @@ YY_RULE_SETUP YY_BREAK case 81: YY_RULE_SETUP -#line 650 "lexer.lxx" +#line 623 "panda/src/egg/lexer.lxx" { accept(); return UKNOTS; @@ -2188,7 +2408,7 @@ YY_RULE_SETUP YY_BREAK case 82: YY_RULE_SETUP -#line 654 "lexer.lxx" +#line 627 "panda/src/egg/lexer.lxx" { accept(); return UV; @@ -2196,7 +2416,7 @@ YY_RULE_SETUP YY_BREAK case 83: YY_RULE_SETUP -#line 658 "lexer.lxx" +#line 631 "panda/src/egg/lexer.lxx" { accept(); return VKNOTS; @@ -2204,7 +2424,7 @@ YY_RULE_SETUP YY_BREAK case 84: YY_RULE_SETUP -#line 662 "lexer.lxx" +#line 635 "panda/src/egg/lexer.lxx" { accept(); return VKNOTS; @@ -2212,7 +2432,7 @@ YY_RULE_SETUP YY_BREAK case 85: YY_RULE_SETUP -#line 666 "lexer.lxx" +#line 639 "panda/src/egg/lexer.lxx" { accept(); return VERTEX; @@ -2220,7 +2440,7 @@ YY_RULE_SETUP YY_BREAK case 86: YY_RULE_SETUP -#line 670 "lexer.lxx" +#line 643 "panda/src/egg/lexer.lxx" { accept(); return VERTEXANIM; @@ -2228,7 +2448,7 @@ YY_RULE_SETUP YY_BREAK case 87: YY_RULE_SETUP -#line 674 "lexer.lxx" +#line 647 "panda/src/egg/lexer.lxx" { accept(); return VERTEXPOOL; @@ -2236,7 +2456,7 @@ YY_RULE_SETUP YY_BREAK case 88: YY_RULE_SETUP -#line 678 "lexer.lxx" +#line 651 "panda/src/egg/lexer.lxx" { accept(); return VERTEXREF; @@ -2244,7 +2464,7 @@ YY_RULE_SETUP YY_BREAK case 89: YY_RULE_SETUP -#line 682 "lexer.lxx" +#line 655 "panda/src/egg/lexer.lxx" { accept(); return XFMANIM; @@ -2252,7 +2472,7 @@ YY_RULE_SETUP YY_BREAK case 90: YY_RULE_SETUP -#line 686 "lexer.lxx" +#line 659 "panda/src/egg/lexer.lxx" { accept(); return XFMSANIM; @@ -2260,144 +2480,144 @@ YY_RULE_SETUP YY_BREAK case 91: YY_RULE_SETUP -#line 693 "lexer.lxx" -{ +#line 666 "panda/src/egg/lexer.lxx" +{ // An integer or floating-point number. - accept(); - eggyylval._number = patof(eggyytext); - eggyylval._string = eggyytext; - return EGG_NUMBER; + accept(); + yylval->_number = patof(yytext); + yylval->_string = yytext; + return EGG_NUMBER; } YY_BREAK case 92: YY_RULE_SETUP -#line 701 "lexer.lxx" +#line 674 "panda/src/egg/lexer.lxx" { // A hexadecimal integer number. - accept(); - eggyylval._ulong = strtoul(eggyytext+2, NULL, 16); - eggyylval._string = eggyytext; - return EGG_ULONG; + accept(); + yylval->_ulong = strtoul(yytext+2, nullptr, 16); + yylval->_string = yytext; + return EGG_ULONG; } YY_BREAK case 93: YY_RULE_SETUP -#line 709 "lexer.lxx" +#line 682 "panda/src/egg/lexer.lxx" { // A binary integer number. - accept(); - eggyylval._ulong = strtoul(eggyytext+2, NULL, 2); - eggyylval._string = eggyytext; - return EGG_ULONG; + accept(); + yylval->_ulong = strtoul(yytext+2, nullptr, 2); + yylval->_string = yytext; + return EGG_ULONG; } YY_BREAK case 94: YY_RULE_SETUP -#line 717 "lexer.lxx" +#line 690 "panda/src/egg/lexer.lxx" { // not-a-number. These sometimes show up in egg files accidentally. - accept(); - memset(&eggyylval._number, 0, sizeof(eggyylval._number)); - *(unsigned long *)&eggyylval._number = strtoul(eggyytext+3, NULL, 0); - eggyylval._string = eggyytext; + accept(); + memset(&yylval->_number, 0, sizeof(yylval->_number)); + *(unsigned long *)&yylval->_number = strtoul(yytext+3, nullptr, 0); + yylval->_string = yytext; return EGG_NUMBER; } YY_BREAK case 95: YY_RULE_SETUP -#line 726 "lexer.lxx" -{ +#line 699 "panda/src/egg/lexer.lxx" +{ // infinity. As above. - accept(); - eggyylval._number = HUGE_VAL; - eggyylval._string = eggyytext; - return EGG_NUMBER; + accept(); + yylval->_number = HUGE_VAL; + yylval->_string = yytext; + return EGG_NUMBER; } YY_BREAK case 96: YY_RULE_SETUP -#line 734 "lexer.lxx" +#line 707 "panda/src/egg/lexer.lxx" { // minus infinity. As above. - accept(); - eggyylval._number = -HUGE_VAL; - eggyylval._string = eggyytext; - return EGG_NUMBER; + accept(); + yylval->_number = -HUGE_VAL; + yylval->_string = yytext; + return EGG_NUMBER; } YY_BREAK case 97: YY_RULE_SETUP -#line 742 "lexer.lxx" -{ +#line 715 "panda/src/egg/lexer.lxx" +{ // infinity, on Win32. As above. - accept(); - eggyylval._number = HUGE_VAL; - eggyylval._string = eggyytext; - return EGG_NUMBER; + accept(); + yylval->_number = HUGE_VAL; + yylval->_string = yytext; + return EGG_NUMBER; } YY_BREAK case 98: YY_RULE_SETUP -#line 750 "lexer.lxx" +#line 723 "panda/src/egg/lexer.lxx" { // minus infinity, on Win32. As above. - accept(); - eggyylval._number = -HUGE_VAL; - eggyylval._string = eggyytext; - return EGG_NUMBER; + accept(); + yylval->_number = -HUGE_VAL; + yylval->_string = yytext; + return EGG_NUMBER; } YY_BREAK case 99: YY_RULE_SETUP -#line 759 "lexer.lxx" +#line 732 "panda/src/egg/lexer.lxx" { // Quoted string. accept(); - eggyylval._string = scan_quoted_string(); + yylval->_string = scan_quoted_string(yylloc, yyscanner); return EGG_STRING; } YY_BREAK case 100: YY_RULE_SETUP -#line 766 "lexer.lxx" -{ +#line 739 "panda/src/egg/lexer.lxx" +{ // Unquoted string. accept(); - eggyylval._string = eggyytext; + yylval->_string = yytext; return EGG_STRING; } YY_BREAK case 101: YY_RULE_SETUP -#line 772 "lexer.lxx" +#line 745 "panda/src/egg/lexer.lxx" ECHO; YY_BREAK -#line 2363 "lex.yy.c" +#line 2595 "panda/src/egg/lexer.cxx.prebuilt" case YY_STATE_EOF(INITIAL): yyterminate(); case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); + *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 eggyyin at a new source and called - * eggyylex(). If so, then we have to assure + * 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. */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = eggyyin; + 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; } @@ -2408,13 +2628,13 @@ case YY_STATE_EOF(INITIAL): * end-of-buffer state). Contrast this with the test * in input(). */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + 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; - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state( ); + yy_current_state = yy_get_previous_state( yyscanner ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have @@ -2425,43 +2645,43 @@ case YY_STATE_EOF(INITIAL): * will run more slowly). */ - yy_next_state = yy_try_NUL_trans( yy_current_state ); + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); + yy_cp = ++yyg->yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { - yy_cp = (yy_c_buf_p); + yy_cp = yyg->yy_c_buf_p; goto yy_find_action; } } - else switch ( yy_get_next_buffer( ) ) + else switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_END_OF_FILE: { - (yy_did_buffer_switch_on_eof) = 0; + yyg->yy_did_buffer_switch_on_eof = 0; - if ( eggyywrap( ) ) + if ( yywrap( yyscanner ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up - * eggyytext, we can now 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. */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; @@ -2469,30 +2689,30 @@ case YY_STATE_EOF(INITIAL): else { - if ( ! (yy_did_buffer_switch_on_eof) ) + if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state( ); + yy_current_state = yy_get_previous_state( yyscanner ); - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - yy_current_state = yy_get_previous_state( ); + yy_current_state = yy_get_previous_state( yyscanner ); - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } break; @@ -2503,7 +2723,8 @@ case YY_STATE_EOF(INITIAL): "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ -} /* end of eggyylex */ + } /* end of user's declarations */ +} /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * @@ -2512,20 +2733,21 @@ case YY_STATE_EOF(INITIAL): * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ -static int yy_get_next_buffer (void) +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 = (yytext_ptr); + char *source = yyg->yytext_ptr; int number_to_move, i; int ret_val; - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + 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 ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + 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. @@ -2545,7 +2767,7 @@ static int yy_get_next_buffer (void) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -2554,7 +2776,7 @@ static int yy_get_next_buffer (void) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; else { @@ -2565,10 +2787,10 @@ static int yy_get_next_buffer (void) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { @@ -2581,17 +2803,18 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - eggyyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + 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 = 0; + b->yy_ch_buf = NULL; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + 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; @@ -2603,17 +2826,17 @@ static int yy_get_next_buffer (void) /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), (size_t) num_to_read ); + yyg->yy_n_chars, num_to_read ); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } - if ( (yy_n_chars) == 0 ) + if ( yyg->yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - eggyyrestart(eggyyin ); + yyrestart( yyin , yyscanner); } else @@ -2627,47 +2850,51 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + 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. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) eggyyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + 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); } - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + 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; - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + 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 (void) + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { yy_state_type yy_current_state; char *yy_cp; - - yy_current_state = (yy_start); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + 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] ) { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; + 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 >= 585 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -2678,42 +2905,47 @@ static int yy_get_next_buffer (void) * synopsis * next_state = yy_try_NUL_trans( current_state ); */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { int yy_is_jam; - char *yy_cp = (yy_c_buf_p); + 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] ) { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; + 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 >= 585 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_is_jam = (yy_current_state == 584); + (void)yyg; return yy_is_jam ? 0 : yy_current_state; } - static void yyunput (int c, char * yy_bp ) +#ifndef YY_NO_UNPUT + + static void yyunput (int c, char * yy_bp , yyscan_t yyscanner) { char *yy_cp; - - yy_cp = (yy_c_buf_p); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* undo effects of setting up eggyytext */ - *yy_cp = (yy_hold_char); + yy_cp = yyg->yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yyg->yy_hold_char; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - int number_to_move = (yy_n_chars) + 2; + int number_to_move = yyg->yy_n_chars + 2; char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; char *source = @@ -2725,7 +2957,7 @@ static int yy_get_next_buffer (void) yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + yyg->yy_n_chars = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); @@ -2733,39 +2965,42 @@ static int yy_get_next_buffer (void) *--yy_cp = (char) c; - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; + yyg->yytext_ptr = yy_bp; + yyg->yy_hold_char = *yy_cp; + yyg->yy_c_buf_p = yy_cp; } +#endif + #ifndef YY_NO_INPUT #ifdef __cplusplus - static int yyinput (void) + static int yyinput (yyscan_t yyscanner) #else - static int input (void) + static int input (yyscan_t yyscanner) #endif { int c; - - *(yy_c_buf_p) = (yy_hold_char); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + *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 ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; + *yyg->yy_c_buf_p = '\0'; else { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); + int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); + ++yyg->yy_c_buf_p; - switch ( yy_get_next_buffer( ) ) + switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() @@ -2779,34 +3014,34 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - eggyyrestart(eggyyin ); + yyrestart( yyin , yyscanner); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( eggyywrap( ) ) - return EOF; + if ( yywrap( yyscanner ) ) + return 0; - if ( ! (yy_did_buffer_switch_on_eof) ) + if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; #ifdef __cplusplus - return yyinput(); + return yyinput(yyscanner); #else - return input(); + return input(yyscanner); #endif } case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; break; } } } - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve eggyytext */ - (yy_hold_char) = *++(yy_c_buf_p); + 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; } @@ -2814,102 +3049,106 @@ static int yy_get_next_buffer (void) /** 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 eggyyrestart (FILE * input_file ) + void yyrestart (FILE * input_file , yyscan_t yyscanner) { - + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! YY_CURRENT_BUFFER ){ - eggyyensure_buffer_stack (); + yyensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - eggyy_create_buffer(eggyyin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); } - eggyy_init_buffer(YY_CURRENT_BUFFER,input_file ); - eggyy_load_buffer_state( ); + 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 eggyy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) + 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 - * eggyypop_buffer_state(); - * eggyypush_buffer_state(new_buffer); + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); */ - eggyyensure_buffer_stack (); + yyensure_buffer_stack (yyscanner); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + *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; - eggyy_load_buffer_state( ); + yy_load_buffer_state( yyscanner ); /* We don't actually know whether we did this switch during - * EOF (eggyywrap()) processing, but the only time this flag - * is looked at is after eggyywrap() is called, so it's safe + * 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. */ - (yy_did_buffer_switch_on_eof) = 1; + yyg->yy_did_buffer_switch_on_eof = 1; } -static void eggyy_load_buffer_state (void) +static void yy_load_buffer_state (yyscan_t yyscanner) { - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - eggyyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); + 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 eggyy_create_buffer (FILE * file, int size ) + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) eggyyalloc(sizeof( struct yy_buffer_state ) ); + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in eggyy_create_buffer()" ); + 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 *) eggyyalloc(b->yy_buf_size + 2 ); + 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 eggyy_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - eggyy_init_buffer(b,file ); + yy_init_buffer( b, file , yyscanner); return b; } /** Destroy the buffer. - * @param b a buffer created with eggyy_create_buffer() - * + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. */ - void eggyy_delete_buffer (YY_BUFFER_STATE b ) + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { - + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) return; @@ -2917,31 +3156,28 @@ static void eggyy_load_buffer_state (void) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - eggyyfree((void *) b->yy_ch_buf ); + yyfree( (void *) b->yy_ch_buf , yyscanner ); - eggyyfree((void *) b ); + yyfree( (void *) b , yyscanner ); } -#ifndef __cplusplus -extern int isatty (int ); -#endif /* __cplusplus */ - /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, - * such as during a eggyyrestart() or at EOF. + * such as during a yyrestart() or at EOF. */ - static void eggyy_init_buffer (YY_BUFFER_STATE b, FILE * file ) + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { int oerrno = errno; - - eggyy_flush_buffer(b ); + 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 eggyy_init_buffer was _probably_ - * called from eggyyrestart() or through yy_get_next_buffer. + /* 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){ @@ -2950,17 +3186,18 @@ extern int isatty (int ); } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 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 eggyy_flush_buffer (YY_BUFFER_STATE b ) + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { - if ( ! b ) + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) return; b->yy_n_chars = 0; @@ -2978,184 +3215,187 @@ extern int isatty (int ); b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - eggyy_load_buffer_state( ); + 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 eggyypush_buffer_state (YY_BUFFER_STATE new_buffer ) +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { - if (new_buffer == NULL) + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) return; - eggyyensure_buffer_stack(); + yyensure_buffer_stack(yyscanner); - /* This block is copied from eggyy_switch_to_buffer. */ + /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + *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) - (yy_buffer_stack_top)++; + yyg->yy_buffer_stack_top++; YY_CURRENT_BUFFER_LVALUE = new_buffer; - /* copied from eggyy_switch_to_buffer. */ - eggyy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; + /* 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 eggyypop_buffer_state (void) +void yypop_buffer_state (yyscan_t yyscanner) { - if (!YY_CURRENT_BUFFER) + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) return; - eggyy_delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; if (YY_CURRENT_BUFFER) { - eggyy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; + 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 eggyyensure_buffer_stack (void) +static void yyensure_buffer_stack (yyscan_t yyscanner) { - int num_to_alloc; - - if (!(yy_buffer_stack)) { + 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; - (yy_buffer_stack) = (struct yy_buffer_state**)eggyyalloc + 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*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in eggyyensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; + , 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 ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; + yy_size_t grow_size = 8 /* arbitrary grow size */; - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)eggyyrealloc - ((yy_buffer_stack), + 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*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in eggyyensure_buffer_stack()" ); + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; + 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 - * - * @return the newly allocated buffer state object. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE eggyy_scan_buffer (char * base, yy_size_t size ) +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 0; + return NULL; - b = (YY_BUFFER_STATE) eggyyalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in eggyy_scan_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + 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 = 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; - eggyy_switch_to_buffer(b ); + yy_switch_to_buffer( b , yyscanner ); return b; } -/** Setup the input buffer state to scan a string. The next call to eggyylex() will +/** 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 - * eggyy_scan_bytes() instead. + * yy_scan_bytes() instead. */ -YY_BUFFER_STATE eggyy_scan_string (yyconst char * yystr ) +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) { - - return eggyy_scan_bytes(yystr,strlen(yystr) ); + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); } -/** Setup the input buffer state to scan the given bytes. The next call to eggyylex() will +/** 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 bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @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 eggyy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +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 = _yybytes_len + 2; - buf = (char *) eggyyalloc(n ); + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in eggyy_scan_bytes()" ); + 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 = eggyy_scan_buffer(buf,n ); + b = yy_scan_buffer( buf, n , yyscanner); if ( ! b ) - YY_FATAL_ERROR( "bad buffer in eggyy_scan_bytes()" ); + 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. @@ -3169,9 +3409,11 @@ YY_BUFFER_STATE eggyy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg ) +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) { - (void) fprintf( stderr, "%s\n", msg ); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -3181,144 +3423,307 @@ static void yy_fatal_error (yyconst char* msg ) #define yyless(n) \ do \ { \ - /* Undo effects of setting up eggyytext. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - eggyytext[eggyyleng] = (yy_hold_char); \ - (yy_c_buf_p) = eggyytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - eggyyleng = 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 current line number. - * +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. */ -int eggyyget_lineno (void) +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { - - return eggyylineno; + 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 *eggyyget_in (void) +FILE *yyget_in (yyscan_t yyscanner) { - return eggyyin; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; } /** Get the output stream. - * + * @param yyscanner The scanner object. */ -FILE *eggyyget_out (void) +FILE *yyget_out (yyscan_t yyscanner) { - return eggyyout; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; } /** Get the length of the current token. - * + * @param yyscanner The scanner object. */ -int eggyyget_leng (void) +int yyget_leng (yyscan_t yyscanner) { - return eggyyleng; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; } /** Get the current token. - * + * @param yyscanner The scanner object. */ -char *eggyyget_text (void) +char *yyget_text (yyscan_t yyscanner) { - return eggyytext; + 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 - * + * @param _line_number line number + * @param yyscanner The scanner object. */ -void eggyyset_lineno (int line_number ) +void yyset_lineno (int _line_number , yyscan_t yyscanner) { - - eggyylineno = line_number; + 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. - * - * @see eggyy_switch_to_buffer + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer */ -void eggyyset_in (FILE * in_str ) +void yyset_in (FILE * _in_str , yyscan_t yyscanner) { - eggyyin = in_str ; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; } -void eggyyset_out (FILE * out_str ) +void yyset_out (FILE * _out_str , yyscan_t yyscanner) { - eggyyout = out_str ; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; } -int eggyyget_debug (void) +int yyget_debug (yyscan_t yyscanner) { - return eggyy_flex_debug; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; } -void eggyyset_debug (int bdebug ) +void yyset_debug (int _bdebug , yyscan_t yyscanner) { - eggyy_flex_debug = bdebug ; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; } -static int yy_init_globals (void) +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) { - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from eggyylex_destroy(), so don't allocate here. + 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. */ - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; + 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 - eggyyin = stdin; - eggyyout = stdout; + yyin = stdin; + yyout = stdout; #else - eggyyin = (FILE *) 0; - eggyyout = (FILE *) 0; + yyin = NULL; + yyout = NULL; #endif /* For future reference: Set errno on error, since we are called by - * eggyylex_init() + * yylex_init() */ return 0; } -/* eggyylex_destroy is for both reentrant and non-reentrant scanners. */ -int eggyylex_destroy (void) +/* 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){ - eggyy_delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); YY_CURRENT_BUFFER_LVALUE = NULL; - eggyypop_buffer_state(); + yypop_buffer_state(yyscanner); } /* Destroy the stack itself. */ - eggyyfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; + 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 - * eggyylex() is called, initialization will occur. */ - yy_init_globals( ); + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; return 0; } @@ -3327,8 +3732,11 @@ int eggyylex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +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]; @@ -3336,7 +3744,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) { int n; for ( n = 0; s[n]; ++n ) @@ -3346,13 +3754,18 @@ static int yy_flex_strlen (yyconst char * s ) } #endif -void *eggyyalloc (yy_size_t size ) +void *yyalloc (yy_size_t size , yyscan_t yyscanner) { - return (void *) malloc( size ); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); } -void *eggyyrealloc (void * ptr, yy_size_t 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 @@ -3360,14 +3773,16 @@ void *eggyyrealloc (void * ptr, yy_size_t size ) * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ - return (void *) realloc( (char *) ptr, size ); + return realloc(ptr, size); } -void eggyyfree (void * ptr ) +void yyfree (void * ptr , yyscan_t yyscanner) { - free( (char *) ptr ); /* see eggyyrealloc() for (char *) cast */ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" -#line 772 "lexer.lxx" +#line 745 "panda/src/egg/lexer.lxx" diff --git a/panda/src/egg/lexer.lxx b/panda/src/egg/lexer.lxx index c4b6f88028..de86eed3c9 100644 --- a/panda/src/egg/lexer.lxx +++ b/panda/src/egg/lexer.lxx @@ -4,6 +4,10 @@ * @date 1999-01-16 */ +%option reentrant bison-bridge bison-locations +%option noyywrap +%option case-insensitive + %{ #include "pandabase.h" #include "lexerDefs.h" @@ -18,182 +22,156 @@ #include -using std::istream; -using std::ostream; -using std::string; - -extern "C" int eggyywrap(void); // declared below. - -static int yyinput(void); // declared by flex. - -int eggyylex_destroy(void); - -//////////////////////////////////////////////////////////////////// -// Static variables -//////////////////////////////////////////////////////////////////// - -// This mutex protects all of these global variables. -LightMutex egg_lock; - -// We'll increment line_number and col_number as we parse the file, so -// that we can report the position of an error. -static int line_number = 0; -static int col_number = 0; - -// current_line holds as much of the current line as will fit. Its -// only purpose is for printing it out to report an error to the user. -static const int max_error_width = 1024; -static char current_line[max_error_width + 1]; - -static int error_count = 0; -static int warning_count = 0; - -// This is the pointer to the current input stream. -static istream *input_p = nullptr; - -// This is the name of the egg file we're parsing. We keep it so we -// can print it out for error messages. -static string egg_filename; - -// This is the initial token state returned by the lexer. It allows -// the yacc grammar to start from initial points. -static int initial_token; +// These are declared by flex. +static int yyinput(yyscan_t yyscanner); +static EggLexerState *eggyyget_extra(yyscan_t scanner); //////////////////////////////////////////////////////////////////// // Defining the interface to the lexer. //////////////////////////////////////////////////////////////////// void -egg_init_lexer(istream &in, const string &filename) { - input_p = ∈ - egg_filename = filename; - line_number = 0; - col_number = 0; - error_count = 0; - warning_count = 0; - initial_token = START_EGG; +egg_init_lexer_state(EggLexerState &state, std::istream &in, const std::string &filename) { + state._error_count = 0; + state._warning_count = 0; + state._input_p = ∈ + state._egg_filename = filename; + state._initial_token = START_EGG; } void -egg_cleanup_lexer() { - // Reset the lexer state. - yylex_destroy(); - - input_p = nullptr; - egg_filename.clear(); +egg_cleanup_lexer_state(EggLexerState &state) { + state._input_p = nullptr; + state._egg_filename.clear(); } void -egg_start_group_body() { +egg_start_group_body(EggLexerState &state) { /* Set the initial state to begin within a group_body context, instead of at the beginning of the egg file. */ - initial_token = START_GROUP_BODY; + state._initial_token = START_GROUP_BODY; } void -egg_start_texture_body() { - initial_token = START_TEXTURE_BODY; +egg_start_texture_body(EggLexerState &state) { + state._initial_token = START_TEXTURE_BODY; } void -egg_start_primitive_body() { - initial_token = START_PRIMITIVE_BODY; +egg_start_primitive_body(EggLexerState &state) { + state._initial_token = START_PRIMITIVE_BODY; } -int -egg_error_count() { - return error_count; -} - -int -egg_warning_count() { - return warning_count; -} - - //////////////////////////////////////////////////////////////////// // Internal support functions. //////////////////////////////////////////////////////////////////// -int -eggyywrap(void) { - return 1; -} - void -eggyyerror(const string &msg) { +eggyyerror(YYLTYPE *loc, yyscan_t scanner, const std::string &msg) { + EggLexerState *lexer_state = eggyyget_extra(scanner); + if (egg_cat.is_error()) { - ostream &out = egg_cat.error(false); + std::ostream &out = egg_cat.error(false); out << "\nError"; - if (!egg_filename.empty()) { - out << " in " << egg_filename; + if (!lexer_state->_egg_filename.empty()) { + out << " in " << lexer_state->_egg_filename; + } + if (loc != nullptr) { + out + << " at line " << loc->first_line << ", column " << loc->first_column << ":\n" + << std::setiosflags(Notify::get_literal_flag()) + << lexer_state->_current_line << "\n"; + indent(out, loc->first_column - 1) + << "^"; + + int last_column; + if (loc->first_line == loc->last_line) { + last_column = loc->last_column; + } else { + last_column = strlen(lexer_state->_current_line); + } + for (int i = loc->first_column; i < last_column; ++i) { + out.put('~'); + } + + out + << "\n" << msg << "\n\n" + << std::resetiosflags(Notify::get_literal_flag()) << std::flush; + } + else { + out << ":\n" << msg << "\n\n" << std::flush; } - out - << " at line " << line_number << ", column " << col_number << ":\n" - << std::setiosflags(Notify::get_literal_flag()) - << current_line << "\n"; - indent(out, col_number-1) - << "^\n" << msg << "\n\n" - << std::resetiosflags(Notify::get_literal_flag()) << std::flush; } - error_count++; + lexer_state->_error_count++; } void -eggyyerror(std::ostringstream &strm) { - string s = strm.str(); - eggyyerror(s); -} +eggyywarning(YYLTYPE *loc, yyscan_t scanner, const std::string &msg) { + EggLexerState *lexer_state = eggyyget_extra(scanner); -void -eggyywarning(const string &msg) { if (egg_cat.is_warning()) { - ostream &out = egg_cat.warning(false); + std::ostream &out = egg_cat.warning(false); out << "\nWarning"; - if (!egg_filename.empty()) { - out << " in " << egg_filename; + if (!lexer_state->_egg_filename.empty()) { + out << " in " << lexer_state->_egg_filename; } - out - << " at line " << line_number << ", column " << col_number << ":\n" - << std::setiosflags(Notify::get_literal_flag()) - << current_line << "\n"; - indent(out, col_number-1) - << "^\n" << msg << "\n\n" - << std::resetiosflags(Notify::get_literal_flag()) << std::flush; - } - warning_count++; -} + if (loc != nullptr) { + out + << " at line " << loc->first_line << ", column " << loc->first_column << ":\n" + << std::setiosflags(Notify::get_literal_flag()) + << lexer_state->_current_line << "\n"; + indent(out, loc->first_column - 1) + << "^"; -void -eggyywarning(std::ostringstream &strm) { - string s = strm.str(); - eggyywarning(s); + int last_column; + if (loc->first_line == loc->last_line) { + last_column = loc->last_column; + } else { + last_column = strlen(lexer_state->_current_line); + } + for (int i = loc->first_column; i < last_column; ++i) { + out.put('~'); + } + + out + << "\n" << msg << "\n\n" + << std::resetiosflags(Notify::get_literal_flag()) << std::flush; + } + else { + out << ":\n" << msg << "\n\n" << std::flush; + } + } + lexer_state->_warning_count++; } // Now define a function to take input from an istream instead of a // stdio FILE pointer. This is flex-specific. static void -input_chars(char *buffer, int &result, int max_size) { - nassertv(input_p != nullptr); - if (*input_p) { - input_p->read(buffer, max_size); - result = input_p->gcount(); +input_chars(YYLTYPE *yylloc, yyscan_t yyscanner, char *buffer, int &result, int max_size) { + EggLexerState &state = *yyget_extra(yyscanner); - if (line_number == 0) { + nassertv(state._input_p != nullptr); + if (*state._input_p) { + state._input_p->read(buffer, max_size); + result = state._input_p->gcount(); + + if (yylloc->last_line == 0) { // This is a special case. If we are reading the very first bit - // from the stream, copy it into the current_line array. This - // is because the \n.* rule below, which fills current_line + // from the stream, copy it into the _current_line array. This + // is because the \n.* rule below, which fills _current_line // normally, doesn't catch the first line. - int length = std::min(max_error_width, result); - strncpy(current_line, buffer, length); - current_line[length] = '\0'; - line_number++; - col_number = 0; + size_t length = std::min(egg_max_error_width, (size_t)result); + strncpy(state._current_line, buffer, length); + state._current_line[length] = '\0'; + yylloc->first_line = 1; + yylloc->last_line = 1; + yylloc->first_column = 0; + yylloc->last_column = 0; // Truncate it at the newline. - char *end = strchr(current_line, '\n'); + char *end = strchr(state._current_line, '\n'); if (end != nullptr) { *end = '\0'; } @@ -211,7 +189,7 @@ input_chars(char *buffer, int &result, int max_size) { // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ int int_result = 0; \ - input_chars((buffer), int_result, (max_size)); \ + input_chars(yylloc, yyscanner, (buffer), int_result, (max_size)); \ (result) = int_result; \ } @@ -219,8 +197,8 @@ input_chars(char *buffer, int &result, int max_size) { // supplied line and column numbers as appropriate. A convenience // function for the scanning functions below. static int -read_char(int &line, int &col) { - int c = yyinput(); +read_char(yyscan_t yyscanner, int &line, int &col) { + int c = yyinput(yyscanner); if (c == '\n') { line++; col = 0; @@ -232,78 +210,56 @@ read_char(int &line, int &col) { // scan_quoted_string reads a string delimited by quotation marks and // returns it. -static string -scan_quoted_string() { - string result; - - // We don't touch the current line number and column number during - // scanning, so that if we detect an error while scanning the string - // (e.g. an unterminated string), we'll report the error as - // occurring at the start of the string, not at the end--somewhat - // more convenient for the user. - - // Instead of adjusting the global line_number and col_number - // variables, we'll operate on our own local variables for the - // interim. - int line = line_number; - int col = col_number; +static std::string +scan_quoted_string(YYLTYPE *yylloc, yyscan_t yyscanner) { + std::string result; int c; - c = read_char(line, col); + c = read_char(yyscanner, yylloc->last_line, yylloc->last_column); while (c != '"' && c != 0 && c != EOF) { result += c; - c = read_char(line, col); + c = read_char(yyscanner, yylloc->last_line, yylloc->last_column); } if (c == 0 || c == EOF) { - eggyyerror("This quotation mark is unterminated."); + eggyyerror(yylloc, yyscanner, "This quotation mark is unterminated."); } - line_number = line; - col_number = col; - return result; } // eat_c_comment scans past all characters up until the first */ // encountered. static void -eat_c_comment() { - // As above, we'll operate on our own local copies of line_number - // and col_number within this function. - - int line = line_number; - int col = col_number; - +eat_c_comment(YYLTYPE *yylloc, yyscan_t yyscanner) { int c, last_c; last_c = '\0'; - c = read_char(line, col); + c = read_char(yyscanner, yylloc->last_line, yylloc->last_column); while (c != 0 && c != EOF && !(last_c == '*' && c == '/')) { if (last_c == '/' && c == '*') { std::ostringstream errmsg; errmsg << "This comment contains a nested /* symbol at line " - << line << ", column " << col-1 << "--possibly unclosed?" - << std::ends; - eggyywarning(errmsg); + << yylloc->last_line << ", column " << yylloc->last_column - 1 + << "--possibly unclosed?" << std::ends; + eggyywarning(yylloc, yyscanner, errmsg.str()); } last_c = c; - c = read_char(line, col); + c = read_char(yyscanner, yylloc->last_line, yylloc->last_column); } if (c == 0 || c == EOF) { - eggyyerror("This comment marker is unclosed."); + eggyyerror(yylloc, yyscanner, "This comment marker is unclosed."); } - - line_number = line; - col_number = col; } // accept() is called below as each piece is pulled off and // accepted by the lexer; it increments the current column number. -INLINE void accept() { - col_number += yyleng; +#define accept() { \ + yylloc->first_line = yylloc->last_line; \ + yylloc->first_column = yylloc->last_column + 1; \ + yylloc->last_column += yyleng; \ } %} @@ -315,9 +271,9 @@ NUMERIC ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) %% %{ - if (initial_token != 0) { - int t = initial_token; - initial_token = 0; + if (yyextra->_initial_token != 0) { + int t = yyextra->_initial_token; + yyextra->_initial_token = 0; return t; } %} @@ -326,10 +282,13 @@ NUMERIC ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) // New line. Save a copy of the line so we can print it out for the // benefit of the user in case we get an error. - strncpy(current_line, yytext+1, max_error_width); - current_line[max_error_width] = '\0'; - line_number++; - col_number=0; + strncpy(yyextra->_current_line, yytext+1, egg_max_error_width); + yyextra->_current_line[egg_max_error_width] = '\0'; + + yylloc->first_line++; + yylloc->last_line++; + yylloc->first_column = 0; + yylloc->last_column = 0; // Return the whole line to the lexer, except the newline character, // which we eat. @@ -349,13 +308,13 @@ NUMERIC ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) "/*" { // Eat C-style comments. accept(); - eat_c_comment(); + eat_c_comment(yylloc, yyscanner); } [{}] { // Send curly braces as themselves. accept(); - return eggyytext[0]; + return yytext[0]; } @@ -706,65 +665,65 @@ NUMERIC ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) {NUMERIC} { // An integer or floating-point number. accept(); - eggyylval._number = patof(eggyytext); - eggyylval._string = yytext; + yylval->_number = patof(yytext); + yylval->_string = yytext; return EGG_NUMBER; } {HEX} { // A hexadecimal integer number. accept(); - eggyylval._ulong = strtoul(yytext+2, nullptr, 16); - eggyylval._string = yytext; + yylval->_ulong = strtoul(yytext+2, nullptr, 16); + yylval->_string = yytext; return EGG_ULONG; } {BINARY} { // A binary integer number. accept(); - eggyylval._ulong = strtoul(yytext+2, nullptr, 2); - eggyylval._string = yytext; + yylval->_ulong = strtoul(yytext+2, nullptr, 2); + yylval->_string = yytext; return EGG_ULONG; } "nan"{HEX} { // not-a-number. These sometimes show up in egg files accidentally. accept(); - memset(&eggyylval._number, 0, sizeof(eggyylval._number)); - *(unsigned long *)&eggyylval._number = strtoul(yytext+3, nullptr, 0); - eggyylval._string = yytext; + memset(&yylval->_number, 0, sizeof(yylval->_number)); + *(unsigned long *)&yylval->_number = strtoul(yytext+3, nullptr, 0); + yylval->_string = yytext; return EGG_NUMBER; } "inf" { // infinity. As above. accept(); - eggyylval._number = HUGE_VAL; - eggyylval._string = yytext; + yylval->_number = HUGE_VAL; + yylval->_string = yytext; return EGG_NUMBER; } "-inf" { // minus infinity. As above. accept(); - eggyylval._number = -HUGE_VAL; - eggyylval._string = yytext; + yylval->_number = -HUGE_VAL; + yylval->_string = yytext; return EGG_NUMBER; } "1.#inf" { // infinity, on Win32. As above. accept(); - eggyylval._number = HUGE_VAL; - eggyylval._string = yytext; + yylval->_number = HUGE_VAL; + yylval->_string = yytext; return EGG_NUMBER; } "-1.#inf" { // minus infinity, on Win32. As above. accept(); - eggyylval._number = -HUGE_VAL; - eggyylval._string = yytext; + yylval->_number = -HUGE_VAL; + yylval->_string = yytext; return EGG_NUMBER; } @@ -772,13 +731,13 @@ NUMERIC ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) ["] { // Quoted string. accept(); - eggyylval._string = scan_quoted_string(); + yylval->_string = scan_quoted_string(yylloc, yyscanner); return EGG_STRING; } [^ \t\n\r{}"]+ { // Unquoted string. accept(); - eggyylval._string = yytext; + yylval->_string = yytext; return EGG_STRING; } diff --git a/panda/src/egg/lexerDefs.h b/panda/src/egg/lexerDefs.h index 6b1f321cb5..8c0b4331f0 100644 --- a/panda/src/egg/lexerDefs.h +++ b/panda/src/egg/lexerDefs.h @@ -15,26 +15,56 @@ #define LEXER_H #include "pandabase.h" - +#include "parserDefs.h" #include "typedef.h" #include -void egg_init_lexer(std::istream &in, const std::string &filename); -void egg_cleanup_lexer(); -void egg_start_group_body(); -void egg_start_texture_body(); -void egg_start_primitive_body(); -int egg_error_count(); -int egg_warning_count(); +typedef void *yyscan_t; +struct EggLexerState; +struct EggParserState; +struct EggTokenType; +struct EggLocType; -void eggyyerror(const std::string &msg); -void eggyyerror(std::ostringstream &strm); +void egg_init_lexer_state(EggLexerState &state, std::istream &in, const std::string &filename); +void egg_cleanup_lexer_state(EggLexerState &state); -void eggyywarning(const std::string &msg); -void eggyywarning(std::ostringstream &strm); +void egg_start_group_body(EggLexerState &state); +void egg_start_texture_body(EggLexerState &state); +void egg_start_primitive_body(EggLexerState &state); -int eggyylex(); +// These functions are declared by flex. +int eggyylex_init_extra(EggLexerState *state, yyscan_t *scanner); +int eggyylex_destroy(yyscan_t scanner); + +void eggyyerror(EggLocType *loc, yyscan_t scanner, const std::string &msg); +void eggyywarning(EggLocType *loc, yyscan_t scanner, const std::string &msg); + +int eggyylex(EggTokenType *yylval_param, EggLocType *yylloc_param, yyscan_t yyscanner); + +static const size_t egg_max_error_width = 1024; + +struct EggLexerState { + // current_line holds as much of the current line as will fit. Its + // only purpose is for printing it out to report an error to the user. + char _current_line[egg_max_error_width + 1]; + + int _error_count = 0; + int _warning_count = 0; + + // This is the pointer to the current input stream. + std::istream *_input_p = nullptr; + + // This is the name of the egg file we're parsing. We keep it so we + // can print it out for error messages. + std::string _egg_filename; + + // This is the initial token state returned by the lexer. It allows + // the yacc grammar to start from initial points. + int _initial_token = 0; +}; + +#define YY_EXTRA_TYPE EggLexerState * // always read from files #define YY_NEVER_INTERACTIVE 1 diff --git a/panda/src/egg/parser.cxx.prebuilt b/panda/src/egg/parser.cxx.prebuilt index d9b32aced5..c926fcbc45 100644 --- a/panda/src/egg/parser.cxx.prebuilt +++ b/panda/src/egg/parser.cxx.prebuilt @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.2.2. */ +/* A Bison parser, made by GNU Bison 3.7.2. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +34,10 @@ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. @@ -40,20 +45,17 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Undocumented macros, especially those whose name start with YY_, - are private implementation details. Do not rely on them. */ - /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.2.2" +#define YYBISON_VERSION "3.7.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ -#define YYPURE 0 +#define YYPURE 2 /* Push parsers. */ #define YYPUSH 0 @@ -69,11 +71,8 @@ #define yydebug eggyydebug #define yynerrs eggyynerrs -#define yylval eggyylval -#define yychar eggyychar - /* First part of user prologue. */ -#line 7 "panda/src/egg/parser.yxx" /* yacc.c:338 */ +#line 12 "panda/src/egg/parser.yxx" #include "pandabase.h" @@ -127,78 +126,73 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 -using std::istream; using std::ostringstream; using std::string; -// We need a stack of EggObject pointers. Each time we encounter a -// nested EggObject of some kind, we'll allocate a new one of these -// and push it onto the stack. At any given time, the top of the -// stack is the EggObject we are currently scanning. +typedef pvector< PT(EggObject)> EggStack; +typedef pmap VertexPools; +typedef pmap Textures; +typedef pmap Materials; +typedef pmap Groups; -typedef pvector< PT(EggObject) > EggStack; -static EggStack egg_stack; +struct EggParserState { + // We need a stack of EggObject pointers. Each time we encounter a + // nested EggObject of some kind, we'll allocate a new one of these + // and push it onto the stack. At any given time, the top of the + // stack is the EggObject we are currently scanning. + EggStack stack; -// This is used just when parsing a or entry. -static EggTransform *egg_top_transform; + // This is used just when parsing a or entry. + EggTransform *top_transform; -// There's one "top-level" egg node, which is where we should parent -// things (e.g. implicit textures) encountered in the egg file that -// don't have an explicit place in the tree. If this is NULL, such -// things won't be parented anywhere. -static EggGroupNode *egg_top_node; + // There's one "top-level" egg node, which is where we should parent + // things (e.g. implicit state.textures) encountered in the egg file that + // don't have an explicit place in the tree. If this is NULL, such + // things won't be parented anywhere. + EggGroupNode *top_node; -// We need a table mapping vertex pool names to vertex pools. -typedef pmap VertexPools; -static VertexPools vertex_pools; + // We need a table mapping vertex pool names to vertex pools. + VertexPools vertex_pools; -// And another one mapping texture names to textures. -typedef pmap Textures; -static Textures textures; + // And another one mapping texture names to state.textures. + Textures textures; -// And again for material names to materials. -typedef pmap Materials; -static Materials materials; + // And again for material names to state.materials. + Materials materials; -// Group names to groups. -typedef pmap Groups; -static Groups groups; + // Group names to state.groups. + Groups groups; -// We need to be able to save the index number requested for a vertex -// temporarily. -static int vertex_index; + // We need to be able to save the index number requested for a vertex + // temporarily. + int vertex_index; +}; +static int eggyyparse(EggParserState &state, yyscan_t scanner); //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. //////////////////////////////////////////////////////////////////// -void -egg_init_parser(istream &in, const string &filename, - EggObject *tos, EggGroupNode *top_node) { - egg_init_lexer(in, filename); +bool +egg_parse(EggLexerState &lexer_state, EggObject *tos, EggGroupNode *top_node) { + yyscan_t scanner = nullptr; + eggyylex_init_extra(&lexer_state, &scanner); - egg_stack.clear(); - vertex_pools.clear(); - textures.clear(); - materials.clear(); - groups.clear(); + EggParserState state; + state.stack.push_back(tos); + state.top_node = top_node; + eggyyparse(state, scanner); - egg_stack.push_back(tos); - egg_top_node = top_node; -} - -void -egg_cleanup_parser() { // Check for undefined vertex pools. VertexPools::const_iterator vpi; - for (vpi = vertex_pools.begin(); vpi != vertex_pools.end(); ++vpi) { + for (vpi = state.vertex_pools.begin(); vpi != state.vertex_pools.end(); ++vpi) { EggVertexPool *pool = (*vpi).second; if (pool->has_forward_vertices()) { if (!pool->has_defined_vertices()) { - eggyyerror("Undefined vertex pool " + pool->get_name()); + eggyyerror(nullptr, scanner, "Undefined vertex pool " + pool->get_name()); } else { - eggyyerror("Undefined vertices in pool " + pool->get_name()); + eggyyerror(nullptr, scanner, "Undefined vertices in pool " + pool->get_name()); egg_cat.error(false) << "Undefined vertex index numbers:"; @@ -216,19 +210,37 @@ egg_cleanup_parser() { } } - // Clean these out after we're done, so we don't keep big memory - // structures around needlessly. - egg_stack.clear(); - vertex_pools.clear(); - textures.clear(); - materials.clear(); - groups.clear(); + eggyylex_destroy(scanner); - egg_cleanup_lexer(); + return lexer_state._error_count == 0; +} + +//////////////////////////////////////////////////////////////////// +// Internal support functions. +//////////////////////////////////////////////////////////////////// + +void +eggyyerror(YYLTYPE *loc, EggParserState &state, yyscan_t scanner, const std::string &msg) { + eggyyerror(loc, scanner, msg); +} + +void +eggyywarning(YYLTYPE *loc, EggParserState &state, yyscan_t scanner, const string &msg) { + eggyywarning(loc, scanner, msg); } -#line 234 "built/tmp/parser.yxx.c" /* yacc.c:338 */ +#line 234 "built/tmp/parser.yxx.c" + +# ifndef YY_CAST +# ifdef __cplusplus +# define YY_CAST(Type, Val) static_cast (Val) +# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) +# else +# define YY_CAST(Type, Val) ((Type) (Val)) +# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) +# endif +# endif # ifndef YY_NULLPTR # if defined __cplusplus # if 201103L <= __cplusplus @@ -241,221 +253,235 @@ egg_cleanup_parser() { # endif # endif -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif +#include "parser.yxx.h" +/* Symbol kind. */ +enum yysymbol_kind_t +{ + YYSYMBOL_YYEMPTY = -2, + YYSYMBOL_YYEOF = 0, /* "end of file" */ + YYSYMBOL_YYerror = 1, /* error */ + YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ + YYSYMBOL_EGG_NUMBER = 3, /* EGG_NUMBER */ + YYSYMBOL_EGG_ULONG = 4, /* EGG_ULONG */ + YYSYMBOL_EGG_STRING = 5, /* EGG_STRING */ + YYSYMBOL_ANIMPRELOAD = 6, /* ANIMPRELOAD */ + YYSYMBOL_BEZIERCURVE = 7, /* BEZIERCURVE */ + YYSYMBOL_BFACE = 8, /* BFACE */ + YYSYMBOL_BILLBOARD = 9, /* BILLBOARD */ + YYSYMBOL_BILLBOARDCENTER = 10, /* BILLBOARDCENTER */ + YYSYMBOL_BINORMAL = 11, /* BINORMAL */ + YYSYMBOL_BUNDLE = 12, /* BUNDLE */ + YYSYMBOL_CLOSED = 13, /* CLOSED */ + YYSYMBOL_COLLIDE = 14, /* COLLIDE */ + YYSYMBOL_COMMENT = 15, /* COMMENT */ + YYSYMBOL_COMPONENT = 16, /* COMPONENT */ + YYSYMBOL_COORDSYSTEM = 17, /* COORDSYSTEM */ + YYSYMBOL_CV = 18, /* CV */ + YYSYMBOL_DART = 19, /* DART */ + YYSYMBOL_DNORMAL = 20, /* DNORMAL */ + YYSYMBOL_DRGBA = 21, /* DRGBA */ + YYSYMBOL_DUV = 22, /* DUV */ + YYSYMBOL_DXYZ = 23, /* DXYZ */ + YYSYMBOL_DCS = 24, /* DCS */ + YYSYMBOL_DISTANCE = 25, /* DISTANCE */ + YYSYMBOL_DTREF = 26, /* DTREF */ + YYSYMBOL_DYNAMICVERTEXPOOL = 27, /* DYNAMICVERTEXPOOL */ + YYSYMBOL_EXTERNAL_FILE = 28, /* EXTERNAL_FILE */ + YYSYMBOL_GROUP = 29, /* GROUP */ + YYSYMBOL_DEFAULTPOSE = 30, /* DEFAULTPOSE */ + YYSYMBOL_JOINT = 31, /* JOINT */ + YYSYMBOL_KNOTS = 32, /* KNOTS */ + YYSYMBOL_INCLUDE = 33, /* INCLUDE */ + YYSYMBOL_INSTANCE = 34, /* INSTANCE */ + YYSYMBOL_LINE = 35, /* LINE */ + YYSYMBOL_LOOP = 36, /* LOOP */ + YYSYMBOL_MATERIAL = 37, /* MATERIAL */ + YYSYMBOL_MATRIX3 = 38, /* MATRIX3 */ + YYSYMBOL_MATRIX4 = 39, /* MATRIX4 */ + YYSYMBOL_MODEL = 40, /* MODEL */ + YYSYMBOL_MREF = 41, /* MREF */ + YYSYMBOL_NORMAL = 42, /* NORMAL */ + YYSYMBOL_NURBSCURVE = 43, /* NURBSCURVE */ + YYSYMBOL_NURBSSURFACE = 44, /* NURBSSURFACE */ + YYSYMBOL_OBJECTTYPE = 45, /* OBJECTTYPE */ + YYSYMBOL_ORDER = 46, /* ORDER */ + YYSYMBOL_OUTTANGENT = 47, /* OUTTANGENT */ + YYSYMBOL_PATCH = 48, /* PATCH */ + YYSYMBOL_POINTLIGHT = 49, /* POINTLIGHT */ + YYSYMBOL_POLYGON = 50, /* POLYGON */ + YYSYMBOL_REF = 51, /* REF */ + YYSYMBOL_RGBA = 52, /* RGBA */ + YYSYMBOL_ROTATE = 53, /* ROTATE */ + YYSYMBOL_ROTX = 54, /* ROTX */ + YYSYMBOL_ROTY = 55, /* ROTY */ + YYSYMBOL_ROTZ = 56, /* ROTZ */ + YYSYMBOL_SANIM = 57, /* SANIM */ + YYSYMBOL_SCALAR = 58, /* SCALAR */ + YYSYMBOL_SCALE = 59, /* SCALE */ + YYSYMBOL_SEQUENCE = 60, /* SEQUENCE */ + YYSYMBOL_SHADING = 61, /* SHADING */ + YYSYMBOL_SWITCH = 62, /* SWITCH */ + YYSYMBOL_SWITCHCONDITION = 63, /* SWITCHCONDITION */ + YYSYMBOL_TABLE = 64, /* TABLE */ + YYSYMBOL_TABLE_V = 65, /* TABLE_V */ + YYSYMBOL_TAG = 66, /* TAG */ + YYSYMBOL_TANGENT = 67, /* TANGENT */ + YYSYMBOL_TEXLIST = 68, /* TEXLIST */ + YYSYMBOL_TEXTURE = 69, /* TEXTURE */ + YYSYMBOL_TLENGTHS = 70, /* TLENGTHS */ + YYSYMBOL_TRANSFORM = 71, /* TRANSFORM */ + YYSYMBOL_TRANSLATE = 72, /* TRANSLATE */ + YYSYMBOL_TREF = 73, /* TREF */ + YYSYMBOL_TRIANGLEFAN = 74, /* TRIANGLEFAN */ + YYSYMBOL_TRIANGLESTRIP = 75, /* TRIANGLESTRIP */ + YYSYMBOL_TRIM = 76, /* TRIM */ + YYSYMBOL_TXT = 77, /* TXT */ + YYSYMBOL_UKNOTS = 78, /* UKNOTS */ + YYSYMBOL_UV = 79, /* UV */ + YYSYMBOL_AUX = 80, /* AUX */ + YYSYMBOL_VKNOTS = 81, /* VKNOTS */ + YYSYMBOL_VERTEX = 82, /* VERTEX */ + YYSYMBOL_VERTEXANIM = 83, /* VERTEXANIM */ + YYSYMBOL_VERTEXPOOL = 84, /* VERTEXPOOL */ + YYSYMBOL_VERTEXREF = 85, /* VERTEXREF */ + YYSYMBOL_XFMANIM = 86, /* XFMANIM */ + YYSYMBOL_XFMSANIM = 87, /* XFMSANIM */ + YYSYMBOL_START_EGG = 88, /* START_EGG */ + YYSYMBOL_START_GROUP_BODY = 89, /* START_GROUP_BODY */ + YYSYMBOL_START_TEXTURE_BODY = 90, /* START_TEXTURE_BODY */ + YYSYMBOL_START_PRIMITIVE_BODY = 91, /* START_PRIMITIVE_BODY */ + YYSYMBOL_92_ = 92, /* '{' */ + YYSYMBOL_93_ = 93, /* '}' */ + YYSYMBOL_YYACCEPT = 94, /* $accept */ + YYSYMBOL_grammar = 95, /* grammar */ + YYSYMBOL_egg = 96, /* egg */ + YYSYMBOL_node = 97, /* node */ + YYSYMBOL_coordsystem = 98, /* coordsystem */ + YYSYMBOL_comment = 99, /* comment */ + YYSYMBOL_texture = 100, /* texture */ + YYSYMBOL_101_1 = 101, /* $@1 */ + YYSYMBOL_texture_body = 102, /* texture_body */ + YYSYMBOL_material = 103, /* material */ + YYSYMBOL_104_2 = 104, /* $@2 */ + YYSYMBOL_material_body = 105, /* material_body */ + YYSYMBOL_external_reference = 106, /* external_reference */ + YYSYMBOL_vertex_pool = 107, /* vertex_pool */ + YYSYMBOL_108_3 = 108, /* $@3 */ + YYSYMBOL_vertex_pool_body = 109, /* vertex_pool_body */ + YYSYMBOL_vertex = 110, /* vertex */ + YYSYMBOL_111_4 = 111, /* $@4 */ + YYSYMBOL_112_5 = 112, /* $@5 */ + YYSYMBOL_vertex_body = 113, /* vertex_body */ + YYSYMBOL_114_6 = 114, /* $@6 */ + YYSYMBOL_115_7 = 115, /* $@7 */ + YYSYMBOL_vertex_uv_body = 116, /* vertex_uv_body */ + YYSYMBOL_vertex_aux_body = 117, /* vertex_aux_body */ + YYSYMBOL_vertex_normal_body = 118, /* vertex_normal_body */ + YYSYMBOL_vertex_color_body = 119, /* vertex_color_body */ + YYSYMBOL_group = 120, /* group */ + YYSYMBOL_121_8 = 121, /* $@8 */ + YYSYMBOL_joint = 122, /* joint */ + YYSYMBOL_123_9 = 123, /* $@9 */ + YYSYMBOL_instance = 124, /* instance */ + YYSYMBOL_125_10 = 125, /* $@10 */ + YYSYMBOL_group_body = 126, /* group_body */ + YYSYMBOL_cs_type = 127, /* cs_type */ + YYSYMBOL_collide_flags = 128, /* collide_flags */ + YYSYMBOL_transform = 129, /* transform */ + YYSYMBOL_130_11 = 130, /* $@11 */ + YYSYMBOL_default_pose = 131, /* default_pose */ + YYSYMBOL_132_12 = 132, /* $@12 */ + YYSYMBOL_transform_body = 133, /* transform_body */ + YYSYMBOL_translate2d = 134, /* translate2d */ + YYSYMBOL_translate3d = 135, /* translate3d */ + YYSYMBOL_rotate2d = 136, /* rotate2d */ + YYSYMBOL_rotx = 137, /* rotx */ + YYSYMBOL_roty = 138, /* roty */ + YYSYMBOL_rotz = 139, /* rotz */ + YYSYMBOL_rotate3d = 140, /* rotate3d */ + YYSYMBOL_scale2d = 141, /* scale2d */ + YYSYMBOL_scale3d = 142, /* scale3d */ + YYSYMBOL_uniform_scale = 143, /* uniform_scale */ + YYSYMBOL_matrix3 = 144, /* matrix3 */ + YYSYMBOL_matrix3_body = 145, /* matrix3_body */ + YYSYMBOL_matrix4 = 146, /* matrix4 */ + YYSYMBOL_matrix4_body = 147, /* matrix4_body */ + YYSYMBOL_group_vertex_ref = 148, /* group_vertex_ref */ + YYSYMBOL_group_vertex_membership = 149, /* group_vertex_membership */ + YYSYMBOL_switchcondition = 150, /* switchcondition */ + YYSYMBOL_switchcondition_body = 151, /* switchcondition_body */ + YYSYMBOL_polygon = 152, /* polygon */ + YYSYMBOL_153_13 = 153, /* $@13 */ + YYSYMBOL_trianglefan = 154, /* trianglefan */ + YYSYMBOL_155_14 = 155, /* $@14 */ + YYSYMBOL_trianglestrip = 156, /* trianglestrip */ + YYSYMBOL_157_15 = 157, /* $@15 */ + YYSYMBOL_patch = 158, /* patch */ + YYSYMBOL_159_16 = 159, /* $@16 */ + YYSYMBOL_point_light = 160, /* point_light */ + YYSYMBOL_161_17 = 161, /* $@17 */ + YYSYMBOL_line = 162, /* line */ + YYSYMBOL_163_18 = 163, /* $@18 */ + YYSYMBOL_nurbs_surface = 164, /* nurbs_surface */ + YYSYMBOL_165_19 = 165, /* $@19 */ + YYSYMBOL_nurbs_curve = 166, /* nurbs_curve */ + YYSYMBOL_167_20 = 167, /* $@20 */ + YYSYMBOL_primitive_component_body = 168, /* primitive_component_body */ + YYSYMBOL_primitive_body = 169, /* primitive_body */ + YYSYMBOL_170_21 = 170, /* $@21 */ + YYSYMBOL_nurbs_surface_body = 171, /* nurbs_surface_body */ + YYSYMBOL_nurbs_curve_body = 172, /* nurbs_curve_body */ + YYSYMBOL_primitive_tref_body = 173, /* primitive_tref_body */ + YYSYMBOL_primitive_texture_body = 174, /* primitive_texture_body */ + YYSYMBOL_primitive_material_body = 175, /* primitive_material_body */ + YYSYMBOL_primitive_normal_body = 176, /* primitive_normal_body */ + YYSYMBOL_primitive_color_body = 177, /* primitive_color_body */ + YYSYMBOL_primitive_bface_body = 178, /* primitive_bface_body */ + YYSYMBOL_primitive_vertex_ref = 179, /* primitive_vertex_ref */ + YYSYMBOL_nurbs_surface_order_body = 180, /* nurbs_surface_order_body */ + YYSYMBOL_nurbs_surface_uknots_body = 181, /* nurbs_surface_uknots_body */ + YYSYMBOL_nurbs_surface_vknots_body = 182, /* nurbs_surface_vknots_body */ + YYSYMBOL_nurbs_surface_trim_body = 183, /* nurbs_surface_trim_body */ + YYSYMBOL_nurbs_surface_trim_loop_body = 184, /* nurbs_surface_trim_loop_body */ + YYSYMBOL_nurbs_curve_order_body = 185, /* nurbs_curve_order_body */ + YYSYMBOL_nurbs_curve_knots_body = 186, /* nurbs_curve_knots_body */ + YYSYMBOL_table = 187, /* table */ + YYSYMBOL_188_22 = 188, /* $@22 */ + YYSYMBOL_bundle = 189, /* bundle */ + YYSYMBOL_190_23 = 190, /* $@23 */ + YYSYMBOL_table_body = 191, /* table_body */ + YYSYMBOL_sanim = 192, /* sanim */ + YYSYMBOL_193_24 = 193, /* $@24 */ + YYSYMBOL_sanim_body = 194, /* sanim_body */ + YYSYMBOL_xfmanim = 195, /* xfmanim */ + YYSYMBOL_196_25 = 196, /* $@25 */ + YYSYMBOL_xfmanim_body = 197, /* xfmanim_body */ + YYSYMBOL_xfm_s_anim = 198, /* xfm_s_anim */ + YYSYMBOL_199_26 = 199, /* $@26 */ + YYSYMBOL_xfm_s_anim_body = 200, /* xfm_s_anim_body */ + YYSYMBOL_anim_preload = 201, /* anim_preload */ + YYSYMBOL_202_27 = 202, /* $@27 */ + YYSYMBOL_anim_preload_body = 203, /* anim_preload_body */ + YYSYMBOL_integer_list = 204, /* integer_list */ + YYSYMBOL_real_list = 205, /* real_list */ + YYSYMBOL_texture_name = 206, /* texture_name */ + YYSYMBOL_material_name = 207, /* material_name */ + YYSYMBOL_vertex_pool_name = 208, /* vertex_pool_name */ + YYSYMBOL_group_name = 209, /* group_name */ + YYSYMBOL_required_name = 210, /* required_name */ + YYSYMBOL_optional_name = 211, /* optional_name */ + YYSYMBOL_required_string = 212, /* required_string */ + YYSYMBOL_optional_string = 213, /* optional_string */ + YYSYMBOL_string = 214, /* string */ + YYSYMBOL_repeated_string = 215, /* repeated_string */ + YYSYMBOL_repeated_string_body = 216, /* repeated_string_body */ + YYSYMBOL_real = 217, /* real */ + YYSYMBOL_real_or_string = 218, /* real_or_string */ + YYSYMBOL_integer = 219, /* integer */ + YYSYMBOL_empty = 220 /* empty */ +}; +typedef enum yysymbol_kind_t yysymbol_kind_t; -/* In a future release of Bison, this section will be replaced - by #include "parser.yxx.h". */ -#ifndef YY_EGGYY_BUILT_TMP_PARSER_YXX_H_INCLUDED -# define YY_EGGYY_BUILT_TMP_PARSER_YXX_H_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif -#if YYDEBUG -extern int eggyydebug; -#endif - -/* Token type. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - EGG_NUMBER = 258, - EGG_ULONG = 259, - EGG_STRING = 260, - ANIMPRELOAD = 261, - BEZIERCURVE = 262, - BFACE = 263, - BILLBOARD = 264, - BILLBOARDCENTER = 265, - BINORMAL = 266, - BUNDLE = 267, - CLOSED = 268, - COLLIDE = 269, - COMMENT = 270, - COMPONENT = 271, - COORDSYSTEM = 272, - CV = 273, - DART = 274, - DNORMAL = 275, - DRGBA = 276, - DUV = 277, - DXYZ = 278, - DCS = 279, - DISTANCE = 280, - DTREF = 281, - DYNAMICVERTEXPOOL = 282, - EXTERNAL_FILE = 283, - GROUP = 284, - DEFAULTPOSE = 285, - JOINT = 286, - KNOTS = 287, - INCLUDE = 288, - INSTANCE = 289, - LINE = 290, - LOOP = 291, - MATERIAL = 292, - MATRIX3 = 293, - MATRIX4 = 294, - MODEL = 295, - MREF = 296, - NORMAL = 297, - NURBSCURVE = 298, - NURBSSURFACE = 299, - OBJECTTYPE = 300, - ORDER = 301, - OUTTANGENT = 302, - PATCH = 303, - POINTLIGHT = 304, - POLYGON = 305, - REF = 306, - RGBA = 307, - ROTATE = 308, - ROTX = 309, - ROTY = 310, - ROTZ = 311, - SANIM = 312, - SCALAR = 313, - SCALE = 314, - SEQUENCE = 315, - SHADING = 316, - SWITCH = 317, - SWITCHCONDITION = 318, - TABLE = 319, - TABLE_V = 320, - TAG = 321, - TANGENT = 322, - TEXLIST = 323, - TEXTURE = 324, - TLENGTHS = 325, - TRANSFORM = 326, - TRANSLATE = 327, - TREF = 328, - TRIANGLEFAN = 329, - TRIANGLESTRIP = 330, - TRIM = 331, - TXT = 332, - UKNOTS = 333, - UV = 334, - AUX = 335, - VKNOTS = 336, - VERTEX = 337, - VERTEXANIM = 338, - VERTEXPOOL = 339, - VERTEXREF = 340, - XFMANIM = 341, - XFMSANIM = 342, - START_EGG = 343, - START_GROUP_BODY = 344, - START_TEXTURE_BODY = 345, - START_PRIMITIVE_BODY = 346 - }; -#endif -/* Tokens. */ -#define EGG_NUMBER 258 -#define EGG_ULONG 259 -#define EGG_STRING 260 -#define ANIMPRELOAD 261 -#define BEZIERCURVE 262 -#define BFACE 263 -#define BILLBOARD 264 -#define BILLBOARDCENTER 265 -#define BINORMAL 266 -#define BUNDLE 267 -#define CLOSED 268 -#define COLLIDE 269 -#define COMMENT 270 -#define COMPONENT 271 -#define COORDSYSTEM 272 -#define CV 273 -#define DART 274 -#define DNORMAL 275 -#define DRGBA 276 -#define DUV 277 -#define DXYZ 278 -#define DCS 279 -#define DISTANCE 280 -#define DTREF 281 -#define DYNAMICVERTEXPOOL 282 -#define EXTERNAL_FILE 283 -#define GROUP 284 -#define DEFAULTPOSE 285 -#define JOINT 286 -#define KNOTS 287 -#define INCLUDE 288 -#define INSTANCE 289 -#define LINE 290 -#define LOOP 291 -#define MATERIAL 292 -#define MATRIX3 293 -#define MATRIX4 294 -#define MODEL 295 -#define MREF 296 -#define NORMAL 297 -#define NURBSCURVE 298 -#define NURBSSURFACE 299 -#define OBJECTTYPE 300 -#define ORDER 301 -#define OUTTANGENT 302 -#define PATCH 303 -#define POINTLIGHT 304 -#define POLYGON 305 -#define REF 306 -#define RGBA 307 -#define ROTATE 308 -#define ROTX 309 -#define ROTY 310 -#define ROTZ 311 -#define SANIM 312 -#define SCALAR 313 -#define SCALE 314 -#define SEQUENCE 315 -#define SHADING 316 -#define SWITCH 317 -#define SWITCHCONDITION 318 -#define TABLE 319 -#define TABLE_V 320 -#define TAG 321 -#define TANGENT 322 -#define TEXLIST 323 -#define TEXTURE 324 -#define TLENGTHS 325 -#define TRANSFORM 326 -#define TRANSLATE 327 -#define TREF 328 -#define TRIANGLEFAN 329 -#define TRIANGLESTRIP 330 -#define TRIM 331 -#define TXT 332 -#define UKNOTS 333 -#define UV 334 -#define AUX 335 -#define VKNOTS 336 -#define VERTEX 337 -#define VERTEXANIM 338 -#define VERTEXPOOL 339 -#define VERTEXREF 340 -#define XFMANIM 341 -#define XFMSANIM 342 -#define START_EGG 343 -#define START_GROUP_BODY 344 -#define START_TEXTURE_BODY 345 -#define START_PRIMITIVE_BODY 346 - -/* Value type. */ - - -extern YYSTYPE eggyylval; - -int eggyyparse (void); - -#endif /* !YY_EGGYY_BUILT_TMP_PARSER_YXX_H_INCLUDED */ @@ -463,36 +489,83 @@ int eggyyparse (void); # undef short #endif -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; +/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure + and (if available) are included + so that the code can choose integer types of a good width. */ + +#ifndef __PTRDIFF_MAX__ +# include /* INFRINGES ON USER NAME SPACE */ +# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_STDINT_H +# endif #endif -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; +/* Narrow types that promote to a signed type and that can represent a + signed or unsigned integer of at least N bits. In tables they can + save space and decrease cache pressure. Promoting to a signed type + helps avoid bugs in integer arithmetic. */ + +#ifdef __INT_LEAST8_MAX__ +typedef __INT_LEAST8_TYPE__ yytype_int8; +#elif defined YY_STDINT_H +typedef int_least8_t yytype_int8; #else typedef signed char yytype_int8; #endif -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; +#ifdef __INT_LEAST16_MAX__ +typedef __INT_LEAST16_TYPE__ yytype_int16; +#elif defined YY_STDINT_H +typedef int_least16_t yytype_int16; #else typedef short yytype_int16; #endif +#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST8_TYPE__ yytype_uint8; +#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST8_MAX <= INT_MAX) +typedef uint_least8_t yytype_uint8; +#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX +typedef unsigned char yytype_uint8; +#else +typedef short yytype_uint8; +#endif + +#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST16_TYPE__ yytype_uint16; +#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST16_MAX <= INT_MAX) +typedef uint_least16_t yytype_uint16; +#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX +typedef unsigned short yytype_uint16; +#else +typedef int yytype_uint16; +#endif + +#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined PTRDIFF_MAX +# ifndef ptrdiff_t +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T long +# define YYPTRDIFF_MAXIMUM LONG_MAX +# endif +#endif + #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -500,7 +573,20 @@ typedef short yytype_int16; # endif #endif -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) +#define YYSIZE_MAXIMUM \ + YY_CAST (YYPTRDIFF_T, \ + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ + ? YYPTRDIFF_MAXIMUM \ + : YY_CAST (YYSIZE_T, -1))) + +#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) + + +/* Stored state numbers (used for stacks). */ +typedef yytype_int16 yy_state_t; + +/* State numbers in computations. */ +typedef int yy_state_fast_t; #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -514,22 +600,21 @@ typedef short yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) + +#ifndef YY_ATTRIBUTE_PURE +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) # else -# define YY_ATTRIBUTE(Spec) /* empty */ +# define YY_ATTRIBUTE_PURE # endif #endif -#ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) -#endif - #ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +# else +# define YY_ATTRIBUTE_UNUSED +# endif #endif /* Suppress unused-variable warnings by "using" E. */ @@ -541,11 +626,11 @@ typedef short yytype_int16; #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value @@ -558,8 +643,22 @@ typedef short yytype_int16; # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif +#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ +# define YY_IGNORE_USELESS_CAST_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") +# define YY_IGNORE_USELESS_CAST_END \ + _Pragma ("GCC diagnostic pop") +#endif +#ifndef YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_END +#endif -#if ! defined yyoverflow || YYERROR_VERBOSE + +#define YY_ASSERT(E) ((void) (0 && (E))) + +#if !defined yyoverflow /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -624,28 +723,30 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - +#endif /* !defined yyoverflow */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ + && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; + yy_state_t yyss_alloc; YYSTYPE yyvs_alloc; + YYLTYPE yyls_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \ + + YYSIZEOF (YYLTYPE)) \ + + 2 * YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 @@ -657,11 +758,11 @@ union yyalloc # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ - YYSIZE_T yynewbytes; \ + YYPTRDIFF_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ } \ while (0) @@ -673,12 +774,12 @@ union yyalloc # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ - YYSIZE_T yyi; \ + YYPTRDIFF_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ @@ -701,17 +802,20 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 765 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ -#define YYUNDEFTOK 2 +/* YYMAXUTOK -- Last valid token kind. */ #define YYMAXUTOK 346 -#define YYTRANSLATE(YYX) \ - ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ +#define YYTRANSLATE(YYX) \ + (0 <= (YYX) && (YYX) <= YYMAXUTOK \ + ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ + : YYSYMBOL_YYUNDEF) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ -static const yytype_uint8 yytranslate[] = + as returned by yylex. */ +static const yytype_int8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -752,95 +856,109 @@ static const yytype_uint8 yytranslate[] = #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = +static const yytype_int16 yyrline[] = { - 0, 239, 239, 240, 241, 242, 253, 254, 270, 271, - 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, - 282, 283, 284, 285, 286, 287, 288, 299, 322, 337, - 336, 364, 365, 720, 732, 731, 758, 759, 880, 887, - 908, 907, 947, 948, 960, 959, 971, 970, 1016, 1020, - 1024, 1028, 1033, 1032, 1048, 1047, 1062, 1063, 1064, 1072, - 1091, 1095, 1099, 1107, 1115, 1123, 1131, 1139, 1147, 1164, - 1165, 1179, 1183, 1191, 1209, 1213, 1221, 1240, 1239, 1265, - 1264, 1286, 1285, 1310, 1311, 1459, 1471, 1476, 1483, 1489, - 1502, 1509, 1522, 1528, 1534, 1540, 1545, 1551, 1552, 1553, - 1554, 1555, 1564, 1578, 1608, 1609, 1632, 1631, 1648, 1647, - 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, - 1678, 1679, 1680, 1684, 1691, 1698, 1705, 1712, 1719, 1726, - 1733, 1740, 1747, 1754, 1758, 1759, 1771, 1775, 1776, 1798, - 1831, 1835, 1860, 1872, 1877, 1895, 1894, 1914, 1913, 1933, - 1932, 1952, 1951, 1971, 1970, 1990, 1989, 2009, 2008, 2028, - 2027, 2047, 2048, 2049, 2060, 2062, 2061, 2082, 2083, 2084, - 2085, 2086, 2087, 2088, 2089, 2164, 2165, 2166, 2167, 2168, - 2169, 2170, 2171, 2172, 2173, 2174, 2175, 2181, 2182, 2248, - 2249, 2250, 2251, 2252, 2253, 2254, 2255, 2256, 2257, 2258, - 2329, 2346, 2386, 2403, 2407, 2415, 2433, 2437, 2445, 2463, - 2479, 2510, 2528, 2548, 2568, 2573, 2584, 2590, 2609, 2625, - 2647, 2646, 2670, 2669, 2690, 2691, 2695, 2699, 2703, 2707, - 2723, 2722, 2743, 2744, 2756, 2771, 2770, 2791, 2792, 2809, - 2824, 2823, 2844, 2845, 2860, 2876, 2875, 2896, 2897, 2921, - 2925, 2939, 2943, 2957, 2978, 2999, 3024, 3045, 3050, 3062, - 3074, 3079, 3090, 3094, 3108, 3112, 3116, 3129, 3133, 3149, - 3153, 3167, 3168, 3183, 3189, 3195, 3212, 3220, 3226 + 0, 245, 245, 246, 247, 248, 259, 260, 276, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + 288, 289, 290, 291, 292, 293, 294, 305, 328, 343, + 342, 370, 371, 726, 738, 737, 764, 765, 886, 893, + 914, 913, 953, 954, 966, 965, 977, 976, 1022, 1026, + 1030, 1034, 1039, 1038, 1054, 1053, 1068, 1069, 1070, 1078, + 1097, 1101, 1105, 1113, 1121, 1129, 1137, 1145, 1153, 1170, + 1171, 1185, 1189, 1197, 1215, 1219, 1227, 1246, 1245, 1271, + 1270, 1292, 1291, 1316, 1317, 1465, 1477, 1482, 1489, 1495, + 1508, 1515, 1528, 1534, 1540, 1546, 1551, 1557, 1558, 1559, + 1560, 1561, 1570, 1584, 1614, 1615, 1638, 1637, 1654, 1653, + 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682, 1683, + 1684, 1685, 1686, 1690, 1697, 1704, 1711, 1718, 1725, 1732, + 1739, 1746, 1753, 1760, 1764, 1765, 1777, 1781, 1782, 1804, + 1837, 1841, 1866, 1878, 1883, 1901, 1900, 1920, 1919, 1939, + 1938, 1958, 1957, 1977, 1976, 1996, 1995, 2015, 2014, 2034, + 2033, 2053, 2054, 2055, 2066, 2068, 2067, 2088, 2089, 2090, + 2091, 2092, 2093, 2094, 2095, 2170, 2171, 2172, 2173, 2174, + 2175, 2176, 2177, 2178, 2179, 2180, 2181, 2187, 2188, 2254, + 2255, 2256, 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264, + 2335, 2352, 2392, 2409, 2413, 2421, 2439, 2443, 2451, 2469, + 2485, 2516, 2534, 2554, 2574, 2579, 2590, 2596, 2615, 2631, + 2653, 2652, 2676, 2675, 2696, 2697, 2701, 2705, 2709, 2713, + 2729, 2728, 2749, 2750, 2762, 2777, 2776, 2797, 2798, 2815, + 2830, 2829, 2850, 2851, 2866, 2882, 2881, 2902, 2903, 2927, + 2931, 2945, 2949, 2963, 2984, 3005, 3030, 3051, 3056, 3068, + 3080, 3085, 3096, 3100, 3114, 3118, 3122, 3135, 3139, 3155, + 3159, 3173, 3174, 3189, 3195, 3201, 3218, 3226, 3232 }; #endif -#if YYDEBUG || YYERROR_VERBOSE || 0 +/** Accessing symbol of state STATE. */ +#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) + +#if YYDEBUG || 0 +/* The user-facing name of the symbol whose (internal) number is + YYSYMBOL. No bounds checking. */ +static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "EGG_NUMBER", "EGG_ULONG", "EGG_STRING", - "ANIMPRELOAD", "BEZIERCURVE", "BFACE", "BILLBOARD", "BILLBOARDCENTER", - "BINORMAL", "BUNDLE", "CLOSED", "COLLIDE", "COMMENT", "COMPONENT", - "COORDSYSTEM", "CV", "DART", "DNORMAL", "DRGBA", "DUV", "DXYZ", "DCS", - "DISTANCE", "DTREF", "DYNAMICVERTEXPOOL", "EXTERNAL_FILE", "GROUP", - "DEFAULTPOSE", "JOINT", "KNOTS", "INCLUDE", "INSTANCE", "LINE", "LOOP", - "MATERIAL", "MATRIX3", "MATRIX4", "MODEL", "MREF", "NORMAL", - "NURBSCURVE", "NURBSSURFACE", "OBJECTTYPE", "ORDER", "OUTTANGENT", - "PATCH", "POINTLIGHT", "POLYGON", "REF", "RGBA", "ROTATE", "ROTX", - "ROTY", "ROTZ", "SANIM", "SCALAR", "SCALE", "SEQUENCE", "SHADING", - "SWITCH", "SWITCHCONDITION", "TABLE", "TABLE_V", "TAG", "TANGENT", - "TEXLIST", "TEXTURE", "TLENGTHS", "TRANSFORM", "TRANSLATE", "TREF", - "TRIANGLEFAN", "TRIANGLESTRIP", "TRIM", "TXT", "UKNOTS", "UV", "AUX", - "VKNOTS", "VERTEX", "VERTEXANIM", "VERTEXPOOL", "VERTEXREF", "XFMANIM", - "XFMSANIM", "START_EGG", "START_GROUP_BODY", "START_TEXTURE_BODY", - "START_PRIMITIVE_BODY", "'{'", "'}'", "$accept", "grammar", "egg", - "node", "coordsystem", "comment", "texture", "$@1", "texture_body", - "material", "$@2", "material_body", "external_reference", "vertex_pool", - "$@3", "vertex_pool_body", "vertex", "$@4", "$@5", "vertex_body", "$@6", - "$@7", "vertex_uv_body", "vertex_aux_body", "vertex_normal_body", - "vertex_color_body", "group", "$@8", "joint", "$@9", "instance", "$@10", - "group_body", "cs_type", "collide_flags", "transform", "$@11", - "default_pose", "$@12", "transform_body", "translate2d", "translate3d", - "rotate2d", "rotx", "roty", "rotz", "rotate3d", "scale2d", "scale3d", - "uniform_scale", "matrix3", "matrix3_body", "matrix4", "matrix4_body", - "group_vertex_ref", "group_vertex_membership", "switchcondition", - "switchcondition_body", "polygon", "$@13", "trianglefan", "$@14", - "trianglestrip", "$@15", "patch", "$@16", "point_light", "$@17", "line", - "$@18", "nurbs_surface", "$@19", "nurbs_curve", "$@20", - "primitive_component_body", "primitive_body", "$@21", - "nurbs_surface_body", "nurbs_curve_body", "primitive_tref_body", - "primitive_texture_body", "primitive_material_body", - "primitive_normal_body", "primitive_color_body", "primitive_bface_body", - "primitive_vertex_ref", "nurbs_surface_order_body", - "nurbs_surface_uknots_body", "nurbs_surface_vknots_body", - "nurbs_surface_trim_body", "nurbs_surface_trim_loop_body", - "nurbs_curve_order_body", "nurbs_curve_knots_body", "table", "$@22", - "bundle", "$@23", "table_body", "sanim", "$@24", "sanim_body", "xfmanim", - "$@25", "xfmanim_body", "xfm_s_anim", "$@26", "xfm_s_anim_body", - "anim_preload", "$@27", "anim_preload_body", "integer_list", "real_list", - "texture_name", "material_name", "vertex_pool_name", "group_name", - "required_name", "optional_name", "required_string", "optional_string", - "string", "repeated_string", "repeated_string_body", "real", - "real_or_string", "integer", "empty", YY_NULLPTR + "\"end of file\"", "error", "\"invalid token\"", "EGG_NUMBER", + "EGG_ULONG", "EGG_STRING", "ANIMPRELOAD", "BEZIERCURVE", "BFACE", + "BILLBOARD", "BILLBOARDCENTER", "BINORMAL", "BUNDLE", "CLOSED", + "COLLIDE", "COMMENT", "COMPONENT", "COORDSYSTEM", "CV", "DART", + "DNORMAL", "DRGBA", "DUV", "DXYZ", "DCS", "DISTANCE", "DTREF", + "DYNAMICVERTEXPOOL", "EXTERNAL_FILE", "GROUP", "DEFAULTPOSE", "JOINT", + "KNOTS", "INCLUDE", "INSTANCE", "LINE", "LOOP", "MATERIAL", "MATRIX3", + "MATRIX4", "MODEL", "MREF", "NORMAL", "NURBSCURVE", "NURBSSURFACE", + "OBJECTTYPE", "ORDER", "OUTTANGENT", "PATCH", "POINTLIGHT", "POLYGON", + "REF", "RGBA", "ROTATE", "ROTX", "ROTY", "ROTZ", "SANIM", "SCALAR", + "SCALE", "SEQUENCE", "SHADING", "SWITCH", "SWITCHCONDITION", "TABLE", + "TABLE_V", "TAG", "TANGENT", "TEXLIST", "TEXTURE", "TLENGTHS", + "TRANSFORM", "TRANSLATE", "TREF", "TRIANGLEFAN", "TRIANGLESTRIP", "TRIM", + "TXT", "UKNOTS", "UV", "AUX", "VKNOTS", "VERTEX", "VERTEXANIM", + "VERTEXPOOL", "VERTEXREF", "XFMANIM", "XFMSANIM", "START_EGG", + "START_GROUP_BODY", "START_TEXTURE_BODY", "START_PRIMITIVE_BODY", "'{'", + "'}'", "$accept", "grammar", "egg", "node", "coordsystem", "comment", + "texture", "$@1", "texture_body", "material", "$@2", "material_body", + "external_reference", "vertex_pool", "$@3", "vertex_pool_body", "vertex", + "$@4", "$@5", "vertex_body", "$@6", "$@7", "vertex_uv_body", + "vertex_aux_body", "vertex_normal_body", "vertex_color_body", "group", + "$@8", "joint", "$@9", "instance", "$@10", "group_body", "cs_type", + "collide_flags", "transform", "$@11", "default_pose", "$@12", + "transform_body", "translate2d", "translate3d", "rotate2d", "rotx", + "roty", "rotz", "rotate3d", "scale2d", "scale3d", "uniform_scale", + "matrix3", "matrix3_body", "matrix4", "matrix4_body", "group_vertex_ref", + "group_vertex_membership", "switchcondition", "switchcondition_body", + "polygon", "$@13", "trianglefan", "$@14", "trianglestrip", "$@15", + "patch", "$@16", "point_light", "$@17", "line", "$@18", "nurbs_surface", + "$@19", "nurbs_curve", "$@20", "primitive_component_body", + "primitive_body", "$@21", "nurbs_surface_body", "nurbs_curve_body", + "primitive_tref_body", "primitive_texture_body", + "primitive_material_body", "primitive_normal_body", + "primitive_color_body", "primitive_bface_body", "primitive_vertex_ref", + "nurbs_surface_order_body", "nurbs_surface_uknots_body", + "nurbs_surface_vknots_body", "nurbs_surface_trim_body", + "nurbs_surface_trim_loop_body", "nurbs_curve_order_body", + "nurbs_curve_knots_body", "table", "$@22", "bundle", "$@23", + "table_body", "sanim", "$@24", "sanim_body", "xfmanim", "$@25", + "xfmanim_body", "xfm_s_anim", "$@26", "xfm_s_anim_body", "anim_preload", + "$@27", "anim_preload_body", "integer_list", "real_list", "texture_name", + "material_name", "vertex_pool_name", "group_name", "required_name", + "optional_name", "required_string", "optional_string", "string", + "repeated_string", "repeated_string_body", "real", "real_or_string", + "integer", "empty", YY_NULLPTR }; + +static const char * +yysymbol_name (yysymbol_kind_t yysymbol) +{ + return yytname[yysymbol]; +} #endif -# ifdef YYPRINT +#ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ -static const yytype_uint16 yytoknum[] = +static const yytype_int16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, @@ -853,16 +971,16 @@ static const yytype_uint16 yytoknum[] = 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 123, 125 }; -# endif +#endif -#define YYPACT_NINF -430 +#define YYPACT_NINF (-430) -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-430))) +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF -1 +#define YYTABLE_NINF (-1) -#define yytable_value_is_error(Yytable_value) \ +#define yytable_value_is_error(Yyn) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing @@ -951,7 +1069,7 @@ static const yytype_int16 yypact[] = /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ -static const yytype_uint16 yydefact[] = +static const yytype_int16 yydefact[] = { 0, 278, 278, 278, 278, 0, 2, 6, 3, 83, 4, 31, 5, 164, 1, 264, 265, 266, 278, 278, @@ -1071,7 +1189,7 @@ static const yytype_int16 yydefgoto[] = /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_uint16 yytable[] = +static const yytype_int16 yytable[] = { 57, 80, 57, 378, 368, 492, 494, 15, 16, 17, 167, 168, 93, 93, 14, 93, 93, 93, 93, 93, @@ -1474,7 +1592,7 @@ static const yytype_uint8 yyr1[] = }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = +static const yytype_int8 yyr2[] = { 0, 2, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -1507,10 +1625,10 @@ static const yytype_uint8 yyr2[] = }; +enum { YYENOMEM = -2 }; + #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab @@ -1519,27 +1637,52 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (&yylloc, state, scanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 +/* Backward compatibility with an undocumented macro. + Use YYerror or YYUNDEF. */ +#define YYERRCODE YYUNDEF +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (0) +#endif + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) /* Enable debugging if requested. */ @@ -1556,19 +1699,58 @@ do { \ YYFPRINTF Args; \ } while (0) -/* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +# ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL + +/* Print *YYLOCP on YYO. Private, do not rely on its existence. */ + +YY_ATTRIBUTE_UNUSED +static int +yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) +{ + int res = 0; + int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; + if (0 <= yylocp->first_line) + { + res += YYFPRINTF (yyo, "%d", yylocp->first_line); + if (0 <= yylocp->first_column) + res += YYFPRINTF (yyo, ".%d", yylocp->first_column); + } + if (0 <= yylocp->last_line) + { + if (yylocp->first_line < yylocp->last_line) + { + res += YYFPRINTF (yyo, "-%d", yylocp->last_line); + if (0 <= end_col) + res += YYFPRINTF (yyo, ".%d", end_col); + } + else if (0 <= end_col && yylocp->first_column < end_col) + res += YYFPRINTF (yyo, "-%d", end_col); + } + return res; + } + +# define YY_LOCATION_PRINT(File, Loc) \ + yy_location_print_ (File, &(Loc)) + +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +# endif /* !defined YY_LOCATION_PRINT */ -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value); \ + Kind, Value, Location, state, scanner); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) @@ -1579,17 +1761,23 @@ do { \ `-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, EggParserState &state, yyscan_t scanner) { FILE *yyoutput = yyo; YYUSE (yyoutput); + YYUSE (yylocationp); + YYUSE (state); + YYUSE (scanner); if (!yyvaluep) return; # ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyo, yytoknum[yytype], *yyvaluep); + if (yykind < YYNTOKENS) + YYPRINT (yyo, yytoknum[yykind], *yyvaluep); # endif - YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END } @@ -1598,12 +1786,15 @@ yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) `---------------------------*/ static void -yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, EggParserState &state, yyscan_t scanner) { YYFPRINTF (yyo, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); - yy_symbol_value_print (yyo, yytype, yyvaluep); + YY_LOCATION_PRINT (yyo, *yylocationp); + YYFPRINTF (yyo, ": "); + yy_symbol_value_print (yyo, yykind, yyvaluep, yylocationp, state, scanner); YYFPRINTF (yyo, ")"); } @@ -1613,7 +1804,7 @@ yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) `------------------------------------------------------------------*/ static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -1636,21 +1827,22 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, + int yyrule, EggParserState &state, yyscan_t scanner) { - unsigned long yylno = yyrline[yyrule]; + int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), + &yyvsp[(yyi + 1) - (yynrhs)], + &(yylsp[(yyi + 1) - (yynrhs)]), state, scanner); YYFPRINTF (stderr, "\n"); } } @@ -1658,15 +1850,15 @@ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (yyssp, yyvsp, Rule); \ + yy_reduce_print (yyssp, yyvsp, yylsp, Rule, state, scanner); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YYDPRINTF(Args) ((void) 0) +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ @@ -1689,256 +1881,34 @@ int yydebug; #endif -#if YYERROR_VERBOSE -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -yystrlen (const char *yystr) -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -yystpcpy (char *yydest, const char *yysrc) -{ - char *yyd = yydest; - const char *yys = yysrc; - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); -} -# endif - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) -{ - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } - } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - default: /* Avoid compiler warnings. */ - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } - - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; -} -#endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +yydestruct (const char *yymsg, + yysymbol_kind_t yykind, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, EggParserState &state, yyscan_t scanner) { YYUSE (yyvaluep); + YYUSE (yylocationp); + YYUSE (state); + YYUSE (scanner); if (!yymsg) yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YYUSE (yytype); + YYUSE (yykind); YY_IGNORE_MAYBE_UNINITIALIZED_END } -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; /*----------. @@ -1946,103 +1916,133 @@ int yynerrs; `----------*/ int -yyparse (void) +yyparse (EggParserState &state, yyscan_t scanner) { - int yystate; +/* Lookahead token kind. */ +int yychar; + + +/* The semantic value of the lookahead symbol. */ +/* Default value used for initialization, for pacifying older GCCs + or non-GCC compilers. */ +YY_INITIAL_VALUE (static YYSTYPE yyval_default;) +YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); + +/* Location data for the lookahead symbol. */ +static YYLTYPE yyloc_default +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL + = { 1, 1, 1, 1 } +# endif +; +YYLTYPE yylloc = yyloc_default; + + /* Number of syntax errors so far. */ + int yynerrs = 0; + + yy_state_fast_t yystate = 0; /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; + int yyerrstatus = 0; - /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. - - Refer to the stacks through separate pointers, to allow yyoverflow + /* Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; + /* Their size. */ + YYPTRDIFF_T yystacksize = YYINITDEPTH; - /* The semantic value stack. */ + /* The state stack: array, bottom, top. */ + yy_state_t yyssa[YYINITDEPTH]; + yy_state_t *yyss = yyssa; + yy_state_t *yyssp = yyss; + + /* The semantic value stack: array, bottom, top. */ YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp = yyvs; - YYSIZE_T yystacksize; + /* The location stack: array, bottom, top. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp = yyls; int yyn; + /* The return value of yyparse. */ int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead symbol kind. */ + yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; + YYLTYPE yyloc; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[3]; -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; - yyssp = yyss = yyssa; - yyvsp = yyvs = yyvsa; - yystacksize = YYINITDEPTH; - YYDPRINTF ((stderr, "Starting parse\n")); - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ + yylsp[0] = yylloc; goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: - *yyssp = (yytype_int16) yystate; + +/*--------------------------------------------------------------------. +| yysetstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + YY_IGNORE_USELESS_CAST_BEGIN + *yyssp = YY_CAST (yy_state_t, yystate); + YY_IGNORE_USELESS_CAST_END + YY_STACK_PRINT (yyss, yyssp); if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); + YYPTRDIFF_T yysize = yyssp - yyss + 1; -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ + yy_state_t *yyss1 = yyss; YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; + YYLTYPE *yyls1 = yyls; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp), + &yyls1, yysize * YYSIZEOF (*yylsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; + yyls = yyls1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -2051,42 +2051,45 @@ yyparse (void) yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; + yy_state_t *yyss1 = yyss; union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + YY_CAST (union yyalloc *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); + YYSTACK_RELOCATE (yyls_alloc, yyls); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; + yylsp = yyls + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long) yystacksize)); + YY_IGNORE_USELESS_CAST_BEGIN + YYDPRINTF ((stderr, "Stack size increased to %ld\n", + YY_CAST (long, yystacksize))); + YY_IGNORE_USELESS_CAST_END if (yyss + yystacksize - 1 <= yyssp) YYABORT; } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ if (yystate == YYFINAL) YYACCEPT; goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -2097,18 +2100,30 @@ yybackup: /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = yylex (); + YYDPRINTF ((stderr, "Reading a token\n")); + yychar = yylex (&yylval, &yylloc, scanner); } if (yychar <= YYEOF) { - yychar = yytoken = YYEOF; + yychar = YYEOF; + yytoken = YYSYMBOL_YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } + else if (yychar == YYerror) + { + /* The scanner already issued an error message, process directly + to error recovery. But do not keep the error token as + lookahead, it is too special and may lead us to an endless + loop in error recovery. */ + yychar = YYUNDEF; + yytoken = YYSYMBOL_YYerror; + yyerror_range[1] = yylloc; + goto yyerrlab1; + } else { yytoken = YYTRANSLATE (yychar); @@ -2136,15 +2151,14 @@ yybackup: /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END + *++yylsp = yylloc; + /* Discard the shifted token. */ + yychar = YYEMPTY; goto yynewstate; @@ -2159,7 +2173,7 @@ yydefault: /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -2175,74 +2189,76 @@ yyreduce: GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; - + /* Default location. */ + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); + yyerror_range[1] = yyloc; YY_REDUCE_PRINT (yyn); switch (yyn) { - case 7: -#line 255 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - assert(!egg_stack.empty()); - DCAST(EggData, egg_stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); + case 7: /* egg: egg node */ +#line 261 "panda/src/egg/parser.yxx" +{ + assert(!state.stack.empty()); + DCAST(EggData, state.stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); } -#line 2191 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2205 "built/tmp/parser.yxx.c" break; - case 27: -#line 300 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 27: /* coordsystem: COORDSYSTEM '{' required_string '}' */ +#line 306 "panda/src/egg/parser.yxx" +{ string strval = (yyvsp[-1]._string); EggCoordinateSystem *cs = new EggCoordinateSystem; CoordinateSystem f = parse_coordinate_system_string(strval); if (f == CS_invalid) { - eggyywarning("Unknown coordinate system " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown coordinate system " + strval); } else { cs->set_value(f); } (yyval._egg) = cs; } -#line 2208 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2222 "built/tmp/parser.yxx.c" break; - case 28: -#line 323 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 28: /* comment: COMMENT optional_name '{' repeated_string '}' */ +#line 329 "panda/src/egg/parser.yxx" +{ (yyval._egg) = new EggComment((yyvsp[-3]._string), (yyvsp[-1]._string)); } -#line 2216 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2230 "built/tmp/parser.yxx.c" break; - case 29: -#line 337 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 29: /* $@1: %empty */ +#line 343 "panda/src/egg/parser.yxx" +{ string tref_name = (yyvsp[-2]._string); Filename filename = (yyvsp[0]._string); EggTexture *texture = new EggTexture(tref_name, filename); - if (textures.find(tref_name) != textures.end()) { - eggyywarning("Duplicate texture name " + tref_name); + if (state.textures.find(tref_name) != state.textures.end()) { + eggyywarning(&(yylsp[-2]), scanner, "Duplicate texture name " + tref_name); } - textures[tref_name] = texture; + state.textures[tref_name] = texture; - egg_stack.push_back(texture); + state.stack.push_back(texture); } -#line 2233 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2247 "built/tmp/parser.yxx.c" break; - case 30: -#line 350 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 30: /* texture: TEXTURE required_name '{' required_string $@1 texture_body '}' */ +#line 356 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 2242 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2256 "built/tmp/parser.yxx.c" break; - case 32: -#line 366 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggTexture *texture = DCAST(EggTexture, egg_stack.back()); + case 32: /* texture_body: texture_body SCALAR required_name '{' real_or_string '}' */ +#line 372 "panda/src/egg/parser.yxx" +{ + EggTexture *texture = DCAST(EggTexture, state.stack.back()); string name = (yyvsp[-3]._string); double value = (yyvsp[-1]._number); string strval = (yyvsp[-1]._string); @@ -2250,7 +2266,7 @@ yyreduce: if (cmp_nocase_uh(name, "type") == 0) { EggTexture::TextureType tt = EggTexture::string_texture_type(strval); if (tt == EggTexture::TT_unspecified) { - eggyywarning("Unknown texture texture_type " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown texture texture_type " + strval); } else { texture->set_texture_type(tt); } @@ -2258,7 +2274,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "format") == 0) { EggTexture::Format f = EggTexture::string_format(strval); if (f == EggTexture::F_unspecified) { - eggyywarning("Unknown texture format " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown texture format " + strval); } else { texture->set_format(f); } @@ -2266,7 +2282,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "compression") == 0) { EggTexture::CompressionMode w = EggTexture::string_compression_mode(strval); if (w == EggTexture::CM_default) { - eggyywarning("Unknown texture compression mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown texture compression mode " + strval); } else { texture->set_compression_mode(w); } @@ -2274,7 +2290,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "wrap") == 0) { EggTexture::WrapMode w = EggTexture::string_wrap_mode(strval); if (w == EggTexture::WM_unspecified) { - eggyywarning("Unknown texture wrap mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown texture wrap mode " + strval); } else { texture->set_wrap_mode(w); } @@ -2282,7 +2298,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "wrapu") == 0) { EggTexture::WrapMode w = EggTexture::string_wrap_mode(strval); if (w == EggTexture::WM_unspecified) { - eggyywarning("Unknown texture wrap mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown texture wrap mode " + strval); } else { texture->set_wrap_u(w); } @@ -2290,7 +2306,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "wrapv") == 0) { EggTexture::WrapMode w = EggTexture::string_wrap_mode(strval); if (w == EggTexture::WM_unspecified) { - eggyywarning("Unknown texture wrap mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown texture wrap mode " + strval); } else { texture->set_wrap_v(w); } @@ -2298,7 +2314,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "minfilter") == 0) { EggTexture::FilterType f = EggTexture::string_filter_type(strval); if (f == EggTexture::FT_unspecified) { - eggyywarning("Unknown texture filter type " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown texture filter type " + strval); } else { texture->set_minfilter(f); } @@ -2306,7 +2322,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "magfilter") == 0) { EggTexture::FilterType f = EggTexture::string_filter_type(strval); if (f == EggTexture::FT_unspecified) { - eggyywarning("Unknown texture filter type " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown texture filter type " + strval); } else { texture->set_magfilter(f); } @@ -2317,7 +2333,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "envtype") == 0) { EggTexture::EnvType e = EggTexture::string_env_type(strval); if (e == EggTexture::ET_unspecified) { - eggyywarning("Unknown texture env type " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown texture env type " + strval); } else { texture->set_env_type(e); } @@ -2325,7 +2341,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-rgb") == 0) { EggTexture::CombineMode cm = EggTexture::string_combine_mode(strval); if (cm == EggTexture::CM_unspecified) { - eggyywarning("Unknown combine mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine mode " + strval); } else { texture->set_combine_mode(EggTexture::CC_rgb, cm); } @@ -2333,7 +2349,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-rgb-source0") == 0) { EggTexture::CombineSource cs = EggTexture::string_combine_source(strval); if (cs == EggTexture::CS_unspecified) { - eggyywarning("Unknown combine source " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine source " + strval); } else { texture->set_combine_source(EggTexture::CC_rgb, 0, cs); } @@ -2341,7 +2357,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-rgb-operand0") == 0) { EggTexture::CombineOperand co = EggTexture::string_combine_operand(strval); if (co == EggTexture::CO_unspecified) { - eggyywarning("Unknown combine operand " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine operand " + strval); } else { texture->set_combine_operand(EggTexture::CC_rgb, 0, co); } @@ -2349,7 +2365,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-rgb-source1") == 0) { EggTexture::CombineSource cs = EggTexture::string_combine_source(strval); if (cs == EggTexture::CS_unspecified) { - eggyywarning("Unknown combine source " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine source " + strval); } else { texture->set_combine_source(EggTexture::CC_rgb, 1, cs); } @@ -2357,7 +2373,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-rgb-operand1") == 0) { EggTexture::CombineOperand co = EggTexture::string_combine_operand(strval); if (co == EggTexture::CO_unspecified) { - eggyywarning("Unknown combine operand " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine operand " + strval); } else { texture->set_combine_operand(EggTexture::CC_rgb, 1, co); } @@ -2365,7 +2381,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-rgb-source2") == 0) { EggTexture::CombineSource cs = EggTexture::string_combine_source(strval); if (cs == EggTexture::CS_unspecified) { - eggyywarning("Unknown combine source " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine source " + strval); } else { texture->set_combine_source(EggTexture::CC_rgb, 2, cs); } @@ -2373,7 +2389,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-rgb-operand2") == 0) { EggTexture::CombineOperand co = EggTexture::string_combine_operand(strval); if (co == EggTexture::CO_unspecified) { - eggyywarning("Unknown combine operand " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine operand " + strval); } else { texture->set_combine_operand(EggTexture::CC_rgb, 2, co); } @@ -2381,7 +2397,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-alpha") == 0) { EggTexture::CombineMode cm = EggTexture::string_combine_mode(strval); if (cm == EggTexture::CM_unspecified) { - eggyywarning("Unknown combine mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine mode " + strval); } else { texture->set_combine_mode(EggTexture::CC_alpha, cm); } @@ -2389,7 +2405,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-alpha-source0") == 0) { EggTexture::CombineSource cs = EggTexture::string_combine_source(strval); if (cs == EggTexture::CS_unspecified) { - eggyywarning("Unknown combine source " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine source " + strval); } else { texture->set_combine_source(EggTexture::CC_alpha, 0, cs); } @@ -2397,7 +2413,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-alpha-operand0") == 0) { EggTexture::CombineOperand co = EggTexture::string_combine_operand(strval); if (co == EggTexture::CO_unspecified) { - eggyywarning("Unknown combine operand " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine operand " + strval); } else { texture->set_combine_operand(EggTexture::CC_alpha, 0, co); } @@ -2405,7 +2421,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-alpha-source1") == 0) { EggTexture::CombineSource cs = EggTexture::string_combine_source(strval); if (cs == EggTexture::CS_unspecified) { - eggyywarning("Unknown combine source " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine source " + strval); } else { texture->set_combine_source(EggTexture::CC_alpha, 1, cs); } @@ -2413,7 +2429,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-alpha-operand1") == 0) { EggTexture::CombineOperand co = EggTexture::string_combine_operand(strval); if (co == EggTexture::CO_unspecified) { - eggyywarning("Unknown combine operand " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine operand " + strval); } else { texture->set_combine_operand(EggTexture::CC_alpha, 1, co); } @@ -2421,7 +2437,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-alpha-source2") == 0) { EggTexture::CombineSource cs = EggTexture::string_combine_source(strval); if (cs == EggTexture::CS_unspecified) { - eggyywarning("Unknown combine source " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine source " + strval); } else { texture->set_combine_source(EggTexture::CC_alpha, 2, cs); } @@ -2429,7 +2445,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "combine-alpha-operand2") == 0) { EggTexture::CombineOperand co = EggTexture::string_combine_operand(strval); if (co == EggTexture::CO_unspecified) { - eggyywarning("Unknown combine operand " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown combine operand " + strval); } else { texture->set_combine_operand(EggTexture::CC_alpha, 2, co); } @@ -2440,7 +2456,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "tex_gen") == 0) { EggTexture::TexGen tex_gen = EggTexture::string_tex_gen(strval); if (tex_gen == EggTexture::TG_unspecified) { - eggyywarning("Unknown tex-gen " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown tex-gen " + strval); } else { texture->set_tex_gen(tex_gen); } @@ -2448,7 +2464,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "quality_level") == 0) { EggTexture::QualityLevel quality_level = EggTexture::string_quality_level(strval); if (quality_level == EggTexture::QL_unspecified) { - eggyywarning("Unknown quality-level " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown quality-level " + strval); } else { texture->set_quality_level(quality_level); } @@ -2465,7 +2481,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "num_views") == 0) { int int_value = (int)value; if (int_value < 1) { - eggyyerror("Invalid num-views value " + strval); + eggyyerror(&(yylsp[-1]), scanner, "Invalid num-views value " + strval); } else { texture->set_num_views(int_value); } @@ -2516,7 +2532,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "rgb_scale") == 0) { int int_value = (int)value; if (int_value != 1 && int_value != 2 && int_value != 4) { - eggyyerror("Invalid rgb-scale value " + strval); + eggyyerror(&(yylsp[-1]), scanner, "Invalid rgb-scale value " + strval); } else { texture->set_rgb_scale(int_value); } @@ -2524,7 +2540,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "alpha_scale") == 0) { int int_value = (int)value; if (int_value != 1 && int_value != 2 && int_value != 4) { - eggyyerror("Invalid alpha-scale value " + strval); + eggyyerror(&(yylsp[-1]), scanner, "Invalid alpha-scale value " + strval); } else { texture->set_alpha_scale(int_value); } @@ -2532,7 +2548,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "alpha") == 0) { EggRenderMode::AlphaMode a = EggRenderMode::string_alpha_mode(strval); if (a == EggRenderMode::AM_unspecified) { - eggyywarning("Unknown alpha mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown alpha mode " + strval); } else { texture->set_alpha_mode(a); } @@ -2541,7 +2557,7 @@ yyreduce: EggRenderMode::DepthWriteMode m = EggRenderMode::string_depth_write_mode(strval); if (m == EggRenderMode::DWM_unspecified) { - eggyywarning("Unknown depth-write mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown depth-write mode " + strval); } else { texture->set_depth_write_mode(m); } @@ -2550,7 +2566,7 @@ yyreduce: EggRenderMode::DepthTestMode m = EggRenderMode::string_depth_test_mode(strval); if (m == EggRenderMode::DTM_unspecified) { - eggyywarning("Unknown depth-test mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown depth-test mode " + strval); } else { texture->set_depth_test_mode(m); } @@ -2559,7 +2575,7 @@ yyreduce: EggRenderMode::VisibilityMode m = EggRenderMode::string_visibility_mode(strval); if (m == EggRenderMode::VM_unspecified) { - eggyywarning("Unknown visibility mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown visibility mode " + strval); } else { texture->set_visibility_mode(m); } @@ -2592,41 +2608,41 @@ yyreduce: texture->set_lod_bias(value); } else { - eggyywarning("Unsupported texture scalar: " + name); + eggyywarning(&(yylsp[-4]), scanner, "Unsupported texture scalar: " + name); } } -#line 2601 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2615 "built/tmp/parser.yxx.c" break; - case 34: -#line 732 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 34: /* $@2: %empty */ +#line 738 "panda/src/egg/parser.yxx" +{ string mref_name = (yyvsp[-1]._string); EggMaterial *material = new EggMaterial(mref_name); - if (materials.find(mref_name) != materials.end()) { - eggyywarning("Duplicate material name " + mref_name); + if (state.materials.find(mref_name) != state.materials.end()) { + eggyywarning(&(yylsp[-1]), scanner, "Duplicate material name " + mref_name); } - materials[mref_name] = material; + state.materials[mref_name] = material; - egg_stack.push_back(material); + state.stack.push_back(material); } -#line 2617 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2631 "built/tmp/parser.yxx.c" break; - case 35: -#line 744 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 35: /* material: MATERIAL required_name '{' $@2 material_body '}' */ +#line 750 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 2626 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2640 "built/tmp/parser.yxx.c" break; - case 37: -#line 760 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggMaterial *material = DCAST(EggMaterial, egg_stack.back()); + case 37: /* material_body: material_body SCALAR required_name '{' real_or_string '}' */ +#line 766 "panda/src/egg/parser.yxx" +{ + EggMaterial *material = DCAST(EggMaterial, state.stack.back()); string name = (yyvsp[-3]._string); double value = (yyvsp[-1]._number); @@ -2731,479 +2747,479 @@ yyreduce: material->set_local(value != 0.0); } else { - eggyywarning("Unsupported material scalar: " + name); + eggyywarning(&(yylsp[-3]), scanner, "Unsupported material scalar: " + name); } } -#line 2740 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2754 "built/tmp/parser.yxx.c" break; - case 38: -#line 881 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 38: /* external_reference: EXTERNAL_FILE optional_name '{' required_string '}' */ +#line 887 "panda/src/egg/parser.yxx" +{ string node_name = (yyvsp[-3]._string); Filename filename = (yyvsp[-1]._string); EggExternalReference *ref = new EggExternalReference(node_name, filename); (yyval._egg) = ref; } -#line 2751 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2765 "built/tmp/parser.yxx.c" break; - case 39: -#line 888 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 39: /* external_reference: string EXTERNAL_FILE optional_name '{' required_string '}' */ +#line 894 "panda/src/egg/parser.yxx" +{ if (cmp_nocase_uh((yyvsp[-5]._string), "group") != 0) { - eggyyerror("keyword 'group' expected"); + eggyyerror(&(yylsp[-5]), scanner, "keyword 'group' expected"); } string node_name = (yyvsp[-3]._string); Filename filename = (yyvsp[-1]._string); EggExternalReference *ref = new EggExternalReference(node_name, filename); (yyval._egg) = ref; } -#line 2765 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2779 "built/tmp/parser.yxx.c" break; - case 40: -#line 908 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 40: /* $@3: %empty */ +#line 914 "panda/src/egg/parser.yxx" +{ string name = (yyvsp[0]._string); EggVertexPool *pool = nullptr; - VertexPools::const_iterator vpi = vertex_pools.find(name); - if (vpi != vertex_pools.end()) { + VertexPools::const_iterator vpi = state.vertex_pools.find(name); + if (vpi != state.vertex_pools.end()) { pool = (*vpi).second; if (pool->has_defined_vertices()) { - eggyywarning("Duplicate vertex pool name " + name); + eggyywarning(&(yylsp[0]), scanner, "Duplicate vertex pool name " + name); pool = new EggVertexPool(name); // The egg syntax starts counting at 1 by convention. pool->set_highest_index(0); - vertex_pools[name] = pool; + state.vertex_pools[name] = pool; } } else { pool = new EggVertexPool(name); // The egg syntax starts counting at 1 by convention. pool->set_highest_index(0); - vertex_pools[name] = pool; + state.vertex_pools[name] = pool; } - egg_stack.push_back(pool); + state.stack.push_back(pool); } -#line 2793 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2807 "built/tmp/parser.yxx.c" break; - case 41: -#line 932 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 41: /* vertex_pool: VERTEXPOOL required_name $@3 '{' vertex_pool_body '}' */ +#line 938 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 2802 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2816 "built/tmp/parser.yxx.c" break; - case 44: -#line 960 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_stack.push_back(new EggVertex); + case 44: /* $@4: %empty */ +#line 966 "panda/src/egg/parser.yxx" +{ + state.stack.push_back(new EggVertex); } -#line 2810 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2824 "built/tmp/parser.yxx.c" break; - case 45: -#line 964 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - PT(EggVertex) vtx = DCAST(EggVertex, egg_stack.back()); - egg_stack.pop_back(); + case 45: /* vertex: VERTEX $@4 '{' vertex_body '}' */ +#line 970 "panda/src/egg/parser.yxx" +{ + PT(EggVertex) vtx = DCAST(EggVertex, state.stack.back()); + state.stack.pop_back(); - DCAST(EggVertexPool, egg_stack.back())->add_vertex(vtx); + DCAST(EggVertexPool, state.stack.back())->add_vertex(vtx); } -#line 2821 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2835 "built/tmp/parser.yxx.c" break; - case 46: -#line 971 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - vertex_index = (int)(yyvsp[0]._number); - EggVertexPool *pool = DCAST(EggVertexPool, egg_stack.back()); + case 46: /* $@5: %empty */ +#line 977 "panda/src/egg/parser.yxx" +{ + state.vertex_index = (int)(yyvsp[0]._number); + EggVertexPool *pool = DCAST(EggVertexPool, state.stack.back()); - if (vertex_index < 0) { + if (state.vertex_index < 0) { ostringstream errmsg; - errmsg << "Ignoring invalid vertex index " << vertex_index + errmsg << "Ignoring invalid vertex index " << state.vertex_index << " in vertex pool " << pool->get_name() << std::ends; - eggyywarning(errmsg); - vertex_index = -1; + eggyywarning(&(yylsp[0]), scanner, errmsg.str()); + state.vertex_index = -1; - } else if (pool->has_vertex(vertex_index)) { + } else if (pool->has_vertex(state.vertex_index)) { ostringstream errmsg; - errmsg << "Ignoring duplicate vertex index " << vertex_index + errmsg << "Ignoring duplicate vertex index " << state.vertex_index << " in vertex pool " << pool->get_name() << std::ends; - eggyywarning(errmsg); - vertex_index = -1; + eggyywarning(&(yylsp[0]), scanner, errmsg.str()); + state.vertex_index = -1; } // Even if we didn't like the vertex index number, we still need to // go ahead and parse the vertex. We just won't save it. - egg_stack.push_back(new EggVertex); + state.stack.push_back(new EggVertex); } -#line 2850 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2864 "built/tmp/parser.yxx.c" break; - case 47: -#line 996 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - PT(EggVertex) vtx = DCAST(EggVertex, egg_stack.back()); - egg_stack.pop_back(); + case 47: /* vertex: VERTEX integer $@5 '{' vertex_body '}' */ +#line 1002 "panda/src/egg/parser.yxx" +{ + PT(EggVertex) vtx = DCAST(EggVertex, state.stack.back()); + state.stack.pop_back(); - EggVertexPool *pool = DCAST(EggVertexPool, egg_stack.back()); - if (vertex_index != -1) { - pool->add_vertex(vtx, vertex_index); + EggVertexPool *pool = DCAST(EggVertexPool, state.stack.back()); + if (state.vertex_index != -1) { + pool->add_vertex(vtx, state.vertex_index); } } -#line 2864 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2878 "built/tmp/parser.yxx.c" break; - case 48: -#line 1017 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggVertex, egg_stack.back())->set_pos((yyvsp[0]._number)); + case 48: /* vertex_body: real */ +#line 1023 "panda/src/egg/parser.yxx" +{ + DCAST(EggVertex, state.stack.back())->set_pos((yyvsp[0]._number)); } -#line 2872 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2886 "built/tmp/parser.yxx.c" break; - case 49: -#line 1021 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggVertex, egg_stack.back())->set_pos(LPoint2d((yyvsp[-1]._number), (yyvsp[0]._number))); + case 49: /* vertex_body: real real */ +#line 1027 "panda/src/egg/parser.yxx" +{ + DCAST(EggVertex, state.stack.back())->set_pos(LPoint2d((yyvsp[-1]._number), (yyvsp[0]._number))); } -#line 2880 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2894 "built/tmp/parser.yxx.c" break; - case 50: -#line 1025 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggVertex, egg_stack.back())->set_pos(LPoint3d((yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); + case 50: /* vertex_body: real real real */ +#line 1031 "panda/src/egg/parser.yxx" +{ + DCAST(EggVertex, state.stack.back())->set_pos(LPoint3d((yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); } -#line 2888 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2902 "built/tmp/parser.yxx.c" break; - case 51: -#line 1029 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggVertex, egg_stack.back())->set_pos(LPoint4d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); + case 51: /* vertex_body: real real real real */ +#line 1035 "panda/src/egg/parser.yxx" +{ + DCAST(EggVertex, state.stack.back())->set_pos(LPoint4d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); } -#line 2896 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2910 "built/tmp/parser.yxx.c" break; - case 52: -#line 1033 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggVertex *vertex = DCAST(EggVertex, egg_stack.back()); + case 52: /* $@6: %empty */ +#line 1039 "panda/src/egg/parser.yxx" +{ + EggVertex *vertex = DCAST(EggVertex, state.stack.back()); EggVertexUV *uv = new EggVertexUV((yyvsp[-1]._string), LTexCoordd::zero()); - egg_stack.push_back(uv); + state.stack.push_back(uv); if (vertex->has_uv((yyvsp[-1]._string))) { - eggyywarning("Ignoring repeated UV name " + (yyvsp[-1]._string)); + eggyywarning(&(yylsp[-1]), scanner, "Ignoring repeated UV name " + (yyvsp[-1]._string)); } else { vertex->set_uv_obj(uv); } } -#line 2911 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2925 "built/tmp/parser.yxx.c" break; - case 53: -#line 1044 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_stack.pop_back(); + case 53: /* vertex_body: vertex_body UV optional_name '{' $@6 vertex_uv_body '}' */ +#line 1050 "panda/src/egg/parser.yxx" +{ + state.stack.pop_back(); } -#line 2919 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2933 "built/tmp/parser.yxx.c" break; - case 54: -#line 1048 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggVertex *vertex = DCAST(EggVertex, egg_stack.back()); + case 54: /* $@7: %empty */ +#line 1054 "panda/src/egg/parser.yxx" +{ + EggVertex *vertex = DCAST(EggVertex, state.stack.back()); EggVertexAux *aux = new EggVertexAux((yyvsp[-1]._string), LVecBase4d::zero()); - egg_stack.push_back(aux); + state.stack.push_back(aux); if (vertex->has_aux((yyvsp[-1]._string))) { - eggyywarning("Ignoring repeated Aux name " + (yyvsp[-1]._string)); + eggyywarning(&(yylsp[-1]), scanner, "Ignoring repeated Aux name " + (yyvsp[-1]._string)); } else { vertex->set_aux_obj(aux); } } -#line 2934 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2948 "built/tmp/parser.yxx.c" break; - case 55: -#line 1059 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_stack.pop_back(); + case 55: /* vertex_body: vertex_body AUX required_name '{' $@7 vertex_aux_body '}' */ +#line 1065 "panda/src/egg/parser.yxx" +{ + state.stack.pop_back(); } -#line 2942 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2956 "built/tmp/parser.yxx.c" break; - case 58: -#line 1065 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggVertex, egg_stack.back())->_dxyzs. + case 58: /* vertex_body: vertex_body DXYZ string '{' real real real '}' */ +#line 1071 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggVertex, state.stack.back())->_dxyzs. insert(EggMorphVertex((yyvsp[-5]._string), LVector3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number)))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-5]._string)); + eggyywarning(&(yylsp[-5]), scanner, "Ignoring repeated morph name " + (yyvsp[-5]._string)); } } -#line 2954 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2968 "built/tmp/parser.yxx.c" break; - case 59: -#line 1073 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggVertex, egg_stack.back())->_dxyzs. + case 59: /* vertex_body: vertex_body DXYZ '{' string real real real '}' */ +#line 1079 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggVertex, state.stack.back())->_dxyzs. insert(EggMorphVertex((yyvsp[-4]._string), LVector3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number)))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-4]._string)); + eggyywarning(&(yylsp[-4]), scanner, "Ignoring repeated morph name " + (yyvsp[-4]._string)); } } -#line 2966 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2980 "built/tmp/parser.yxx.c" break; - case 60: -#line 1092 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggVertexUV, egg_stack.back())->set_uv(LTexCoordd((yyvsp[-1]._number), (yyvsp[0]._number))); + case 60: /* vertex_uv_body: real real */ +#line 1098 "panda/src/egg/parser.yxx" +{ + DCAST(EggVertexUV, state.stack.back())->set_uv(LTexCoordd((yyvsp[-1]._number), (yyvsp[0]._number))); } -#line 2974 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2988 "built/tmp/parser.yxx.c" break; - case 61: -#line 1096 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggVertexUV, egg_stack.back())->set_uvw(LVecBase3d((yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); + case 61: /* vertex_uv_body: real real real */ +#line 1102 "panda/src/egg/parser.yxx" +{ + DCAST(EggVertexUV, state.stack.back())->set_uvw(LVecBase3d((yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); } -#line 2982 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 2996 "built/tmp/parser.yxx.c" break; - case 62: -#line 1100 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - if (DCAST(EggVertexUV, egg_stack.back())->has_tangent()) { - eggyywarning("Ignoring repeated tangent"); + case 62: /* vertex_uv_body: vertex_uv_body TANGENT '{' real real real '}' */ +#line 1106 "panda/src/egg/parser.yxx" +{ + if (DCAST(EggVertexUV, state.stack.back())->has_tangent()) { + eggyywarning(&(yylsp[-5]), scanner, "Ignoring repeated tangent"); } else { - DCAST(EggVertexUV, egg_stack.back())->set_tangent(LNormald((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number))); + DCAST(EggVertexUV, state.stack.back())->set_tangent(LNormald((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number))); } } -#line 2994 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3008 "built/tmp/parser.yxx.c" break; - case 63: -#line 1108 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - if (DCAST(EggVertexUV, egg_stack.back())->has_tangent()) { - eggyywarning("Ignoring repeated tangent"); + case 63: /* vertex_uv_body: vertex_uv_body TANGENT '{' real real real real '}' */ +#line 1114 "panda/src/egg/parser.yxx" +{ + if (DCAST(EggVertexUV, state.stack.back())->has_tangent()) { + eggyywarning(&(yylsp[-6]), scanner, "Ignoring repeated tangent"); } else { - DCAST(EggVertexUV, egg_stack.back())->set_tangent4(LVecBase4d((yyvsp[-4]._number), (yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number))); + DCAST(EggVertexUV, state.stack.back())->set_tangent4(LVecBase4d((yyvsp[-4]._number), (yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number))); } } -#line 3006 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3020 "built/tmp/parser.yxx.c" break; - case 64: -#line 1116 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - if (DCAST(EggVertexUV, egg_stack.back())->has_binormal()) { - eggyywarning("Ignoring repeated binormal"); + case 64: /* vertex_uv_body: vertex_uv_body BINORMAL '{' real real real '}' */ +#line 1122 "panda/src/egg/parser.yxx" +{ + if (DCAST(EggVertexUV, state.stack.back())->has_binormal()) { + eggyywarning(&(yylsp[-5]), scanner, "Ignoring repeated binormal"); } else { - DCAST(EggVertexUV, egg_stack.back())->set_binormal(LNormald((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number))); + DCAST(EggVertexUV, state.stack.back())->set_binormal(LNormald((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number))); } } -#line 3018 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3032 "built/tmp/parser.yxx.c" break; - case 65: -#line 1124 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggVertexUV, egg_stack.back())->_duvs. + case 65: /* vertex_uv_body: vertex_uv_body DUV string '{' real real '}' */ +#line 1130 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggVertexUV, state.stack.back())->_duvs. insert(EggMorphTexCoord((yyvsp[-4]._string), LVector3d((yyvsp[-2]._number), (yyvsp[-1]._number), 0.0))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-4]._string)); + eggyywarning(&(yylsp[-4]), scanner, "Ignoring repeated morph name " + (yyvsp[-4]._string)); } } -#line 3030 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3044 "built/tmp/parser.yxx.c" break; - case 66: -#line 1132 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggVertexUV, egg_stack.back())->_duvs. + case 66: /* vertex_uv_body: vertex_uv_body DUV string '{' real real real '}' */ +#line 1138 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggVertexUV, state.stack.back())->_duvs. insert(EggMorphTexCoord((yyvsp[-5]._string), LVector3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number)))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-5]._string)); + eggyywarning(&(yylsp[-5]), scanner, "Ignoring repeated morph name " + (yyvsp[-5]._string)); } } -#line 3042 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3056 "built/tmp/parser.yxx.c" break; - case 67: -#line 1140 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggVertexUV, egg_stack.back())->_duvs. + case 67: /* vertex_uv_body: vertex_uv_body DUV '{' string real real '}' */ +#line 1146 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggVertexUV, state.stack.back())->_duvs. insert(EggMorphTexCoord((yyvsp[-3]._string), LVector3d((yyvsp[-2]._number), (yyvsp[-1]._number), 0.0))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-3]._string)); + eggyywarning(&(yylsp[-3]), scanner, "Ignoring repeated morph name " + (yyvsp[-3]._string)); } } -#line 3054 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3068 "built/tmp/parser.yxx.c" break; - case 68: -#line 1148 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggVertexUV, egg_stack.back())->_duvs. + case 68: /* vertex_uv_body: vertex_uv_body DUV '{' string real real real '}' */ +#line 1154 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggVertexUV, state.stack.back())->_duvs. insert(EggMorphTexCoord((yyvsp[-4]._string), LVector3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number)))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-4]._string)); + eggyywarning(&(yylsp[-4]), scanner, "Ignoring repeated morph name " + (yyvsp[-4]._string)); } } -#line 3066 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3080 "built/tmp/parser.yxx.c" break; - case 70: -#line 1166 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggVertexAux, egg_stack.back())->set_aux(LVecBase4d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); + case 70: /* vertex_aux_body: real real real real */ +#line 1172 "panda/src/egg/parser.yxx" +{ + DCAST(EggVertexAux, state.stack.back())->set_aux(LVecBase4d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); } -#line 3074 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3088 "built/tmp/parser.yxx.c" break; - case 71: -#line 1180 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggVertex, egg_stack.back())->set_normal(LNormald((yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); + case 71: /* vertex_normal_body: real real real */ +#line 1186 "panda/src/egg/parser.yxx" +{ + DCAST(EggVertex, state.stack.back())->set_normal(LNormald((yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); } -#line 3082 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3096 "built/tmp/parser.yxx.c" break; - case 72: -#line 1184 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggVertex, egg_stack.back())->_dnormals. + case 72: /* vertex_normal_body: vertex_normal_body DNORMAL string '{' real real real '}' */ +#line 1190 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggVertex, state.stack.back())->_dnormals. insert(EggMorphNormal((yyvsp[-5]._string), LVector3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number)))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-5]._string)); + eggyywarning(&(yylsp[-5]), scanner, "Ignoring repeated morph name " + (yyvsp[-5]._string)); } } -#line 3094 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3108 "built/tmp/parser.yxx.c" break; - case 73: -#line 1192 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggVertex, egg_stack.back())->_dnormals. + case 73: /* vertex_normal_body: vertex_normal_body DNORMAL '{' string real real real '}' */ +#line 1198 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggVertex, state.stack.back())->_dnormals. insert(EggMorphNormal((yyvsp[-4]._string), LVector3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number)))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-4]._string)); + eggyywarning(&(yylsp[-4]), scanner, "Ignoring repeated morph name " + (yyvsp[-4]._string)); } } -#line 3106 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3120 "built/tmp/parser.yxx.c" break; - case 74: -#line 1210 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggVertex, egg_stack.back())->set_color(LColor((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); + case 74: /* vertex_color_body: real real real real */ +#line 1216 "panda/src/egg/parser.yxx" +{ + DCAST(EggVertex, state.stack.back())->set_color(LColor((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); } -#line 3114 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3128 "built/tmp/parser.yxx.c" break; - case 75: -#line 1214 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggVertex, egg_stack.back())->_drgbas. + case 75: /* vertex_color_body: vertex_color_body DRGBA string '{' real real real real '}' */ +#line 1220 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggVertex, state.stack.back())->_drgbas. insert(EggMorphColor((yyvsp[-6]._string), LVector4((yyvsp[-4]._number), (yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number)))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-6]._string)); + eggyywarning(&(yylsp[-6]), scanner, "Ignoring repeated morph name " + (yyvsp[-6]._string)); } } -#line 3126 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3140 "built/tmp/parser.yxx.c" break; - case 76: -#line 1222 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggVertex, egg_stack.back())->_drgbas. + case 76: /* vertex_color_body: vertex_color_body DRGBA '{' string real real real real '}' */ +#line 1228 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggVertex, state.stack.back())->_drgbas. insert(EggMorphColor((yyvsp[-5]._string), LVector4((yyvsp[-4]._number), (yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number)))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-5]._string)); + eggyywarning(&(yylsp[-5]), scanner, "Ignoring repeated morph name " + (yyvsp[-5]._string)); } } -#line 3138 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3152 "built/tmp/parser.yxx.c" break; - case 77: -#line 1240 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 77: /* $@8: %empty */ +#line 1246 "panda/src/egg/parser.yxx" +{ EggGroup *group = new EggGroup((yyvsp[0]._string)); - egg_stack.push_back(group); + state.stack.push_back(group); } -#line 3147 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3161 "built/tmp/parser.yxx.c" break; - case 78: -#line 1245 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 78: /* group: GROUP optional_name $@8 '{' group_body '}' */ +#line 1251 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); (yyval._egg) = group; - egg_stack.pop_back(); + state.stack.pop_back(); if (group->has_name()) { - groups[group->get_name()] = group; + state.groups[group->get_name()] = group; } Thread::consider_yield(); } -#line 3161 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3175 "built/tmp/parser.yxx.c" break; - case 79: -#line 1265 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 79: /* $@9: %empty */ +#line 1271 "panda/src/egg/parser.yxx" +{ EggGroup *group = new EggGroup((yyvsp[0]._string)); group->set_group_type(EggGroup::GT_joint); - egg_stack.push_back(group); + state.stack.push_back(group); } -#line 3171 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3185 "built/tmp/parser.yxx.c" break; - case 80: -#line 1271 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 80: /* joint: JOINT optional_name $@9 '{' group_body '}' */ +#line 1277 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 3180 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3194 "built/tmp/parser.yxx.c" break; - case 81: -#line 1286 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 81: /* $@10: %empty */ +#line 1292 "panda/src/egg/parser.yxx" +{ EggGroup *group = new EggGroup((yyvsp[0]._string)); group->set_group_type(EggGroup::GT_instance); - egg_stack.push_back(group); + state.stack.push_back(group); } -#line 3190 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3204 "built/tmp/parser.yxx.c" break; - case 82: -#line 1292 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 82: /* instance: INSTANCE optional_name $@10 '{' group_body '}' */ +#line 1298 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); (yyval._egg) = group; - egg_stack.pop_back(); + state.stack.pop_back(); if (group->has_name()) { - groups[group->get_name()] = group; + state.groups[group->get_name()] = group; } } -#line 3203 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3217 "built/tmp/parser.yxx.c" break; - case 84: -#line 1312 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 84: /* group_body: group_body SCALAR required_name '{' real_or_string '}' */ +#line 1318 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); string name = (yyvsp[-3]._string); double value = (yyvsp[-1]._number); unsigned long ulong_value = (yyvsp[-1]._ulong); @@ -3224,7 +3240,7 @@ yyreduce: } else if (cmp_nocase_uh(name, "alpha") == 0) { EggRenderMode::AlphaMode a = EggRenderMode::string_alpha_mode(strval); if (a == EggRenderMode::AM_unspecified) { - eggyywarning("Unknown alpha mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown alpha mode " + strval); } else { group->set_alpha_mode(a); } @@ -3233,7 +3249,7 @@ yyreduce: EggRenderMode::DepthWriteMode m = EggRenderMode::string_depth_write_mode(strval); if (m == EggRenderMode::DWM_unspecified) { - eggyywarning("Unknown depth-write mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown depth-write mode " + strval); } else { group->set_depth_write_mode(m); } @@ -3242,7 +3258,7 @@ yyreduce: EggRenderMode::DepthTestMode m = EggRenderMode::string_depth_test_mode(strval); if (m == EggRenderMode::DTM_unspecified) { - eggyywarning("Unknown depth-test mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown depth-test mode " + strval); } else { group->set_depth_test_mode(m); } @@ -3251,7 +3267,7 @@ yyreduce: EggRenderMode::VisibilityMode m = EggRenderMode::string_visibility_mode(strval); if (m == EggRenderMode::VM_unspecified) { - eggyywarning("Unknown visibility mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown visibility mode " + strval); } else { group->set_visibility_mode(m); } @@ -3302,7 +3318,7 @@ yyreduce: EggGroup::BlendMode blend_mode = EggGroup::string_blend_mode(strval); if (blend_mode == EggGroup::BM_unspecified) { - eggyywarning("Unknown blend mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown blend mode " + strval); } else { group->set_blend_mode(blend_mode); } @@ -3311,7 +3327,7 @@ yyreduce: EggGroup::BlendOperand blend_operand = EggGroup::string_blend_operand(strval); if (blend_operand == EggGroup::BO_unspecified) { - eggyywarning("Unknown blend operand " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown blend operand " + strval); } else { group->set_blend_operand_a(blend_operand); } @@ -3320,7 +3336,7 @@ yyreduce: EggGroup::BlendOperand blend_operand = EggGroup::string_blend_operand(strval); if (blend_operand == EggGroup::BO_unspecified) { - eggyywarning("Unknown blend operand " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown blend operand " + strval); } else { group->set_blend_operand_b(blend_operand); } @@ -3346,182 +3362,182 @@ yyreduce: group->set_blend_color(color); } else { - eggyywarning("Unknown group scalar " + name); + eggyywarning(&(yylsp[-3]), scanner, "Unknown group scalar " + name); } } -#line 3355 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3369 "built/tmp/parser.yxx.c" break; - case 85: -#line 1460 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 85: /* group_body: group_body BILLBOARD '{' string '}' */ +#line 1466 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); string strval = (yyvsp[-1]._string); EggGroup::BillboardType f = EggGroup::string_billboard_type(strval); if (f == EggGroup::BT_none) { - eggyywarning("Unknown billboard type " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown billboard type " + strval); } else { group->set_billboard_type(f); } } -#line 3371 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3385 "built/tmp/parser.yxx.c" break; - case 86: -#line 1472 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 86: /* group_body: group_body BILLBOARDCENTER '{' real real real '}' */ +#line 1478 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); group->set_billboard_center(LPoint3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number))); } -#line 3380 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3394 "built/tmp/parser.yxx.c" break; - case 87: -#line 1477 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 87: /* group_body: group_body COLLIDE optional_name '{' cs_type collide_flags '}' */ +#line 1483 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); string name = (yyvsp[-4]._string); group->set_collision_name(name); } -#line 3391 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3405 "built/tmp/parser.yxx.c" break; - case 88: -#line 1484 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 88: /* group_body: group_body DCS '{' integer '}' */ +#line 1490 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); int value = (int)(yyvsp[-1]._number); group->set_dcs_type(value!=0 ? EggGroup::DC_default : EggGroup::DC_none); } -#line 3401 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3415 "built/tmp/parser.yxx.c" break; - case 89: -#line 1490 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 89: /* group_body: group_body DCS '{' EGG_STRING '}' */ +#line 1496 "panda/src/egg/parser.yxx" +{ // The special flavor of DCS, with { sync } or { nosync }. - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); string strval = (yyvsp[-1]._string); EggGroup::DCSType f = EggGroup::string_dcs_type(strval); if (f == EggGroup::DC_unspecified) { - eggyywarning("Unknown DCS type " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown DCS type " + strval); } else { group->set_dcs_type(f); } } -#line 3418 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3432 "built/tmp/parser.yxx.c" break; - case 90: -#line 1503 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 90: /* group_body: group_body DART '{' integer '}' */ +#line 1509 "panda/src/egg/parser.yxx" +{ // The traditional flavor of DART, with { 0 } or { 1 }. - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); int value = (int)(yyvsp[-1]._number); group->set_dart_type(value!=0 ? EggGroup::DT_default : EggGroup::DT_none); } -#line 3429 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3443 "built/tmp/parser.yxx.c" break; - case 91: -#line 1510 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 91: /* group_body: group_body DART '{' EGG_STRING '}' */ +#line 1516 "panda/src/egg/parser.yxx" +{ // The special flavor of DART, with { sync } or { nosync }. - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); string strval = (yyvsp[-1]._string); EggGroup::DartType f = EggGroup::string_dart_type(strval); if (f == EggGroup::DT_none) { - eggyywarning("Unknown dart type " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown dart type " + strval); } else { group->set_dart_type(f); } } -#line 3446 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3460 "built/tmp/parser.yxx.c" break; - case 92: -#line 1523 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 92: /* group_body: group_body SWITCH '{' integer '}' */ +#line 1529 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); int value = (int)(yyvsp[-1]._number); group->set_switch_flag(value!=0); } -#line 3456 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3470 "built/tmp/parser.yxx.c" break; - case 93: -#line 1529 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 93: /* group_body: group_body OBJECTTYPE '{' required_string '}' */ +#line 1535 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); string type = (yyvsp[-1]._string); group->add_object_type(type); } -#line 3466 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3480 "built/tmp/parser.yxx.c" break; - case 94: -#line 1535 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 94: /* group_body: group_body MODEL '{' integer '}' */ +#line 1541 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); int value = (int)(yyvsp[-1]._number); group->set_model_flag(value!=0); } -#line 3476 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3490 "built/tmp/parser.yxx.c" break; - case 95: -#line 1541 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 95: /* group_body: group_body TAG optional_name '{' repeated_string '}' */ +#line 1547 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); group->set_tag((yyvsp[-3]._string), (yyvsp[-1]._string)); } -#line 3485 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3499 "built/tmp/parser.yxx.c" break; - case 96: -#line 1546 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 96: /* group_body: group_body TEXLIST '{' integer '}' */ +#line 1552 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); int value = (int)(yyvsp[-1]._number); group->set_texlist_flag(value!=0); } -#line 3495 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3509 "built/tmp/parser.yxx.c" break; - case 101: -#line 1556 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 101: /* group_body: group_body REF '{' group_name '}' */ +#line 1562 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); if (group->get_group_type() != EggGroup::GT_instance) { - eggyyerror(" valid only within "); + eggyyerror(&(yylsp[-4]), scanner, " valid only within "); } else if ((yyvsp[-1]._egg) != nullptr) { group->add_group_ref(DCAST(EggGroup, (yyvsp[-1]._egg))); } } -#line 3508 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3522 "built/tmp/parser.yxx.c" break; - case 102: -#line 1565 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggGroup, egg_stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); + case 102: /* group_body: group_body node */ +#line 1571 "panda/src/egg/parser.yxx" +{ + DCAST(EggGroup, state.stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); } -#line 3516 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3530 "built/tmp/parser.yxx.c" break; - case 103: -#line 1579 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 103: /* cs_type: string */ +#line 1585 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); string strval = (yyvsp[0]._string); EggGroup::CollisionSolidType f = EggGroup::string_cs_type(strval); if (f == EggGroup::CST_none) { - eggyywarning("Unknown collision solid type " + strval); + eggyywarning(&(yylsp[0]), scanner, "Unknown collision solid type " + strval); } else { if (f == EggGroup::CST_polyset && group->get_cs_type() != EggGroup::CST_none) { // By convention, a CST_polyset doesn't replace any existing @@ -3534,156 +3550,156 @@ yyreduce: } } } -#line 3540 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3554 "built/tmp/parser.yxx.c" break; - case 105: -#line 1610 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 105: /* collide_flags: collide_flags string */ +#line 1616 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); string strval = (yyvsp[0]._string); EggGroup::CollideFlags f = EggGroup::string_collide_flags(strval); if (f == EggGroup::CF_none) { - eggyywarning("Unknown collision flag " + strval); + eggyywarning(&(yylsp[0]), scanner, "Unknown collision flag " + strval); } else { group->set_collide_flags(group->get_collide_flags() | f); } } -#line 3556 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3570 "built/tmp/parser.yxx.c" break; - case 106: -#line 1632 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_top_transform = egg_stack.back()->as_transform(); - egg_top_transform->clear_transform(); + case 106: /* $@11: %empty */ +#line 1638 "panda/src/egg/parser.yxx" +{ + state.top_transform = state.stack.back()->as_transform(); + state.top_transform->clear_transform(); } -#line 3565 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3579 "built/tmp/parser.yxx.c" break; - case 108: -#line 1648 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 108: /* $@12: %empty */ +#line 1654 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); if (group->get_group_type() != EggGroup::GT_joint) { - eggyywarning("Unexpected outside of "); + eggyywarning(&(yylsp[0]), scanner, "Unexpected outside of "); } - egg_top_transform = &group->modify_default_pose(); - egg_top_transform->clear_transform(); + state.top_transform = &group->modify_default_pose(); + state.top_transform->clear_transform(); } -#line 3578 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3592 "built/tmp/parser.yxx.c" break; - case 123: -#line 1685 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_top_transform->add_translate2d(LVector2d((yyvsp[-2]._number), (yyvsp[-1]._number))); + case 123: /* translate2d: TRANSLATE '{' real real '}' */ +#line 1691 "panda/src/egg/parser.yxx" +{ + state.top_transform->add_translate2d(LVector2d((yyvsp[-2]._number), (yyvsp[-1]._number))); } -#line 3586 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3600 "built/tmp/parser.yxx.c" break; - case 124: -#line 1692 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_top_transform->add_translate3d(LVector3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number))); + case 124: /* translate3d: TRANSLATE '{' real real real '}' */ +#line 1698 "panda/src/egg/parser.yxx" +{ + state.top_transform->add_translate3d(LVector3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number))); } -#line 3594 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3608 "built/tmp/parser.yxx.c" break; - case 125: -#line 1699 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_top_transform->add_rotate2d((yyvsp[-1]._number)); + case 125: /* rotate2d: ROTATE '{' real '}' */ +#line 1705 "panda/src/egg/parser.yxx" +{ + state.top_transform->add_rotate2d((yyvsp[-1]._number)); } -#line 3602 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3616 "built/tmp/parser.yxx.c" break; - case 126: -#line 1706 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_top_transform->add_rotx((yyvsp[-1]._number)); + case 126: /* rotx: ROTX '{' real '}' */ +#line 1712 "panda/src/egg/parser.yxx" +{ + state.top_transform->add_rotx((yyvsp[-1]._number)); } -#line 3610 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3624 "built/tmp/parser.yxx.c" break; - case 127: -#line 1713 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_top_transform->add_roty((yyvsp[-1]._number)); + case 127: /* roty: ROTY '{' real '}' */ +#line 1719 "panda/src/egg/parser.yxx" +{ + state.top_transform->add_roty((yyvsp[-1]._number)); } -#line 3618 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3632 "built/tmp/parser.yxx.c" break; - case 128: -#line 1720 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_top_transform->add_rotz((yyvsp[-1]._number)); + case 128: /* rotz: ROTZ '{' real '}' */ +#line 1726 "panda/src/egg/parser.yxx" +{ + state.top_transform->add_rotz((yyvsp[-1]._number)); } -#line 3626 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3640 "built/tmp/parser.yxx.c" break; - case 129: -#line 1727 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_top_transform->add_rotate3d((yyvsp[-4]._number), LVector3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number))); + case 129: /* rotate3d: ROTATE '{' real real real real '}' */ +#line 1733 "panda/src/egg/parser.yxx" +{ + state.top_transform->add_rotate3d((yyvsp[-4]._number), LVector3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number))); } -#line 3634 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3648 "built/tmp/parser.yxx.c" break; - case 130: -#line 1734 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_top_transform->add_scale2d(LVecBase2d((yyvsp[-2]._number), (yyvsp[-1]._number))); + case 130: /* scale2d: SCALE '{' real real '}' */ +#line 1740 "panda/src/egg/parser.yxx" +{ + state.top_transform->add_scale2d(LVecBase2d((yyvsp[-2]._number), (yyvsp[-1]._number))); } -#line 3642 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3656 "built/tmp/parser.yxx.c" break; - case 131: -#line 1741 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_top_transform->add_scale3d(LVecBase3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number))); + case 131: /* scale3d: SCALE '{' real real real '}' */ +#line 1747 "panda/src/egg/parser.yxx" +{ + state.top_transform->add_scale3d(LVecBase3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number))); } -#line 3650 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3664 "built/tmp/parser.yxx.c" break; - case 132: -#line 1748 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_top_transform->add_uniform_scale((yyvsp[-1]._number)); + case 132: /* uniform_scale: SCALE '{' real '}' */ +#line 1754 "panda/src/egg/parser.yxx" +{ + state.top_transform->add_uniform_scale((yyvsp[-1]._number)); } -#line 3658 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3672 "built/tmp/parser.yxx.c" break; - case 135: -#line 1762 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_top_transform->add_matrix3 + case 135: /* matrix3_body: real real real real real real real real real */ +#line 1768 "panda/src/egg/parser.yxx" +{ + state.top_transform->add_matrix3 (LMatrix3d((yyvsp[-8]._number), (yyvsp[-7]._number), (yyvsp[-6]._number), (yyvsp[-5]._number), (yyvsp[-4]._number), (yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); } -#line 3669 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3683 "built/tmp/parser.yxx.c" break; - case 138: -#line 1780 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_top_transform->add_matrix4 + case 138: /* matrix4_body: real real real real real real real real real real real real real real real real */ +#line 1786 "panda/src/egg/parser.yxx" +{ + state.top_transform->add_matrix4 (LMatrix4d((yyvsp[-15]._number), (yyvsp[-14]._number), (yyvsp[-13]._number), (yyvsp[-12]._number), (yyvsp[-11]._number), (yyvsp[-10]._number), (yyvsp[-9]._number), (yyvsp[-8]._number), (yyvsp[-7]._number), (yyvsp[-6]._number), (yyvsp[-5]._number), (yyvsp[-4]._number), (yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); } -#line 3681 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3695 "built/tmp/parser.yxx.c" break; - case 139: -#line 1799 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 139: /* group_vertex_ref: VERTEXREF '{' integer_list group_vertex_membership REF '{' vertex_pool_name '}' '}' */ +#line 1805 "panda/src/egg/parser.yxx" +{ if ((yyvsp[-2]._egg) != nullptr) { EggVertexPool *pool = DCAST(EggVertexPool, (yyvsp[-2]._egg)); - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); PTA_double nums = (yyvsp[-6]._number_list); double membership = (yyvsp[-5]._number); @@ -3694,27 +3710,27 @@ yyreduce: ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() << std::ends; - eggyyerror(errmsg); + eggyyerror(&(yylsp[-6]), scanner, errmsg.str()); } else { group->ref_vertex(vertex, membership); } } } } -#line 3707 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3721 "built/tmp/parser.yxx.c" break; - case 140: -#line 1832 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 140: /* group_vertex_membership: empty */ +#line 1838 "panda/src/egg/parser.yxx" +{ (yyval._number) = 1.0; } -#line 3715 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3729 "built/tmp/parser.yxx.c" break; - case 141: -#line 1836 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 141: /* group_vertex_membership: group_vertex_membership SCALAR required_name '{' real_or_string '}' */ +#line 1842 "panda/src/egg/parser.yxx" +{ string name = (yyvsp[-3]._string); double value = (yyvsp[-1]._number); double result = (yyvsp[-5]._number); @@ -3722,201 +3738,201 @@ yyreduce: if (cmp_nocase_uh(name, "membership") == 0) { result = value; } else { - eggyywarning("Unknown group vertex scalar " + name); + eggyywarning(&(yylsp[-3]), scanner, "Unknown group vertex scalar " + name); } (yyval._number) = result; } -#line 3733 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3747 "built/tmp/parser.yxx.c" break; - case 143: -#line 1873 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 143: /* switchcondition_body: DISTANCE '{' real real VERTEX '{' real real real '}' '}' */ +#line 1879 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); group->set_lod(EggSwitchConditionDistance((yyvsp[-8]._number), (yyvsp[-7]._number), LPoint3d((yyvsp[-4]._number), (yyvsp[-3]._number), (yyvsp[-2]._number)))); } -#line 3742 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3756 "built/tmp/parser.yxx.c" break; - case 144: -#line 1878 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + case 144: /* switchcondition_body: DISTANCE '{' real real real VERTEX '{' real real real '}' '}' */ +#line 1884 "panda/src/egg/parser.yxx" +{ + EggGroup *group = DCAST(EggGroup, state.stack.back()); group->set_lod(EggSwitchConditionDistance((yyvsp[-9]._number), (yyvsp[-8]._number), LPoint3d((yyvsp[-4]._number), (yyvsp[-3]._number), (yyvsp[-2]._number)), (yyvsp[-7]._number))); } -#line 3751 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3765 "built/tmp/parser.yxx.c" break; - case 145: -#line 1895 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_stack.push_back(new EggPolygon((yyvsp[0]._string))); + case 145: /* $@13: %empty */ +#line 1901 "panda/src/egg/parser.yxx" +{ + state.stack.push_back(new EggPolygon((yyvsp[0]._string))); } -#line 3759 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3773 "built/tmp/parser.yxx.c" break; - case 146: -#line 1899 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 146: /* polygon: POLYGON optional_name $@13 '{' primitive_body '}' */ +#line 1905 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 3768 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3782 "built/tmp/parser.yxx.c" break; - case 147: -#line 1914 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_stack.push_back(new EggTriangleFan((yyvsp[0]._string))); + case 147: /* $@14: %empty */ +#line 1920 "panda/src/egg/parser.yxx" +{ + state.stack.push_back(new EggTriangleFan((yyvsp[0]._string))); } -#line 3776 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3790 "built/tmp/parser.yxx.c" break; - case 148: -#line 1918 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 148: /* trianglefan: TRIANGLEFAN optional_name $@14 '{' primitive_body '}' */ +#line 1924 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 3785 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3799 "built/tmp/parser.yxx.c" break; - case 149: -#line 1933 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_stack.push_back(new EggTriangleStrip((yyvsp[0]._string))); + case 149: /* $@15: %empty */ +#line 1939 "panda/src/egg/parser.yxx" +{ + state.stack.push_back(new EggTriangleStrip((yyvsp[0]._string))); } -#line 3793 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3807 "built/tmp/parser.yxx.c" break; - case 150: -#line 1937 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 150: /* trianglestrip: TRIANGLESTRIP optional_name $@15 '{' primitive_body '}' */ +#line 1943 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 3802 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3816 "built/tmp/parser.yxx.c" break; - case 151: -#line 1952 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_stack.push_back(new EggPatch((yyvsp[0]._string))); + case 151: /* $@16: %empty */ +#line 1958 "panda/src/egg/parser.yxx" +{ + state.stack.push_back(new EggPatch((yyvsp[0]._string))); } -#line 3810 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3824 "built/tmp/parser.yxx.c" break; - case 152: -#line 1956 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 152: /* patch: PATCH optional_name $@16 '{' primitive_body '}' */ +#line 1962 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 3819 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3833 "built/tmp/parser.yxx.c" break; - case 153: -#line 1971 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_stack.push_back(new EggPoint((yyvsp[0]._string))); + case 153: /* $@17: %empty */ +#line 1977 "panda/src/egg/parser.yxx" +{ + state.stack.push_back(new EggPoint((yyvsp[0]._string))); } -#line 3827 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3841 "built/tmp/parser.yxx.c" break; - case 154: -#line 1975 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 154: /* point_light: POINTLIGHT optional_name $@17 '{' primitive_body '}' */ +#line 1981 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 3836 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3850 "built/tmp/parser.yxx.c" break; - case 155: -#line 1990 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_stack.push_back(new EggLine((yyvsp[0]._string))); + case 155: /* $@18: %empty */ +#line 1996 "panda/src/egg/parser.yxx" +{ + state.stack.push_back(new EggLine((yyvsp[0]._string))); } -#line 3844 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3858 "built/tmp/parser.yxx.c" break; - case 156: -#line 1994 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 156: /* line: LINE optional_name $@18 '{' primitive_body '}' */ +#line 2000 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 3853 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3867 "built/tmp/parser.yxx.c" break; - case 157: -#line 2009 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_stack.push_back(new EggNurbsSurface((yyvsp[0]._string))); + case 157: /* $@19: %empty */ +#line 2015 "panda/src/egg/parser.yxx" +{ + state.stack.push_back(new EggNurbsSurface((yyvsp[0]._string))); } -#line 3861 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3875 "built/tmp/parser.yxx.c" break; - case 158: -#line 2013 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 158: /* nurbs_surface: NURBSSURFACE optional_name $@19 '{' nurbs_surface_body '}' */ +#line 2019 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 3870 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3884 "built/tmp/parser.yxx.c" break; - case 159: -#line 2028 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - egg_stack.push_back(new EggNurbsCurve((yyvsp[0]._string))); + case 159: /* $@20: %empty */ +#line 2034 "panda/src/egg/parser.yxx" +{ + state.stack.push_back(new EggNurbsCurve((yyvsp[0]._string))); } -#line 3878 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3892 "built/tmp/parser.yxx.c" break; - case 160: -#line 2032 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 160: /* nurbs_curve: NURBSCURVE optional_name $@20 '{' nurbs_curve_body '}' */ +#line 2038 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 3887 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3901 "built/tmp/parser.yxx.c" break; - case 165: -#line 2062 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - if (!egg_stack.back()->is_of_type(EggCompositePrimitive::get_class_type())) { - eggyyerror("Not a composite primitive; components are not allowed here."); + case 165: /* $@21: %empty */ +#line 2068 "panda/src/egg/parser.yxx" +{ + if (!state.stack.back()->is_of_type(EggCompositePrimitive::get_class_type())) { + eggyyerror(&(yylsp[-2]), scanner, "Not a composite primitive; components are not allowed here."); } else { - PT(EggCompositePrimitive) comp = DCAST(EggCompositePrimitive, egg_stack.back()); + PT(EggCompositePrimitive) comp = DCAST(EggCompositePrimitive, state.stack.back()); if ((yyvsp[-1]._number) < 0 || (yyvsp[-1]._number) >= comp->get_num_components()) { - eggyyerror("Invalid component number"); + eggyyerror(&(yylsp[-1]), scanner, "Invalid component number"); } } // We temporarily add an EggPolygon to the stack, just to receive // the component attributes. - egg_stack.push_back(new EggPolygon); + state.stack.push_back(new EggPolygon); } -#line 3905 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3919 "built/tmp/parser.yxx.c" break; - case 166: -#line 2076 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - PT(EggPrimitive) prim = DCAST(EggPrimitive, egg_stack.back()); - egg_stack.pop_back(); - PT(EggCompositePrimitive) comp = DCAST(EggCompositePrimitive, egg_stack.back()); + case 166: /* primitive_body: primitive_body COMPONENT integer '{' $@21 primitive_component_body '}' */ +#line 2082 "panda/src/egg/parser.yxx" +{ + PT(EggPrimitive) prim = DCAST(EggPrimitive, state.stack.back()); + state.stack.pop_back(); + PT(EggCompositePrimitive) comp = DCAST(EggCompositePrimitive, state.stack.back()); comp->set_component((int)(yyvsp[-4]._number), prim); } -#line 3916 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3930 "built/tmp/parser.yxx.c" break; - case 174: -#line 2090 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggPrimitive *primitive = DCAST(EggPrimitive, egg_stack.back()); + case 174: /* primitive_body: primitive_body SCALAR required_name '{' real_or_string '}' */ +#line 2096 "panda/src/egg/parser.yxx" +{ + EggPrimitive *primitive = DCAST(EggPrimitive, state.stack.back()); string name = (yyvsp[-3]._string); double value = (yyvsp[-1]._number); string strval = (yyvsp[-1]._string); @@ -3924,7 +3940,7 @@ yyreduce: if (cmp_nocase_uh(name, "alpha") == 0) { EggRenderMode::AlphaMode a = EggRenderMode::string_alpha_mode(strval); if (a == EggRenderMode::AM_unspecified) { - eggyywarning("Unknown alpha mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown alpha mode " + strval); } else { primitive->set_alpha_mode(a); } @@ -3932,7 +3948,7 @@ yyreduce: EggRenderMode::DepthWriteMode m = EggRenderMode::string_depth_write_mode(strval); if (m == EggRenderMode::DWM_unspecified) { - eggyywarning("Unknown depth-write mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown depth-write mode " + strval); } else { primitive->set_depth_write_mode(m); } @@ -3941,7 +3957,7 @@ yyreduce: EggRenderMode::DepthTestMode m = EggRenderMode::string_depth_test_mode(strval); if (m == EggRenderMode::DTM_unspecified) { - eggyywarning("Unknown depth-test mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown depth-test mode " + strval); } else { primitive->set_depth_test_mode(m); } @@ -3950,7 +3966,7 @@ yyreduce: EggRenderMode::VisibilityMode m = EggRenderMode::string_visibility_mode(strval); if (m == EggRenderMode::VM_unspecified) { - eggyywarning("Unknown visibility mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown visibility mode " + strval); } else { primitive->set_visibility_mode(m); } @@ -3967,35 +3983,35 @@ yyreduce: } else if (primitive->is_of_type(EggPoint::get_class_type())) { DCAST(EggPoint, primitive)->set_thick(value); } else { - eggyywarning("scalar thick is only meaningful for points and lines."); + eggyywarning(&(yylsp[-1]), scanner, "scalar thick is only meaningful for points and lines."); } } else if (cmp_nocase_uh(name, "perspective") == 0) { if (primitive->is_of_type(EggPoint::get_class_type())) { DCAST(EggPoint, primitive)->set_perspective(value != 0); } else { - eggyywarning("scalar perspective is only meaningful for points."); + eggyywarning(&(yylsp[-1]), scanner, "scalar perspective is only meaningful for points."); } } else { - eggyywarning("Unknown scalar " + name); + eggyywarning(&(yylsp[-3]), scanner, "Unknown scalar " + name); } } -#line 3985 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 3999 "built/tmp/parser.yxx.c" break; - case 186: -#line 2176 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 186: /* nurbs_surface_body: nurbs_surface_body nurbs_curve */ +#line 2182 "panda/src/egg/parser.yxx" +{ EggNurbsCurve *curve = DCAST(EggNurbsCurve, (yyvsp[0]._egg)); - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); nurbs->_curves_on_surface.push_back(curve); } -#line 3995 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4009 "built/tmp/parser.yxx.c" break; - case 188: -#line 2183 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggNurbsSurface *primitive = DCAST(EggNurbsSurface, egg_stack.back()); + case 188: /* nurbs_surface_body: nurbs_surface_body SCALAR required_name '{' real_or_string '}' */ +#line 2189 "panda/src/egg/parser.yxx" +{ + EggNurbsSurface *primitive = DCAST(EggNurbsSurface, state.stack.back()); string name = (yyvsp[-3]._string); double value = (yyvsp[-1]._number); string strval = (yyvsp[-1]._string); @@ -4003,7 +4019,7 @@ yyreduce: if (cmp_nocase_uh(name, "alpha") == 0) { EggRenderMode::AlphaMode a = EggRenderMode::string_alpha_mode(strval); if (a == EggRenderMode::AM_unspecified) { - eggyywarning("Unknown alpha mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown alpha mode " + strval); } else { primitive->set_alpha_mode(a); } @@ -4011,7 +4027,7 @@ yyreduce: EggRenderMode::DepthWriteMode m = EggRenderMode::string_depth_write_mode(strval); if (m == EggRenderMode::DWM_unspecified) { - eggyywarning("Unknown depth-write mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown depth-write mode " + strval); } else { primitive->set_depth_write_mode(m); } @@ -4020,7 +4036,7 @@ yyreduce: EggRenderMode::DepthTestMode m = EggRenderMode::string_depth_test_mode(strval); if (m == EggRenderMode::DTM_unspecified) { - eggyywarning("Unknown depth-test mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown depth-test mode " + strval); } else { primitive->set_depth_test_mode(m); } @@ -4029,7 +4045,7 @@ yyreduce: EggRenderMode::VisibilityMode m = EggRenderMode::string_visibility_mode(strval); if (m == EggRenderMode::VM_unspecified) { - eggyywarning("Unknown visibility mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown visibility mode " + strval); } else { primitive->set_visibility_mode(m); } @@ -4045,16 +4061,16 @@ yyreduce: } else if (cmp_nocase_uh(name, "v_subdiv") == 0) { primitive->set_v_subdiv((int)value); } else { - eggyywarning("Unknown scalar " + name); + eggyywarning(&(yylsp[-3]), scanner, "Unknown scalar " + name); } } -#line 4054 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4068 "built/tmp/parser.yxx.c" break; - case 199: -#line 2259 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggNurbsCurve *primitive = DCAST(EggNurbsCurve, egg_stack.back()); + case 199: /* nurbs_curve_body: nurbs_curve_body SCALAR required_name '{' real_or_string '}' */ +#line 2265 "panda/src/egg/parser.yxx" +{ + EggNurbsCurve *primitive = DCAST(EggNurbsCurve, state.stack.back()); string name = (yyvsp[-3]._string); double value = (yyvsp[-1]._number); string strval = (yyvsp[-1]._string); @@ -4062,7 +4078,7 @@ yyreduce: if (cmp_nocase_uh(name, "alpha") == 0) { EggRenderMode::AlphaMode a = EggRenderMode::string_alpha_mode(strval); if (a == EggRenderMode::AM_unspecified) { - eggyywarning("Unknown alpha mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown alpha mode " + strval); } else { primitive->set_alpha_mode(a); } @@ -4070,7 +4086,7 @@ yyreduce: EggRenderMode::DepthWriteMode m = EggRenderMode::string_depth_write_mode(strval); if (m == EggRenderMode::DWM_unspecified) { - eggyywarning("Unknown depth-write mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown depth-write mode " + strval); } else { primitive->set_depth_write_mode(m); } @@ -4079,7 +4095,7 @@ yyreduce: EggRenderMode::DepthTestMode m = EggRenderMode::string_depth_test_mode(strval); if (m == EggRenderMode::DTM_unspecified) { - eggyywarning("Unknown depth-test mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown depth-test mode " + strval); } else { primitive->set_depth_test_mode(m); } @@ -4088,7 +4104,7 @@ yyreduce: EggRenderMode::VisibilityMode m = EggRenderMode::string_visibility_mode(strval); if (m == EggRenderMode::VM_unspecified) { - eggyywarning("Unknown visibility mode " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown visibility mode " + strval); } else { primitive->set_visibility_mode(m); } @@ -4104,154 +4120,154 @@ yyreduce: } else if (cmp_nocase_uh(name, "type") == 0) { EggCurve::CurveType a = EggCurve::string_curve_type(strval); if (a == EggCurve::CT_none) { - eggyywarning("Unknown curve type " + strval); + eggyywarning(&(yylsp[-1]), scanner, "Unknown curve type " + strval); } else { primitive->set_curve_type(a); } } else { - eggyywarning("Unknown scalar " + name); + eggyywarning(&(yylsp[-3]), scanner, "Unknown scalar " + name); } } -#line 4119 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4133 "built/tmp/parser.yxx.c" break; - case 200: -#line 2330 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 200: /* primitive_tref_body: texture_name */ +#line 2336 "panda/src/egg/parser.yxx" +{ if ((yyvsp[0]._egg) != nullptr) { EggTexture *texture = DCAST(EggTexture, (yyvsp[0]._egg)); - DCAST(EggPrimitive, egg_stack.back())->add_texture(texture); + DCAST(EggPrimitive, state.stack.back())->add_texture(texture); } } -#line 4130 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4144 "built/tmp/parser.yxx.c" break; - case 201: -#line 2347 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 201: /* primitive_texture_body: required_name */ +#line 2353 "panda/src/egg/parser.yxx" +{ EggTexture *texture = nullptr; // Defining a texture on-the-fly. Filename filename = (yyvsp[0]._string); string tref_name = filename.get_basename(); - Textures::iterator vpi = textures.find(tref_name); - if (vpi == textures.end()) { + Textures::iterator vpi = state.textures.find(tref_name); + if (vpi == state.textures.end()) { // The texture was not yet defined. Define it. texture = new EggTexture(tref_name, filename); - textures[tref_name] = texture; + state.textures[tref_name] = texture; - if (egg_top_node != nullptr) { - egg_top_node->add_child(texture); + if (state.top_node != nullptr) { + state.top_node->add_child(texture); } } else { // The texture already existed. Use it. texture = (*vpi).second; if (filename != texture->get_filename()) { - eggyywarning(string("Using previous path: ") + + eggyywarning(&(yylsp[0]), scanner, string("Using previous path: ") + texture->get_filename().get_fullpath()); } } nassertr(texture != nullptr, 0); - DCAST(EggPrimitive, egg_stack.back())->add_texture(texture); + DCAST(EggPrimitive, state.stack.back())->add_texture(texture); } -#line 4164 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4178 "built/tmp/parser.yxx.c" break; - case 202: -#line 2387 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 202: /* primitive_material_body: material_name */ +#line 2393 "panda/src/egg/parser.yxx" +{ if ((yyvsp[0]._egg) != nullptr) { EggMaterial *material = DCAST(EggMaterial, (yyvsp[0]._egg)); - DCAST(EggPrimitive, egg_stack.back())->set_material(material); + DCAST(EggPrimitive, state.stack.back())->set_material(material); } } -#line 4175 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4189 "built/tmp/parser.yxx.c" break; - case 203: -#line 2404 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggPrimitive, egg_stack.back())->set_normal(LNormald((yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); + case 203: /* primitive_normal_body: real real real */ +#line 2410 "panda/src/egg/parser.yxx" +{ + DCAST(EggPrimitive, state.stack.back())->set_normal(LNormald((yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); } -#line 4183 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4197 "built/tmp/parser.yxx.c" break; - case 204: -#line 2408 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggPrimitive, egg_stack.back())->_dnormals. + case 204: /* primitive_normal_body: primitive_normal_body DNORMAL string '{' real real real '}' */ +#line 2414 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggPrimitive, state.stack.back())->_dnormals. insert(EggMorphNormal((yyvsp[-5]._string), LVector3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number)))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-5]._string)); + eggyywarning(&(yylsp[-5]), scanner, "Ignoring repeated morph name " + (yyvsp[-5]._string)); } } -#line 4195 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4209 "built/tmp/parser.yxx.c" break; - case 205: -#line 2416 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggPrimitive, egg_stack.back())->_dnormals. + case 205: /* primitive_normal_body: primitive_normal_body DNORMAL '{' string real real real '}' */ +#line 2422 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggPrimitive, state.stack.back())->_dnormals. insert(EggMorphNormal((yyvsp[-4]._string), LVector3d((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number)))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-4]._string)); + eggyywarning(&(yylsp[-4]), scanner, "Ignoring repeated morph name " + (yyvsp[-4]._string)); } } -#line 4207 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4221 "built/tmp/parser.yxx.c" break; - case 206: -#line 2434 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggPrimitive, egg_stack.back())->set_color(LColor((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); + case 206: /* primitive_color_body: real real real real */ +#line 2440 "panda/src/egg/parser.yxx" +{ + DCAST(EggPrimitive, state.stack.back())->set_color(LColor((yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number), (yyvsp[0]._number))); } -#line 4215 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4229 "built/tmp/parser.yxx.c" break; - case 207: -#line 2438 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggPrimitive, egg_stack.back())->_drgbas. + case 207: /* primitive_color_body: primitive_color_body DRGBA string '{' real real real real '}' */ +#line 2444 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggPrimitive, state.stack.back())->_drgbas. insert(EggMorphColor((yyvsp[-6]._string), LVector4((yyvsp[-4]._number), (yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number)))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-6]._string)); + eggyywarning(&(yylsp[-6]), scanner, "Ignoring repeated morph name " + (yyvsp[-6]._string)); } } -#line 4227 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4241 "built/tmp/parser.yxx.c" break; - case 208: -#line 2446 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - bool inserted = DCAST(EggPrimitive, egg_stack.back())->_drgbas. + case 208: /* primitive_color_body: primitive_color_body DRGBA '{' string real real real real '}' */ +#line 2452 "panda/src/egg/parser.yxx" +{ + bool inserted = DCAST(EggPrimitive, state.stack.back())->_drgbas. insert(EggMorphColor((yyvsp[-5]._string), LVector4((yyvsp[-4]._number), (yyvsp[-3]._number), (yyvsp[-2]._number), (yyvsp[-1]._number)))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + (yyvsp[-5]._string)); + eggyywarning(&(yylsp[-5]), scanner, "Ignoring repeated morph name " + (yyvsp[-5]._string)); } } -#line 4239 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4253 "built/tmp/parser.yxx.c" break; - case 209: -#line 2464 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggPrimitive *primitive = DCAST(EggPrimitive, egg_stack.back()); + case 209: /* primitive_bface_body: integer */ +#line 2470 "panda/src/egg/parser.yxx" +{ + EggPrimitive *primitive = DCAST(EggPrimitive, state.stack.back()); int value = (int)(yyvsp[0]._number); primitive->set_bface_flag(value!=0); } -#line 4249 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4263 "built/tmp/parser.yxx.c" break; - case 210: -#line 2480 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 210: /* primitive_vertex_ref: VERTEXREF '{' integer_list REF '{' vertex_pool_name '}' '}' */ +#line 2486 "panda/src/egg/parser.yxx" +{ if ((yyvsp[-2]._egg) != nullptr) { EggVertexPool *pool = DCAST(EggVertexPool, (yyvsp[-2]._egg)); - EggPrimitive *prim = DCAST(EggPrimitive, egg_stack.back()); + EggPrimitive *prim = DCAST(EggPrimitive, state.stack.back()); PTA_double nums = (yyvsp[-5]._number_list); for (int i = 0; i < (int)nums.size(); i++) { @@ -4261,32 +4277,32 @@ yyreduce: ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() << std::ends; - eggyyerror(errmsg); + eggyyerror(&(yylsp[-5]), scanner, errmsg.str()); } else { prim->add_vertex(vertex); } } } } -#line 4274 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4288 "built/tmp/parser.yxx.c" break; - case 211: -#line 2511 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + case 211: /* nurbs_surface_order_body: integer integer */ +#line 2517 "panda/src/egg/parser.yxx" +{ + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); int u_order = (int)(yyvsp[-1]._number); int v_order = (int)(yyvsp[0]._number); nurbs->set_u_order(u_order); nurbs->set_v_order(v_order); } -#line 4286 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4300 "built/tmp/parser.yxx.c" break; - case 212: -#line 2529 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + case 212: /* nurbs_surface_uknots_body: real_list */ +#line 2535 "panda/src/egg/parser.yxx" +{ + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); PTA_double nums = (yyvsp[0]._number_list); nurbs->set_num_u_knots(nums.size()); @@ -4294,13 +4310,13 @@ yyreduce: nurbs->set_u_knot(i, nums[i]); } } -#line 4300 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4314 "built/tmp/parser.yxx.c" break; - case 213: -#line 2549 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + case 213: /* nurbs_surface_vknots_body: real_list */ +#line 2555 "panda/src/egg/parser.yxx" +{ + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); PTA_double nums = (yyvsp[0]._number_list); nurbs->set_num_v_knots(nums.size()); @@ -4308,54 +4324,54 @@ yyreduce: nurbs->set_v_knot(i, nums[i]); } } -#line 4314 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4328 "built/tmp/parser.yxx.c" break; - case 214: -#line 2569 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + case 214: /* nurbs_surface_trim_body: empty */ +#line 2575 "panda/src/egg/parser.yxx" +{ + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); nurbs->_trims.push_back(EggNurbsSurface::Trim()); } -#line 4323 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4337 "built/tmp/parser.yxx.c" break; - case 216: -#line 2585 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + case 216: /* nurbs_surface_trim_loop_body: empty */ +#line 2591 "panda/src/egg/parser.yxx" +{ + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); nassertr(!nurbs->_trims.empty(), 0); nurbs->_trims.back().push_back(EggNurbsSurface::Loop()); } -#line 4333 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4347 "built/tmp/parser.yxx.c" break; - case 217: -#line 2591 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + case 217: /* nurbs_surface_trim_loop_body: nurbs_surface_trim_loop_body nurbs_curve */ +#line 2597 "panda/src/egg/parser.yxx" +{ + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); nassertr(!nurbs->_trims.empty(), 0); nassertr(!nurbs->_trims.back().empty(), 0); EggNurbsCurve *curve = DCAST(EggNurbsCurve, (yyvsp[0]._egg)); nurbs->_trims.back().back().push_back(curve); } -#line 4345 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4359 "built/tmp/parser.yxx.c" break; - case 218: -#line 2610 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggNurbsCurve *nurbs = DCAST(EggNurbsCurve, egg_stack.back()); + case 218: /* nurbs_curve_order_body: integer */ +#line 2616 "panda/src/egg/parser.yxx" +{ + EggNurbsCurve *nurbs = DCAST(EggNurbsCurve, state.stack.back()); int order = (int)(yyvsp[0]._number); nurbs->set_order(order); } -#line 4355 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4369 "built/tmp/parser.yxx.c" break; - case 219: -#line 2626 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggNurbsCurve *nurbs = DCAST(EggNurbsCurve, egg_stack.back()); + case 219: /* nurbs_curve_knots_body: real_list */ +#line 2632 "panda/src/egg/parser.yxx" +{ + EggNurbsCurve *nurbs = DCAST(EggNurbsCurve, state.stack.back()); PTA_double nums = (yyvsp[0]._number_list); nurbs->set_num_knots(nums.size()); @@ -4363,152 +4379,152 @@ yyreduce: nurbs->set_knot(i, nums[i]); } } -#line 4369 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4383 "built/tmp/parser.yxx.c" break; - case 220: -#line 2647 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 220: /* $@22: %empty */ +#line 2653 "panda/src/egg/parser.yxx" +{ EggTable *table = new EggTable((yyvsp[0]._string)); table->set_table_type(EggTable::TT_table); - egg_stack.push_back(table); + state.stack.push_back(table); } -#line 4379 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4393 "built/tmp/parser.yxx.c" break; - case 221: -#line 2653 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 221: /* table: TABLE optional_name $@22 '{' table_body '}' */ +#line 2659 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); Thread::consider_yield(); } -#line 4389 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4403 "built/tmp/parser.yxx.c" break; - case 222: -#line 2670 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 222: /* $@23: %empty */ +#line 2676 "panda/src/egg/parser.yxx" +{ EggTable *table = new EggTable((yyvsp[0]._string)); table->set_table_type(EggTable::TT_bundle); - egg_stack.push_back(table); + state.stack.push_back(table); } -#line 4399 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4413 "built/tmp/parser.yxx.c" break; - case 223: -#line 2676 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 223: /* bundle: BUNDLE optional_name $@23 '{' table_body '}' */ +#line 2682 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 4408 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4422 "built/tmp/parser.yxx.c" break; - case 225: -#line 2692 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggTable, egg_stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); + case 225: /* table_body: table_body table */ +#line 2698 "panda/src/egg/parser.yxx" +{ + DCAST(EggTable, state.stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); } -#line 4416 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4430 "built/tmp/parser.yxx.c" break; - case 226: -#line 2696 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggTable, egg_stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); + case 226: /* table_body: table_body bundle */ +#line 2702 "panda/src/egg/parser.yxx" +{ + DCAST(EggTable, state.stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); } -#line 4424 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4438 "built/tmp/parser.yxx.c" break; - case 227: -#line 2700 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggTable, egg_stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); + case 227: /* table_body: table_body sanim */ +#line 2706 "panda/src/egg/parser.yxx" +{ + DCAST(EggTable, state.stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); } -#line 4432 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4446 "built/tmp/parser.yxx.c" break; - case 228: -#line 2704 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggTable, egg_stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); + case 228: /* table_body: table_body xfmanim */ +#line 2710 "panda/src/egg/parser.yxx" +{ + DCAST(EggTable, state.stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); } -#line 4440 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4454 "built/tmp/parser.yxx.c" break; - case 229: -#line 2708 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggTable, egg_stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); + case 229: /* table_body: table_body xfm_s_anim */ +#line 2714 "panda/src/egg/parser.yxx" +{ + DCAST(EggTable, state.stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); } -#line 4448 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4462 "built/tmp/parser.yxx.c" break; - case 230: -#line 2723 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 230: /* $@24: %empty */ +#line 2729 "panda/src/egg/parser.yxx" +{ EggSAnimData *anim_data = new EggSAnimData((yyvsp[0]._string)); - egg_stack.push_back(anim_data); + state.stack.push_back(anim_data); } -#line 4457 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4471 "built/tmp/parser.yxx.c" break; - case 231: -#line 2728 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 231: /* sanim: SANIM optional_name $@24 '{' sanim_body '}' */ +#line 2734 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 4466 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4480 "built/tmp/parser.yxx.c" break; - case 233: -#line 2745 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggSAnimData *anim_data = DCAST(EggSAnimData, egg_stack.back()); + case 233: /* sanim_body: sanim_body SCALAR required_name '{' real_or_string '}' */ +#line 2751 "panda/src/egg/parser.yxx" +{ + EggSAnimData *anim_data = DCAST(EggSAnimData, state.stack.back()); string name = (yyvsp[-3]._string); double value = (yyvsp[-1]._number); if (cmp_nocase_uh(name, "fps") == 0) { anim_data->set_fps(value); } else { - eggyywarning("Unsupported S$Anim scalar: " + name); + eggyywarning(&(yylsp[-3]), scanner, "Unsupported S$Anim scalar: " + name); } } -#line 4482 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4496 "built/tmp/parser.yxx.c" break; - case 234: -#line 2757 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggSAnimData, egg_stack.back())->set_data((yyvsp[-1]._number_list)); + case 234: /* sanim_body: sanim_body TABLE_V '{' real_list '}' */ +#line 2763 "panda/src/egg/parser.yxx" +{ + DCAST(EggSAnimData, state.stack.back())->set_data((yyvsp[-1]._number_list)); } -#line 4490 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4504 "built/tmp/parser.yxx.c" break; - case 235: -#line 2771 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 235: /* $@25: %empty */ +#line 2777 "panda/src/egg/parser.yxx" +{ EggXfmAnimData *anim_data = new EggXfmAnimData((yyvsp[0]._string)); - egg_stack.push_back(anim_data); + state.stack.push_back(anim_data); } -#line 4499 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4513 "built/tmp/parser.yxx.c" break; - case 236: -#line 2776 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 236: /* xfmanim: XFMANIM optional_name $@25 '{' xfmanim_body '}' */ +#line 2782 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 4508 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4522 "built/tmp/parser.yxx.c" break; - case 238: -#line 2793 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggXfmAnimData *anim_data = DCAST(EggXfmAnimData, egg_stack.back()); + case 238: /* xfmanim_body: xfmanim_body SCALAR required_name '{' real_or_string '}' */ +#line 2799 "panda/src/egg/parser.yxx" +{ + EggXfmAnimData *anim_data = DCAST(EggXfmAnimData, state.stack.back()); string name = (yyvsp[-3]._string); double value = (yyvsp[-1]._number); string strval = (yyvsp[-1]._string); @@ -4520,42 +4536,42 @@ yyreduce: } else if (cmp_nocase_uh(name, "contents") == 0) { anim_data->set_contents(strval); } else { - eggyywarning("Unsupported Xfm$Anim scalar: " + name); + eggyywarning(&(yylsp[-3]), scanner, "Unsupported Xfm$Anim scalar: " + name); } } -#line 4529 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4543 "built/tmp/parser.yxx.c" break; - case 239: -#line 2810 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggXfmAnimData, egg_stack.back())->set_data((yyvsp[-1]._number_list)); + case 239: /* xfmanim_body: xfmanim_body TABLE_V '{' real_list '}' */ +#line 2816 "panda/src/egg/parser.yxx" +{ + DCAST(EggXfmAnimData, state.stack.back())->set_data((yyvsp[-1]._number_list)); } -#line 4537 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4551 "built/tmp/parser.yxx.c" break; - case 240: -#line 2824 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 240: /* $@26: %empty */ +#line 2830 "panda/src/egg/parser.yxx" +{ EggXfmSAnim *anim_group = new EggXfmSAnim((yyvsp[0]._string)); - egg_stack.push_back(anim_group); + state.stack.push_back(anim_group); } -#line 4546 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4560 "built/tmp/parser.yxx.c" break; - case 241: -#line 2829 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 241: /* xfm_s_anim: XFMSANIM optional_name $@26 '{' xfm_s_anim_body '}' */ +#line 2835 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 4555 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4569 "built/tmp/parser.yxx.c" break; - case 243: -#line 2846 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggXfmSAnim *anim_group = DCAST(EggXfmSAnim, egg_stack.back()); + case 243: /* xfm_s_anim_body: xfm_s_anim_body SCALAR required_name '{' real_or_string '}' */ +#line 2852 "panda/src/egg/parser.yxx" +{ + EggXfmSAnim *anim_group = DCAST(EggXfmSAnim, state.stack.back()); string name = (yyvsp[-3]._string); double value = (yyvsp[-1]._number); string strval = (yyvsp[-1]._string); @@ -4565,42 +4581,42 @@ yyreduce: } else if (cmp_nocase_uh(name, "order") == 0) { anim_group->set_order(strval); } else { - eggyywarning("Unsupported Xfm$Anim_S$ scalar: " + name); + eggyywarning(&(yylsp[-3]), scanner, "Unsupported Xfm$Anim_S$ scalar: " + name); } } -#line 4574 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4588 "built/tmp/parser.yxx.c" break; - case 244: -#line 2861 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - DCAST(EggXfmSAnim, egg_stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); + case 244: /* xfm_s_anim_body: xfm_s_anim_body sanim */ +#line 2867 "panda/src/egg/parser.yxx" +{ + DCAST(EggXfmSAnim, state.stack.back())->add_child(DCAST(EggNode, (yyvsp[0]._egg))); } -#line 4582 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4596 "built/tmp/parser.yxx.c" break; - case 245: -#line 2876 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 245: /* $@27: %empty */ +#line 2882 "panda/src/egg/parser.yxx" +{ EggAnimPreload *anim_preload = new EggAnimPreload((yyvsp[0]._string)); - egg_stack.push_back(anim_preload); + state.stack.push_back(anim_preload); } -#line 4591 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4605 "built/tmp/parser.yxx.c" break; - case 246: -#line 2881 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - (yyval._egg) = egg_stack.back(); - egg_stack.pop_back(); + case 246: /* anim_preload: ANIMPRELOAD optional_name $@27 '{' anim_preload_body '}' */ +#line 2887 "panda/src/egg/parser.yxx" +{ + (yyval._egg) = state.stack.back(); + state.stack.pop_back(); } -#line 4600 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4614 "built/tmp/parser.yxx.c" break; - case 248: -#line 2898 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - EggAnimPreload *anim_preload = DCAST(EggAnimPreload, egg_stack.back()); + case 248: /* anim_preload_body: anim_preload_body SCALAR required_name '{' real_or_string '}' */ +#line 2904 "panda/src/egg/parser.yxx" +{ + EggAnimPreload *anim_preload = DCAST(EggAnimPreload, state.stack.back()); string name = (yyvsp[-3]._string); double value = (yyvsp[-1]._number); @@ -4609,242 +4625,243 @@ yyreduce: } else if (cmp_nocase_uh(name, "frames") == 0) { anim_preload->set_num_frames((int)value); } else { - eggyywarning("Unsupported AnimPreload scalar: " + name); + eggyywarning(&(yylsp[-3]), scanner, "Unsupported AnimPreload scalar: " + name); } } -#line 4618 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4632 "built/tmp/parser.yxx.c" break; - case 249: -#line 2922 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 249: /* integer_list: empty */ +#line 2928 "panda/src/egg/parser.yxx" +{ (yyval._number_list) = PTA_double::empty_array(0); } -#line 4626 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4640 "built/tmp/parser.yxx.c" break; - case 250: -#line 2926 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 250: /* integer_list: integer_list integer */ +#line 2932 "panda/src/egg/parser.yxx" +{ (yyval._number_list).push_back((double)(yyvsp[0]._number)); } -#line 4634 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4648 "built/tmp/parser.yxx.c" break; - case 251: -#line 2940 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 251: /* real_list: empty */ +#line 2946 "panda/src/egg/parser.yxx" +{ (yyval._number_list) = PTA_double::empty_array(0); } -#line 4642 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4656 "built/tmp/parser.yxx.c" break; - case 252: -#line 2944 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 252: /* real_list: real_list real */ +#line 2950 "panda/src/egg/parser.yxx" +{ (yyval._number_list).push_back((yyvsp[0]._number)); } -#line 4650 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4664 "built/tmp/parser.yxx.c" break; - case 253: -#line 2958 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 253: /* texture_name: required_name */ +#line 2964 "panda/src/egg/parser.yxx" +{ string name = (yyvsp[0]._string); - Textures::iterator vpi = textures.find(name); - if (vpi == textures.end()) { - eggyyerror("Unknown texture " + name); + Textures::iterator vpi = state.textures.find(name); + if (vpi == state.textures.end()) { + eggyyerror(&(yylsp[0]), scanner, "Unknown texture " + name); (yyval._egg) = PT(EggObject)(); } else { (yyval._egg) = (*vpi).second; } } -#line 4665 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4679 "built/tmp/parser.yxx.c" break; - case 254: -#line 2979 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 254: /* material_name: required_name */ +#line 2985 "panda/src/egg/parser.yxx" +{ string name = (yyvsp[0]._string); - Materials::iterator vpi = materials.find(name); - if (vpi == materials.end()) { - eggyyerror("Unknown material " + name); + Materials::iterator vpi = state.materials.find(name); + if (vpi == state.materials.end()) { + eggyyerror(&(yylsp[0]), scanner, "Unknown material " + name); (yyval._egg) = PT(EggObject)(); } else { (yyval._egg) = (*vpi).second; } } -#line 4680 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4694 "built/tmp/parser.yxx.c" break; - case 255: -#line 3000 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 255: /* vertex_pool_name: required_name */ +#line 3006 "panda/src/egg/parser.yxx" +{ string name = (yyvsp[0]._string); - VertexPools::iterator vpi = vertex_pools.find(name); - if (vpi == vertex_pools.end()) { + VertexPools::iterator vpi = state.vertex_pools.find(name); + if (vpi == state.vertex_pools.end()) { // This will become a forward reference. EggVertexPool *pool = new EggVertexPool(name); // The egg syntax starts counting at 1 by convention. pool->set_highest_index(0); - vertex_pools[name] = pool; + state.vertex_pools[name] = pool; (yyval._egg) = pool; } else { (yyval._egg) = (*vpi).second; } } -#line 4699 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4713 "built/tmp/parser.yxx.c" break; - case 256: -#line 3025 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 256: /* group_name: required_name */ +#line 3031 "panda/src/egg/parser.yxx" +{ string name = (yyvsp[0]._string); - Groups::iterator vpi = groups.find(name); - if (vpi == groups.end()) { - eggyyerror("Unknown group " + name); + Groups::iterator vpi = state.groups.find(name); + if (vpi == state.groups.end()) { + eggyyerror(&(yylsp[0]), scanner, "Unknown group " + name); (yyval._egg) = PT(EggObject)(); } else { (yyval._egg) = (*vpi).second; } } -#line 4714 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4728 "built/tmp/parser.yxx.c" break; - case 257: -#line 3046 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - eggyyerror("Name required."); + case 257: /* required_name: empty */ +#line 3052 "panda/src/egg/parser.yxx" +{ + eggyyerror(&(yylsp[0]), scanner, "Name required."); (yyval._string) = ""; } -#line 4723 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4737 "built/tmp/parser.yxx.c" break; - case 260: -#line 3075 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { - eggyyerror("String required."); + case 260: /* required_string: empty */ +#line 3081 "panda/src/egg/parser.yxx" +{ + eggyyerror(&(yylsp[0]), scanner, "String required."); (yyval._string) = ""; } -#line 4732 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4746 "built/tmp/parser.yxx.c" break; - case 262: -#line 3091 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 262: /* optional_string: empty */ +#line 3097 "panda/src/egg/parser.yxx" +{ (yyval._string) = ""; } -#line 4740 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4754 "built/tmp/parser.yxx.c" break; - case 264: -#line 3109 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 264: /* string: EGG_NUMBER */ +#line 3115 "panda/src/egg/parser.yxx" +{ (yyval._string) = (yyvsp[0]._string); } -#line 4748 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4762 "built/tmp/parser.yxx.c" break; - case 265: -#line 3113 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 265: /* string: EGG_ULONG */ +#line 3119 "panda/src/egg/parser.yxx" +{ (yyval._string) = (yyvsp[0]._string); } -#line 4756 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4770 "built/tmp/parser.yxx.c" break; - case 267: -#line 3130 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 267: /* repeated_string: empty */ +#line 3136 "panda/src/egg/parser.yxx" +{ (yyval._string) = ""; } -#line 4764 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4778 "built/tmp/parser.yxx.c" break; - case 268: -#line 3134 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 268: /* repeated_string: repeated_string_body */ +#line 3140 "panda/src/egg/parser.yxx" +{ (yyval._string) = (yyvsp[0]._string); } -#line 4772 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4786 "built/tmp/parser.yxx.c" break; - case 269: -#line 3150 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 269: /* repeated_string_body: string */ +#line 3156 "panda/src/egg/parser.yxx" +{ (yyval._string) = (yyvsp[0]._string); } -#line 4780 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4794 "built/tmp/parser.yxx.c" break; - case 270: -#line 3154 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 270: /* repeated_string_body: repeated_string_body string */ +#line 3160 "panda/src/egg/parser.yxx" +{ (yyval._string) = (yyvsp[-1]._string) + "\n" + (yyvsp[0]._string); } -#line 4788 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4802 "built/tmp/parser.yxx.c" break; - case 272: -#line 3169 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 272: /* real: EGG_ULONG */ +#line 3175 "panda/src/egg/parser.yxx" +{ (yyval._number) = (yyvsp[0]._ulong); } -#line 4796 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4810 "built/tmp/parser.yxx.c" break; - case 273: -#line 3184 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 273: /* real_or_string: EGG_NUMBER */ +#line 3190 "panda/src/egg/parser.yxx" +{ (yyval._number) = (yyvsp[0]._number); (yyval._ulong) = (unsigned long)(yyvsp[0]._number); (yyval._string) = (yyvsp[0]._string); } -#line 4806 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4820 "built/tmp/parser.yxx.c" break; - case 274: -#line 3190 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 274: /* real_or_string: EGG_ULONG */ +#line 3196 "panda/src/egg/parser.yxx" +{ (yyval._number) = (yyvsp[0]._ulong); (yyval._ulong) = (yyvsp[0]._ulong); (yyval._string) = (yyvsp[0]._string); } -#line 4816 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4830 "built/tmp/parser.yxx.c" break; - case 275: -#line 3196 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 275: /* real_or_string: EGG_STRING */ +#line 3202 "panda/src/egg/parser.yxx" +{ (yyval._number) = 0.0; (yyval._ulong) = 0; (yyval._string) = (yyvsp[0]._string); } -#line 4826 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4840 "built/tmp/parser.yxx.c" break; - case 276: -#line 3213 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 276: /* integer: EGG_NUMBER */ +#line 3219 "panda/src/egg/parser.yxx" +{ int i = (int)(yyvsp[0]._number); if ((double)i != (yyvsp[0]._number)) { - eggyywarning("Integer expected."); + eggyywarning(&(yylsp[0]), scanner, "Integer expected."); (yyval._number) = (double)i; } } -#line 4838 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4852 "built/tmp/parser.yxx.c" break; - case 277: -#line 3221 "panda/src/egg/parser.yxx" /* yacc.c:1645 */ - { + case 277: /* integer: EGG_ULONG */ +#line 3227 "panda/src/egg/parser.yxx" +{ (yyval._number) = (yyvsp[0]._ulong); } -#line 4846 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4860 "built/tmp/parser.yxx.c" break; -#line 4850 "built/tmp/parser.yxx.c" /* yacc.c:1645 */ +#line 4864 "built/tmp/parser.yxx.c" + default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4858,13 +4875,13 @@ yyreduce: case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; - YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; + *++yylsp = yyloc; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule @@ -4886,50 +4903,15 @@ yyreduce: yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - + yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) - { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - } -# undef YYSYNTAX_ERROR -#endif + yyerror (&yylloc, state, scanner, YY_("syntax error")); } - - + yyerror_range[1] = yylloc; if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an @@ -4944,7 +4926,7 @@ yyerrlab: else { yydestruct ("Error: discarding", - yytoken, &yylval); + yytoken, &yylval, &yylloc, state, scanner); yychar = YYEMPTY; } } @@ -4958,12 +4940,10 @@ yyerrlab: | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -4980,13 +4960,14 @@ yyerrorlab: yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ + /* Pop stack until we find a state that shifts the error token. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + yyn += YYSYMBOL_YYerror; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) { yyn = yytable[yyn]; if (0 < yyn) @@ -4998,9 +4979,9 @@ yyerrlab1: if (yyssp == yyss) YYABORT; - + yyerror_range[1] = *yylsp; yydestruct ("Error: popping", - yystos[yystate], yyvsp); + YY_ACCESSING_SYMBOL (yystate), yyvsp, yylsp, state, scanner); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -5010,9 +4991,12 @@ yyerrlab1: *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END + yyerror_range[2] = yylloc; + ++yylsp; + YYLLOC_DEFAULT (*yylsp, yyerror_range, 2); /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -5025,6 +5009,7 @@ yyacceptlab: yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -5032,16 +5017,21 @@ yyabortlab: yyresult = 1; goto yyreturn; -#if !defined yyoverflow || YYERROR_VERBOSE + +#if !defined yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: - yyerror (YY_("memory exhausted")); + yyerror (&yylloc, state, scanner, YY_("memory exhausted")); yyresult = 2; - /* Fall through. */ + goto yyreturn; #endif + +/*-------------------------------------------------------. +| yyreturn -- parsing is finished, clean up and return. | +`-------------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -5049,7 +5039,7 @@ yyreturn: user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); + yytoken, &yylval, &yylloc, state, scanner); } /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ @@ -5058,16 +5048,13 @@ yyreturn: while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yylsp, state, scanner); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif + return yyresult; } diff --git a/panda/src/egg/parser.h.prebuilt b/panda/src/egg/parser.h.prebuilt index 24f4dde7da..0d04132b25 100644 --- a/panda/src/egg/parser.h.prebuilt +++ b/panda/src/egg/parser.h.prebuilt @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.2.2. */ +/* A Bison parser, made by GNU Bison 3.7.2. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,8 +31,9 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -/* Undocumented macros, especially those whose name start with YY_, - are private implementation details. Do not rely on them. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ #ifndef YY_EGGYY_BUILT_TMP_PARSER_YXX_H_INCLUDED # define YY_EGGYY_BUILT_TMP_PARSER_YXX_H_INCLUDED @@ -43,103 +45,111 @@ extern int eggyydebug; #endif -/* Token type. */ +/* Token kinds. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { - EGG_NUMBER = 258, - EGG_ULONG = 259, - EGG_STRING = 260, - ANIMPRELOAD = 261, - BEZIERCURVE = 262, - BFACE = 263, - BILLBOARD = 264, - BILLBOARDCENTER = 265, - BINORMAL = 266, - BUNDLE = 267, - CLOSED = 268, - COLLIDE = 269, - COMMENT = 270, - COMPONENT = 271, - COORDSYSTEM = 272, - CV = 273, - DART = 274, - DNORMAL = 275, - DRGBA = 276, - DUV = 277, - DXYZ = 278, - DCS = 279, - DISTANCE = 280, - DTREF = 281, - DYNAMICVERTEXPOOL = 282, - EXTERNAL_FILE = 283, - GROUP = 284, - DEFAULTPOSE = 285, - JOINT = 286, - KNOTS = 287, - INCLUDE = 288, - INSTANCE = 289, - LINE = 290, - LOOP = 291, - MATERIAL = 292, - MATRIX3 = 293, - MATRIX4 = 294, - MODEL = 295, - MREF = 296, - NORMAL = 297, - NURBSCURVE = 298, - NURBSSURFACE = 299, - OBJECTTYPE = 300, - ORDER = 301, - OUTTANGENT = 302, - PATCH = 303, - POINTLIGHT = 304, - POLYGON = 305, - REF = 306, - RGBA = 307, - ROTATE = 308, - ROTX = 309, - ROTY = 310, - ROTZ = 311, - SANIM = 312, - SCALAR = 313, - SCALE = 314, - SEQUENCE = 315, - SHADING = 316, - SWITCH = 317, - SWITCHCONDITION = 318, - TABLE = 319, - TABLE_V = 320, - TAG = 321, - TANGENT = 322, - TEXLIST = 323, - TEXTURE = 324, - TLENGTHS = 325, - TRANSFORM = 326, - TRANSLATE = 327, - TREF = 328, - TRIANGLEFAN = 329, - TRIANGLESTRIP = 330, - TRIM = 331, - TXT = 332, - UKNOTS = 333, - UV = 334, - AUX = 335, - VKNOTS = 336, - VERTEX = 337, - VERTEXANIM = 338, - VERTEXPOOL = 339, - VERTEXREF = 340, - XFMANIM = 341, - XFMSANIM = 342, - START_EGG = 343, - START_GROUP_BODY = 344, - START_TEXTURE_BODY = 345, - START_PRIMITIVE_BODY = 346 + YYEMPTY = -2, + YYEOF = 0, /* "end of file" */ + YYerror = 256, /* error */ + YYUNDEF = 257, /* "invalid token" */ + EGG_NUMBER = 258, /* EGG_NUMBER */ + EGG_ULONG = 259, /* EGG_ULONG */ + EGG_STRING = 260, /* EGG_STRING */ + ANIMPRELOAD = 261, /* ANIMPRELOAD */ + BEZIERCURVE = 262, /* BEZIERCURVE */ + BFACE = 263, /* BFACE */ + BILLBOARD = 264, /* BILLBOARD */ + BILLBOARDCENTER = 265, /* BILLBOARDCENTER */ + BINORMAL = 266, /* BINORMAL */ + BUNDLE = 267, /* BUNDLE */ + CLOSED = 268, /* CLOSED */ + COLLIDE = 269, /* COLLIDE */ + COMMENT = 270, /* COMMENT */ + COMPONENT = 271, /* COMPONENT */ + COORDSYSTEM = 272, /* COORDSYSTEM */ + CV = 273, /* CV */ + DART = 274, /* DART */ + DNORMAL = 275, /* DNORMAL */ + DRGBA = 276, /* DRGBA */ + DUV = 277, /* DUV */ + DXYZ = 278, /* DXYZ */ + DCS = 279, /* DCS */ + DISTANCE = 280, /* DISTANCE */ + DTREF = 281, /* DTREF */ + DYNAMICVERTEXPOOL = 282, /* DYNAMICVERTEXPOOL */ + EXTERNAL_FILE = 283, /* EXTERNAL_FILE */ + GROUP = 284, /* GROUP */ + DEFAULTPOSE = 285, /* DEFAULTPOSE */ + JOINT = 286, /* JOINT */ + KNOTS = 287, /* KNOTS */ + INCLUDE = 288, /* INCLUDE */ + INSTANCE = 289, /* INSTANCE */ + LINE = 290, /* LINE */ + LOOP = 291, /* LOOP */ + MATERIAL = 292, /* MATERIAL */ + MATRIX3 = 293, /* MATRIX3 */ + MATRIX4 = 294, /* MATRIX4 */ + MODEL = 295, /* MODEL */ + MREF = 296, /* MREF */ + NORMAL = 297, /* NORMAL */ + NURBSCURVE = 298, /* NURBSCURVE */ + NURBSSURFACE = 299, /* NURBSSURFACE */ + OBJECTTYPE = 300, /* OBJECTTYPE */ + ORDER = 301, /* ORDER */ + OUTTANGENT = 302, /* OUTTANGENT */ + PATCH = 303, /* PATCH */ + POINTLIGHT = 304, /* POINTLIGHT */ + POLYGON = 305, /* POLYGON */ + REF = 306, /* REF */ + RGBA = 307, /* RGBA */ + ROTATE = 308, /* ROTATE */ + ROTX = 309, /* ROTX */ + ROTY = 310, /* ROTY */ + ROTZ = 311, /* ROTZ */ + SANIM = 312, /* SANIM */ + SCALAR = 313, /* SCALAR */ + SCALE = 314, /* SCALE */ + SEQUENCE = 315, /* SEQUENCE */ + SHADING = 316, /* SHADING */ + SWITCH = 317, /* SWITCH */ + SWITCHCONDITION = 318, /* SWITCHCONDITION */ + TABLE = 319, /* TABLE */ + TABLE_V = 320, /* TABLE_V */ + TAG = 321, /* TAG */ + TANGENT = 322, /* TANGENT */ + TEXLIST = 323, /* TEXLIST */ + TEXTURE = 324, /* TEXTURE */ + TLENGTHS = 325, /* TLENGTHS */ + TRANSFORM = 326, /* TRANSFORM */ + TRANSLATE = 327, /* TRANSLATE */ + TREF = 328, /* TREF */ + TRIANGLEFAN = 329, /* TRIANGLEFAN */ + TRIANGLESTRIP = 330, /* TRIANGLESTRIP */ + TRIM = 331, /* TRIM */ + TXT = 332, /* TXT */ + UKNOTS = 333, /* UKNOTS */ + UV = 334, /* UV */ + AUX = 335, /* AUX */ + VKNOTS = 336, /* VKNOTS */ + VERTEX = 337, /* VERTEX */ + VERTEXANIM = 338, /* VERTEXANIM */ + VERTEXPOOL = 339, /* VERTEXPOOL */ + VERTEXREF = 340, /* VERTEXREF */ + XFMANIM = 341, /* XFMANIM */ + XFMSANIM = 342, /* XFMSANIM */ + START_EGG = 343, /* START_EGG */ + START_GROUP_BODY = 344, /* START_GROUP_BODY */ + START_TEXTURE_BODY = 345, /* START_TEXTURE_BODY */ + START_PRIMITIVE_BODY = 346 /* START_PRIMITIVE_BODY */ }; + typedef enum yytokentype yytoken_kind_t; #endif -/* Tokens. */ +/* Token kinds. */ +#define YYEOF 0 +#define YYerror 256 +#define YYUNDEF 257 #define EGG_NUMBER 258 #define EGG_ULONG 259 #define EGG_STRING 260 @@ -232,9 +242,22 @@ extern int eggyydebug; /* Value type. */ +/* Location type. */ +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE YYLTYPE; +struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +}; +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif -extern YYSTYPE eggyylval; -int eggyyparse (void); + +int eggyyparse (EggParserState &state, yyscan_t scanner); #endif /* !YY_EGGYY_BUILT_TMP_PARSER_YXX_H_INCLUDED */ diff --git a/panda/src/egg/parser.yxx b/panda/src/egg/parser.yxx index 6f4ed4d443..f3ce93cc6f 100644 --- a/panda/src/egg/parser.yxx +++ b/panda/src/egg/parser.yxx @@ -4,6 +4,12 @@ * @date 1999-01-16 */ +%define api.pure full +%locations +%parse-param {EggParserState &state} +%parse-param {yyscan_t scanner} +%lex-param {yyscan_t scanner} + %{ #include "pandabase.h" @@ -57,78 +63,73 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 -using std::istream; using std::ostringstream; using std::string; -// We need a stack of EggObject pointers. Each time we encounter a -// nested EggObject of some kind, we'll allocate a new one of these -// and push it onto the stack. At any given time, the top of the -// stack is the EggObject we are currently scanning. +typedef pvector< PT(EggObject)> EggStack; +typedef pmap VertexPools; +typedef pmap Textures; +typedef pmap Materials; +typedef pmap Groups; -typedef pvector< PT(EggObject) > EggStack; -static EggStack egg_stack; +struct EggParserState { + // We need a stack of EggObject pointers. Each time we encounter a + // nested EggObject of some kind, we'll allocate a new one of these + // and push it onto the stack. At any given time, the top of the + // stack is the EggObject we are currently scanning. + EggStack stack; -// This is used just when parsing a or entry. -static EggTransform *egg_top_transform; + // This is used just when parsing a or entry. + EggTransform *top_transform; -// There's one "top-level" egg node, which is where we should parent -// things (e.g. implicit textures) encountered in the egg file that -// don't have an explicit place in the tree. If this is NULL, such -// things won't be parented anywhere. -static EggGroupNode *egg_top_node; + // There's one "top-level" egg node, which is where we should parent + // things (e.g. implicit state.textures) encountered in the egg file that + // don't have an explicit place in the tree. If this is NULL, such + // things won't be parented anywhere. + EggGroupNode *top_node; -// We need a table mapping vertex pool names to vertex pools. -typedef pmap VertexPools; -static VertexPools vertex_pools; + // We need a table mapping vertex pool names to vertex pools. + VertexPools vertex_pools; -// And another one mapping texture names to textures. -typedef pmap Textures; -static Textures textures; + // And another one mapping texture names to state.textures. + Textures textures; -// And again for material names to materials. -typedef pmap Materials; -static Materials materials; + // And again for material names to state.materials. + Materials materials; -// Group names to groups. -typedef pmap Groups; -static Groups groups; + // Group names to state.groups. + Groups groups; -// We need to be able to save the index number requested for a vertex -// temporarily. -static int vertex_index; + // We need to be able to save the index number requested for a vertex + // temporarily. + int vertex_index; +}; +static int eggyyparse(EggParserState &state, yyscan_t scanner); //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. //////////////////////////////////////////////////////////////////// -void -egg_init_parser(istream &in, const string &filename, - EggObject *tos, EggGroupNode *top_node) { - egg_init_lexer(in, filename); +bool +egg_parse(EggLexerState &lexer_state, EggObject *tos, EggGroupNode *top_node) { + yyscan_t scanner = nullptr; + eggyylex_init_extra(&lexer_state, &scanner); - egg_stack.clear(); - vertex_pools.clear(); - textures.clear(); - materials.clear(); - groups.clear(); + EggParserState state; + state.stack.push_back(tos); + state.top_node = top_node; + eggyyparse(state, scanner); - egg_stack.push_back(tos); - egg_top_node = top_node; -} - -void -egg_cleanup_parser() { // Check for undefined vertex pools. VertexPools::const_iterator vpi; - for (vpi = vertex_pools.begin(); vpi != vertex_pools.end(); ++vpi) { + for (vpi = state.vertex_pools.begin(); vpi != state.vertex_pools.end(); ++vpi) { EggVertexPool *pool = (*vpi).second; if (pool->has_forward_vertices()) { if (!pool->has_defined_vertices()) { - eggyyerror("Undefined vertex pool " + pool->get_name()); + eggyyerror(nullptr, scanner, "Undefined vertex pool " + pool->get_name()); } else { - eggyyerror("Undefined vertices in pool " + pool->get_name()); + eggyyerror(nullptr, scanner, "Undefined vertices in pool " + pool->get_name()); egg_cat.error(false) << "Undefined vertex index numbers:"; @@ -146,15 +147,23 @@ egg_cleanup_parser() { } } - // Clean these out after we're done, so we don't keep big memory - // structures around needlessly. - egg_stack.clear(); - vertex_pools.clear(); - textures.clear(); - materials.clear(); - groups.clear(); + eggyylex_destroy(scanner); - egg_cleanup_lexer(); + return lexer_state._error_count == 0; +} + +//////////////////////////////////////////////////////////////////// +// Internal support functions. +//////////////////////////////////////////////////////////////////// + +void +eggyyerror(YYLTYPE *loc, EggParserState &state, yyscan_t scanner, const std::string &msg) { + eggyyerror(loc, scanner, msg); +} + +void +eggyywarning(YYLTYPE *loc, EggParserState &state, yyscan_t scanner, const string &msg) { + eggyywarning(loc, scanner, msg); } %} @@ -251,8 +260,8 @@ egg: empty | egg node { - assert(!egg_stack.empty()); - DCAST(EggData, egg_stack.back())->add_child(DCAST(EggNode, $2)); + assert(!state.stack.empty()); + DCAST(EggData, state.stack.back())->add_child(DCAST(EggNode, $2)); } ; @@ -301,7 +310,7 @@ coordsystem: CoordinateSystem f = parse_coordinate_system_string(strval); if (f == CS_invalid) { - eggyywarning("Unknown coordinate system " + strval); + eggyywarning(&@3, scanner, "Unknown coordinate system " + strval); } else { cs->set_value(f); } @@ -337,17 +346,17 @@ texture: Filename filename = $4; EggTexture *texture = new EggTexture(tref_name, filename); - if (textures.find(tref_name) != textures.end()) { - eggyywarning("Duplicate texture name " + tref_name); + if (state.textures.find(tref_name) != state.textures.end()) { + eggyywarning(&@2, scanner, "Duplicate texture name " + tref_name); } - textures[tref_name] = texture; + state.textures[tref_name] = texture; - egg_stack.push_back(texture); + state.stack.push_back(texture); } texture_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -362,7 +371,7 @@ texture_body: empty | texture_body SCALAR required_name '{' real_or_string '}' { - EggTexture *texture = DCAST(EggTexture, egg_stack.back()); + EggTexture *texture = DCAST(EggTexture, state.stack.back()); string name = $3; double value = $<_number>5; string strval = $<_string>5; @@ -370,7 +379,7 @@ texture_body: if (cmp_nocase_uh(name, "type") == 0) { EggTexture::TextureType tt = EggTexture::string_texture_type(strval); if (tt == EggTexture::TT_unspecified) { - eggyywarning("Unknown texture texture_type " + strval); + eggyywarning(&@5, scanner, "Unknown texture texture_type " + strval); } else { texture->set_texture_type(tt); } @@ -378,7 +387,7 @@ texture_body: } else if (cmp_nocase_uh(name, "format") == 0) { EggTexture::Format f = EggTexture::string_format(strval); if (f == EggTexture::F_unspecified) { - eggyywarning("Unknown texture format " + strval); + eggyywarning(&@5, scanner, "Unknown texture format " + strval); } else { texture->set_format(f); } @@ -386,7 +395,7 @@ texture_body: } else if (cmp_nocase_uh(name, "compression") == 0) { EggTexture::CompressionMode w = EggTexture::string_compression_mode(strval); if (w == EggTexture::CM_default) { - eggyywarning("Unknown texture compression mode " + strval); + eggyywarning(&@5, scanner, "Unknown texture compression mode " + strval); } else { texture->set_compression_mode(w); } @@ -394,7 +403,7 @@ texture_body: } else if (cmp_nocase_uh(name, "wrap") == 0) { EggTexture::WrapMode w = EggTexture::string_wrap_mode(strval); if (w == EggTexture::WM_unspecified) { - eggyywarning("Unknown texture wrap mode " + strval); + eggyywarning(&@5, scanner, "Unknown texture wrap mode " + strval); } else { texture->set_wrap_mode(w); } @@ -402,7 +411,7 @@ texture_body: } else if (cmp_nocase_uh(name, "wrapu") == 0) { EggTexture::WrapMode w = EggTexture::string_wrap_mode(strval); if (w == EggTexture::WM_unspecified) { - eggyywarning("Unknown texture wrap mode " + strval); + eggyywarning(&@5, scanner, "Unknown texture wrap mode " + strval); } else { texture->set_wrap_u(w); } @@ -410,7 +419,7 @@ texture_body: } else if (cmp_nocase_uh(name, "wrapv") == 0) { EggTexture::WrapMode w = EggTexture::string_wrap_mode(strval); if (w == EggTexture::WM_unspecified) { - eggyywarning("Unknown texture wrap mode " + strval); + eggyywarning(&@5, scanner, "Unknown texture wrap mode " + strval); } else { texture->set_wrap_v(w); } @@ -418,7 +427,7 @@ texture_body: } else if (cmp_nocase_uh(name, "minfilter") == 0) { EggTexture::FilterType f = EggTexture::string_filter_type(strval); if (f == EggTexture::FT_unspecified) { - eggyywarning("Unknown texture filter type " + strval); + eggyywarning(&@5, scanner, "Unknown texture filter type " + strval); } else { texture->set_minfilter(f); } @@ -426,7 +435,7 @@ texture_body: } else if (cmp_nocase_uh(name, "magfilter") == 0) { EggTexture::FilterType f = EggTexture::string_filter_type(strval); if (f == EggTexture::FT_unspecified) { - eggyywarning("Unknown texture filter type " + strval); + eggyywarning(&@5, scanner, "Unknown texture filter type " + strval); } else { texture->set_magfilter(f); } @@ -437,7 +446,7 @@ texture_body: } else if (cmp_nocase_uh(name, "envtype") == 0) { EggTexture::EnvType e = EggTexture::string_env_type(strval); if (e == EggTexture::ET_unspecified) { - eggyywarning("Unknown texture env type " + strval); + eggyywarning(&@5, scanner, "Unknown texture env type " + strval); } else { texture->set_env_type(e); } @@ -445,7 +454,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-rgb") == 0) { EggTexture::CombineMode cm = EggTexture::string_combine_mode(strval); if (cm == EggTexture::CM_unspecified) { - eggyywarning("Unknown combine mode " + strval); + eggyywarning(&@5, scanner, "Unknown combine mode " + strval); } else { texture->set_combine_mode(EggTexture::CC_rgb, cm); } @@ -453,7 +462,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-rgb-source0") == 0) { EggTexture::CombineSource cs = EggTexture::string_combine_source(strval); if (cs == EggTexture::CS_unspecified) { - eggyywarning("Unknown combine source " + strval); + eggyywarning(&@5, scanner, "Unknown combine source " + strval); } else { texture->set_combine_source(EggTexture::CC_rgb, 0, cs); } @@ -461,7 +470,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-rgb-operand0") == 0) { EggTexture::CombineOperand co = EggTexture::string_combine_operand(strval); if (co == EggTexture::CO_unspecified) { - eggyywarning("Unknown combine operand " + strval); + eggyywarning(&@5, scanner, "Unknown combine operand " + strval); } else { texture->set_combine_operand(EggTexture::CC_rgb, 0, co); } @@ -469,7 +478,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-rgb-source1") == 0) { EggTexture::CombineSource cs = EggTexture::string_combine_source(strval); if (cs == EggTexture::CS_unspecified) { - eggyywarning("Unknown combine source " + strval); + eggyywarning(&@5, scanner, "Unknown combine source " + strval); } else { texture->set_combine_source(EggTexture::CC_rgb, 1, cs); } @@ -477,7 +486,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-rgb-operand1") == 0) { EggTexture::CombineOperand co = EggTexture::string_combine_operand(strval); if (co == EggTexture::CO_unspecified) { - eggyywarning("Unknown combine operand " + strval); + eggyywarning(&@5, scanner, "Unknown combine operand " + strval); } else { texture->set_combine_operand(EggTexture::CC_rgb, 1, co); } @@ -485,7 +494,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-rgb-source2") == 0) { EggTexture::CombineSource cs = EggTexture::string_combine_source(strval); if (cs == EggTexture::CS_unspecified) { - eggyywarning("Unknown combine source " + strval); + eggyywarning(&@5, scanner, "Unknown combine source " + strval); } else { texture->set_combine_source(EggTexture::CC_rgb, 2, cs); } @@ -493,7 +502,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-rgb-operand2") == 0) { EggTexture::CombineOperand co = EggTexture::string_combine_operand(strval); if (co == EggTexture::CO_unspecified) { - eggyywarning("Unknown combine operand " + strval); + eggyywarning(&@5, scanner, "Unknown combine operand " + strval); } else { texture->set_combine_operand(EggTexture::CC_rgb, 2, co); } @@ -501,7 +510,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-alpha") == 0) { EggTexture::CombineMode cm = EggTexture::string_combine_mode(strval); if (cm == EggTexture::CM_unspecified) { - eggyywarning("Unknown combine mode " + strval); + eggyywarning(&@5, scanner, "Unknown combine mode " + strval); } else { texture->set_combine_mode(EggTexture::CC_alpha, cm); } @@ -509,7 +518,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-alpha-source0") == 0) { EggTexture::CombineSource cs = EggTexture::string_combine_source(strval); if (cs == EggTexture::CS_unspecified) { - eggyywarning("Unknown combine source " + strval); + eggyywarning(&@5, scanner, "Unknown combine source " + strval); } else { texture->set_combine_source(EggTexture::CC_alpha, 0, cs); } @@ -517,7 +526,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-alpha-operand0") == 0) { EggTexture::CombineOperand co = EggTexture::string_combine_operand(strval); if (co == EggTexture::CO_unspecified) { - eggyywarning("Unknown combine operand " + strval); + eggyywarning(&@5, scanner, "Unknown combine operand " + strval); } else { texture->set_combine_operand(EggTexture::CC_alpha, 0, co); } @@ -525,7 +534,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-alpha-source1") == 0) { EggTexture::CombineSource cs = EggTexture::string_combine_source(strval); if (cs == EggTexture::CS_unspecified) { - eggyywarning("Unknown combine source " + strval); + eggyywarning(&@5, scanner, "Unknown combine source " + strval); } else { texture->set_combine_source(EggTexture::CC_alpha, 1, cs); } @@ -533,7 +542,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-alpha-operand1") == 0) { EggTexture::CombineOperand co = EggTexture::string_combine_operand(strval); if (co == EggTexture::CO_unspecified) { - eggyywarning("Unknown combine operand " + strval); + eggyywarning(&@5, scanner, "Unknown combine operand " + strval); } else { texture->set_combine_operand(EggTexture::CC_alpha, 1, co); } @@ -541,7 +550,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-alpha-source2") == 0) { EggTexture::CombineSource cs = EggTexture::string_combine_source(strval); if (cs == EggTexture::CS_unspecified) { - eggyywarning("Unknown combine source " + strval); + eggyywarning(&@5, scanner, "Unknown combine source " + strval); } else { texture->set_combine_source(EggTexture::CC_alpha, 2, cs); } @@ -549,7 +558,7 @@ texture_body: } else if (cmp_nocase_uh(name, "combine-alpha-operand2") == 0) { EggTexture::CombineOperand co = EggTexture::string_combine_operand(strval); if (co == EggTexture::CO_unspecified) { - eggyywarning("Unknown combine operand " + strval); + eggyywarning(&@5, scanner, "Unknown combine operand " + strval); } else { texture->set_combine_operand(EggTexture::CC_alpha, 2, co); } @@ -560,7 +569,7 @@ texture_body: } else if (cmp_nocase_uh(name, "tex_gen") == 0) { EggTexture::TexGen tex_gen = EggTexture::string_tex_gen(strval); if (tex_gen == EggTexture::TG_unspecified) { - eggyywarning("Unknown tex-gen " + strval); + eggyywarning(&@5, scanner, "Unknown tex-gen " + strval); } else { texture->set_tex_gen(tex_gen); } @@ -568,7 +577,7 @@ texture_body: } else if (cmp_nocase_uh(name, "quality_level") == 0) { EggTexture::QualityLevel quality_level = EggTexture::string_quality_level(strval); if (quality_level == EggTexture::QL_unspecified) { - eggyywarning("Unknown quality-level " + strval); + eggyywarning(&@5, scanner, "Unknown quality-level " + strval); } else { texture->set_quality_level(quality_level); } @@ -585,7 +594,7 @@ texture_body: } else if (cmp_nocase_uh(name, "num_views") == 0) { int int_value = (int)value; if (int_value < 1) { - eggyyerror("Invalid num-views value " + strval); + eggyyerror(&@5, scanner, "Invalid num-views value " + strval); } else { texture->set_num_views(int_value); } @@ -636,7 +645,7 @@ texture_body: } else if (cmp_nocase_uh(name, "rgb_scale") == 0) { int int_value = (int)value; if (int_value != 1 && int_value != 2 && int_value != 4) { - eggyyerror("Invalid rgb-scale value " + strval); + eggyyerror(&@5, scanner, "Invalid rgb-scale value " + strval); } else { texture->set_rgb_scale(int_value); } @@ -644,7 +653,7 @@ texture_body: } else if (cmp_nocase_uh(name, "alpha_scale") == 0) { int int_value = (int)value; if (int_value != 1 && int_value != 2 && int_value != 4) { - eggyyerror("Invalid alpha-scale value " + strval); + eggyyerror(&@5, scanner, "Invalid alpha-scale value " + strval); } else { texture->set_alpha_scale(int_value); } @@ -652,7 +661,7 @@ texture_body: } else if (cmp_nocase_uh(name, "alpha") == 0) { EggRenderMode::AlphaMode a = EggRenderMode::string_alpha_mode(strval); if (a == EggRenderMode::AM_unspecified) { - eggyywarning("Unknown alpha mode " + strval); + eggyywarning(&@5, scanner, "Unknown alpha mode " + strval); } else { texture->set_alpha_mode(a); } @@ -661,7 +670,7 @@ texture_body: EggRenderMode::DepthWriteMode m = EggRenderMode::string_depth_write_mode(strval); if (m == EggRenderMode::DWM_unspecified) { - eggyywarning("Unknown depth-write mode " + strval); + eggyywarning(&@5, scanner, "Unknown depth-write mode " + strval); } else { texture->set_depth_write_mode(m); } @@ -670,7 +679,7 @@ texture_body: EggRenderMode::DepthTestMode m = EggRenderMode::string_depth_test_mode(strval); if (m == EggRenderMode::DTM_unspecified) { - eggyywarning("Unknown depth-test mode " + strval); + eggyywarning(&@5, scanner, "Unknown depth-test mode " + strval); } else { texture->set_depth_test_mode(m); } @@ -679,7 +688,7 @@ texture_body: EggRenderMode::VisibilityMode m = EggRenderMode::string_visibility_mode(strval); if (m == EggRenderMode::VM_unspecified) { - eggyywarning("Unknown visibility mode " + strval); + eggyywarning(&@5, scanner, "Unknown visibility mode " + strval); } else { texture->set_visibility_mode(m); } @@ -712,7 +721,7 @@ texture_body: texture->set_lod_bias(value); } else { - eggyywarning("Unsupported texture scalar: " + name); + eggyywarning(&@2, scanner, "Unsupported texture scalar: " + name); } } | texture_body transform @@ -731,17 +740,17 @@ material: string mref_name = $2; EggMaterial *material = new EggMaterial(mref_name); - if (materials.find(mref_name) != materials.end()) { - eggyywarning("Duplicate material name " + mref_name); + if (state.materials.find(mref_name) != state.materials.end()) { + eggyywarning(&@2, scanner, "Duplicate material name " + mref_name); } - materials[mref_name] = material; + state.materials[mref_name] = material; - egg_stack.push_back(material); + state.stack.push_back(material); } material_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -756,7 +765,7 @@ material_body: empty | material_body SCALAR required_name '{' real_or_string '}' { - EggMaterial *material = DCAST(EggMaterial, egg_stack.back()); + EggMaterial *material = DCAST(EggMaterial, state.stack.back()); string name = $3; double value = $<_number>5; @@ -861,7 +870,7 @@ material_body: material->set_local(value != 0.0); } else { - eggyywarning("Unsupported material scalar: " + name); + eggyywarning(&@3, scanner, "Unsupported material scalar: " + name); } } ; @@ -885,7 +894,7 @@ external_reference: | string EXTERNAL_FILE optional_name '{' required_string '}' { if (cmp_nocase_uh($1, "group") != 0) { - eggyyerror("keyword 'group' expected"); + eggyyerror(&@1, scanner, "keyword 'group' expected"); } string node_name = $3; Filename filename = $5; @@ -907,29 +916,29 @@ vertex_pool: string name = $2; EggVertexPool *pool = nullptr; - VertexPools::const_iterator vpi = vertex_pools.find(name); - if (vpi != vertex_pools.end()) { + VertexPools::const_iterator vpi = state.vertex_pools.find(name); + if (vpi != state.vertex_pools.end()) { pool = (*vpi).second; if (pool->has_defined_vertices()) { - eggyywarning("Duplicate vertex pool name " + name); + eggyywarning(&@2, scanner, "Duplicate vertex pool name " + name); pool = new EggVertexPool(name); // The egg syntax starts counting at 1 by convention. pool->set_highest_index(0); - vertex_pools[name] = pool; + state.vertex_pools[name] = pool; } } else { pool = new EggVertexPool(name); // The egg syntax starts counting at 1 by convention. pool->set_highest_index(0); - vertex_pools[name] = pool; + state.vertex_pools[name] = pool; } - egg_stack.push_back(pool); + state.stack.push_back(pool); } '{' vertex_pool_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -956,48 +965,48 @@ vertex_pool_body: vertex: VERTEX { - egg_stack.push_back(new EggVertex); + state.stack.push_back(new EggVertex); } '{' vertex_body '}' { - PT(EggVertex) vtx = DCAST(EggVertex, egg_stack.back()); - egg_stack.pop_back(); + PT(EggVertex) vtx = DCAST(EggVertex, state.stack.back()); + state.stack.pop_back(); - DCAST(EggVertexPool, egg_stack.back())->add_vertex(vtx); + DCAST(EggVertexPool, state.stack.back())->add_vertex(vtx); } | VERTEX integer { - vertex_index = (int)$2; - EggVertexPool *pool = DCAST(EggVertexPool, egg_stack.back()); + state.vertex_index = (int)$2; + EggVertexPool *pool = DCAST(EggVertexPool, state.stack.back()); - if (vertex_index < 0) { + if (state.vertex_index < 0) { ostringstream errmsg; - errmsg << "Ignoring invalid vertex index " << vertex_index + errmsg << "Ignoring invalid vertex index " << state.vertex_index << " in vertex pool " << pool->get_name() << std::ends; - eggyywarning(errmsg); - vertex_index = -1; + eggyywarning(&@2, scanner, errmsg.str()); + state.vertex_index = -1; - } else if (pool->has_vertex(vertex_index)) { + } else if (pool->has_vertex(state.vertex_index)) { ostringstream errmsg; - errmsg << "Ignoring duplicate vertex index " << vertex_index + errmsg << "Ignoring duplicate vertex index " << state.vertex_index << " in vertex pool " << pool->get_name() << std::ends; - eggyywarning(errmsg); - vertex_index = -1; + eggyywarning(&@2, scanner, errmsg.str()); + state.vertex_index = -1; } // Even if we didn't like the vertex index number, we still need to // go ahead and parse the vertex. We just won't save it. - egg_stack.push_back(new EggVertex); + state.stack.push_back(new EggVertex); } '{' vertex_body '}' { - PT(EggVertex) vtx = DCAST(EggVertex, egg_stack.back()); - egg_stack.pop_back(); + PT(EggVertex) vtx = DCAST(EggVertex, state.stack.back()); + state.stack.pop_back(); - EggVertexPool *pool = DCAST(EggVertexPool, egg_stack.back()); - if (vertex_index != -1) { - pool->add_vertex(vtx, vertex_index); + EggVertexPool *pool = DCAST(EggVertexPool, state.stack.back()); + if (state.vertex_index != -1) { + pool->add_vertex(vtx, state.vertex_index); } } ; @@ -1013,66 +1022,66 @@ vertex: vertex_body: real { - DCAST(EggVertex, egg_stack.back())->set_pos($1); + DCAST(EggVertex, state.stack.back())->set_pos($1); } | real real { - DCAST(EggVertex, egg_stack.back())->set_pos(LPoint2d($1, $2)); + DCAST(EggVertex, state.stack.back())->set_pos(LPoint2d($1, $2)); } | real real real { - DCAST(EggVertex, egg_stack.back())->set_pos(LPoint3d($1, $2, $3)); + DCAST(EggVertex, state.stack.back())->set_pos(LPoint3d($1, $2, $3)); } | real real real real { - DCAST(EggVertex, egg_stack.back())->set_pos(LPoint4d($1, $2, $3, $4)); + DCAST(EggVertex, state.stack.back())->set_pos(LPoint4d($1, $2, $3, $4)); } | vertex_body UV optional_name '{' { - EggVertex *vertex = DCAST(EggVertex, egg_stack.back()); + EggVertex *vertex = DCAST(EggVertex, state.stack.back()); EggVertexUV *uv = new EggVertexUV($3, LTexCoordd::zero()); - egg_stack.push_back(uv); + state.stack.push_back(uv); if (vertex->has_uv($3)) { - eggyywarning("Ignoring repeated UV name " + $3); + eggyywarning(&@3, scanner, "Ignoring repeated UV name " + $3); } else { vertex->set_uv_obj(uv); } } vertex_uv_body '}' { - egg_stack.pop_back(); + state.stack.pop_back(); } | vertex_body AUX required_name '{' { - EggVertex *vertex = DCAST(EggVertex, egg_stack.back()); + EggVertex *vertex = DCAST(EggVertex, state.stack.back()); EggVertexAux *aux = new EggVertexAux($3, LVecBase4d::zero()); - egg_stack.push_back(aux); + state.stack.push_back(aux); if (vertex->has_aux($3)) { - eggyywarning("Ignoring repeated Aux name " + $3); + eggyywarning(&@3, scanner, "Ignoring repeated Aux name " + $3); } else { vertex->set_aux_obj(aux); } } vertex_aux_body '}' { - egg_stack.pop_back(); + state.stack.pop_back(); } | vertex_body NORMAL '{' vertex_normal_body '}' | vertex_body RGBA '{' vertex_color_body '}' | vertex_body DXYZ string '{' real real real '}' { - bool inserted = DCAST(EggVertex, egg_stack.back())->_dxyzs. + bool inserted = DCAST(EggVertex, state.stack.back())->_dxyzs. insert(EggMorphVertex($3, LVector3d($5, $6, $7))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $3); + eggyywarning(&@3, scanner, "Ignoring repeated morph name " + $3); } } | vertex_body DXYZ '{' string real real real '}' { - bool inserted = DCAST(EggVertex, egg_stack.back())->_dxyzs. + bool inserted = DCAST(EggVertex, state.stack.back())->_dxyzs. insert(EggMorphVertex($4, LVector3d($5, $6, $7))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $4); + eggyywarning(&@4, scanner, "Ignoring repeated morph name " + $4); } } ; @@ -1088,66 +1097,66 @@ vertex_body: vertex_uv_body: real real { - DCAST(EggVertexUV, egg_stack.back())->set_uv(LTexCoordd($1, $2)); + DCAST(EggVertexUV, state.stack.back())->set_uv(LTexCoordd($1, $2)); } | real real real { - DCAST(EggVertexUV, egg_stack.back())->set_uvw(LVecBase3d($1, $2, $3)); + DCAST(EggVertexUV, state.stack.back())->set_uvw(LVecBase3d($1, $2, $3)); } | vertex_uv_body TANGENT '{' real real real '}' { - if (DCAST(EggVertexUV, egg_stack.back())->has_tangent()) { - eggyywarning("Ignoring repeated tangent"); + if (DCAST(EggVertexUV, state.stack.back())->has_tangent()) { + eggyywarning(&@2, scanner, "Ignoring repeated tangent"); } else { - DCAST(EggVertexUV, egg_stack.back())->set_tangent(LNormald($4, $5, $6)); + DCAST(EggVertexUV, state.stack.back())->set_tangent(LNormald($4, $5, $6)); } } | vertex_uv_body TANGENT '{' real real real real '}' { - if (DCAST(EggVertexUV, egg_stack.back())->has_tangent()) { - eggyywarning("Ignoring repeated tangent"); + if (DCAST(EggVertexUV, state.stack.back())->has_tangent()) { + eggyywarning(&@2, scanner, "Ignoring repeated tangent"); } else { - DCAST(EggVertexUV, egg_stack.back())->set_tangent4(LVecBase4d($4, $5, $6, $7)); + DCAST(EggVertexUV, state.stack.back())->set_tangent4(LVecBase4d($4, $5, $6, $7)); } } | vertex_uv_body BINORMAL '{' real real real '}' { - if (DCAST(EggVertexUV, egg_stack.back())->has_binormal()) { - eggyywarning("Ignoring repeated binormal"); + if (DCAST(EggVertexUV, state.stack.back())->has_binormal()) { + eggyywarning(&@2, scanner, "Ignoring repeated binormal"); } else { - DCAST(EggVertexUV, egg_stack.back())->set_binormal(LNormald($4, $5, $6)); + DCAST(EggVertexUV, state.stack.back())->set_binormal(LNormald($4, $5, $6)); } } | vertex_uv_body DUV string '{' real real '}' { - bool inserted = DCAST(EggVertexUV, egg_stack.back())->_duvs. + bool inserted = DCAST(EggVertexUV, state.stack.back())->_duvs. insert(EggMorphTexCoord($3, LVector3d($5, $6, 0.0))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $3); + eggyywarning(&@3, scanner, "Ignoring repeated morph name " + $3); } } | vertex_uv_body DUV string '{' real real real '}' { - bool inserted = DCAST(EggVertexUV, egg_stack.back())->_duvs. + bool inserted = DCAST(EggVertexUV, state.stack.back())->_duvs. insert(EggMorphTexCoord($3, LVector3d($5, $6, $7))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $3); + eggyywarning(&@3, scanner, "Ignoring repeated morph name " + $3); } } | vertex_uv_body DUV '{' string real real '}' { - bool inserted = DCAST(EggVertexUV, egg_stack.back())->_duvs. + bool inserted = DCAST(EggVertexUV, state.stack.back())->_duvs. insert(EggMorphTexCoord($4, LVector3d($5, $6, 0.0))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $4); + eggyywarning(&@4, scanner, "Ignoring repeated morph name " + $4); } } | vertex_uv_body DUV '{' string real real real '}' { - bool inserted = DCAST(EggVertexUV, egg_stack.back())->_duvs. + bool inserted = DCAST(EggVertexUV, state.stack.back())->_duvs. insert(EggMorphTexCoord($4, LVector3d($5, $6, $7))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $4); + eggyywarning(&@4, scanner, "Ignoring repeated morph name " + $4); } } ; @@ -1162,7 +1171,7 @@ vertex_uv_body: vertex_aux_body: | real real real real { - DCAST(EggVertexAux, egg_stack.back())->set_aux(LVecBase4d($1, $2, $3, $4)); + DCAST(EggVertexAux, state.stack.back())->set_aux(LVecBase4d($1, $2, $3, $4)); } ; @@ -1176,22 +1185,22 @@ vertex_aux_body: vertex_normal_body: real real real { - DCAST(EggVertex, egg_stack.back())->set_normal(LNormald($1, $2, $3)); + DCAST(EggVertex, state.stack.back())->set_normal(LNormald($1, $2, $3)); } | vertex_normal_body DNORMAL string '{' real real real '}' { - bool inserted = DCAST(EggVertex, egg_stack.back())->_dnormals. + bool inserted = DCAST(EggVertex, state.stack.back())->_dnormals. insert(EggMorphNormal($3, LVector3d($5, $6, $7))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $3); + eggyywarning(&@3, scanner, "Ignoring repeated morph name " + $3); } } | vertex_normal_body DNORMAL '{' string real real real '}' { - bool inserted = DCAST(EggVertex, egg_stack.back())->_dnormals. + bool inserted = DCAST(EggVertex, state.stack.back())->_dnormals. insert(EggMorphNormal($4, LVector3d($5, $6, $7))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $4); + eggyywarning(&@4, scanner, "Ignoring repeated morph name " + $4); } } ; @@ -1206,22 +1215,22 @@ vertex_normal_body: vertex_color_body: real real real real { - DCAST(EggVertex, egg_stack.back())->set_color(LColor($1, $2, $3, $4)); + DCAST(EggVertex, state.stack.back())->set_color(LColor($1, $2, $3, $4)); } | vertex_color_body DRGBA string '{' real real real real '}' { - bool inserted = DCAST(EggVertex, egg_stack.back())->_drgbas. + bool inserted = DCAST(EggVertex, state.stack.back())->_drgbas. insert(EggMorphColor($3, LVector4($5, $6, $7, $8))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $3); + eggyywarning(&@3, scanner, "Ignoring repeated morph name " + $3); } } | vertex_color_body DRGBA '{' string real real real real '}' { - bool inserted = DCAST(EggVertex, egg_stack.back())->_drgbas. + bool inserted = DCAST(EggVertex, state.stack.back())->_drgbas. insert(EggMorphColor($4, LVector4($5, $6, $7, $8))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $4); + eggyywarning(&@4, scanner, "Ignoring repeated morph name " + $4); } } ; @@ -1237,15 +1246,15 @@ group: GROUP optional_name { EggGroup *group = new EggGroup($2); - egg_stack.push_back(group); + state.stack.push_back(group); } '{' group_body '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); $$ = group; - egg_stack.pop_back(); + state.stack.pop_back(); if (group->has_name()) { - groups[group->get_name()] = group; + state.groups[group->get_name()] = group; } Thread::consider_yield(); } @@ -1263,12 +1272,12 @@ joint: { EggGroup *group = new EggGroup($2); group->set_group_type(EggGroup::GT_joint); - egg_stack.push_back(group); + state.stack.push_back(group); } '{' group_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -1284,15 +1293,15 @@ instance: { EggGroup *group = new EggGroup($2); group->set_group_type(EggGroup::GT_instance); - egg_stack.push_back(group); + state.stack.push_back(group); } '{' group_body '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); $$ = group; - egg_stack.pop_back(); + state.stack.pop_back(); if (group->has_name()) { - groups[group->get_name()] = group; + state.groups[group->get_name()] = group; } } ; @@ -1308,7 +1317,7 @@ group_body: empty | group_body SCALAR required_name '{' real_or_string '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); string name = $3; double value = $<_number>5; unsigned long ulong_value = $<_ulong>5; @@ -1329,7 +1338,7 @@ group_body: } else if (cmp_nocase_uh(name, "alpha") == 0) { EggRenderMode::AlphaMode a = EggRenderMode::string_alpha_mode(strval); if (a == EggRenderMode::AM_unspecified) { - eggyywarning("Unknown alpha mode " + strval); + eggyywarning(&@5, scanner, "Unknown alpha mode " + strval); } else { group->set_alpha_mode(a); } @@ -1338,7 +1347,7 @@ group_body: EggRenderMode::DepthWriteMode m = EggRenderMode::string_depth_write_mode(strval); if (m == EggRenderMode::DWM_unspecified) { - eggyywarning("Unknown depth-write mode " + strval); + eggyywarning(&@5, scanner, "Unknown depth-write mode " + strval); } else { group->set_depth_write_mode(m); } @@ -1347,7 +1356,7 @@ group_body: EggRenderMode::DepthTestMode m = EggRenderMode::string_depth_test_mode(strval); if (m == EggRenderMode::DTM_unspecified) { - eggyywarning("Unknown depth-test mode " + strval); + eggyywarning(&@5, scanner, "Unknown depth-test mode " + strval); } else { group->set_depth_test_mode(m); } @@ -1356,7 +1365,7 @@ group_body: EggRenderMode::VisibilityMode m = EggRenderMode::string_visibility_mode(strval); if (m == EggRenderMode::VM_unspecified) { - eggyywarning("Unknown visibility mode " + strval); + eggyywarning(&@5, scanner, "Unknown visibility mode " + strval); } else { group->set_visibility_mode(m); } @@ -1407,7 +1416,7 @@ group_body: EggGroup::BlendMode blend_mode = EggGroup::string_blend_mode(strval); if (blend_mode == EggGroup::BM_unspecified) { - eggyywarning("Unknown blend mode " + strval); + eggyywarning(&@5, scanner, "Unknown blend mode " + strval); } else { group->set_blend_mode(blend_mode); } @@ -1416,7 +1425,7 @@ group_body: EggGroup::BlendOperand blend_operand = EggGroup::string_blend_operand(strval); if (blend_operand == EggGroup::BO_unspecified) { - eggyywarning("Unknown blend operand " + strval); + eggyywarning(&@5, scanner, "Unknown blend operand " + strval); } else { group->set_blend_operand_a(blend_operand); } @@ -1425,7 +1434,7 @@ group_body: EggGroup::BlendOperand blend_operand = EggGroup::string_blend_operand(strval); if (blend_operand == EggGroup::BO_unspecified) { - eggyywarning("Unknown blend operand " + strval); + eggyywarning(&@5, scanner, "Unknown blend operand " + strval); } else { group->set_blend_operand_b(blend_operand); } @@ -1451,48 +1460,48 @@ group_body: group->set_blend_color(color); } else { - eggyywarning("Unknown group scalar " + name); + eggyywarning(&@3, scanner, "Unknown group scalar " + name); } } | group_body BILLBOARD '{' string '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); string strval = $4; EggGroup::BillboardType f = EggGroup::string_billboard_type(strval); if (f == EggGroup::BT_none) { - eggyywarning("Unknown billboard type " + strval); + eggyywarning(&@4, scanner, "Unknown billboard type " + strval); } else { group->set_billboard_type(f); } } | group_body BILLBOARDCENTER '{' real real real '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); group->set_billboard_center(LPoint3d($4, $5, $6)); } | group_body COLLIDE optional_name '{' cs_type collide_flags '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); string name = $3; group->set_collision_name(name); } | group_body DCS '{' integer '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); int value = (int)$4; group->set_dcs_type(value!=0 ? EggGroup::DC_default : EggGroup::DC_none); } | group_body DCS '{' EGG_STRING '}' { // The special flavor of DCS, with { sync } or { nosync }. - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); string strval = $4; EggGroup::DCSType f = EggGroup::string_dcs_type(strval); if (f == EggGroup::DC_unspecified) { - eggyywarning("Unknown DCS type " + strval); + eggyywarning(&@4, scanner, "Unknown DCS type " + strval); } else { group->set_dcs_type(f); } @@ -1500,49 +1509,49 @@ group_body: | group_body DART '{' integer '}' { // The traditional flavor of DART, with { 0 } or { 1 }. - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); int value = (int)$4; group->set_dart_type(value!=0 ? EggGroup::DT_default : EggGroup::DT_none); } | group_body DART '{' EGG_STRING '}' { // The special flavor of DART, with { sync } or { nosync }. - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); string strval = $4; EggGroup::DartType f = EggGroup::string_dart_type(strval); if (f == EggGroup::DT_none) { - eggyywarning("Unknown dart type " + strval); + eggyywarning(&@4, scanner, "Unknown dart type " + strval); } else { group->set_dart_type(f); } } | group_body SWITCH '{' integer '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); int value = (int)$4; group->set_switch_flag(value!=0); } | group_body OBJECTTYPE '{' required_string '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); string type = $4; group->add_object_type(type); } | group_body MODEL '{' integer '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); int value = (int)$4; group->set_model_flag(value!=0); } | group_body TAG optional_name '{' repeated_string '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); group->set_tag($3, $5); } | group_body TEXLIST '{' integer '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); int value = (int)$4; group->set_texlist_flag(value!=0); } @@ -1552,16 +1561,16 @@ group_body: | group_body switchcondition | group_body REF '{' group_name '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); if (group->get_group_type() != EggGroup::GT_instance) { - eggyyerror(" valid only within "); + eggyyerror(&@1, scanner, " valid only within "); } else if ($4 != nullptr) { group->add_group_ref(DCAST(EggGroup, $4)); } } | group_body node { - DCAST(EggGroup, egg_stack.back())->add_child(DCAST(EggNode, $2)); + DCAST(EggGroup, state.stack.back())->add_child(DCAST(EggNode, $2)); } ; @@ -1575,12 +1584,12 @@ group_body: cs_type: string { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); string strval = $1; EggGroup::CollisionSolidType f = EggGroup::string_cs_type(strval); if (f == EggGroup::CST_none) { - eggyywarning("Unknown collision solid type " + strval); + eggyywarning(&@1, scanner, "Unknown collision solid type " + strval); } else { if (f == EggGroup::CST_polyset && group->get_cs_type() != EggGroup::CST_none) { // By convention, a CST_polyset doesn't replace any existing @@ -1606,12 +1615,12 @@ collide_flags: empty | collide_flags string { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); string strval = $2; EggGroup::CollideFlags f = EggGroup::string_collide_flags(strval); if (f == EggGroup::CF_none) { - eggyywarning("Unknown collision flag " + strval); + eggyywarning(&@2, scanner, "Unknown collision flag " + strval); } else { group->set_collide_flags(group->get_collide_flags() | f); } @@ -1628,8 +1637,8 @@ collide_flags: transform: TRANSFORM { - egg_top_transform = egg_stack.back()->as_transform(); - egg_top_transform->clear_transform(); + state.top_transform = state.stack.back()->as_transform(); + state.top_transform->clear_transform(); } '{' transform_body '}' ; @@ -1644,12 +1653,12 @@ transform: default_pose: DEFAULTPOSE { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); if (group->get_group_type() != EggGroup::GT_joint) { - eggyywarning("Unexpected outside of "); + eggyywarning(&@1, scanner, "Unexpected outside of "); } - egg_top_transform = &group->modify_default_pose(); - egg_top_transform->clear_transform(); + state.top_transform = &group->modify_default_pose(); + state.top_transform->clear_transform(); } '{' transform_body '}' ; @@ -1658,7 +1667,7 @@ default_pose: /* * transform_body * - * enter: egg_top_transform has been assigned. + * enter: state.top_transform has been assigned. * exit: transform has been filled in. * */ @@ -1681,70 +1690,70 @@ transform_body: translate2d: TRANSLATE '{' real real '}' { - egg_top_transform->add_translate2d(LVector2d($3, $4)); + state.top_transform->add_translate2d(LVector2d($3, $4)); } ; translate3d: TRANSLATE '{' real real real '}' { - egg_top_transform->add_translate3d(LVector3d($3, $4, $5)); + state.top_transform->add_translate3d(LVector3d($3, $4, $5)); } ; rotate2d: ROTATE '{' real '}' { - egg_top_transform->add_rotate2d($3); + state.top_transform->add_rotate2d($3); } ; rotx: ROTX '{' real '}' { - egg_top_transform->add_rotx($3); + state.top_transform->add_rotx($3); } ; roty: ROTY '{' real '}' { - egg_top_transform->add_roty($3); + state.top_transform->add_roty($3); } ; rotz: ROTZ '{' real '}' { - egg_top_transform->add_rotz($3); + state.top_transform->add_rotz($3); } ; rotate3d: ROTATE '{' real real real real '}' { - egg_top_transform->add_rotate3d($3, LVector3d($4, $5, $6)); + state.top_transform->add_rotate3d($3, LVector3d($4, $5, $6)); } ; scale2d: SCALE '{' real real '}' { - egg_top_transform->add_scale2d(LVecBase2d($3, $4)); + state.top_transform->add_scale2d(LVecBase2d($3, $4)); } ; scale3d: SCALE '{' real real real '}' { - egg_top_transform->add_scale3d(LVecBase3d($3, $4, $5)); + state.top_transform->add_scale3d(LVecBase3d($3, $4, $5)); } ; uniform_scale: SCALE '{' real '}' { - egg_top_transform->add_uniform_scale($3); + state.top_transform->add_uniform_scale($3); } ; @@ -1758,7 +1767,7 @@ matrix3_body: real real real real real real { - egg_top_transform->add_matrix3 + state.top_transform->add_matrix3 (LMatrix3d($1, $2, $3, $4, $5, $6, $7, $8, $9)); @@ -1776,7 +1785,7 @@ matrix4_body: real real real real real real real real { - egg_top_transform->add_matrix4 + state.top_transform->add_matrix4 (LMatrix4d($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, @@ -1797,7 +1806,7 @@ group_vertex_ref: { if ($7 != nullptr) { EggVertexPool *pool = DCAST(EggVertexPool, $7); - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); PTA_double nums = $3; double membership = $4; @@ -1808,7 +1817,7 @@ group_vertex_ref: ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() << std::ends; - eggyyerror(errmsg); + eggyyerror(&@3, scanner, errmsg.str()); } else { group->ref_vertex(vertex, membership); } @@ -1839,7 +1848,7 @@ group_vertex_membership: if (cmp_nocase_uh(name, "membership") == 0) { result = value; } else { - eggyywarning("Unknown group vertex scalar " + name); + eggyywarning(&@3, scanner, "Unknown group vertex scalar " + name); } $$ = result; @@ -1869,12 +1878,12 @@ switchcondition: switchcondition_body: DISTANCE '{' real real VERTEX '{' real real real '}' '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); group->set_lod(EggSwitchConditionDistance($3, $4, LPoint3d($7, $8, $9))); } | DISTANCE '{' real real real VERTEX '{' real real real '}' '}' { - EggGroup *group = DCAST(EggGroup, egg_stack.back()); + EggGroup *group = DCAST(EggGroup, state.stack.back()); group->set_lod(EggSwitchConditionDistance($3, $4, LPoint3d($8, $9, $10), $5)); } ; @@ -1891,12 +1900,12 @@ switchcondition_body: polygon: POLYGON optional_name { - egg_stack.push_back(new EggPolygon($2)); + state.stack.push_back(new EggPolygon($2)); } '{' primitive_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -1910,12 +1919,12 @@ polygon: trianglefan: TRIANGLEFAN optional_name { - egg_stack.push_back(new EggTriangleFan($2)); + state.stack.push_back(new EggTriangleFan($2)); } '{' primitive_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -1929,12 +1938,12 @@ trianglefan: trianglestrip: TRIANGLESTRIP optional_name { - egg_stack.push_back(new EggTriangleStrip($2)); + state.stack.push_back(new EggTriangleStrip($2)); } '{' primitive_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -1948,12 +1957,12 @@ trianglestrip: patch: PATCH optional_name { - egg_stack.push_back(new EggPatch($2)); + state.stack.push_back(new EggPatch($2)); } '{' primitive_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -1967,12 +1976,12 @@ patch: point_light: POINTLIGHT optional_name { - egg_stack.push_back(new EggPoint($2)); + state.stack.push_back(new EggPoint($2)); } '{' primitive_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -1986,12 +1995,12 @@ point_light: line: LINE optional_name { - egg_stack.push_back(new EggLine($2)); + state.stack.push_back(new EggLine($2)); } '{' primitive_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -2005,12 +2014,12 @@ line: nurbs_surface: NURBSSURFACE optional_name { - egg_stack.push_back(new EggNurbsSurface($2)); + state.stack.push_back(new EggNurbsSurface($2)); } '{' nurbs_surface_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -2024,12 +2033,12 @@ nurbs_surface: nurbs_curve: NURBSCURVE optional_name { - egg_stack.push_back(new EggNurbsCurve($2)); + state.stack.push_back(new EggNurbsCurve($2)); } '{' nurbs_curve_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -2058,23 +2067,23 @@ primitive_body: empty | primitive_body COMPONENT integer '{' { - if (!egg_stack.back()->is_of_type(EggCompositePrimitive::get_class_type())) { - eggyyerror("Not a composite primitive; components are not allowed here."); + if (!state.stack.back()->is_of_type(EggCompositePrimitive::get_class_type())) { + eggyyerror(&@2, scanner, "Not a composite primitive; components are not allowed here."); } else { - PT(EggCompositePrimitive) comp = DCAST(EggCompositePrimitive, egg_stack.back()); + PT(EggCompositePrimitive) comp = DCAST(EggCompositePrimitive, state.stack.back()); if ($3 < 0 || $3 >= comp->get_num_components()) { - eggyyerror("Invalid component number"); + eggyyerror(&@3, scanner, "Invalid component number"); } } // We temporarily add an EggPolygon to the stack, just to receive // the component attributes. - egg_stack.push_back(new EggPolygon); + state.stack.push_back(new EggPolygon); } primitive_component_body '}' { - PT(EggPrimitive) prim = DCAST(EggPrimitive, egg_stack.back()); - egg_stack.pop_back(); - PT(EggCompositePrimitive) comp = DCAST(EggCompositePrimitive, egg_stack.back()); + PT(EggPrimitive) prim = DCAST(EggPrimitive, state.stack.back()); + state.stack.pop_back(); + PT(EggCompositePrimitive) comp = DCAST(EggCompositePrimitive, state.stack.back()); comp->set_component((int)$3, prim); } | primitive_body TREF '{' primitive_tref_body '}' @@ -2086,7 +2095,7 @@ primitive_body: | primitive_body BFACE '{' primitive_bface_body '}' | primitive_body SCALAR required_name '{' real_or_string '}' { - EggPrimitive *primitive = DCAST(EggPrimitive, egg_stack.back()); + EggPrimitive *primitive = DCAST(EggPrimitive, state.stack.back()); string name = $3; double value = $<_number>5; string strval = $<_string>5; @@ -2094,7 +2103,7 @@ primitive_body: if (cmp_nocase_uh(name, "alpha") == 0) { EggRenderMode::AlphaMode a = EggRenderMode::string_alpha_mode(strval); if (a == EggRenderMode::AM_unspecified) { - eggyywarning("Unknown alpha mode " + strval); + eggyywarning(&@5, scanner, "Unknown alpha mode " + strval); } else { primitive->set_alpha_mode(a); } @@ -2102,7 +2111,7 @@ primitive_body: EggRenderMode::DepthWriteMode m = EggRenderMode::string_depth_write_mode(strval); if (m == EggRenderMode::DWM_unspecified) { - eggyywarning("Unknown depth-write mode " + strval); + eggyywarning(&@5, scanner, "Unknown depth-write mode " + strval); } else { primitive->set_depth_write_mode(m); } @@ -2111,7 +2120,7 @@ primitive_body: EggRenderMode::DepthTestMode m = EggRenderMode::string_depth_test_mode(strval); if (m == EggRenderMode::DTM_unspecified) { - eggyywarning("Unknown depth-test mode " + strval); + eggyywarning(&@5, scanner, "Unknown depth-test mode " + strval); } else { primitive->set_depth_test_mode(m); } @@ -2120,7 +2129,7 @@ primitive_body: EggRenderMode::VisibilityMode m = EggRenderMode::string_visibility_mode(strval); if (m == EggRenderMode::VM_unspecified) { - eggyywarning("Unknown visibility mode " + strval); + eggyywarning(&@5, scanner, "Unknown visibility mode " + strval); } else { primitive->set_visibility_mode(m); } @@ -2137,16 +2146,16 @@ primitive_body: } else if (primitive->is_of_type(EggPoint::get_class_type())) { DCAST(EggPoint, primitive)->set_thick(value); } else { - eggyywarning("scalar thick is only meaningful for points and lines."); + eggyywarning(&@5, scanner, "scalar thick is only meaningful for points and lines."); } } else if (cmp_nocase_uh(name, "perspective") == 0) { if (primitive->is_of_type(EggPoint::get_class_type())) { DCAST(EggPoint, primitive)->set_perspective(value != 0); } else { - eggyywarning("scalar perspective is only meaningful for points."); + eggyywarning(&@5, scanner, "scalar perspective is only meaningful for points."); } } else { - eggyywarning("Unknown scalar " + name); + eggyywarning(&@3, scanner, "Unknown scalar " + name); } } ; @@ -2173,13 +2182,13 @@ nurbs_surface_body: | nurbs_surface_body nurbs_curve { EggNurbsCurve *curve = DCAST(EggNurbsCurve, $2); - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); nurbs->_curves_on_surface.push_back(curve); } | nurbs_surface_body TRIM '{' nurbs_surface_trim_body '}' | nurbs_surface_body SCALAR required_name '{' real_or_string '}' { - EggNurbsSurface *primitive = DCAST(EggNurbsSurface, egg_stack.back()); + EggNurbsSurface *primitive = DCAST(EggNurbsSurface, state.stack.back()); string name = $3; double value = $<_number>5; string strval = $<_string>5; @@ -2187,7 +2196,7 @@ nurbs_surface_body: if (cmp_nocase_uh(name, "alpha") == 0) { EggRenderMode::AlphaMode a = EggRenderMode::string_alpha_mode(strval); if (a == EggRenderMode::AM_unspecified) { - eggyywarning("Unknown alpha mode " + strval); + eggyywarning(&@5, scanner, "Unknown alpha mode " + strval); } else { primitive->set_alpha_mode(a); } @@ -2195,7 +2204,7 @@ nurbs_surface_body: EggRenderMode::DepthWriteMode m = EggRenderMode::string_depth_write_mode(strval); if (m == EggRenderMode::DWM_unspecified) { - eggyywarning("Unknown depth-write mode " + strval); + eggyywarning(&@5, scanner, "Unknown depth-write mode " + strval); } else { primitive->set_depth_write_mode(m); } @@ -2204,7 +2213,7 @@ nurbs_surface_body: EggRenderMode::DepthTestMode m = EggRenderMode::string_depth_test_mode(strval); if (m == EggRenderMode::DTM_unspecified) { - eggyywarning("Unknown depth-test mode " + strval); + eggyywarning(&@5, scanner, "Unknown depth-test mode " + strval); } else { primitive->set_depth_test_mode(m); } @@ -2213,7 +2222,7 @@ nurbs_surface_body: EggRenderMode::VisibilityMode m = EggRenderMode::string_visibility_mode(strval); if (m == EggRenderMode::VM_unspecified) { - eggyywarning("Unknown visibility mode " + strval); + eggyywarning(&@5, scanner, "Unknown visibility mode " + strval); } else { primitive->set_visibility_mode(m); } @@ -2229,7 +2238,7 @@ nurbs_surface_body: } else if (cmp_nocase_uh(name, "v_subdiv") == 0) { primitive->set_v_subdiv((int)value); } else { - eggyywarning("Unknown scalar " + name); + eggyywarning(&@3, scanner, "Unknown scalar " + name); } } ; @@ -2255,7 +2264,7 @@ nurbs_curve_body: | nurbs_curve_body KNOTS '{' nurbs_curve_knots_body '}' | nurbs_curve_body SCALAR required_name '{' real_or_string '}' { - EggNurbsCurve *primitive = DCAST(EggNurbsCurve, egg_stack.back()); + EggNurbsCurve *primitive = DCAST(EggNurbsCurve, state.stack.back()); string name = $3; double value = $<_number>5; string strval = $<_string>5; @@ -2263,7 +2272,7 @@ nurbs_curve_body: if (cmp_nocase_uh(name, "alpha") == 0) { EggRenderMode::AlphaMode a = EggRenderMode::string_alpha_mode(strval); if (a == EggRenderMode::AM_unspecified) { - eggyywarning("Unknown alpha mode " + strval); + eggyywarning(&@5, scanner, "Unknown alpha mode " + strval); } else { primitive->set_alpha_mode(a); } @@ -2271,7 +2280,7 @@ nurbs_curve_body: EggRenderMode::DepthWriteMode m = EggRenderMode::string_depth_write_mode(strval); if (m == EggRenderMode::DWM_unspecified) { - eggyywarning("Unknown depth-write mode " + strval); + eggyywarning(&@5, scanner, "Unknown depth-write mode " + strval); } else { primitive->set_depth_write_mode(m); } @@ -2280,7 +2289,7 @@ nurbs_curve_body: EggRenderMode::DepthTestMode m = EggRenderMode::string_depth_test_mode(strval); if (m == EggRenderMode::DTM_unspecified) { - eggyywarning("Unknown depth-test mode " + strval); + eggyywarning(&@5, scanner, "Unknown depth-test mode " + strval); } else { primitive->set_depth_test_mode(m); } @@ -2289,7 +2298,7 @@ nurbs_curve_body: EggRenderMode::VisibilityMode m = EggRenderMode::string_visibility_mode(strval); if (m == EggRenderMode::VM_unspecified) { - eggyywarning("Unknown visibility mode " + strval); + eggyywarning(&@5, scanner, "Unknown visibility mode " + strval); } else { primitive->set_visibility_mode(m); } @@ -2305,13 +2314,13 @@ nurbs_curve_body: } else if (cmp_nocase_uh(name, "type") == 0) { EggCurve::CurveType a = EggCurve::string_curve_type(strval); if (a == EggCurve::CT_none) { - eggyywarning("Unknown curve type " + strval); + eggyywarning(&@5, scanner, "Unknown curve type " + strval); } else { primitive->set_curve_type(a); } } else { - eggyywarning("Unknown scalar " + name); + eggyywarning(&@3, scanner, "Unknown scalar " + name); } } ; @@ -2328,7 +2337,7 @@ primitive_tref_body: { if ($1 != nullptr) { EggTexture *texture = DCAST(EggTexture, $1); - DCAST(EggPrimitive, egg_stack.back())->add_texture(texture); + DCAST(EggPrimitive, state.stack.back())->add_texture(texture); } } ; @@ -2349,27 +2358,27 @@ primitive_texture_body: Filename filename = $1; string tref_name = filename.get_basename(); - Textures::iterator vpi = textures.find(tref_name); - if (vpi == textures.end()) { + Textures::iterator vpi = state.textures.find(tref_name); + if (vpi == state.textures.end()) { // The texture was not yet defined. Define it. texture = new EggTexture(tref_name, filename); - textures[tref_name] = texture; + state.textures[tref_name] = texture; - if (egg_top_node != nullptr) { - egg_top_node->add_child(texture); + if (state.top_node != nullptr) { + state.top_node->add_child(texture); } } else { // The texture already existed. Use it. texture = (*vpi).second; if (filename != texture->get_filename()) { - eggyywarning(string("Using previous path: ") + + eggyywarning(&@1, scanner, string("Using previous path: ") + texture->get_filename().get_fullpath()); } } nassertr(texture != nullptr, 0); - DCAST(EggPrimitive, egg_stack.back())->add_texture(texture); + DCAST(EggPrimitive, state.stack.back())->add_texture(texture); } ; @@ -2385,7 +2394,7 @@ primitive_material_body: { if ($1 != nullptr) { EggMaterial *material = DCAST(EggMaterial, $1); - DCAST(EggPrimitive, egg_stack.back())->set_material(material); + DCAST(EggPrimitive, state.stack.back())->set_material(material); } } ; @@ -2400,22 +2409,22 @@ primitive_material_body: primitive_normal_body: real real real { - DCAST(EggPrimitive, egg_stack.back())->set_normal(LNormald($1, $2, $3)); + DCAST(EggPrimitive, state.stack.back())->set_normal(LNormald($1, $2, $3)); } | primitive_normal_body DNORMAL string '{' real real real '}' { - bool inserted = DCAST(EggPrimitive, egg_stack.back())->_dnormals. + bool inserted = DCAST(EggPrimitive, state.stack.back())->_dnormals. insert(EggMorphNormal($3, LVector3d($5, $6, $7))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $3); + eggyywarning(&@3, scanner, "Ignoring repeated morph name " + $3); } } | primitive_normal_body DNORMAL '{' string real real real '}' { - bool inserted = DCAST(EggPrimitive, egg_stack.back())->_dnormals. + bool inserted = DCAST(EggPrimitive, state.stack.back())->_dnormals. insert(EggMorphNormal($4, LVector3d($5, $6, $7))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $4); + eggyywarning(&@4, scanner, "Ignoring repeated morph name " + $4); } } ; @@ -2430,22 +2439,22 @@ primitive_normal_body: primitive_color_body: real real real real { - DCAST(EggPrimitive, egg_stack.back())->set_color(LColor($1, $2, $3, $4)); + DCAST(EggPrimitive, state.stack.back())->set_color(LColor($1, $2, $3, $4)); } | primitive_color_body DRGBA string '{' real real real real '}' { - bool inserted = DCAST(EggPrimitive, egg_stack.back())->_drgbas. + bool inserted = DCAST(EggPrimitive, state.stack.back())->_drgbas. insert(EggMorphColor($3, LVector4($5, $6, $7, $8))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $3); + eggyywarning(&@3, scanner, "Ignoring repeated morph name " + $3); } } | primitive_color_body DRGBA '{' string real real real real '}' { - bool inserted = DCAST(EggPrimitive, egg_stack.back())->_drgbas. + bool inserted = DCAST(EggPrimitive, state.stack.back())->_drgbas. insert(EggMorphColor($4, LVector4($5, $6, $7, $8))).second; if (!inserted) { - eggyywarning("Ignoring repeated morph name " + $4); + eggyywarning(&@4, scanner, "Ignoring repeated morph name " + $4); } } ; @@ -2460,7 +2469,7 @@ primitive_color_body: primitive_bface_body: integer { - EggPrimitive *primitive = DCAST(EggPrimitive, egg_stack.back()); + EggPrimitive *primitive = DCAST(EggPrimitive, state.stack.back()); int value = (int)$1; primitive->set_bface_flag(value!=0); } @@ -2478,7 +2487,7 @@ primitive_vertex_ref: { if ($6 != nullptr) { EggVertexPool *pool = DCAST(EggVertexPool, $6); - EggPrimitive *prim = DCAST(EggPrimitive, egg_stack.back()); + EggPrimitive *prim = DCAST(EggPrimitive, state.stack.back()); PTA_double nums = $3; for (int i = 0; i < (int)nums.size(); i++) { @@ -2488,7 +2497,7 @@ primitive_vertex_ref: ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() << std::ends; - eggyyerror(errmsg); + eggyyerror(&@3, scanner, errmsg.str()); } else { prim->add_vertex(vertex); } @@ -2507,7 +2516,7 @@ primitive_vertex_ref: nurbs_surface_order_body: integer integer { - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); int u_order = (int)$1; int v_order = (int)$2; nurbs->set_u_order(u_order); @@ -2525,7 +2534,7 @@ nurbs_surface_order_body: nurbs_surface_uknots_body: real_list { - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); PTA_double nums = $1; nurbs->set_num_u_knots(nums.size()); @@ -2545,7 +2554,7 @@ nurbs_surface_uknots_body: nurbs_surface_vknots_body: real_list { - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); PTA_double nums = $1; nurbs->set_num_v_knots(nums.size()); @@ -2565,7 +2574,7 @@ nurbs_surface_vknots_body: nurbs_surface_trim_body: empty { - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); nurbs->_trims.push_back(EggNurbsSurface::Trim()); } | nurbs_surface_trim_body LOOP '{' nurbs_surface_trim_loop_body '}' @@ -2581,13 +2590,13 @@ nurbs_surface_trim_body: nurbs_surface_trim_loop_body: empty { - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); nassertr(!nurbs->_trims.empty(), 0); nurbs->_trims.back().push_back(EggNurbsSurface::Loop()); } | nurbs_surface_trim_loop_body nurbs_curve { - EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, egg_stack.back()); + EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, state.stack.back()); nassertr(!nurbs->_trims.empty(), 0); nassertr(!nurbs->_trims.back().empty(), 0); EggNurbsCurve *curve = DCAST(EggNurbsCurve, $2); @@ -2606,7 +2615,7 @@ nurbs_surface_trim_loop_body: nurbs_curve_order_body: integer { - EggNurbsCurve *nurbs = DCAST(EggNurbsCurve, egg_stack.back()); + EggNurbsCurve *nurbs = DCAST(EggNurbsCurve, state.stack.back()); int order = (int)$1; nurbs->set_order(order); } @@ -2622,7 +2631,7 @@ nurbs_curve_order_body: nurbs_curve_knots_body: real_list { - EggNurbsCurve *nurbs = DCAST(EggNurbsCurve, egg_stack.back()); + EggNurbsCurve *nurbs = DCAST(EggNurbsCurve, state.stack.back()); PTA_double nums = $1; nurbs->set_num_knots(nums.size()); @@ -2645,12 +2654,12 @@ table: { EggTable *table = new EggTable($2); table->set_table_type(EggTable::TT_table); - egg_stack.push_back(table); + state.stack.push_back(table); } '{' table_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); Thread::consider_yield(); } ; @@ -2668,12 +2677,12 @@ bundle: { EggTable *table = new EggTable($2); table->set_table_type(EggTable::TT_bundle); - egg_stack.push_back(table); + state.stack.push_back(table); } '{' table_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -2688,23 +2697,23 @@ table_body: empty | table_body table { - DCAST(EggTable, egg_stack.back())->add_child(DCAST(EggNode, $2)); + DCAST(EggTable, state.stack.back())->add_child(DCAST(EggNode, $2)); } | table_body bundle { - DCAST(EggTable, egg_stack.back())->add_child(DCAST(EggNode, $2)); + DCAST(EggTable, state.stack.back())->add_child(DCAST(EggNode, $2)); } | table_body sanim { - DCAST(EggTable, egg_stack.back())->add_child(DCAST(EggNode, $2)); + DCAST(EggTable, state.stack.back())->add_child(DCAST(EggNode, $2)); } | table_body xfmanim { - DCAST(EggTable, egg_stack.back())->add_child(DCAST(EggNode, $2)); + DCAST(EggTable, state.stack.back())->add_child(DCAST(EggNode, $2)); } | table_body xfm_s_anim { - DCAST(EggTable, egg_stack.back())->add_child(DCAST(EggNode, $2)); + DCAST(EggTable, state.stack.back())->add_child(DCAST(EggNode, $2)); } ; @@ -2720,12 +2729,12 @@ sanim: SANIM optional_name { EggSAnimData *anim_data = new EggSAnimData($2); - egg_stack.push_back(anim_data); + state.stack.push_back(anim_data); } '{' sanim_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -2741,19 +2750,19 @@ sanim_body: empty | sanim_body SCALAR required_name '{' real_or_string '}' { - EggSAnimData *anim_data = DCAST(EggSAnimData, egg_stack.back()); + EggSAnimData *anim_data = DCAST(EggSAnimData, state.stack.back()); string name = $3; double value = $<_number>5; if (cmp_nocase_uh(name, "fps") == 0) { anim_data->set_fps(value); } else { - eggyywarning("Unsupported S$Anim scalar: " + name); + eggyywarning(&@3, scanner, "Unsupported S$Anim scalar: " + name); } } | sanim_body TABLE_V '{' real_list '}' { - DCAST(EggSAnimData, egg_stack.back())->set_data($4); + DCAST(EggSAnimData, state.stack.back())->set_data($4); } ; @@ -2768,12 +2777,12 @@ xfmanim: XFMANIM optional_name { EggXfmAnimData *anim_data = new EggXfmAnimData($2); - egg_stack.push_back(anim_data); + state.stack.push_back(anim_data); } '{' xfmanim_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -2789,7 +2798,7 @@ xfmanim_body: empty | xfmanim_body SCALAR required_name '{' real_or_string '}' { - EggXfmAnimData *anim_data = DCAST(EggXfmAnimData, egg_stack.back()); + EggXfmAnimData *anim_data = DCAST(EggXfmAnimData, state.stack.back()); string name = $3; double value = $<_number>5; string strval = $<_string>5; @@ -2801,12 +2810,12 @@ xfmanim_body: } else if (cmp_nocase_uh(name, "contents") == 0) { anim_data->set_contents(strval); } else { - eggyywarning("Unsupported Xfm$Anim scalar: " + name); + eggyywarning(&@3, scanner, "Unsupported Xfm$Anim scalar: " + name); } } | xfmanim_body TABLE_V '{' real_list '}' { - DCAST(EggXfmAnimData, egg_stack.back())->set_data($4); + DCAST(EggXfmAnimData, state.stack.back())->set_data($4); } ; @@ -2821,12 +2830,12 @@ xfm_s_anim: XFMSANIM optional_name { EggXfmSAnim *anim_group = new EggXfmSAnim($2); - egg_stack.push_back(anim_group); + state.stack.push_back(anim_group); } '{' xfm_s_anim_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -2842,7 +2851,7 @@ xfm_s_anim_body: empty | xfm_s_anim_body SCALAR required_name '{' real_or_string '}' { - EggXfmSAnim *anim_group = DCAST(EggXfmSAnim, egg_stack.back()); + EggXfmSAnim *anim_group = DCAST(EggXfmSAnim, state.stack.back()); string name = $3; double value = $<_number>5; string strval = $<_string>5; @@ -2852,12 +2861,12 @@ xfm_s_anim_body: } else if (cmp_nocase_uh(name, "order") == 0) { anim_group->set_order(strval); } else { - eggyywarning("Unsupported Xfm$Anim_S$ scalar: " + name); + eggyywarning(&@3, scanner, "Unsupported Xfm$Anim_S$ scalar: " + name); } } | xfm_s_anim_body sanim { - DCAST(EggXfmSAnim, egg_stack.back())->add_child(DCAST(EggNode, $2)); + DCAST(EggXfmSAnim, state.stack.back())->add_child(DCAST(EggNode, $2)); } ; @@ -2873,12 +2882,12 @@ anim_preload: ANIMPRELOAD optional_name { EggAnimPreload *anim_preload = new EggAnimPreload($2); - egg_stack.push_back(anim_preload); + state.stack.push_back(anim_preload); } '{' anim_preload_body '}' { - $$ = egg_stack.back(); - egg_stack.pop_back(); + $$ = state.stack.back(); + state.stack.pop_back(); } ; @@ -2894,7 +2903,7 @@ anim_preload_body: empty | anim_preload_body SCALAR required_name '{' real_or_string '}' { - EggAnimPreload *anim_preload = DCAST(EggAnimPreload, egg_stack.back()); + EggAnimPreload *anim_preload = DCAST(EggAnimPreload, state.stack.back()); string name = $3; double value = $<_number>5; @@ -2903,7 +2912,7 @@ anim_preload_body: } else if (cmp_nocase_uh(name, "frames") == 0) { anim_preload->set_num_frames((int)value); } else { - eggyywarning("Unsupported AnimPreload scalar: " + name); + eggyywarning(&@3, scanner, "Unsupported AnimPreload scalar: " + name); } } ; @@ -2955,9 +2964,9 @@ texture_name: required_name { string name = $1; - Textures::iterator vpi = textures.find(name); - if (vpi == textures.end()) { - eggyyerror("Unknown texture " + name); + Textures::iterator vpi = state.textures.find(name); + if (vpi == state.textures.end()) { + eggyyerror(&@1, scanner, "Unknown texture " + name); $$ = PT(EggObject)(); } else { $$ = (*vpi).second; @@ -2976,9 +2985,9 @@ material_name: required_name { string name = $1; - Materials::iterator vpi = materials.find(name); - if (vpi == materials.end()) { - eggyyerror("Unknown material " + name); + Materials::iterator vpi = state.materials.find(name); + if (vpi == state.materials.end()) { + eggyyerror(&@1, scanner, "Unknown material " + name); $$ = PT(EggObject)(); } else { $$ = (*vpi).second; @@ -2997,13 +3006,13 @@ vertex_pool_name: required_name { string name = $1; - VertexPools::iterator vpi = vertex_pools.find(name); - if (vpi == vertex_pools.end()) { + VertexPools::iterator vpi = state.vertex_pools.find(name); + if (vpi == state.vertex_pools.end()) { // This will become a forward reference. EggVertexPool *pool = new EggVertexPool(name); // The egg syntax starts counting at 1 by convention. pool->set_highest_index(0); - vertex_pools[name] = pool; + state.vertex_pools[name] = pool; $$ = pool; } else { $$ = (*vpi).second; @@ -3022,9 +3031,9 @@ group_name: required_name { string name = $1; - Groups::iterator vpi = groups.find(name); - if (vpi == groups.end()) { - eggyyerror("Unknown group " + name); + Groups::iterator vpi = state.groups.find(name); + if (vpi == state.groups.end()) { + eggyyerror(&@1, scanner, "Unknown group " + name); $$ = PT(EggObject)(); } else { $$ = (*vpi).second; @@ -3042,7 +3051,7 @@ group_name: required_name: empty { - eggyyerror("Name required."); + eggyyerror(&@1, scanner, "Name required."); $$ = ""; } | string @@ -3071,7 +3080,7 @@ optional_name: required_string: empty { - eggyyerror("String required."); + eggyyerror(&@1, scanner, "String required."); $$ = ""; } | string @@ -3211,7 +3220,7 @@ integer: { int i = (int)$1; if ((double)i != $1) { - eggyywarning("Integer expected."); + eggyywarning(&@1, scanner, "Integer expected."); $$ = (double)i; } } diff --git a/panda/src/egg/parserDefs.h b/panda/src/egg/parserDefs.h index b20cba96db..d30c91ee5c 100644 --- a/panda/src/egg/parserDefs.h +++ b/panda/src/egg/parserDefs.h @@ -27,12 +27,9 @@ class EggGroupNode; class LightMutex; -extern LightMutex egg_lock; +struct EggLexerState; -void egg_init_parser(std::istream &in, const std::string &filename, - EggObject *tos, EggGroupNode *egg_top_node); - -void egg_cleanup_parser(); +bool egg_parse(EggLexerState &lexer, EggObject *tos, EggGroupNode *egg_top_node); // This structure holds the return value for each token. Traditionally, this // is a union, and is declared with the %union declaration in the parser.y @@ -40,8 +37,7 @@ void egg_cleanup_parser(); // that has member functions in a union), so we'll use a class instead. That // means we need to declare it externally, here. -class EXPCL_PANDA_EGG EggTokenType { -public: +struct EggTokenType { double _number; unsigned long _ulong; std::string _string; @@ -53,4 +49,14 @@ public: // above class. #define YYSTYPE EggTokenType +struct EggLocType { + // Bison expects these members to be part of this struct. + int first_line; + int first_column; + int last_line; + int last_column; +}; + +#define YYLTYPE EggLocType + #endif