From 836cc8224d3a61e45c1d3b86541442517717881d Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 2 Jul 2004 16:47:55 +0000 Subject: [PATCH] various refinements --- direct/src/dcparser/dcClass.cxx | 25 +- direct/src/dcparser/dcPacker.cxx | 57 +- direct/src/dcparser/dcPacker.h | 2 + direct/src/dcparser/dcPackerCatalog.cxx | 8 +- direct/src/dcparser/dcPackerInterface.cxx | 24 + direct/src/dcparser/dcParser.cxx.prebuilt | 701 +++++++++++----------- direct/src/dcparser/dcParser.yxx | 24 +- 7 files changed, 479 insertions(+), 362 deletions(-) diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index 34b13c8322..a260f5c0b9 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -482,6 +482,14 @@ pack_required_field(DCPacker &packer, PyObject *distobj, string field_name = field->get_name(); if (!PyObject_HasAttrString(distobj, (char *)field_name.c_str())) { + // If the attribute is not defined, but the field has a default + // value specified, quietly pack the default value. + if (field->has_default_value()) { + packer.pack_default_value(); + return true; + } + + // If there is no default value specified, it's an error. ostringstream strm; strm << "Data element " << field_name << ", required by dc file for dclass " << get_name() @@ -503,7 +511,7 @@ pack_required_field(DCPacker &packer, PyObject *distobj, const DCAtomicField *atom = field->as_atomic_field(); if (atom == (DCAtomicField *)NULL) { ostringstream strm; - strm << "Cannot pack non-atomic field " << field->get_name() + strm << "Cannot pack molecular field " << field->get_name() << " for generate"; nassert_raise(strm.str()); return false; @@ -547,6 +555,14 @@ pack_required_field(DCPacker &packer, PyObject *distobj, // Now we have to look up the getter on the distributed object // and call it. if (!PyObject_HasAttrString(distobj, (char *)getter_name.c_str())) { + // As above, if there's no getter but the field has a default + // value specified, quietly pack the default value. + if (field->has_default_value()) { + packer.pack_default_value(); + return true; + } + + // Otherwise, with no default value it's an error. ostringstream strm; strm << "Distributed class " << get_name() << " doesn't have getter named " << getter_name @@ -671,10 +687,9 @@ ai_format_generate(PyObject *distobj, int do_id, int num_fields = get_num_inherited_fields(); for (int i = 0; i < num_fields; i++) { DCField *field = get_inherited_field(i); - DCAtomicField *atom = field->as_atomic_field(); - if (atom != (DCAtomicField *)NULL && atom->is_required()) { - packer.begin_pack(atom); - if (!pack_required_field(packer, distobj, atom)) { + if (field->is_required() && field->as_molecular_field() == NULL) { + packer.begin_pack(field); + if (!pack_required_field(packer, distobj, field)) { return Datagram(); } packer.end_pack(); diff --git a/direct/src/dcparser/dcPacker.cxx b/direct/src/dcparser/dcPacker.cxx index 70df5bb6ee..a5c9c41162 100755 --- a/direct/src/dcparser/dcPacker.cxx +++ b/direct/src/dcparser/dcPacker.cxx @@ -464,7 +464,6 @@ push() { length = DCPackerInterface::do_unpack_uint32 (_unpack_data + _unpack_p); _unpack_p += 4; - _pop_marker = _unpack_p + length; } else { length = DCPackerInterface::do_unpack_uint16 (_unpack_data + _unpack_p); @@ -1122,17 +1121,12 @@ clear() { void DCPacker:: pack_class_object(const DCClass *dclass, PyObject *object) { PyObject *str = PyObject_Str(object); - cerr << "pack_class_object(" << dclass->get_name() << ", " - << PyString_AsString(str) << ")\n"; Py_DECREF(str); push(); - while (more_nested_fields()) { + while (more_nested_fields() && !_pack_error) { const DCField *field = get_current_field()->as_field(); nassertv(field != (DCField *)NULL); - - if (!dclass->pack_required_field(*this, object, field)) { - break; - } + get_class_element(dclass, object, field); } pop(); } @@ -1257,3 +1251,50 @@ set_class_element(PyObject *class_def, PyObject *&object, } } #endif // HAVE_PYTHON + + +#ifdef HAVE_PYTHON +//////////////////////////////////////////////////////////////////// +// Function: DCPacker::get_class_element +// Access: Private +// Description: Gets the current element from the Python object and +// packs it. +//////////////////////////////////////////////////////////////////// +void DCPacker:: +get_class_element(const DCClass *dclass, PyObject *object, + const DCField *field) { + string field_name = field->get_name(); + DCPackType pack_type = get_pack_type(); + + if (field_name.empty()) { + switch (pack_type) { + case PT_class: + case PT_switch: + // If the field has no name, but it is one of these container + // objects, we want to get its nested objects directly from + // the class. + push(); + while (more_nested_fields() && !_pack_error) { + const DCField *field = get_current_field()->as_field(); + nassertv(field != (DCField *)NULL); + get_class_element(dclass, object, field); + } + pop(); + break; + + default: + // Otherwise, we just pack the default value. + pack_default_value(); + } + + } else { + // If the field does have a name, we will want to get it from the + // class and pack it. It just so happens that there's already a + // method that does this on DCClass. + + if (!dclass->pack_required_field(*this, object, field)) { + _pack_error = true; + } + } +} +#endif // HAVE_PYTHON diff --git a/direct/src/dcparser/dcPacker.h b/direct/src/dcparser/dcPacker.h index ae43f82e5f..2b780d3a02 100755 --- a/direct/src/dcparser/dcPacker.h +++ b/direct/src/dcparser/dcPacker.h @@ -183,6 +183,8 @@ private: PyObject *unpack_class_object(const DCClass *dclass); void set_class_element(PyObject *class_def, PyObject *&object, const DCField *field); + void get_class_element(const DCClass *dclass, PyObject *object, + const DCField *field); #endif private: diff --git a/direct/src/dcparser/dcPackerCatalog.cxx b/direct/src/dcparser/dcPackerCatalog.cxx index f7c04f100f..9f11aec7ce 100644 --- a/direct/src/dcparser/dcPackerCatalog.cxx +++ b/direct/src/dcparser/dcPackerCatalog.cxx @@ -328,7 +328,13 @@ update_switch_fields(const DCSwitchParameter *switch_parameter, // because we must have come across the DCSwitch when building the // catalog the first time. SwitchPrefixes::const_iterator pi = _switch_prefixes.find(switch_parameter); - nassertr(pi != _switch_prefixes.end(), NULL); + if (pi == _switch_prefixes.end()) { + // If it's not stored in the record, the switch must be hidden + // within some non-seekable object, like an array; in this case, + // never mind. + return this; + } + string name_prefix = (*pi).second; // Start by creating a new DCPackerCatalog object that contains all diff --git a/direct/src/dcparser/dcPackerInterface.cxx b/direct/src/dcparser/dcPackerInterface.cxx index 9844c63b1f..60c1916523 100755 --- a/direct/src/dcparser/dcPackerInterface.cxx +++ b/direct/src/dcparser/dcPackerInterface.cxx @@ -350,12 +350,36 @@ bool DCPackerInterface:: unpack_skip(const char *data, size_t length, size_t &p, bool &pack_error) const { if (_has_fixed_byte_size) { + // If this field has a fixed byte size, it's easy to skip. p += _fixed_byte_size; if (p > length) { pack_error = true; } return true; } + + if (_has_nested_fields && _num_length_bytes != 0) { + // If we have a length prefix, use that for skipping. + if (p + _num_length_bytes > length) { + pack_error = true; + + } else { + if (_num_length_bytes == 4) { + size_t this_length = do_unpack_uint32(data + p); + p += this_length + 4; + } else { + size_t this_length = do_unpack_uint16(data + p); + p += this_length + 2; + } + if (p > length) { + pack_error = true; + } + } + return true; + } + + // Otherwise, we don't know how to skip this field (presumably it + // can be skipped by skipping over its nested fields individually). return false; } diff --git a/direct/src/dcparser/dcParser.cxx.prebuilt b/direct/src/dcparser/dcParser.cxx.prebuilt index ff56881da4..e89fb0f75a 100644 --- a/direct/src/dcparser/dcParser.cxx.prebuilt +++ b/direct/src/dcparser/dcParser.cxx.prebuilt @@ -121,12 +121,12 @@ dc_cleanup_parser() { -#define YYFINAL 252 +#define YYFINAL 258 #define YYFLAG -32768 #define YYNTBASE 61 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ -#define YYTRANSLATE(x) ((unsigned)(x) <= 300 ? yytranslate[x] : 131) +#define YYTRANSLATE(x) ((unsigned)(x) <= 300 ? yytranslate[x] : 132) /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ static const char yytranslate[] = @@ -170,73 +170,74 @@ static const short yyprhs[] = 0, 0, 3, 6, 8, 11, 14, 17, 20, 23, 25, 29, 31, 35, 38, 39, 45, 47, 49, 51, 55, 58, 60, 62, 63, 71, 73, 75, 78, 80, - 84, 86, 89, 92, 95, 97, 101, 104, 105, 113, - 115, 117, 120, 122, 126, 128, 131, 134, 136, 138, - 141, 143, 144, 150, 152, 154, 156, 160, 162, 163, - 167, 169, 171, 172, 177, 179, 180, 185, 187, 189, - 191, 193, 195, 200, 204, 211, 218, 220, 222, 224, - 226, 228, 232, 235, 239, 245, 250, 252, 254, 258, - 262, 268, 270, 275, 277, 281, 286, 288, 290, 292, - 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, - 314, 316, 317, 322, 323, 328, 329, 334, 338, 342, - 346, 350, 352, 355, 357, 359, 361, 365, 367, 369, - 371, 373, 375, 377, 379, 381, 383, 385, 387, 389, - 391, 393, 395, 397, 399, 401, 403, 405, 407, 410, - 413, 416, 419, 422, 425, 428, 431, 434, 435, 440, - 442, 444, 448, 450, 452, 453, 463, 465, 468, 471, - 474, 475, 480, 483, 485 + 84, 86, 89, 92, 95, 98, 102, 105, 106, 114, + 116, 118, 121, 123, 127, 129, 132, 135, 138, 141, + 145, 148, 149, 155, 157, 159, 161, 165, 167, 168, + 172, 174, 176, 177, 182, 184, 185, 190, 192, 194, + 196, 198, 200, 205, 209, 216, 223, 225, 227, 229, + 231, 233, 237, 240, 244, 250, 255, 257, 259, 263, + 267, 273, 275, 280, 282, 286, 291, 293, 295, 297, + 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, + 319, 321, 322, 327, 328, 333, 334, 339, 343, 347, + 351, 355, 357, 360, 362, 364, 366, 370, 372, 374, + 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, + 396, 398, 400, 402, 404, 406, 408, 410, 412, 415, + 418, 421, 424, 427, 430, 433, 436, 439, 441, 442, + 447, 449, 451, 455, 457, 459, 460, 470, 472, 475, + 478, 481, 482, 487, 490, 492 }; static const short yyrhs[] = { - 45, 62, 0, 46, 110, 0, 130, 0, 62, 47, - 0, 62, 70, 0, 62, 124, 0, 62, 65, 0, + 45, 62, 0, 46, 110, 0, 131, 0, 62, 47, + 0, 62, 70, 0, 62, 125, 0, 62, 65, 0, 62, 69, 0, 8, 0, 63, 48, 8, 0, 63, 0, 64, 49, 63, 0, 12, 64, 0, 0, 11, 64, 12, 66, 67, 0, 68, 0, 50, 0, 63, 0, 68, 51, 63, 0, 13, 98, 0, 71, 0, - 78, 0, 0, 9, 123, 72, 74, 52, 76, 53, - 0, 8, 0, 130, 0, 54, 75, 0, 73, 0, - 75, 51, 73, 0, 130, 0, 76, 47, 0, 76, - 77, 0, 85, 118, 0, 119, 0, 95, 118, 47, - 0, 93, 118, 0, 0, 10, 123, 79, 81, 52, - 83, 53, 0, 8, 0, 130, 0, 54, 82, 0, - 80, 0, 82, 51, 80, 0, 130, 0, 83, 47, - 0, 83, 84, 0, 85, 0, 119, 0, 95, 47, - 0, 93, 0, 0, 8, 55, 86, 87, 56, 0, - 130, 0, 88, 0, 89, 0, 88, 51, 89, 0, - 98, 0, 0, 102, 91, 103, 0, 102, 0, 90, - 0, 0, 90, 57, 94, 110, 0, 92, 0, 0, - 92, 57, 96, 110, 0, 90, 0, 92, 0, 93, - 0, 95, 0, 117, 0, 117, 55, 100, 56, 0, - 117, 48, 105, 0, 117, 48, 105, 55, 100, 56, - 0, 117, 55, 100, 56, 48, 105, 0, 8, 0, - 78, 0, 124, 0, 130, 0, 109, 0, 109, 58, - 109, 0, 109, 108, 0, 100, 51, 109, 0, 100, - 51, 109, 58, 109, 0, 100, 51, 109, 108, 0, - 130, 0, 104, 0, 104, 58, 104, 0, 101, 51, - 104, 0, 101, 51, 104, 58, 104, 0, 99, 0, - 102, 59, 101, 60, 0, 8, 0, 103, 48, 105, - 0, 103, 59, 101, 60, 0, 6, 0, 105, 0, - 3, 0, 4, 0, 3, 0, 107, 0, 106, 0, - 5, 0, 6, 0, 108, 0, 106, 0, 107, 0, - 5, 0, 6, 0, 7, 0, 0, 52, 111, 114, - 53, 0, 0, 59, 112, 114, 60, 0, 0, 55, - 113, 114, 56, 0, 106, 50, 105, 0, 107, 50, - 105, 0, 5, 50, 105, 0, 7, 50, 105, 0, - 115, 0, 116, 115, 0, 130, 0, 51, 0, 110, - 0, 116, 51, 110, 0, 16, 0, 17, 0, 18, - 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, - 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, - 0, 29, 0, 30, 0, 31, 0, 32, 0, 33, - 0, 34, 0, 35, 0, 130, 0, 118, 36, 0, - 118, 37, 0, 118, 38, 0, 118, 39, 0, 118, - 40, 0, 118, 41, 0, 118, 42, 0, 118, 43, - 0, 118, 44, 0, 0, 8, 54, 120, 122, 0, - 8, 0, 121, 0, 122, 51, 121, 0, 130, 0, - 8, 0, 0, 14, 123, 55, 97, 56, 52, 125, - 126, 53, 0, 130, 0, 126, 47, 0, 126, 127, - 0, 126, 129, 0, 0, 15, 128, 110, 54, 0, - 95, 47, 0, 93, 0, 0 + 78, 0, 0, 9, 124, 72, 74, 52, 76, 53, + 0, 8, 0, 131, 0, 54, 75, 0, 73, 0, + 75, 51, 73, 0, 131, 0, 76, 47, 0, 76, + 77, 0, 85, 118, 0, 120, 119, 0, 95, 118, + 47, 0, 93, 118, 0, 0, 10, 124, 79, 81, + 52, 83, 53, 0, 8, 0, 131, 0, 54, 82, + 0, 80, 0, 82, 51, 80, 0, 131, 0, 83, + 47, 0, 83, 84, 0, 85, 119, 0, 120, 119, + 0, 95, 119, 47, 0, 93, 119, 0, 0, 8, + 55, 86, 87, 56, 0, 131, 0, 88, 0, 89, + 0, 88, 51, 89, 0, 98, 0, 0, 102, 91, + 103, 0, 102, 0, 90, 0, 0, 90, 57, 94, + 110, 0, 92, 0, 0, 92, 57, 96, 110, 0, + 90, 0, 92, 0, 93, 0, 95, 0, 117, 0, + 117, 55, 100, 56, 0, 117, 48, 105, 0, 117, + 48, 105, 55, 100, 56, 0, 117, 55, 100, 56, + 48, 105, 0, 8, 0, 78, 0, 125, 0, 131, + 0, 109, 0, 109, 58, 109, 0, 109, 108, 0, + 100, 51, 109, 0, 100, 51, 109, 58, 109, 0, + 100, 51, 109, 108, 0, 131, 0, 104, 0, 104, + 58, 104, 0, 101, 51, 104, 0, 101, 51, 104, + 58, 104, 0, 99, 0, 102, 59, 101, 60, 0, + 8, 0, 103, 48, 105, 0, 103, 59, 101, 60, + 0, 6, 0, 105, 0, 3, 0, 4, 0, 3, + 0, 107, 0, 106, 0, 5, 0, 6, 0, 108, + 0, 106, 0, 107, 0, 5, 0, 6, 0, 7, + 0, 0, 52, 111, 114, 53, 0, 0, 59, 112, + 114, 60, 0, 0, 55, 113, 114, 56, 0, 106, + 50, 105, 0, 107, 50, 105, 0, 5, 50, 105, + 0, 7, 50, 105, 0, 115, 0, 116, 115, 0, + 131, 0, 51, 0, 110, 0, 116, 51, 110, 0, + 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, + 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, + 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, + 31, 0, 32, 0, 33, 0, 34, 0, 35, 0, + 131, 0, 118, 36, 0, 118, 37, 0, 118, 38, + 0, 118, 39, 0, 118, 40, 0, 118, 41, 0, + 118, 42, 0, 118, 43, 0, 118, 44, 0, 118, + 0, 0, 8, 54, 121, 123, 0, 8, 0, 122, + 0, 123, 51, 122, 0, 131, 0, 8, 0, 0, + 14, 124, 55, 97, 56, 52, 126, 127, 53, 0, + 131, 0, 127, 47, 0, 127, 128, 0, 127, 130, + 0, 0, 15, 129, 110, 54, 0, 95, 47, 0, + 93, 0, 0 }; #endif @@ -245,24 +246,24 @@ static const short yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const short yyrline[] = { - 0, 152, 154, 157, 159, 160, 171, 177, 178, 181, - 183, 189, 191, 197, 202, 202, 209, 211, 217, 222, - 228, 244, 246, 249, 249, 262, 279, 281, 284, 291, - 299, 301, 302, 310, 316, 317, 322, 329, 329, 342, - 359, 361, 364, 371, 379, 381, 382, 390, 392, 393, - 397, 403, 403, 416, 418, 421, 423, 426, 433, 433, - 444, 448, 450, 450, 473, 475, 475, 498, 500, 503, - 505, 508, 513, 521, 532, 546, 560, 589, 595, 603, - 608, 615, 622, 631, 637, 643, 653, 658, 665, 672, - 678, 686, 688, 694, 700, 714, 720, 730, 733, 744, - 748, 752, 757, 761, 764, 774, 778, 783, 787, 791, - 795, 799, 799, 807, 807, 815, 815, 823, 829, 835, - 841, 849, 851, 854, 856, 859, 861, 864, 869, 873, - 877, 881, 885, 889, 893, 897, 901, 905, 909, 913, - 917, 921, 925, 929, 933, 937, 941, 947, 952, 956, - 960, 964, 968, 972, 976, 980, 984, 990, 990, 1001, - 1017, 1024, 1037, 1042, 1045, 1045, 1059, 1061, 1062, 1063, - 1073, 1073, 1090, 1095, 1101 + 0, 153, 155, 158, 160, 161, 172, 178, 179, 182, + 184, 190, 192, 198, 203, 203, 210, 212, 218, 223, + 229, 245, 247, 250, 250, 263, 280, 282, 285, 292, + 300, 302, 303, 313, 319, 320, 326, 333, 333, 346, + 363, 365, 368, 375, 383, 385, 386, 394, 396, 397, + 401, 407, 407, 420, 422, 425, 427, 430, 437, 437, + 448, 452, 454, 454, 477, 479, 479, 502, 504, 507, + 509, 512, 517, 525, 536, 550, 564, 593, 599, 607, + 612, 619, 626, 635, 641, 647, 657, 662, 669, 676, + 682, 690, 692, 698, 704, 718, 724, 734, 737, 748, + 752, 756, 761, 765, 768, 778, 782, 787, 791, 795, + 799, 803, 803, 811, 811, 819, 819, 827, 833, 839, + 845, 853, 855, 858, 860, 863, 865, 868, 873, 877, + 881, 885, 889, 893, 897, 901, 905, 909, 913, 917, + 921, 925, 929, 933, 937, 941, 945, 951, 956, 960, + 964, 968, 972, 976, 980, 984, 988, 994, 1004, 1004, + 1015, 1031, 1038, 1051, 1056, 1059, 1059, 1073, 1075, 1076, + 1077, 1087, 1087, 1104, 1109, 1115 }; #endif @@ -297,8 +298,8 @@ static const char *const yytname[] = "char_or_uint", "small_unsigned_integer", "signed_integer", "unsigned_integer", "number", "char_or_number", "parameter_value", "@8", "@9", "@10", "array", "maybe_comma", "array_def", "type_token", - "server_flags", "molecular_field", "@11", "atomic_name", - "molecular_atom_list", "optional_name", "switch", "@12", + "server_flags", "no_server_flags", "molecular_field", "@11", + "atomic_name", "molecular_atom_list", "optional_name", "switch", "@12", "switch_fields", "switch_case", "@13", "switch_field", "empty", 0 }; #endif @@ -321,9 +322,9 @@ static const short yyr1[] = 110, 114, 114, 115, 115, 116, 116, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 118, 120, 119, 121, - 122, 122, 123, 123, 125, 124, 126, 126, 126, 126, - 128, 127, 129, 129, 130 + 118, 118, 118, 118, 118, 118, 118, 119, 121, 120, + 122, 123, 123, 124, 124, 126, 125, 127, 127, 127, + 127, 129, 128, 130, 130, 131 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -332,9 +333,9 @@ static const short yyr2[] = 0, 2, 2, 1, 2, 2, 2, 2, 2, 1, 3, 1, 3, 2, 0, 5, 1, 1, 1, 3, 2, 1, 1, 0, 7, 1, 1, 2, 1, 3, - 1, 2, 2, 2, 1, 3, 2, 0, 7, 1, - 1, 2, 1, 3, 1, 2, 2, 1, 1, 2, - 1, 0, 5, 1, 1, 1, 3, 1, 0, 3, + 1, 2, 2, 2, 2, 3, 2, 0, 7, 1, + 1, 2, 1, 3, 1, 2, 2, 2, 2, 3, + 2, 0, 5, 1, 1, 1, 3, 1, 0, 3, 1, 1, 0, 4, 1, 0, 4, 1, 1, 1, 1, 1, 4, 3, 6, 6, 1, 1, 1, 1, 1, 3, 2, 3, 5, 4, 1, 1, 3, 3, @@ -344,9 +345,9 @@ static const short yyr2[] = 3, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 0, 4, 1, - 1, 3, 1, 1, 0, 9, 1, 2, 2, 2, - 0, 4, 2, 1, 0 + 2, 2, 2, 2, 2, 2, 2, 1, 0, 4, + 1, 1, 3, 1, 1, 0, 9, 1, 2, 2, + 2, 0, 4, 2, 1, 0 }; /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE @@ -354,160 +355,162 @@ static const short yyr2[] = error. */ static const short yydefact[] = { - 0, 174, 0, 1, 3, 100, 99, 108, 109, 110, - 111, 115, 113, 106, 107, 2, 174, 174, 0, 0, - 0, 174, 4, 7, 8, 5, 21, 22, 6, 0, - 0, 174, 174, 174, 0, 0, 163, 23, 162, 37, + 0, 175, 0, 1, 3, 100, 99, 108, 109, 110, + 111, 115, 113, 106, 107, 2, 175, 175, 0, 0, + 0, 175, 4, 7, 8, 5, 21, 22, 6, 0, + 0, 175, 175, 175, 0, 0, 164, 23, 163, 37, 9, 11, 0, 13, 76, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 77, 61, 64, 69, 70, 20, 91, 60, 71, 78, 0, 98, 119, 120, 124, - 125, 0, 121, 174, 123, 0, 0, 117, 118, 174, - 174, 0, 14, 0, 62, 65, 174, 0, 0, 174, + 125, 0, 121, 175, 123, 0, 0, 117, 118, 175, + 175, 0, 14, 0, 62, 65, 175, 0, 0, 175, 0, 112, 124, 122, 116, 114, 0, 0, 26, 0, 0, 40, 10, 0, 12, 0, 0, 96, 0, 87, 97, 86, 93, 59, 73, 103, 104, 0, 102, 101, 105, 80, 79, 67, 68, 0, 126, 25, 28, 27, - 174, 39, 42, 41, 174, 17, 18, 15, 16, 63, - 66, 0, 92, 0, 0, 174, 174, 0, 72, 0, + 175, 39, 42, 41, 175, 17, 18, 15, 16, 63, + 66, 0, 92, 0, 0, 175, 175, 0, 72, 0, 82, 0, 0, 0, 30, 0, 0, 44, 0, 89, - 88, 94, 0, 0, 83, 0, 81, 164, 29, 76, - 31, 24, 32, 174, 174, 174, 34, 43, 45, 38, - 46, 47, 50, 0, 48, 19, 0, 95, 74, 0, - 85, 75, 174, 157, 51, 33, 147, 36, 0, 49, - 90, 84, 0, 166, 0, 174, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 35, 170, 167, 165, 173, - 0, 168, 169, 159, 160, 158, 0, 54, 55, 57, - 53, 0, 172, 0, 52, 0, 0, 161, 56, 171, - 0, 0, 0 + 88, 94, 0, 0, 83, 0, 81, 165, 29, 76, + 31, 24, 32, 175, 175, 175, 175, 43, 45, 38, + 46, 175, 175, 175, 175, 19, 0, 95, 74, 0, + 85, 75, 175, 158, 51, 33, 147, 36, 0, 157, + 34, 47, 50, 0, 48, 90, 84, 0, 167, 0, + 175, 148, 149, 150, 151, 152, 153, 154, 155, 156, + 35, 49, 171, 168, 166, 174, 0, 169, 170, 160, + 161, 159, 0, 54, 55, 57, 53, 0, 173, 0, + 52, 0, 0, 162, 56, 172, 0, 0, 0 }; static const short yydefgoto[] = { - 250, 3, 41, 42, 23, 113, 147, 148, 24, 25, + 256, 3, 41, 42, 23, 113, 147, 148, 24, 25, 26, 89, 138, 107, 139, 163, 182, 65, 90, 142, - 110, 143, 166, 190, 183, 215, 236, 237, 238, 66, - 97, 67, 68, 115, 69, 116, 135, 239, 71, 127, + 110, 143, 166, 190, 183, 220, 242, 243, 244, 66, + 97, 67, 68, 115, 69, 116, 135, 245, 71, 127, 118, 72, 123, 119, 120, 13, 14, 130, 131, 80, - 31, 33, 32, 81, 82, 83, 73, 205, 186, 214, - 234, 235, 37, 74, 202, 212, 231, 241, 232, 84 + 31, 33, 32, 81, 82, 83, 73, 209, 210, 186, + 219, 240, 241, 37, 74, 202, 217, 237, 247, 238, + 206 }; static const short yypact[] = { - -23,-32768, 39, 46,-32768,-32768,-32768, -26,-32768, 2, - -32768,-32768,-32768, 4, 22,-32768, 77, 77, 89, 89, - 276, 77,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 84, - 84, 23, 23, 23, 84, 84,-32768,-32768,-32768,-32768, - -32768, 60, 27, 63,-32768,-32768,-32768,-32768,-32768,-32768, + -22,-32768, 39, 46,-32768,-32768,-32768, 20,-32768, 22, + -32768,-32768,-32768, 37, 55,-32768, 89, 89, 95, 95, + 281, 89,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 139, + 139, 23, 23, 23, 139, 139,-32768,-32768,-32768,-32768, + -32768, 97, 28, 94,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768,-32768, 82, 85,-32768,-32768, - -32768,-32768, 11, 40,-32768, 88,-32768,-32768,-32768,-32768, - -32768, 93,-32768, 90,-32768, 91, 94,-32768,-32768, 95, - 96, 137,-32768, 89,-32768,-32768, 99, 144, 84, 176, - 276,-32768, 39,-32768,-32768,-32768, 178, 135,-32768, 180, - 139,-32768,-32768, 42, 60, 39, 39,-32768, -13, 131, - -32768,-32768,-32768, -8, 138,-32768,-32768, -3,-32768,-32768, - -32768, 7,-32768,-32768,-32768, 136,-32768,-32768,-32768, 146, - -32768,-32768,-32768, 147,-32768,-32768, 60,-32768, 148,-32768, - -32768, 99,-32768, 99, 84, 99, 176, 176, 152, 176, - -32768, 142, 178, 200,-32768, 180, 238,-32768, 89, 145, - -32768,-32768, 26, 50, 10, 84,-32768,-32768,-32768, 56, + -32768,-32768,-32768,-32768,-32768,-32768, 90, 93,-32768,-32768, + -32768,-32768, 27, 53,-32768, 91,-32768,-32768,-32768,-32768, + -32768, 96,-32768, 101,-32768, 98, 127,-32768,-32768, 134, + 135, 183,-32768, 95,-32768,-32768, 48, 184, 139, 176, + 281,-32768, 39,-32768,-32768,-32768, 185, 142,-32768, 187, + 145,-32768,-32768, 31, 97, 39, 39,-32768, -13, 140, + -32768,-32768,-32768, 47, 144,-32768,-32768, -3,-32768,-32768, + -32768, 7,-32768,-32768,-32768, 147,-32768,-32768,-32768, 149, + -32768,-32768,-32768, 150,-32768,-32768, 97,-32768, 153,-32768, + -32768, 48,-32768, 48, 139, 48, 176, 176, 157, 176, + -32768, 154, 185, 205,-32768, 187, 243,-32768, 95, 151, + -32768,-32768, 25, 51, 10, 139,-32768,-32768,-32768, 70, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768,-32768, 154,-32768, 60, 99,-32768,-32768, 176, - -32768,-32768,-32768,-32768,-32768, 92,-32768, 92, 79,-32768, - -32768,-32768, 143,-32768, 187, 276,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - 157,-32768,-32768,-32768,-32768, 155, 149, 156,-32768,-32768, - -32768, 39,-32768, 187,-32768, 276, 158,-32768,-32768,-32768, - 209, 211,-32768 + -32768,-32768,-32768,-32768,-32768, 97, 48,-32768,-32768, 176, + -32768,-32768,-32768,-32768,-32768, 92,-32768, 92, 79, 92, + -32768,-32768,-32768, 160,-32768,-32768,-32768, 143,-32768, 200, + 281,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + -32768,-32768,-32768,-32768,-32768,-32768, 163,-32768,-32768,-32768, + -32768, 161, 155, 165,-32768,-32768,-32768, 39,-32768, 200, + -32768, 281, 164,-32768,-32768,-32768, 214, 217,-32768 }; static const short yypgoto[] = { - -32768,-32768, -88, 194,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768, 74,-32768,-32768,-32768,-32768, 234,-32768, 73, - -32768,-32768,-32768,-32768, 75,-32768,-32768,-32768, -5, 150, - -32768, 151, -131,-32768, -129,-32768,-32768, 222,-32768, 87, - 119,-32768,-32768, -133, -27, -95, -90, -125, -126, -2, - -32768,-32768,-32768, 105, 161,-32768,-32768, -60, 83,-32768, - 32,-32768, 86, 242,-32768,-32768,-32768,-32768,-32768, 0 + -32768,-32768, -88, 222,-32768,-32768,-32768,-32768,-32768,-32768, + -32768,-32768, 80,-32768,-32768,-32768,-32768, 240,-32768, 81, + -32768,-32768,-32768,-32768, 78,-32768,-32768,-32768, -4, 148, + -32768, 156, -144,-32768, -129,-32768,-32768, 229,-32768, 99, + 124,-32768,-32768, -133, -27, -95, -90, -125, -107, -2, + -32768,-32768,-32768, 106, 167,-32768,-32768, -73, -8, 88, + -32768, 32,-32768, 120, 277,-32768,-32768,-32768,-32768,-32768, + 0 }; -#define YYLAST 311 +#define YYLAST 316 static const short yytable[] = { 15, 4, 77, 78, 128, 114, 160, 87, 88, 129, - 5, 6, 125, 5, 6, 125, 38, 38, 169, -58, - 170, 38, 1, 2, 29, 146, 5, 6, 7, 8, - 9, 174, 184, 176, 185, 192, 128, 193, 151, 92, - 154, 129, 5, 6, 7, 8, 9, 152, 157, 200, - 40, 155, 30, 158, 34, 16, 17, 18, 19, 20, - 21, 128, 128, 210, 128, 159, 129, 129, 199, 129, - 96, 124, 35, 211, 79, 10, 93, 151, 11, 128, - 195, 229, 12, 230, 129, 36, 197, 76, 98, 108, - 111, 10, 145, 22, 11, 99, 121, 40, 12, 132, - 136, 157, 76, 39, 128, 117, 198, 75, 91, 129, - 203, 204, 93, 149, 150, 216, 217, 218, 219, 220, - 221, 222, 223, 224, 207, 208, 225, 171, 216, 217, - 218, 219, 220, 221, 222, 223, 224, 85, 86, 94, - 164, 102, 95, 100, 167, 112, 101, 104, 201, 106, - 109, 44, 122, 17, 105, 121, 132, 21, 226, 45, + 5, 6, 125, 5, 6, 125, 38, 38, 169, 184, + 170, 38, 192, 1, 2, 146, 5, 6, 7, 8, + 9, 84, 84, 84, 185, -58, 128, 193, 151, 40, + 92, 129, 5, 6, 7, 8, 9, 152, 157, 200, + 174, 76, 176, 158, 117, 16, 17, 18, 19, 20, + 21, 128, 128, 215, 128, 159, 129, 129, 199, 129, + 29, 124, 30, 235, 79, 10, 151, 93, 11, 128, + 195, 145, 12, 84, 129, 197, 96, 34, 236, 108, + 111, 10, 216, 22, 11, 154, 121, 36, 12, 132, + 136, 98, 157, 40, 128, 35, 155, 198, 99, 129, + 205, 207, 208, 149, 150, 221, 222, 223, 224, 225, + 226, 227, 228, 229, 203, 204, 230, 171, 221, 222, + 223, 224, 225, 226, 227, 228, 229, 39, 85, 86, + 164, 75, 76, 93, 167, 91, 100, 94, 201, 101, + 95, 44, 102, 17, 104, 121, 132, 21, 232, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 5, - 6, 125, 126, 206, 206, 206, 137, 140, 141, 153, - 227, 144, 161, 156, 177, 233, 228, 162, 165, 168, - 175, 209, 213, 196, 242, 244, 243, 245, 179, 251, - 17, 252, 249, 43, 21, 240, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 178, 27, 187, 246, - 248, 191, 70, 173, 103, 28, 179, 180, 17, 194, - 133, 134, 21, 181, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 172, 247, 0, 0, 0, 0, - 0, 0, 0, 0, 44, 188, 17, 0, 0, 0, - 21, 189, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64 + 6, 125, 126, 211, 212, 213, 214, 105, 106, 109, + 233, 112, 122, 137, 140, 141, 234, 144, 153, 156, + 162, 165, 218, 161, 168, 175, 177, 231, 239, 196, + 248, 250, 249, 179, 257, 17, 251, 258, 255, 21, + 246, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 43, 178, 27, 191, 252, 187, 254, 133, 70, + 103, 179, 180, 17, 194, 173, 134, 21, 181, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 172, + 28, 253, 0, 0, 0, 0, 0, 0, 0, 44, + 188, 17, 0, 0, 0, 21, 189, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64 }; static const short yycheck[] = { 2, 1, 29, 30, 99, 93, 131, 34, 35, 99, - 3, 4, 5, 3, 4, 5, 16, 17, 151, 8, - 153, 21, 45, 46, 50, 113, 3, 4, 5, 6, - 7, 157, 163, 159, 163, 166, 131, 166, 51, 12, - 48, 131, 3, 4, 5, 6, 7, 60, 51, 174, - 8, 59, 50, 56, 50, 9, 10, 11, 12, 13, + 3, 4, 5, 3, 4, 5, 16, 17, 151, 163, + 153, 21, 166, 45, 46, 113, 3, 4, 5, 6, + 7, 31, 32, 33, 163, 8, 131, 166, 51, 8, + 12, 131, 3, 4, 5, 6, 7, 60, 51, 174, + 157, 3, 159, 56, 6, 9, 10, 11, 12, 13, 14, 156, 157, 196, 159, 58, 156, 157, 58, 159, - 59, 98, 50, 199, 51, 52, 49, 51, 55, 174, - 168, 212, 59, 212, 174, 8, 60, 3, 48, 89, - 90, 52, 50, 47, 55, 55, 96, 8, 59, 99, - 102, 51, 3, 17, 199, 6, 56, 21, 48, 199, - 54, 55, 49, 115, 116, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 184, 185, 47, 154, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 32, 33, 57, - 140, 51, 57, 55, 144, 8, 53, 56, 175, 54, - 54, 8, 8, 10, 60, 155, 156, 14, 15, 16, + 50, 98, 50, 217, 51, 52, 51, 49, 55, 174, + 168, 50, 59, 83, 174, 60, 59, 50, 217, 89, + 90, 52, 199, 47, 55, 48, 96, 8, 59, 99, + 102, 48, 51, 8, 199, 50, 59, 56, 55, 199, + 183, 184, 185, 115, 116, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 54, 55, 47, 154, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 17, 32, 33, + 140, 21, 3, 49, 144, 48, 55, 57, 175, 53, + 57, 8, 51, 10, 56, 155, 156, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 3, - 4, 5, 6, 183, 184, 185, 8, 52, 8, 58, - 47, 52, 56, 55, 52, 8, 53, 51, 51, 51, - 48, 47, 202, 58, 47, 56, 51, 51, 8, 0, - 10, 0, 54, 19, 14, 215, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 162, 3, 165, 241, - 245, 166, 20, 156, 83, 3, 8, 47, 10, 166, - 100, 100, 14, 53, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 155, 243, -1, -1, -1, -1, - -1, -1, -1, -1, 8, 47, 10, -1, -1, -1, - 14, 53, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35 + 4, 5, 6, 191, 192, 193, 194, 60, 54, 54, + 47, 8, 8, 8, 52, 8, 53, 52, 58, 55, + 51, 51, 202, 56, 51, 48, 52, 47, 8, 58, + 47, 56, 51, 8, 0, 10, 51, 0, 54, 14, + 220, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 19, 162, 3, 166, 247, 165, 251, 100, 20, + 83, 8, 47, 10, 166, 156, 100, 14, 53, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 155, + 3, 249, -1, -1, -1, -1, -1, -1, -1, 8, + 47, 10, -1, -1, -1, 14, 53, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/usr/share/bison/bison.simple" @@ -1217,7 +1220,7 @@ yyreduce: switch (yyn) { case 5: -#line 161 "dcParser.yxx" +#line 162 "dcParser.yxx" { if (!dc_file->add_class(yyvsp[0].u.dclass)) { DCClass *old_class = dc_file->get_class_by_name(yyvsp[0].u.dclass->get_name()); @@ -1230,7 +1233,7 @@ case 5: } break; case 6: -#line 172 "dcParser.yxx" +#line 173 "dcParser.yxx" { if (!dc_file->add_switch(yyvsp[0].u.dswitch)) { yyerror("Duplicate class name: " + yyvsp[0].u.dswitch->get_name()); @@ -1238,49 +1241,49 @@ case 6: } break; case 10: -#line 184 "dcParser.yxx" +#line 185 "dcParser.yxx" { yyval.str = yyvsp[-2].str + string("/") + yyvsp[0].str; } break; case 12: -#line 192 "dcParser.yxx" +#line 193 "dcParser.yxx" { yyval.str = yyvsp[-2].str + string(".") + yyvsp[0].str; } break; case 13: -#line 199 "dcParser.yxx" +#line 200 "dcParser.yxx" { dc_file->add_import_module(yyvsp[0].str); } break; case 14: -#line 203 "dcParser.yxx" +#line 204 "dcParser.yxx" { dc_file->add_import_module(yyvsp[-1].str); } break; case 17: -#line 212 "dcParser.yxx" +#line 213 "dcParser.yxx" { dc_file->add_import_symbol("*"); } break; case 18: -#line 219 "dcParser.yxx" +#line 220 "dcParser.yxx" { dc_file->add_import_symbol(yyvsp[0].str); } break; case 19: -#line 223 "dcParser.yxx" +#line 224 "dcParser.yxx" { dc_file->add_import_symbol(yyvsp[0].str); } break; case 20: -#line 230 "dcParser.yxx" +#line 231 "dcParser.yxx" { DCTypedef *dtypedef = new DCTypedef(yyvsp[0].u.parameter); @@ -1295,21 +1298,21 @@ case 20: } break; case 23: -#line 251 "dcParser.yxx" +#line 252 "dcParser.yxx" { yyval.u.dclass = current_class; current_class = new DCClass(yyvsp[0].str, false, false); } break; case 24: -#line 256 "dcParser.yxx" +#line 257 "dcParser.yxx" { yyval.u.dclass = current_class; current_class = yyvsp[-4].u.dclass; } break; case 25: -#line 264 "dcParser.yxx" +#line 265 "dcParser.yxx" { DCClass *dclass = dc_file->get_class_by_name(yyvsp[0].str); if (dclass == (DCClass *)NULL) { @@ -1325,7 +1328,7 @@ case 25: } break; case 28: -#line 286 "dcParser.yxx" +#line 287 "dcParser.yxx" { if (yyvsp[0].u.dclass != (DCClass *)NULL) { current_class->add_parent(yyvsp[0].u.dclass); @@ -1333,7 +1336,7 @@ case 28: } break; case 29: -#line 292 "dcParser.yxx" +#line 293 "dcParser.yxx" { if (yyvsp[0].u.dclass != (DCClass *)NULL) { current_class->add_parent(yyvsp[0].u.dclass); @@ -1341,50 +1344,53 @@ case 29: } break; case 32: -#line 303 "dcParser.yxx" +#line 304 "dcParser.yxx" { if (!current_class->add_field(yyvsp[0].u.field)) { yyerror("Duplicate field name: " + yyvsp[0].u.field->get_name()); + } else if (yyvsp[0].u.field->get_number() < 0) { + yyerror("A non-network field cannot be stored on a dclass"); } } break; case 33: -#line 312 "dcParser.yxx" +#line 315 "dcParser.yxx" { yyval.u.field = yyvsp[-1].u.field; yyval.u.field->set_flags(yyvsp[0].u.s_int); } break; case 35: -#line 318 "dcParser.yxx" +#line 321 "dcParser.yxx" { + yyerror("Unnamed parameters are not allowed on a dclass"); yyval.u.field = yyvsp[-2].u.parameter; yyval.u.field->set_flags(yyvsp[-1].u.s_int); } break; case 36: -#line 323 "dcParser.yxx" +#line 327 "dcParser.yxx" { yyval.u.field = yyvsp[-1].u.parameter; yyval.u.field->set_flags(yyvsp[0].u.s_int); } break; case 37: -#line 331 "dcParser.yxx" +#line 335 "dcParser.yxx" { yyval.u.dclass = current_class; current_class = new DCClass(yyvsp[0].str, true, false); } break; case 38: -#line 336 "dcParser.yxx" +#line 340 "dcParser.yxx" { yyval.u.dclass = current_class; current_class = yyvsp[-4].u.dclass; } break; case 39: -#line 344 "dcParser.yxx" +#line 348 "dcParser.yxx" { DCClass *dstruct = dc_file->get_class_by_name(yyvsp[0].str); if (dstruct == (DCClass *)NULL) { @@ -1400,7 +1406,7 @@ case 39: } break; case 42: -#line 366 "dcParser.yxx" +#line 370 "dcParser.yxx" { if (yyvsp[0].u.dclass != (DCClass *)NULL) { current_class->add_parent(yyvsp[0].u.dclass); @@ -1408,7 +1414,7 @@ case 42: } break; case 43: -#line 372 "dcParser.yxx" +#line 376 "dcParser.yxx" { if (yyvsp[0].u.dclass != (DCClass *)NULL) { current_class->add_parent(yyvsp[0].u.dclass); @@ -1416,7 +1422,7 @@ case 43: } break; case 46: -#line 383 "dcParser.yxx" +#line 387 "dcParser.yxx" { if (!current_class->add_field(yyvsp[0].u.field)) { yyerror("Duplicate field name: " + yyvsp[0].u.field->get_name()); @@ -1424,51 +1430,51 @@ case 46: } break; case 49: -#line 394 "dcParser.yxx" +#line 398 "dcParser.yxx" +{ + yyval.u.field = yyvsp[-2].u.parameter; +} + break; +case 50: +#line 402 "dcParser.yxx" { yyval.u.field = yyvsp[-1].u.parameter; } break; -case 50: -#line 398 "dcParser.yxx" -{ - yyval.u.field = yyvsp[0].u.parameter; -} - break; case 51: -#line 405 "dcParser.yxx" +#line 409 "dcParser.yxx" { yyval.u.field = current_atomic; current_atomic = new DCAtomicField(yyvsp[-1].str); } break; case 52: -#line 410 "dcParser.yxx" +#line 414 "dcParser.yxx" { yyval.u.field = current_atomic; current_atomic = yyvsp[-2].u.atomic; } break; case 57: -#line 428 "dcParser.yxx" +#line 432 "dcParser.yxx" { current_atomic->add_element(yyvsp[0].u.parameter); } break; case 58: -#line 435 "dcParser.yxx" +#line 439 "dcParser.yxx" { current_parameter = yyvsp[0].u.parameter; } break; case 59: -#line 439 "dcParser.yxx" +#line 443 "dcParser.yxx" { yyval.u.parameter = yyvsp[0].u.parameter; } break; case 62: -#line 451 "dcParser.yxx" +#line 455 "dcParser.yxx" { current_packer = &default_packer; current_packer->clear_data(); @@ -1476,7 +1482,7 @@ case 62: } break; case 63: -#line 457 "dcParser.yxx" +#line 461 "dcParser.yxx" { bool is_valid = yyvsp[-3].u.parameter->is_valid(); if (current_packer->end_pack()) { @@ -1493,7 +1499,7 @@ case 63: } break; case 65: -#line 476 "dcParser.yxx" +#line 480 "dcParser.yxx" { current_packer = &default_packer; current_packer->clear_data(); @@ -1501,7 +1507,7 @@ case 65: } break; case 66: -#line 482 "dcParser.yxx" +#line 486 "dcParser.yxx" { bool is_valid = yyvsp[-3].u.parameter->is_valid(); if (current_packer->end_pack()) { @@ -1518,13 +1524,13 @@ case 66: } break; case 71: -#line 510 "dcParser.yxx" +#line 514 "dcParser.yxx" { yyval.u.parameter = new DCSimpleParameter(yyvsp[0].u.subatomic); } break; case 72: -#line 514 "dcParser.yxx" +#line 518 "dcParser.yxx" { DCSimpleParameter *simple_param = new DCSimpleParameter(yyvsp[-3].u.subatomic); if (!simple_param->set_range(double_range)) { @@ -1534,7 +1540,7 @@ case 72: } break; case 73: -#line 522 "dcParser.yxx" +#line 526 "dcParser.yxx" { DCSimpleParameter *simple_param = new DCSimpleParameter(yyvsp[-2].u.subatomic); if (yyvsp[0].u.s_uint == 0) { @@ -1547,7 +1553,7 @@ case 73: } break; case 74: -#line 533 "dcParser.yxx" +#line 537 "dcParser.yxx" { DCSimpleParameter *simple_param = new DCSimpleParameter(yyvsp[-5].u.subatomic); if (yyvsp[-3].u.s_uint == 0) { @@ -1563,7 +1569,7 @@ case 74: } break; case 75: -#line 547 "dcParser.yxx" +#line 551 "dcParser.yxx" { DCSimpleParameter *simple_param = new DCSimpleParameter(yyvsp[-5].u.subatomic); if (yyvsp[0].u.s_uint == 0) { @@ -1579,7 +1585,7 @@ case 75: } break; case 76: -#line 561 "dcParser.yxx" +#line 565 "dcParser.yxx" { DCTypedef *dtypedef = dc_file->get_typedef_by_name(yyvsp[0].str); if (dtypedef == (DCTypedef *)NULL) { @@ -1610,7 +1616,7 @@ case 76: } break; case 77: -#line 590 "dcParser.yxx" +#line 594 "dcParser.yxx" { // This is an inline struct definition. dc_file->add_thing_to_delete(yyvsp[0].u.dclass); @@ -1618,7 +1624,7 @@ case 77: } break; case 78: -#line 596 "dcParser.yxx" +#line 600 "dcParser.yxx" { // This is an inline switch definition. dc_file->add_thing_to_delete(yyvsp[0].u.dswitch); @@ -1626,13 +1632,13 @@ case 78: } break; case 79: -#line 605 "dcParser.yxx" +#line 609 "dcParser.yxx" { double_range.clear(); } break; case 80: -#line 609 "dcParser.yxx" +#line 613 "dcParser.yxx" { double_range.clear(); if (!double_range.add_range(yyvsp[0].u.real, yyvsp[0].u.real)) { @@ -1641,7 +1647,7 @@ case 80: } break; case 81: -#line 616 "dcParser.yxx" +#line 620 "dcParser.yxx" { double_range.clear(); if (!double_range.add_range(yyvsp[-2].u.real, yyvsp[0].u.real)) { @@ -1650,7 +1656,7 @@ case 81: } break; case 82: -#line 623 "dcParser.yxx" +#line 627 "dcParser.yxx" { double_range.clear(); if (yyvsp[0].u.real >= 0) { @@ -1661,7 +1667,7 @@ case 82: } break; case 83: -#line 632 "dcParser.yxx" +#line 636 "dcParser.yxx" { if (!double_range.add_range(yyvsp[0].u.real, yyvsp[0].u.real)) { yyerror("Overlapping range"); @@ -1669,7 +1675,7 @@ case 83: } break; case 84: -#line 638 "dcParser.yxx" +#line 642 "dcParser.yxx" { if (!double_range.add_range(yyvsp[-2].u.real, yyvsp[0].u.real)) { yyerror("Overlapping range"); @@ -1677,7 +1683,7 @@ case 84: } break; case 85: -#line 644 "dcParser.yxx" +#line 648 "dcParser.yxx" { if (yyvsp[0].u.real >= 0) { yyerror("Syntax error"); @@ -1687,13 +1693,13 @@ case 85: } break; case 86: -#line 655 "dcParser.yxx" +#line 659 "dcParser.yxx" { uint_range.clear(); } break; case 87: -#line 659 "dcParser.yxx" +#line 663 "dcParser.yxx" { uint_range.clear(); if (!uint_range.add_range(yyvsp[0].u.s_uint, yyvsp[0].u.s_uint)) { @@ -1702,7 +1708,7 @@ case 87: } break; case 88: -#line 666 "dcParser.yxx" +#line 670 "dcParser.yxx" { uint_range.clear(); if (!uint_range.add_range(yyvsp[-2].u.s_uint, yyvsp[0].u.s_uint)) { @@ -1711,7 +1717,7 @@ case 88: } break; case 89: -#line 673 "dcParser.yxx" +#line 677 "dcParser.yxx" { if (!uint_range.add_range(yyvsp[0].u.s_uint, yyvsp[0].u.s_uint)) { yyerror("Overlapping range"); @@ -1719,7 +1725,7 @@ case 89: } break; case 90: -#line 679 "dcParser.yxx" +#line 683 "dcParser.yxx" { if (!uint_range.add_range(yyvsp[-2].u.s_uint, yyvsp[0].u.s_uint)) { yyerror("Overlapping range"); @@ -1727,20 +1733,20 @@ case 90: } break; case 92: -#line 689 "dcParser.yxx" +#line 693 "dcParser.yxx" { yyval.u.parameter = new DCArrayParameter(yyvsp[-3].u.parameter, uint_range); } break; case 93: -#line 696 "dcParser.yxx" +#line 700 "dcParser.yxx" { current_parameter->set_name(yyvsp[0].str); yyval.u.parameter = current_parameter; } break; case 94: -#line 701 "dcParser.yxx" +#line 705 "dcParser.yxx" { if (yyvsp[0].u.s_uint == 0) { yyerror("Invalid divisor."); @@ -1756,13 +1762,13 @@ case 94: } break; case 95: -#line 715 "dcParser.yxx" +#line 719 "dcParser.yxx" { yyval.u.parameter = new DCArrayParameter(yyvsp[-3].u.parameter, uint_range); } break; case 96: -#line 722 "dcParser.yxx" +#line 726 "dcParser.yxx" { if (yyvsp[0].str.length() != 1) { yyerror("Single character required."); @@ -1773,7 +1779,7 @@ case 96: } break; case 98: -#line 735 "dcParser.yxx" +#line 739 "dcParser.yxx" { yyval.u.s_uint = (unsigned int)yyvsp[0].u.uint64; if (yyval.u.s_uint != yyvsp[0].u.uint64) { @@ -1783,19 +1789,19 @@ case 98: } break; case 101: -#line 754 "dcParser.yxx" +#line 758 "dcParser.yxx" { yyval.u.real = (double)yyvsp[0].u.uint64; } break; case 102: -#line 758 "dcParser.yxx" +#line 762 "dcParser.yxx" { yyval.u.real = (double)yyvsp[0].u.int64; } break; case 104: -#line 766 "dcParser.yxx" +#line 770 "dcParser.yxx" { if (yyvsp[0].str.length() != 1) { yyerror("Single character required."); @@ -1806,73 +1812,73 @@ case 104: } break; case 106: -#line 780 "dcParser.yxx" +#line 784 "dcParser.yxx" { current_packer->pack_int64(yyvsp[0].u.int64); } break; case 107: -#line 784 "dcParser.yxx" +#line 788 "dcParser.yxx" { current_packer->pack_uint64(yyvsp[0].u.uint64); } break; case 108: -#line 788 "dcParser.yxx" +#line 792 "dcParser.yxx" { current_packer->pack_double(yyvsp[0].u.real); } break; case 109: -#line 792 "dcParser.yxx" +#line 796 "dcParser.yxx" { current_packer->pack_string(yyvsp[0].str); } break; case 110: -#line 796 "dcParser.yxx" +#line 800 "dcParser.yxx" { current_packer->pack_literal_value(yyvsp[0].str); } break; case 111: -#line 800 "dcParser.yxx" +#line 804 "dcParser.yxx" { current_packer->push(); } break; case 112: -#line 804 "dcParser.yxx" +#line 808 "dcParser.yxx" { current_packer->pop(); } break; case 113: -#line 808 "dcParser.yxx" +#line 812 "dcParser.yxx" { current_packer->push(); } break; case 114: -#line 812 "dcParser.yxx" +#line 816 "dcParser.yxx" { current_packer->pop(); } break; case 115: -#line 816 "dcParser.yxx" +#line 820 "dcParser.yxx" { current_packer->push(); } break; case 116: -#line 820 "dcParser.yxx" +#line 824 "dcParser.yxx" { current_packer->pop(); } break; case 117: -#line 824 "dcParser.yxx" +#line 828 "dcParser.yxx" { for (unsigned int i = 0; i < yyvsp[0].u.s_uint; i++) { current_packer->pack_int64(yyvsp[-2].u.int64); @@ -1880,7 +1886,7 @@ case 117: } break; case 118: -#line 830 "dcParser.yxx" +#line 834 "dcParser.yxx" { for (unsigned int i = 0; i < yyvsp[0].u.s_uint; i++) { current_packer->pack_uint64(yyvsp[-2].u.uint64); @@ -1888,7 +1894,7 @@ case 118: } break; case 119: -#line 836 "dcParser.yxx" +#line 840 "dcParser.yxx" { for (unsigned int i = 0; i < yyvsp[0].u.s_uint; i++) { current_packer->pack_double(yyvsp[-2].u.real); @@ -1896,7 +1902,7 @@ case 119: } break; case 120: -#line 842 "dcParser.yxx" +#line 846 "dcParser.yxx" { for (unsigned int i = 0; i < yyvsp[0].u.s_uint; i++) { current_packer->pack_literal_value(yyvsp[-2].str); @@ -1904,199 +1910,208 @@ case 120: } break; case 127: -#line 866 "dcParser.yxx" +#line 870 "dcParser.yxx" { yyval.u.subatomic = ST_int8; } break; case 128: -#line 870 "dcParser.yxx" +#line 874 "dcParser.yxx" { yyval.u.subatomic = ST_int16; } break; case 129: -#line 874 "dcParser.yxx" +#line 878 "dcParser.yxx" { yyval.u.subatomic = ST_int32; } break; case 130: -#line 878 "dcParser.yxx" +#line 882 "dcParser.yxx" { yyval.u.subatomic = ST_int64; } break; case 131: -#line 882 "dcParser.yxx" +#line 886 "dcParser.yxx" { yyval.u.subatomic = ST_uint8; } break; case 132: -#line 886 "dcParser.yxx" +#line 890 "dcParser.yxx" { yyval.u.subatomic = ST_uint16; } break; case 133: -#line 890 "dcParser.yxx" +#line 894 "dcParser.yxx" { yyval.u.subatomic = ST_uint32; } break; case 134: -#line 894 "dcParser.yxx" +#line 898 "dcParser.yxx" { yyval.u.subatomic = ST_uint64; } break; case 135: -#line 898 "dcParser.yxx" +#line 902 "dcParser.yxx" { yyval.u.subatomic = ST_float64; } break; case 136: -#line 902 "dcParser.yxx" +#line 906 "dcParser.yxx" { yyval.u.subatomic = ST_string; } break; case 137: -#line 906 "dcParser.yxx" +#line 910 "dcParser.yxx" { yyval.u.subatomic = ST_blob; } break; case 138: -#line 910 "dcParser.yxx" +#line 914 "dcParser.yxx" { yyval.u.subatomic = ST_blob32; } break; case 139: -#line 914 "dcParser.yxx" +#line 918 "dcParser.yxx" { yyval.u.subatomic = ST_int8array; } break; case 140: -#line 918 "dcParser.yxx" +#line 922 "dcParser.yxx" { yyval.u.subatomic = ST_int16array; } break; case 141: -#line 922 "dcParser.yxx" +#line 926 "dcParser.yxx" { yyval.u.subatomic = ST_int32array; } break; case 142: -#line 926 "dcParser.yxx" +#line 930 "dcParser.yxx" { yyval.u.subatomic = ST_uint8array; } break; case 143: -#line 930 "dcParser.yxx" +#line 934 "dcParser.yxx" { yyval.u.subatomic = ST_uint16array; } break; case 144: -#line 934 "dcParser.yxx" +#line 938 "dcParser.yxx" { yyval.u.subatomic = ST_uint32array; } break; case 145: -#line 938 "dcParser.yxx" +#line 942 "dcParser.yxx" { yyval.u.subatomic = ST_uint32uint8array; } break; case 146: -#line 942 "dcParser.yxx" +#line 946 "dcParser.yxx" { yyval.u.subatomic = ST_char; } break; case 147: -#line 949 "dcParser.yxx" +#line 953 "dcParser.yxx" { yyval.u.s_int = 0; } break; case 148: -#line 953 "dcParser.yxx" +#line 957 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_required; } break; case 149: -#line 957 "dcParser.yxx" +#line 961 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_broadcast; } break; case 150: -#line 961 "dcParser.yxx" +#line 965 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_p2p; } break; case 151: -#line 965 "dcParser.yxx" +#line 969 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_ram; } break; case 152: -#line 969 "dcParser.yxx" +#line 973 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_db; } break; case 153: -#line 973 "dcParser.yxx" +#line 977 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_clsend; } break; case 154: -#line 977 "dcParser.yxx" +#line 981 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_clrecv; } break; case 155: -#line 981 "dcParser.yxx" +#line 985 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_ownsend; } break; case 156: -#line 985 "dcParser.yxx" +#line 989 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_airecv; } break; case 157: -#line 992 "dcParser.yxx" +#line 996 "dcParser.yxx" +{ + if (yyvsp[0].u.s_int != 0) { + yyerror("Server flags are not allowed here."); + } + yyval.u.s_int = yyvsp[0].u.s_int; +} + break; +case 158: +#line 1006 "dcParser.yxx" { current_molecular = new DCMolecularField(yyvsp[-1].str); } break; -case 158: -#line 996 "dcParser.yxx" +case 159: +#line 1010 "dcParser.yxx" { yyval.u.field = current_molecular; } break; -case 159: -#line 1003 "dcParser.yxx" +case 160: +#line 1017 "dcParser.yxx" { DCField *field = current_class->get_field_by_name(yyvsp[0].str); yyval.u.atomic = (DCAtomicField *)NULL; @@ -2110,16 +2125,16 @@ case 159: } } break; -case 160: -#line 1019 "dcParser.yxx" +case 161: +#line 1033 "dcParser.yxx" { if (yyvsp[0].u.atomic != (DCAtomicField *)NULL) { current_molecular->add_atomic(yyvsp[0].u.atomic); } } break; -case 161: -#line 1025 "dcParser.yxx" +case 162: +#line 1039 "dcParser.yxx" { if (yyvsp[0].u.atomic != (DCAtomicField *)NULL) { current_molecular->add_atomic(yyvsp[0].u.atomic); @@ -2131,28 +2146,28 @@ case 161: } } break; -case 162: -#line 1039 "dcParser.yxx" +case 163: +#line 1053 "dcParser.yxx" { yyval.str = ""; } break; -case 164: -#line 1047 "dcParser.yxx" +case 165: +#line 1061 "dcParser.yxx" { yyval.u.dswitch = current_switch; current_switch = new DCSwitch(yyvsp[-4].str, yyvsp[-2].u.parameter); } break; -case 165: -#line 1052 "dcParser.yxx" +case 166: +#line 1066 "dcParser.yxx" { yyval.u.dswitch = current_switch; current_switch = (DCSwitch *)yyvsp[-2].u.parameter; } break; -case 169: -#line 1064 "dcParser.yxx" +case 170: +#line 1078 "dcParser.yxx" { if (current_switch->get_num_cases() == 0) { yyerror("case declaration required before first element"); @@ -2161,16 +2176,16 @@ case 169: } } break; -case 170: -#line 1075 "dcParser.yxx" +case 171: +#line 1089 "dcParser.yxx" { current_packer = &default_packer; current_packer->clear_data(); current_packer->begin_pack(current_switch->get_key_parameter()); } break; -case 171: -#line 1081 "dcParser.yxx" +case 172: +#line 1095 "dcParser.yxx" { if (!current_packer->end_pack()) { yyerror("Invalid value for switch parameter"); @@ -2179,14 +2194,14 @@ case 171: } } break; -case 172: -#line 1092 "dcParser.yxx" +case 173: +#line 1106 "dcParser.yxx" { yyval.u.field = yyvsp[-1].u.parameter; } break; -case 173: -#line 1096 "dcParser.yxx" +case 174: +#line 1110 "dcParser.yxx" { yyval.u.field = yyvsp[0].u.parameter; } @@ -2424,4 +2439,4 @@ yyreturn: #endif return yyresult; } -#line 1104 "dcParser.yxx" +#line 1118 "dcParser.yxx" diff --git a/direct/src/dcparser/dcParser.yxx b/direct/src/dcparser/dcParser.yxx index e94443b189..1833f5094f 100644 --- a/direct/src/dcparser/dcParser.yxx +++ b/direct/src/dcparser/dcParser.yxx @@ -116,6 +116,7 @@ dc_cleanup_parser() { %type atomic_name %type server_flags +%type no_server_flags %type dclass_or_struct %type dclass_name %type dclass @@ -303,6 +304,8 @@ dclass_fields: { if (!current_class->add_field($2)) { yyerror("Duplicate field name: " + $2->get_name()); + } else if ($2->get_number() < 0) { + yyerror("A non-network field cannot be stored on a dclass"); } } ; @@ -313,9 +316,10 @@ dclass_field: $$ = $1; $$->set_flags($2); } - | molecular_field + | molecular_field no_server_flags | unnamed_parameter_with_default server_flags ';' { + yyerror("Unnamed parameters are not allowed on a dclass"); $$ = $1; $$->set_flags($2); } @@ -388,13 +392,13 @@ struct_fields: ; struct_field: - atomic_field - | molecular_field - | unnamed_parameter_with_default ';' + atomic_field no_server_flags + | molecular_field no_server_flags + | unnamed_parameter_with_default no_server_flags ';' { $$ = $1; } - | named_parameter_with_default + | named_parameter_with_default no_server_flags { $$ = $1; } @@ -987,6 +991,16 @@ server_flags: } ; +no_server_flags: + server_flags +{ + if ($1 != 0) { + yyerror("Server flags are not allowed here."); + } + $$ = $1; +} + ; + molecular_field: IDENTIFIER ':' {