diff --git a/pandatool/src/xfile/windowsGuid.cxx b/pandatool/src/xfile/windowsGuid.cxx index a8b063b038..c992113c15 100644 --- a/pandatool/src/xfile/windowsGuid.cxx +++ b/pandatool/src/xfile/windowsGuid.cxx @@ -31,11 +31,11 @@ //////////////////////////////////////////////////////////////////// bool WindowsGuid:: parse_string(const string &str) { - long data1; - short data2, data3; - short b1, b2, b3, b4, b5, b6, b7, b8; + unsigned long data1; + unsigned int data2, data3; + unsigned int b1, b2, b3, b4, b5, b6, b7, b8; int result = sscanf(str.c_str(), - "%08lx-%04hx-%04hx-%02x%02x-%02x%02x%02x%02x%02x%02x", + "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", &data1, &data2, &data3, &b1, &b2, &b3, &b4, &b5, &b6, &b7, &b8); if (result != 11) { @@ -70,7 +70,7 @@ format_string() const { "%08lx-%04hx-%04hx-%02x%02x-%02x%02x%02x%02x%02x%02x", _data1, _data2, _data3, _b1, _b2, _b3, _b4, _b5, _b6, _b7, _b8); - nassertr(strlen(buffer) < buf_length, string()); + nassertr((int)strlen(buffer) < buf_length, string()); return string(buffer); } diff --git a/pandatool/src/xfile/xLexer.cxx.prebuilt b/pandatool/src/xfile/xLexer.cxx.prebuilt index 9b9a897691..0933902729 100644 --- a/pandatool/src/xfile/xLexer.cxx.prebuilt +++ b/pandatool/src/xfile/xLexer.cxx.prebuilt @@ -300,21 +300,25 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); *yy_cp = '\0'; \ yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 26 -#define YY_END_OF_BUFFER 27 -static yyconst short int yy_accept[99] = +#define YY_NUM_RULES 34 +#define YY_END_OF_BUFFER 35 +static yyconst short int yy_accept[132] = { 0, - 0, 0, 27, 25, 2, 1, 21, 4, 22, 25, - 24, 25, 25, 18, 18, 23, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 1, 4, 0, 18, - 24, 18, 0, 20, 3, 20, 19, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 17, - 0, 3, 19, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 0, 20, 24, 6, 7, - 24, 24, 24, 24, 24, 24, 24, 24, 16, 5, - 24, 24, 10, 11, 24, 24, 14, 24, 24, 9, - 12, 24, 24, 8, 24, 15, 13, 0 + 0, 0, 35, 34, 2, 1, 31, 4, 34, 10, + 33, 9, 34, 26, 11, 32, 7, 8, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 5, 6, + 1, 4, 0, 26, 33, 26, 0, 3, 29, 0, + 27, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 30, 28, 0, 3, 0, + 0, 0, 0, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 0, 0, 0, + 0, 0, 0, 0, 0, 33, 13, 14, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 25, 0, + 0, 0, 0, 12, 33, 33, 17, 19, 33, 33, + 24, 33, 22, 33, 0, 0, 33, 16, 18, 20, + 33, 33, 0, 0, 0, 0, 15, 33, 23, 21, + 0 } ; static yyconst int yy_ec[256] = @@ -322,17 +326,17 @@ static yyconst int yy_ec[256] = 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 4, 5, 1, 1, 1, 6, 1, - 1, 1, 7, 1, 8, 9, 10, 11, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 1, 1, 13, - 1, 1, 1, 1, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 14, 14, 24, 25, 26, 27, 28, - 14, 29, 30, 31, 32, 14, 33, 34, 35, 14, - 1, 1, 1, 1, 14, 1, 15, 16, 17, 18, + 1, 2, 1, 4, 5, 1, 1, 1, 1, 1, + 1, 1, 6, 7, 8, 9, 10, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 1, 12, 13, + 1, 1, 1, 1, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 16, 16, 26, 27, 28, 29, 30, + 16, 31, 32, 33, 34, 16, 35, 16, 36, 16, + 14, 1, 15, 1, 16, 1, 17, 18, 19, 20, - 19, 20, 21, 22, 23, 14, 14, 24, 25, 26, - 27, 28, 14, 29, 30, 31, 32, 14, 33, 34, - 35, 14, 1, 1, 1, 1, 1, 1, 1, 1, + 21, 22, 23, 24, 25, 16, 16, 26, 27, 28, + 29, 30, 16, 31, 32, 33, 34, 16, 35, 16, + 36, 16, 37, 1, 38, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -349,106 +353,126 @@ static yyconst int yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst int yy_meta[36] = +static yyconst int yy_meta[39] = { 0, 1, 1, 2, 1, 1, 1, 1, 3, 3, 1, - 4, 4, 1, 3, 4, 4, 4, 4, 4, 4, + 3, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3 + 3, 3, 3, 3, 3, 3, 1, 1 } ; -static yyconst short int yy_base[104] = +static yyconst short int yy_base[136] = { 0, - 0, 0, 207, 208, 208, 0, 208, 0, 208, 27, - 31, 35, 196, 39, 43, 208, 196, 28, 32, 36, - 44, 40, 47, 50, 53, 54, 0, 0, 49, 63, - 195, 71, 194, 73, 0, 75, 0, 59, 67, 80, - 81, 82, 84, 88, 87, 92, 91, 95, 90, 208, - 95, 0, 0, 111, 112, 96, 99, 113, 101, 118, - 100, 115, 123, 125, 126, 125, 128, 132, 191, 185, - 136, 137, 138, 139, 140, 141, 142, 145, 181, 178, - 143, 144, 175, 174, 153, 149, 173, 159, 164, 172, - 171, 148, 167, 166, 169, 151, 146, 208, 188, 192, + 0, 0, 271, 272, 272, 0, 272, 0, 30, 272, + 31, 259, 259, 36, 272, 272, 272, 272, 259, 35, + 37, 40, 41, 42, 45, 46, 43, 48, 272, 272, + 0, 0, 256, 49, 257, 72, 75, 0, 82, 87, + 89, 44, 76, 93, 80, 82, 83, 92, 94, 95, + 96, 97, 50, 98, 102, 109, 126, 130, 0, 254, + 120, 253, 128, 105, 121, 119, 134, 135, 136, 137, + 139, 138, 140, 142, 143, 147, 149, 146, 252, 150, + 153, 251, 164, 249, 167, 161, 248, 245, 167, 168, + 171, 172, 173, 174, 175, 177, 176, 179, 242, 189, - 194, 198, 61 + 202, 178, 200, 241, 178, 205, 240, 239, 207, 192, + 237, 208, 236, 209, 222, 226, 213, 235, 233, 232, + 210, 226, 220, 213, 187, 227, 184, 231, 110, 60, + 272, 252, 255, 60, 258 } ; -static yyconst short int yy_def[104] = +static yyconst short int yy_def[136] = { 0, - 98, 1, 98, 98, 98, 99, 98, 100, 98, 98, - 101, 98, 98, 98, 98, 98, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 99, 100, 98, 98, - 101, 101, 98, 98, 102, 98, 103, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 98, - 98, 102, 103, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 98, 98, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 0, 98, 98, + 131, 1, 131, 131, 131, 132, 131, 133, 131, 131, + 134, 131, 131, 131, 131, 131, 131, 131, 134, 134, + 134, 134, 134, 134, 134, 134, 134, 134, 131, 131, + 132, 133, 131, 131, 134, 134, 131, 135, 131, 131, + 131, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 134, 131, 131, 131, 135, 131, + 131, 131, 131, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 134, 134, 134, 131, 131, 131, + 131, 131, 131, 131, 131, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 131, - 98, 98, 98 + 131, 131, 131, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 131, 131, 134, 134, 134, 134, + 134, 134, 131, 131, 131, 131, 134, 134, 134, 134, + 0, 131, 131, 131, 131 } ; -static yyconst short int yy_nxt[244] = +static yyconst short int yy_nxt[311] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 17, 22, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 23, - 24, 25, 26, 17, 17, 29, 98, 30, 30, 29, - 98, 32, 32, 33, 98, 34, 34, 36, 98, 30, - 30, 36, 98, 30, 30, 98, 38, 40, 98, 34, - 34, 98, 98, 44, 53, 41, 39, 98, 46, 47, - 42, 36, 37, 30, 30, 98, 43, 45, 48, 36, - 49, 32, 32, 34, 34, 34, 34, 54, 98, 98, - 98, 51, 98, 51, 56, 98, 98, 55, 98, 98, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 19, 24, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 25, 26, 27, 28, 19, 29, 30, 33, 33, + 34, 36, 39, 131, 40, 131, 34, 41, 131, 131, + 131, 131, 131, 131, 131, 39, 131, 40, 131, 34, + 41, 53, 35, 44, 49, 42, 52, 48, 131, 46, + 54, 45, 43, 75, 64, 47, 55, 50, 39, 51, + 40, 56, 36, 41, 131, 37, 57, 60, 131, 60, + 131, 131, 61, 56, 62, 58, 62, 37, 57, 63, - 98, 66, 66, 98, 98, 67, 67, 98, 98, 98, - 59, 57, 63, 58, 60, 61, 62, 64, 65, 98, - 98, 98, 75, 98, 70, 68, 98, 71, 72, 73, - 69, 98, 74, 98, 98, 67, 67, 77, 67, 67, - 98, 78, 76, 79, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 83, 98, 98, 81, 98, - 82, 98, 90, 92, 86, 85, 80, 98, 89, 84, - 87, 88, 98, 91, 98, 98, 93, 98, 95, 98, - 98, 98, 98, 98, 94, 96, 98, 97, 27, 98, - 27, 27, 28, 98, 28, 28, 31, 31, 52, 98, + 131, 131, 131, 131, 131, 131, 131, 58, 65, 66, + 131, 69, 67, 131, 78, 68, 78, 79, 131, 80, + 70, 86, 76, 74, 73, 72, 39, 131, 71, 131, + 61, 81, 77, 81, 82, 84, 83, 84, 63, 41, + 85, 87, 131, 131, 131, 131, 131, 131, 131, 88, + 131, 131, 90, 92, 79, 131, 80, 131, 101, 97, + 80, 82, 94, 83, 89, 98, 91, 93, 99, 131, + 95, 96, 103, 56, 83, 131, 131, 85, 57, 131, + 131, 131, 131, 131, 131, 131, 131, 131, 102, 57, + 107, 105, 131, 106, 111, 56, 104, 126, 116, 100, - 52, 52, 50, 98, 98, 35, 98, 3, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98 + 131, 110, 112, 109, 108, 117, 113, 114, 56, 115, + 102, 57, 100, 131, 120, 131, 131, 131, 131, 56, + 116, 131, 115, 124, 121, 118, 119, 123, 122, 123, + 124, 125, 124, 125, 131, 127, 126, 126, 57, 131, + 131, 131, 128, 131, 131, 131, 129, 131, 131, 131, + 131, 130, 31, 131, 31, 32, 131, 32, 59, 85, + 59, 102, 100, 63, 61, 131, 37, 131, 38, 37, + 131, 3, 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, + + 131, 131, 131, 131, 131, 131, 131, 131, 131, 131 } ; -static yyconst short int yy_chk[244] = +static yyconst short int yy_chk[311] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 10, 18, 10, 10, 11, - 19, 11, 11, 12, 20, 12, 12, 14, 22, 14, - 14, 15, 21, 15, 15, 23, 18, 20, 24, 29, - 29, 25, 26, 22, 103, 20, 19, 38, 24, 25, - 21, 30, 14, 30, 30, 39, 21, 23, 25, 32, - 26, 32, 32, 34, 34, 36, 36, 38, 40, 41, - 42, 34, 43, 36, 40, 45, 44, 39, 49, 47, + 1, 1, 1, 1, 1, 1, 1, 1, 9, 11, + 9, 11, 14, 20, 14, 21, 14, 14, 22, 23, + 24, 27, 42, 25, 26, 34, 28, 34, 53, 34, + 34, 27, 134, 22, 25, 20, 26, 24, 130, 23, + 27, 22, 21, 53, 42, 23, 28, 25, 36, 25, + 36, 37, 36, 36, 43, 37, 37, 39, 45, 39, + 46, 47, 39, 40, 41, 37, 41, 40, 40, 41, - 46, 51, 51, 48, 56, 51, 51, 57, 61, 59, - 43, 41, 47, 42, 44, 45, 46, 48, 49, 54, - 55, 58, 61, 62, 56, 54, 60, 57, 58, 59, - 55, 63, 60, 64, 65, 66, 66, 63, 67, 67, - 68, 64, 62, 65, 71, 72, 73, 74, 75, 76, - 77, 81, 82, 78, 97, 73, 92, 86, 71, 96, - 72, 85, 82, 86, 76, 75, 68, 88, 81, 74, - 77, 78, 89, 85, 94, 93, 88, 95, 92, 91, - 90, 87, 84, 83, 89, 93, 80, 95, 99, 79, - 99, 99, 100, 70, 100, 100, 101, 101, 102, 69, + 48, 44, 49, 50, 51, 52, 54, 40, 43, 44, + 55, 47, 45, 64, 56, 46, 56, 56, 129, 56, + 48, 64, 54, 52, 51, 50, 61, 66, 49, 65, + 61, 57, 55, 57, 57, 58, 57, 58, 63, 63, + 58, 65, 67, 68, 69, 70, 72, 71, 73, 66, + 74, 75, 68, 70, 78, 76, 78, 77, 80, 75, + 80, 81, 72, 81, 67, 76, 69, 71, 77, 86, + 73, 74, 83, 85, 83, 89, 90, 85, 85, 91, + 92, 93, 94, 95, 97, 96, 105, 98, 102, 102, + 91, 89, 127, 90, 95, 100, 86, 125, 102, 100, - 102, 102, 33, 31, 17, 13, 3, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98 + 110, 94, 96, 93, 92, 105, 97, 98, 101, 100, + 103, 103, 101, 106, 110, 109, 112, 114, 121, 124, + 103, 117, 101, 124, 112, 106, 109, 115, 114, 115, + 123, 116, 115, 116, 122, 117, 116, 126, 126, 128, + 120, 119, 121, 118, 113, 111, 122, 108, 107, 104, + 99, 128, 132, 88, 132, 133, 87, 133, 135, 84, + 135, 82, 79, 62, 60, 35, 33, 19, 13, 12, + 3, 131, 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, + + 131, 131, 131, 131, 131, 131, 131, 131, 131, 131 } ; static yy_state_type yy_last_accepting_state; @@ -475,6 +499,7 @@ char *yytext; #include "xParserDefs.h" #include "xParser.h" #include "indent.h" +#include "string_utils.h" #include "notify.h" static int yyinput(void); // declared by flex. @@ -805,6 +830,42 @@ scan_guid_string() { return result; } +// Parses the text into a list of integers and returns them. +static PTA_int +parse_int_list(const string &text, const string &delimiter) { + PTA_int result; + + vector_string words; + tokenize(text, words, delimiter); + + vector_string::const_iterator wi; + for (wi = words.begin(); wi != words.end(); ++wi) { + int number = 0; + string_to_int(*wi, number); + result.push_back(number); + } + + return result; +} + +// Parses the text into a list of doubles and returns them. +static PTA_double +parse_double_list(const string &text, const string &delimiter) { + PTA_double result; + + vector_string words; + tokenize(text, words, delimiter); + + vector_string::const_iterator wi; + for (wi = words.begin(); wi != words.end(); ++wi) { + double number = 0; + string_to_double(*wi, number); + result.push_back(number); + } + + return result; +} + // accept() is called below as each piece is pulled off and @@ -813,7 +874,7 @@ inline void accept() { col_number += yyleng; } -#line 818 "lex.yy.c" +#line 879 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -964,13 +1025,13 @@ YY_DECL register char *yy_cp = NULL, *yy_bp = NULL; register int yy_act; -#line 357 "xLexer.lxx" +#line 393 "xLexer.lxx" -#line 975 "lex.yy.c" +#line 1036 "lex.yy.c" if ( yy_init ) { @@ -1021,13 +1082,13 @@ yy_match: 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 >= 99 ) + if ( yy_current_state >= 132 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 208 ); + while ( yy_base[yy_current_state] != 272 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -1055,7 +1116,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 362 "xLexer.lxx" +#line 398 "xLexer.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. @@ -1072,7 +1133,7 @@ YY_RULE_SETUP YY_BREAK case 2: YY_RULE_SETUP -#line 376 "xLexer.lxx" +#line 412 "xLexer.lxx" { // Eat whitespace. accept(); @@ -1080,7 +1141,7 @@ YY_RULE_SETUP YY_BREAK case 3: YY_RULE_SETUP -#line 381 "xLexer.lxx" +#line 417 "xLexer.lxx" { // Eat C++-style comments. accept(); @@ -1088,7 +1149,7 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP -#line 386 "xLexer.lxx" +#line 422 "xLexer.lxx" { // Eat sh-style comments. accept(); @@ -1096,184 +1157,245 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 392 "xLexer.lxx" +#line 427 "xLexer.lxx" { accept(); - return KW_ARRAY; + return TOKEN_OBRACE; } YY_BREAK case 6: YY_RULE_SETUP -#line 397 "xLexer.lxx" +#line 432 "xLexer.lxx" { accept(); - return KW_BYTE; + return TOKEN_CBRACE; } YY_BREAK case 7: YY_RULE_SETUP -#line 402 "xLexer.lxx" +#line 437 "xLexer.lxx" { accept(); - return KW_CHAR; + return TOKEN_OBRACKET; } YY_BREAK case 8: YY_RULE_SETUP -#line 407 "xLexer.lxx" +#line 442 "xLexer.lxx" { accept(); - return KW_CSTRING; + return TOKEN_CBRACKET; } YY_BREAK case 9: YY_RULE_SETUP -#line 412 "xLexer.lxx" +#line 447 "xLexer.lxx" { accept(); - return KW_DOUBLE; + return TOKEN_DOT; } YY_BREAK case 10: YY_RULE_SETUP -#line 417 "xLexer.lxx" +#line 452 "xLexer.lxx" { accept(); - return KW_DWORD; + return TOKEN_COMMA; } YY_BREAK case 11: YY_RULE_SETUP -#line 422 "xLexer.lxx" +#line 457 "xLexer.lxx" { accept(); - return KW_FLOAT; + return TOKEN_SEMICOLON; } YY_BREAK case 12: YY_RULE_SETUP -#line 427 "xLexer.lxx" +#line 462 "xLexer.lxx" { accept(); - return KW_STRING; + return TOKEN_ARRAY; } YY_BREAK case 13: YY_RULE_SETUP -#line 432 "xLexer.lxx" +#line 467 "xLexer.lxx" { accept(); - return KW_TEMPLATE; + return TOKEN_UCHAR; } YY_BREAK case 14: YY_RULE_SETUP -#line 437 "xLexer.lxx" +#line 472 "xLexer.lxx" { accept(); - return KW_UCHAR; + return TOKEN_CHAR; } YY_BREAK case 15: YY_RULE_SETUP -#line 442 "xLexer.lxx" +#line 477 "xLexer.lxx" { accept(); - return KW_UNICODE; + return TOKEN_CSTRING; } YY_BREAK case 16: YY_RULE_SETUP -#line 447 "xLexer.lxx" +#line 482 "xLexer.lxx" { accept(); - return KW_WORD; + return TOKEN_DOUBLE; } YY_BREAK case 17: YY_RULE_SETUP -#line 452 "xLexer.lxx" +#line 487 "xLexer.lxx" { accept(); - return ELLIPSIS; + return TOKEN_DWORD; } YY_BREAK case 18: YY_RULE_SETUP -#line 457 "xLexer.lxx" -{ - // A signed or unsigned integer number. +#line 492 "xLexer.lxx" +{ accept(); - xyylval.u.s_int = atol(xyytext); - xyylval.str = yytext; - - return INTEGER; + return TOKEN_SDWORD; } YY_BREAK case 19: YY_RULE_SETUP -#line 466 "xLexer.lxx" +#line 497 "xLexer.lxx" { - // A hexadecimal integer number. - accept(); - - // As above, we'll decode the hex string by hand. - xyylval.str = xyytext; - xyylval.u.s_int = 0; - const char *p = xyytext + 2; - while (*p != '\0') { - int next_value = xyylval.u.s_int * 16; - if (next_value < xyylval.u.s_int) { - xyyerror("Number out of range."); - xyylval.u.s_int = 1; - return INTEGER; - } - - if (isalpha(*p)) { - xyylval.u.s_int = next_value + (tolower(*p) - 'a' + 10); - } else { - xyylval.u.s_int = next_value + (*p - '0'); - } - ++p; - } - - return INTEGER; + accept(); + return TOKEN_FLOAT; } YY_BREAK case 20: YY_RULE_SETUP -#line 493 "xLexer.lxx" -{ - // A floating-point number. - accept(); - xyylval.u.real = atof(xyytext); - xyylval.str = xyytext; - return REAL; +#line 502 "xLexer.lxx" +{ + accept(); + return TOKEN_LPSTR; } YY_BREAK case 21: YY_RULE_SETUP -#line 501 "xLexer.lxx" +#line 507 "xLexer.lxx" { - // Quoted string. accept(); - xyylval.str = scan_quoted_string('"'); - return STRING; + return TOKEN_TEMPLATE; } YY_BREAK case 22: YY_RULE_SETUP -#line 508 "xLexer.lxx" +#line 512 "xLexer.lxx" { - // Single-quoted string. accept(); - xyylval.str = scan_quoted_string('\''); - return STRING; + return TOKEN_UCHAR; } YY_BREAK case 23: YY_RULE_SETUP -#line 515 "xLexer.lxx" +#line 517 "xLexer.lxx" +{ + accept(); + return TOKEN_UNICODE; +} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 522 "xLexer.lxx" +{ + accept(); + return TOKEN_SWORD; +} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 527 "xLexer.lxx" +{ + accept(); + return TOKEN_WORD; +} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 532 "xLexer.lxx" +{ + // A signed or unsigned integer number. + accept(); + xyylval.u.number = atol(xyytext); + xyylval.str = yytext; + + return TOKEN_INTEGER; +} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 541 "xLexer.lxx" +{ + // An integer as part of a semicolon-delimited list. + accept(); + xyylval.int_list = parse_int_list(xyytext, ";"); + xyylval.u.separator_token = TOKEN_SEMICOLON; + + return TOKEN_INTEGER_LIST; +} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 550 "xLexer.lxx" +{ + // A floating-point number as part of a semicolon-delimited list. + accept(); + xyylval.double_list = parse_double_list(xyytext, ";"); + xyylval.u.separator_token = TOKEN_SEMICOLON; + + return TOKEN_REALNUM_LIST; +} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 559 "xLexer.lxx" +{ + // An integer as part of a semicolon-delimited list. + accept(); + xyylval.int_list = parse_int_list(xyytext, ","); + xyylval.u.separator_token = TOKEN_COMMA; + + return TOKEN_INTEGER_LIST; +} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 568 "xLexer.lxx" +{ + // A floating-point number as part of a semicolon-delimited list. + accept(); + xyylval.double_list = parse_double_list(xyytext, ","); + xyylval.u.separator_token = TOKEN_COMMA; + + return TOKEN_REALNUM_LIST; +} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 577 "xLexer.lxx" +{ + // Quoted string. + accept(); + xyylval.str = scan_quoted_string('"'); + return TOKEN_STRING; +} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 584 "xLexer.lxx" { // Long GUID string. accept(); @@ -1283,34 +1405,25 @@ YY_RULE_SETUP xyyerror("Malformed GUID."); } - return WINDOWS_GUID; + return TOKEN_GUID; } YY_BREAK -case 24: +case 33: YY_RULE_SETUP -#line 527 "xLexer.lxx" +#line 596 "xLexer.lxx" { // Identifier. accept(); xyylval.str = xyytext; - return IDENTIFIER; + return TOKEN_NAME; } YY_BREAK -case 25: +case 34: YY_RULE_SETUP -#line 535 "xLexer.lxx" -{ - // Send any other printable character as itself. - accept(); - return xyytext[0]; -} - YY_BREAK -case 26: -YY_RULE_SETUP -#line 541 "xLexer.lxx" +#line 604 "xLexer.lxx" ECHO; YY_BREAK -#line 1315 "lex.yy.c" +#line 1428 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1602,7 +1715,7 @@ static yy_state_type yy_get_previous_state() 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 >= 99 ) + if ( yy_current_state >= 132 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1637,11 +1750,11 @@ yy_state_type yy_current_state; 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 >= 99 ) + if ( yy_current_state >= 132 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 98); + yy_is_jam = (yy_current_state == 131); return yy_is_jam ? 0 : yy_current_state; } @@ -2191,4 +2304,4 @@ int main() return 0; } #endif -#line 541 "xLexer.lxx" +#line 604 "xLexer.lxx" diff --git a/pandatool/src/xfile/xParser.cxx.prebuilt b/pandatool/src/xfile/xParser.cxx.prebuilt index ab93021f8c..9872c840d6 100644 --- a/pandatool/src/xfile/xParser.cxx.prebuilt +++ b/pandatool/src/xfile/xParser.cxx.prebuilt @@ -10,26 +10,39 @@ #define yychar xyychar #define yydebug xyydebug #define yynerrs xyynerrs -# define INTEGER 257 -# define REAL 258 -# define STRING 259 -# define IDENTIFIER 260 -# define WINDOWS_GUID 261 -# define KW_ARRAY 262 -# define KW_BYTE 263 -# define KW_CHAR 264 -# define KW_CSTRING 265 -# define KW_DOUBLE 266 -# define KW_DWORD 267 -# define KW_FLOAT 268 -# define KW_STRING 269 -# define KW_TEMPLATE 270 -# define KW_UCHAR 271 -# define KW_UNICODE 272 -# define KW_WORD 273 -# define ELLIPSIS 274 +# define TOKEN_NAME 1 +# define TOKEN_STRING 2 +# define TOKEN_INTEGER 3 +# define TOKEN_GUID 5 +# define TOKEN_INTEGER_LIST 6 +# define TOKEN_REALNUM_LIST 7 +# define TOKEN_OBRACE 10 +# define TOKEN_CBRACE 11 +# define TOKEN_OPAREN 12 +# define TOKEN_CPAREN 13 +# define TOKEN_OBRACKET 14 +# define TOKEN_CBRACKET 15 +# define TOKEN_OANGLE 16 +# define TOKEN_CANGLE 17 +# define TOKEN_DOT 18 +# define TOKEN_COMMA 19 +# define TOKEN_SEMICOLON 20 +# define TOKEN_TEMPLATE 31 +# define TOKEN_WORD 40 +# define TOKEN_DWORD 41 +# define TOKEN_FLOAT 42 +# define TOKEN_DOUBLE 43 +# define TOKEN_CHAR 44 +# define TOKEN_UCHAR 45 +# define TOKEN_SWORD 46 +# define TOKEN_SDWORD 47 +# define TOKEN_VOID 48 +# define TOKEN_LPSTR 49 +# define TOKEN_UNICODE 50 +# define TOKEN_CSTRING 51 +# define TOKEN_ARRAY 52 -#line 6 "xParser.yxx" +#line 12 "xParser.yxx" #include "xLexerDefs.h" #include "xParserDefs.h" @@ -37,6 +50,8 @@ #include "xFileTemplate.h" #include "xFileDataDef.h" #include "xFileArrayDef.h" +#include "xFileDataObjectTemplate.h" +#include "pointerTo.h" #include "dcast.h" // Because our token type contains objects of type string, which @@ -49,7 +64,7 @@ static XFile *x_file = (XFile *)NULL; static XFileNode *current_node = (XFileNode *)NULL; -static XFileDataDef *current_data_def = (XFileDataDef *)NULL; +static PT(XFileDataDef) current_data_def = (XFileDataDef *)NULL; //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. @@ -74,29 +89,22 @@ x_cleanup_parser() { -#define YYFINAL 84 +#define YYFINAL 96 #define YYFLAG -32768 -#define YYNTBASE 27 +#define YYNTBASE 34 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ -#define YYTRANSLATE(x) ((unsigned)(x) <= 274 ? yytranslate[x] : 46) +#define YYTRANSLATE(x) ((unsigned)(x) <= 256 ? yytranslate[x] : 67) /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ static const char yytranslate[] = { - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 26, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 23, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 24, 2, 25, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 21, 2, 22, 2, 2, 2, 2, + 0, 3, 4, 5, 2, 6, 7, 8, 2, 2, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 20, 2, 2, 2, 2, 2, 2, 2, 2, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -109,36 +117,46 @@ static const char yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1 }; #if YYDEBUG static const short yyprhs[] = { - 0, 0, 2, 5, 8, 9, 18, 20, 24, 26, - 27, 32, 35, 38, 41, 44, 47, 50, 53, 56, - 59, 62, 65, 67, 70, 74, 78, 80, 84, 88, - 91, 96, 97, 104, 106, 109, 111, 113, 115, 117, - 119, 121, 123, 127, 129, 131, 133, 135 + 0, 0, 2, 5, 8, 9, 17, 22, 24, 26, + 28, 30, 32, 34, 37, 39, 41, 43, 47, 52, + 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, + 76, 78, 81, 84, 86, 89, 93, 95, 97, 99, + 102, 104, 107, 109, 111, 113, 115, 117, 119, 123, + 124, 132, 134, 137, 139, 141, 143, 145, 148, 150, + 152, 154, 156, 158, 160, 165 }; static const short yyrhs[] = { - 45, 0, 27, 28, 0, 27, 38, 0, 0, 16, - 6, 21, 7, 29, 30, 36, 22, 0, 45, 0, - 30, 31, 23, 0, 33, 0, 0, 8, 33, 32, - 34, 0, 19, 43, 0, 13, 43, 0, 14, 43, - 0, 12, 43, 0, 10, 43, 0, 17, 43, 0, - 9, 43, 0, 15, 43, 0, 11, 43, 0, 18, - 43, 0, 6, 43, 0, 35, 0, 34, 35, 0, - 24, 3, 25, 0, 24, 6, 25, 0, 45, 0, - 24, 20, 25, 0, 24, 37, 25, 0, 6, 44, - 0, 37, 26, 6, 44, 0, 0, 6, 43, 21, - 39, 40, 22, 0, 45, 0, 40, 41, 0, 38, - 0, 42, 0, 3, 0, 4, 0, 5, 0, 23, - 0, 26, 0, 21, 6, 22, 0, 45, 0, 6, - 0, 45, 0, 7, 0, 0 + 66, 0, 34, 35, 0, 34, 57, 0, 0, 20, + 52, 9, 54, 36, 37, 10, 0, 38, 13, 39, + 14, 0, 40, 0, 66, 0, 40, 0, 56, 0, + 50, 0, 41, 0, 40, 41, 0, 42, 0, 43, + 0, 44, 0, 45, 53, 19, 0, 33, 46, 47, + 19, 0, 52, 53, 19, 0, 21, 0, 22, 0, + 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, + 28, 0, 30, 0, 31, 0, 32, 0, 45, 52, + 0, 52, 52, 0, 48, 0, 47, 48, 0, 13, + 49, 14, 0, 5, 0, 52, 0, 51, 0, 50, + 51, 0, 52, 0, 52, 6, 0, 3, 0, 66, + 0, 52, 0, 6, 0, 66, 0, 54, 0, 17, + 17, 17, 0, 0, 52, 53, 9, 58, 55, 59, + 10, 0, 60, 0, 59, 60, 0, 65, 0, 57, + 0, 61, 0, 62, 0, 63, 64, 0, 64, 0, + 7, 0, 8, 0, 4, 0, 19, 0, 18, 0, + 9, 52, 55, 10, 0, 0 }; #endif @@ -147,11 +165,13 @@ static const short yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const short yyrline[] = { - 0, 72, 74, 75, 78, 78, 93, 95, 98, 103, - 103, 111, 116, 120, 124, 128, 132, 136, 140, 144, - 148, 152, 158, 160, 163, 168, 179, 181, 182, 185, - 189, 194, 194, 204, 206, 209, 213, 216, 219, 222, - 225, 228, 233, 237, 242, 245, 250, 253 + 0, 104, 106, 107, 110, 110, 125, 127, 130, 132, + 135, 140, 143, 145, 148, 150, 151, 154, 162, 166, + 179, 184, 188, 192, 196, 200, 204, 208, 212, 216, + 220, 226, 232, 244, 246, 249, 253, 258, 269, 273, + 278, 288, 303, 307, 312, 315, 319, 324, 327, 331, + 331, 353, 355, 358, 362, 365, 368, 371, 374, 379, + 383, 387, 391, 393, 396, 400 }; #endif @@ -161,36 +181,48 @@ static const short yyrline[] = /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ static const char *const yytname[] = { - "$", "error", "$undefined.", "INTEGER", "REAL", "STRING", "IDENTIFIER", - "WINDOWS_GUID", "KW_ARRAY", "KW_BYTE", "KW_CHAR", "KW_CSTRING", - "KW_DOUBLE", "KW_DWORD", "KW_FLOAT", "KW_STRING", "KW_TEMPLATE", - "KW_UCHAR", "KW_UNICODE", "KW_WORD", "ELLIPSIS", "'{'", "'}'", "';'", - "'['", "']'", "','", "xfile", "xtemplate", "@1", "template_members", - "template_member", "@2", "data_def", "array_dimensions", "array_level", - "template_restrictions", "template_list", "data_object", "@3", - "data_object_members", "data_object_member", "data_reference", - "optional_identifier", "optional_guid", "empty", 0 + "$", "error", "$undefined.", "TOKEN_NAME", "TOKEN_STRING", + "TOKEN_INTEGER", "TOKEN_GUID", "TOKEN_INTEGER_LIST", + "TOKEN_REALNUM_LIST", "TOKEN_OBRACE", "TOKEN_CBRACE", "TOKEN_OPAREN", + "TOKEN_CPAREN", "TOKEN_OBRACKET", "TOKEN_CBRACKET", "TOKEN_OANGLE", + "TOKEN_CANGLE", "TOKEN_DOT", "TOKEN_COMMA", "TOKEN_SEMICOLON", + "TOKEN_TEMPLATE", "TOKEN_WORD", "TOKEN_DWORD", "TOKEN_FLOAT", + "TOKEN_DOUBLE", "TOKEN_CHAR", "TOKEN_UCHAR", "TOKEN_SWORD", + "TOKEN_SDWORD", "TOKEN_VOID", "TOKEN_LPSTR", "TOKEN_UNICODE", + "TOKEN_CSTRING", "TOKEN_ARRAY", "xfile", "template", "@1", + "template_parts", "template_members_part", "template_option_info", + "template_members_list", "template_members", "primitive", "array", + "template_reference", "primitive_type", "array_data_type", + "dimension_list", "dimension", "dimension_size", "template_option_list", + "template_option_part", "name", "optional_name", "class_id", + "optional_class_id", "ellipsis", "object", "@2", "data_parts_list", + "data_part", "integer_list", "realnum_list", "string", "list_separator", + "data_reference", "empty", 0 }; #endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const short yyr1[] = { - 0, 27, 27, 27, 29, 28, 30, 30, 31, 32, - 31, 33, 33, 33, 33, 33, 33, 33, 33, 33, - 33, 33, 34, 34, 35, 35, 36, 36, 36, 37, - 37, 39, 38, 40, 40, 41, 41, 41, 41, 41, - 41, 41, 42, 43, 43, 44, 44, 45 + 0, 34, 34, 34, 36, 35, 37, 37, 38, 38, + 39, 39, 40, 40, 41, 41, 41, 42, 43, 44, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 46, 46, 47, 47, 48, 49, 49, 50, 50, + 51, 51, 52, 53, 53, 54, 55, 55, 56, 58, + 57, 59, 59, 60, 60, 60, 60, 60, 60, 61, + 62, 63, 64, 64, 65, 66 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const short yyr2[] = { - 0, 1, 2, 2, 0, 8, 1, 3, 1, 0, - 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 1, 2, 3, 3, 1, 3, 3, 2, - 4, 0, 6, 1, 2, 1, 1, 1, 1, 1, - 1, 1, 3, 1, 1, 1, 1, 0 + 0, 1, 2, 2, 0, 7, 4, 1, 1, 1, + 1, 1, 1, 2, 1, 1, 1, 3, 4, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 2, 1, 2, 3, 1, 1, 1, 2, + 1, 2, 1, 1, 1, 1, 1, 1, 3, 0, + 7, 1, 2, 1, 1, 1, 1, 2, 1, 1, + 1, 1, 1, 1, 4, 0 }; /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE @@ -198,68 +230,82 @@ static const short yyr2[] = error. */ static const short yydefact[] = { - 47, 0, 1, 47, 0, 2, 3, 44, 0, 43, - 0, 31, 0, 47, 4, 0, 33, 47, 37, 38, - 39, 0, 32, 40, 41, 35, 34, 36, 47, 6, - 0, 47, 0, 47, 47, 47, 47, 47, 47, 47, - 47, 47, 47, 0, 0, 8, 0, 26, 42, 21, - 9, 17, 15, 19, 14, 12, 13, 18, 16, 20, - 11, 47, 0, 0, 7, 5, 0, 46, 29, 45, - 27, 28, 0, 0, 10, 22, 47, 0, 0, 23, - 30, 24, 25, 0, 0 + 65, 0, 1, 42, 0, 2, 65, 3, 0, 44, + 0, 43, 0, 49, 45, 4, 65, 65, 47, 0, + 46, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 0, 0, 0, 7, 12, 14, 15, 16, + 65, 65, 8, 61, 59, 60, 0, 63, 62, 54, + 0, 51, 55, 56, 0, 58, 53, 0, 0, 0, + 5, 0, 13, 0, 0, 65, 50, 52, 57, 31, + 0, 0, 33, 32, 0, 0, 11, 38, 40, 10, + 17, 19, 0, 36, 0, 37, 18, 34, 0, 6, + 39, 41, 64, 35, 48, 0, 0 }; static const short yydefgoto[] = { - 1, 5, 17, 28, 44, 66, 45, 74, 75, 46, - 63, 6, 13, 15, 26, 27, 8, 68, 9 + 1, 5, 17, 33, 34, 75, 35, 36, 37, 38, + 39, 40, 58, 71, 72, 84, 76, 77, 6, 10, + 18, 19, 79, 49, 16, 50, 51, 52, 53, 54, + 55, 56, 11 }; static const short yypact[] = { - -32768, 6,-32768, 1, 8,-32768,-32768,-32768, -6,-32768, - -5,-32768, 11,-32768,-32768, -2,-32768,-32768,-32768,-32768, - -32768, 19,-32768,-32768,-32768,-32768,-32768,-32768, 21,-32768, - 4, 1, 37, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 14,-32768, 20,-32768,-32768,-32768, + -32768, 1,-32768,-32768, 6,-32768, 6,-32768, 9,-32768, + 18,-32768, 34,-32768,-32768,-32768, 34, 70,-32768, 26, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - -32768, 34, 28, -15,-32768,-32768, 33,-32768,-32768,-32768, - -32768,-32768, 38, 2, 33,-32768, 34, 47, 48,-32768, - -32768,-32768,-32768, 58,-32768 + -32768,-32768, 87, 22, 28, 56,-32768,-32768,-32768,-32768, + 6, 6,-32768,-32768,-32768,-32768, 6,-32768,-32768,-32768, + 7,-32768,-32768,-32768, 20,-32768,-32768, 6, 30, 6, + -32768, 5,-32768, 27, 29, 34,-32768,-32768,-32768,-32768, + 2, -7,-32768,-32768, 32, 33, 6,-32768, 44,-32768, + -32768,-32768, 41,-32768, 38,-32768,-32768,-32768, 37,-32768, + -32768,-32768,-32768,-32768,-32768, 58,-32768 }; static const short yypgoto[] = { - -32768,-32768,-32768,-32768,-32768,-32768, 27,-32768, 5,-32768, - -32768, 59,-32768,-32768,-32768,-32768, 29, -1, 0 + -32768,-32768,-32768,-32768,-32768,-32768,-32768, 21,-32768,-32768, + -32768, 31,-32768,-32768, -11,-32768,-32768, -15, -4, -17, + 50, -1,-32768, 64,-32768,-32768, 17,-32768,-32768,-32768, + 16,-32768, 3 }; -#define YYLAST 79 +#define YYLAST 119 static const short yytable[] = { - 2, 18, 19, 20, 3, 77, 83, 7, 78, 61, - 71, 72, 3, 16, 10, 11, 12, 29, 14, 21, - 22, 23, 4, 62, 24, 30, 48, 31, 47, 32, - 33, 34, 35, 36, 37, 38, 39, 64, 40, 41, - 42, 67, 65, 31, 76, 43, 33, 34, 35, 36, - 37, 38, 39, 70, 40, 41, 42, 73, 84, 50, - 49, 69, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 81, 82, 25, 80, 69, 0, 0, 79 + 8, 95, 9, 2, 3, 3, 70, 83, 3, 3, + 3, 43, 86, 41, 44, 45, 46, 66, 12, 20, + 42, 4, 74, 63, 64, 47, 48, 13, 59, 3, + 43, 41, 60, 44, 45, 46, 9, 9, 47, 48, + 14, 61, 65, 70, 47, 48, 80, 89, 81, 88, + 91, 92, 93, 69, 94, 73, 62, 78, 96, 3, + 87, 90, 15, 57, 82, 7, 85, 67, 20, -9, + 68, 0, 78, 3, 0, 0, 0, 21, 22, 23, + 24, 25, 26, 27, 28, 0, 29, 30, 31, 32, + 3, 21, 22, 23, 24, 25, 26, 27, 28, 0, + 29, 30, 31, 32, 0, 0, 0, 0, 21, 22, + 23, 24, 25, 26, 27, 28, 0, 29, 30, 31 }; static const short yycheck[] = { - 0, 3, 4, 5, 6, 3, 0, 6, 6, 6, - 25, 26, 6, 13, 6, 21, 21, 17, 7, 21, - 22, 23, 16, 20, 26, 6, 22, 6, 28, 8, - 9, 10, 11, 12, 13, 14, 15, 23, 17, 18, - 19, 7, 22, 6, 6, 24, 9, 10, 11, 12, - 13, 14, 15, 25, 17, 18, 19, 24, 0, 32, - 31, 61, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 25, 25, 15, 76, 76, -1, -1, 74 + 4, 0, 6, 0, 3, 3, 13, 5, 3, 3, + 3, 4, 19, 17, 7, 8, 9, 10, 9, 16, + 17, 20, 17, 40, 41, 18, 19, 9, 32, 3, + 4, 35, 10, 7, 8, 9, 40, 41, 18, 19, + 6, 13, 46, 13, 18, 19, 19, 14, 19, 17, + 6, 10, 14, 57, 17, 59, 35, 61, 0, 3, + 71, 76, 12, 32, 65, 1, 70, 50, 65, 13, + 54, -1, 76, 3, -1, -1, -1, 21, 22, 23, + 24, 25, 26, 27, 28, -1, 30, 31, 32, 33, + 3, 21, 22, 23, 24, 25, 26, 27, 28, -1, + 30, 31, 32, 33, -1, -1, -1, -1, 21, 22, + 23, 24, 25, 26, 27, 28, -1, 30, 31, 32 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/usr/share/bison/bison.simple" @@ -969,7 +1015,7 @@ yyreduce: switch (yyn) { case 4: -#line 80 "xParser.yxx" +#line 112 "xParser.yxx" { yyval.u.node = current_node; XFileTemplate *templ = new XFileTemplate(yyvsp[-2].str, yyvsp[0].guid); @@ -978,173 +1024,238 @@ case 4: } break; case 5: -#line 87 "xParser.yxx" +#line 119 "xParser.yxx" { yyval.u.node = current_node; - current_node = yyvsp[-3].u.node; + current_node = yyvsp[-2].u.node; } break; -case 8: -#line 100 "xParser.yxx" +case 10: +#line 137 "xParser.yxx" { - current_node->add_child(yyvsp[0].u.data_def); -} - break; -case 9: -#line 104 "xParser.yxx" -{ - current_node->add_child(yyvsp[0].u.data_def); - current_data_def = yyvsp[0].u.data_def; -} - break; -case 11: -#line 113 "xParser.yxx" -{ - yyval.u.data_def = new XFileDataDef(XFileDataDef::T_word, yyvsp[0].str); -} - break; -case 12: -#line 117 "xParser.yxx" -{ - yyval.u.data_def = new XFileDataDef(XFileDataDef::T_dword, yyvsp[0].str); -} - break; -case 13: -#line 121 "xParser.yxx" -{ - yyval.u.data_def = new XFileDataDef(XFileDataDef::T_float, yyvsp[0].str); -} - break; -case 14: -#line 125 "xParser.yxx" -{ - yyval.u.data_def = new XFileDataDef(XFileDataDef::T_double, yyvsp[0].str); -} - break; -case 15: -#line 129 "xParser.yxx" -{ - yyval.u.data_def = new XFileDataDef(XFileDataDef::T_char, yyvsp[0].str); -} - break; -case 16: -#line 133 "xParser.yxx" -{ - yyval.u.data_def = new XFileDataDef(XFileDataDef::T_uchar, yyvsp[0].str); + DCAST(XFileTemplate, current_node)->set_open(true); } break; case 17: -#line 137 "xParser.yxx" +#line 156 "xParser.yxx" { - yyval.u.data_def = new XFileDataDef(XFileDataDef::T_byte, yyvsp[0].str); -} - break; -case 18: -#line 141 "xParser.yxx" -{ - yyval.u.data_def = new XFileDataDef(XFileDataDef::T_string, yyvsp[0].str); + current_data_def = new XFileDataDef(yyvsp[-2].u.primitive_type, yyvsp[-1].str); + current_node->add_child(current_data_def); } break; case 19: -#line 145 "xParser.yxx" +#line 168 "xParser.yxx" { - yyval.u.data_def = new XFileDataDef(XFileDataDef::T_cstring, yyvsp[0].str); + XFileTemplate *xtemplate = x_file->find_template(yyvsp[-2].str); + if (xtemplate == (XFileTemplate *)NULL) { + yyerror("Unknown template: " + yyvsp[-2].str); + } else { + current_data_def = new XFileDataDef(XFileDataDef::T_template, yyvsp[-1].str, xtemplate); + current_node->add_child(current_data_def); + } } break; case 20: -#line 149 "xParser.yxx" +#line 181 "xParser.yxx" { - yyval.u.data_def = new XFileDataDef(XFileDataDef::T_unicode, yyvsp[0].str); + yyval.u.primitive_type = XFileDataDef::T_word; } break; case 21: -#line 153 "xParser.yxx" +#line 185 "xParser.yxx" { - yyval.u.data_def = new XFileDataDef(XFileDataDef::T_word, yyvsp[0].str); + yyval.u.primitive_type = XFileDataDef::T_dword; +} + break; +case 22: +#line 189 "xParser.yxx" +{ + yyval.u.primitive_type = XFileDataDef::T_float; +} + break; +case 23: +#line 193 "xParser.yxx" +{ + yyval.u.primitive_type = XFileDataDef::T_double; } break; case 24: -#line 165 "xParser.yxx" +#line 197 "xParser.yxx" { - current_data_def->add_array_def(XFileArrayDef(yyvsp[-1].u.s_int)); + yyval.u.primitive_type = XFileDataDef::T_char; } break; case 25: -#line 169 "xParser.yxx" +#line 201 "xParser.yxx" { - XFileNode *data_def = current_node->find_child(yyvsp[-1].str); + yyval.u.primitive_type = XFileDataDef::T_uchar; +} + break; +case 26: +#line 205 "xParser.yxx" +{ + yyval.u.primitive_type = XFileDataDef::T_sword; +} + break; +case 27: +#line 209 "xParser.yxx" +{ + yyval.u.primitive_type = XFileDataDef::T_sdword; +} + break; +case 28: +#line 213 "xParser.yxx" +{ + yyval.u.primitive_type = XFileDataDef::T_string; +} + break; +case 29: +#line 217 "xParser.yxx" +{ + yyval.u.primitive_type = XFileDataDef::T_unicode; +} + break; +case 30: +#line 221 "xParser.yxx" +{ + yyval.u.primitive_type = XFileDataDef::T_cstring; +} + break; +case 31: +#line 228 "xParser.yxx" +{ + current_data_def = new XFileDataDef(yyvsp[-1].u.primitive_type, yyvsp[0].str); + current_node->add_child(current_data_def); +} + break; +case 32: +#line 233 "xParser.yxx" +{ + XFileTemplate *xtemplate = x_file->find_template(yyvsp[-1].str); + if (xtemplate == (XFileTemplate *)NULL) { + yyerror("Unknown template: " + yyvsp[-1].str); + } else { + current_data_def = new XFileDataDef(XFileDataDef::T_template, yyvsp[0].str, xtemplate); + current_node->add_child(current_data_def); + } +} + break; +case 36: +#line 255 "xParser.yxx" +{ + current_data_def->add_array_def(XFileArrayDef(yyvsp[0].u.number)); +} + break; +case 37: +#line 259 "xParser.yxx" +{ + XFileNode *data_def = current_node->find_child(yyvsp[0].str); if (data_def == (XFileNode *)NULL) { - yyerror("Unknown identifier: " + yyvsp[-1].str); + yyerror("Unknown identifier: " + yyvsp[0].str); } else { current_data_def->add_array_def(XFileArrayDef(DCAST(XFileDataDef, data_def))); } -} - break; -case 29: -#line 187 "xParser.yxx" -{ -} - break; -case 30: -#line 190 "xParser.yxx" -{ -} - break; -case 31: -#line 196 "xParser.yxx" -{ -} - break; -case 32: -#line 199 "xParser.yxx" -{ -} - break; -case 35: -#line 211 "xParser.yxx" -{ -} - break; -case 36: -#line 214 "xParser.yxx" -{ -} - break; -case 37: -#line 217 "xParser.yxx" -{ } break; case 38: -#line 220 "xParser.yxx" +#line 271 "xParser.yxx" { } break; case 39: -#line 223 "xParser.yxx" +#line 274 "xParser.yxx" { } break; case 40: -#line 226 "xParser.yxx" +#line 280 "xParser.yxx" { + XFileTemplate *xtemplate = x_file->find_template(yyvsp[0].str); + if (xtemplate == (XFileTemplate *)NULL) { + yyerror("Unknown template: " + yyvsp[0].str); + } else { + DCAST(XFileTemplate, current_node)->add_option(xtemplate); + } } break; case 41: -#line 229 "xParser.yxx" +#line 289 "xParser.yxx" { + XFileTemplate *xtemplate = x_file->find_template(yyvsp[0].guid); + if (xtemplate == (XFileTemplate *)NULL) { + yyerror("Unknown template: " + yyvsp[-1].str); + } else { + if (xtemplate->get_name() != yyvsp[-1].str) { + xyywarning("GUID identifies template " + xtemplate->get_name() + + ", not " + yyvsp[-1].str); + } + DCAST(XFileTemplate, current_node)->add_option(xtemplate); + } } break; case 43: -#line 239 "xParser.yxx" +#line 309 "xParser.yxx" { yyval.str = string(); } break; -case 45: -#line 247 "xParser.yxx" +case 46: +#line 321 "xParser.yxx" { yyval.guid = WindowsGuid(); +} + break; +case 49: +#line 333 "xParser.yxx" +{ + XFileTemplate *xtemplate = x_file->find_template(yyvsp[-2].str); + yyval.u.node = current_node; + + if (xtemplate == (XFileTemplate *)NULL) { + yyerror("Unknown template: " + yyvsp[-2].str); + } else { + XFileDataObjectTemplate *templ = + new XFileDataObjectTemplate(xtemplate, yyvsp[-1].str); + current_node->add_child(templ); + current_node = templ; + } +} + break; +case 50: +#line 347 "xParser.yxx" +{ + yyval.u.node = current_node; + current_node = yyvsp[-3].u.node; +} + break; +case 53: +#line 360 "xParser.yxx" +{ +} + break; +case 54: +#line 363 "xParser.yxx" +{ +} + break; +case 55: +#line 366 "xParser.yxx" +{ +} + break; +case 56: +#line 369 "xParser.yxx" +{ +} + break; +case 57: +#line 372 "xParser.yxx" +{ +} + break; +case 58: +#line 375 "xParser.yxx" +{ } break; } @@ -1380,4 +1491,4 @@ yyreturn: #endif return yyresult; } -#line 256 "xParser.yxx" +#line 402 "xParser.yxx" diff --git a/pandatool/src/xfile/xParser.h.prebuilt b/pandatool/src/xfile/xParser.h.prebuilt index 3b6f0736a0..679f679f39 100644 --- a/pandatool/src/xfile/xParser.h.prebuilt +++ b/pandatool/src/xfile/xParser.h.prebuilt @@ -1,24 +1,37 @@ #ifndef BISON_Y_TAB_H # define BISON_Y_TAB_H -# define INTEGER 257 -# define REAL 258 -# define STRING 259 -# define IDENTIFIER 260 -# define WINDOWS_GUID 261 -# define KW_ARRAY 262 -# define KW_BYTE 263 -# define KW_CHAR 264 -# define KW_CSTRING 265 -# define KW_DOUBLE 266 -# define KW_DWORD 267 -# define KW_FLOAT 268 -# define KW_STRING 269 -# define KW_TEMPLATE 270 -# define KW_UCHAR 271 -# define KW_UNICODE 272 -# define KW_WORD 273 -# define ELLIPSIS 274 +# define TOKEN_NAME 1 +# define TOKEN_STRING 2 +# define TOKEN_INTEGER 3 +# define TOKEN_GUID 5 +# define TOKEN_INTEGER_LIST 6 +# define TOKEN_REALNUM_LIST 7 +# define TOKEN_OBRACE 10 +# define TOKEN_CBRACE 11 +# define TOKEN_OPAREN 12 +# define TOKEN_CPAREN 13 +# define TOKEN_OBRACKET 14 +# define TOKEN_CBRACKET 15 +# define TOKEN_OANGLE 16 +# define TOKEN_CANGLE 17 +# define TOKEN_DOT 18 +# define TOKEN_COMMA 19 +# define TOKEN_SEMICOLON 20 +# define TOKEN_TEMPLATE 31 +# define TOKEN_WORD 40 +# define TOKEN_DWORD 41 +# define TOKEN_FLOAT 42 +# define TOKEN_DOUBLE 43 +# define TOKEN_CHAR 44 +# define TOKEN_UCHAR 45 +# define TOKEN_SWORD 46 +# define TOKEN_SDWORD 47 +# define TOKEN_VOID 48 +# define TOKEN_LPSTR 49 +# define TOKEN_UNICODE 50 +# define TOKEN_CSTRING 51 +# define TOKEN_ARRAY 52 extern YYSTYPE xyylval;