From 2cc8ea03b8ef0e979cb1a5219ed7d98dcb485ab0 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 25 Jul 2005 18:42:30 +0000 Subject: [PATCH] add customizable dc keywords --- direct/src/dcparser/Sources.pp | 5 +- direct/src/dcparser/dcAtomicField.cxx | 5 +- direct/src/dcparser/dcField.cxx | 98 +- direct/src/dcparser/dcField.h | 30 +- direct/src/dcparser/dcFile.cxx | 105 + direct/src/dcparser/dcFile.h | 12 + direct/src/dcparser/dcKeyword.cxx | 111 + direct/src/dcparser/dcKeyword.h | 59 + direct/src/dcparser/dcKeywordList.cxx | 220 ++ direct/src/dcparser/dcKeywordList.h | 67 + direct/src/dcparser/dcLexer.cxx.prebuilt | 504 ++- direct/src/dcparser/dcLexer.lxx | 61 +- direct/src/dcparser/dcMolecularField.cxx | 2 +- direct/src/dcparser/dcParameter.cxx | 8 +- direct/src/dcparser/dcParser.cxx.prebuilt | 3430 ++++++++++--------- direct/src/dcparser/dcParser.h.prebuilt | 173 +- direct/src/dcparser/dcParser.yxx | 121 +- direct/src/dcparser/dcParserDefs.h | 4 + direct/src/dcparser/dcbase.h | 3 + direct/src/dcparser/dcparser_composite1.cxx | 2 + 20 files changed, 2875 insertions(+), 2145 deletions(-) create mode 100644 direct/src/dcparser/dcKeyword.cxx create mode 100644 direct/src/dcparser/dcKeyword.h create mode 100644 direct/src/dcparser/dcKeywordList.cxx create mode 100644 direct/src/dcparser/dcKeywordList.h diff --git a/direct/src/dcparser/Sources.pp b/direct/src/dcparser/Sources.pp index f8aec3a075..8b0003cba2 100644 --- a/direct/src/dcparser/Sources.pp +++ b/direct/src/dcparser/Sources.pp @@ -18,7 +18,9 @@ #define SOURCES \ dcAtomicField.h dcClass.h dcClass.I \ dcDeclaration.h \ - dcField.h dcFile.h dcLexer.lxx \ + dcField.h dcFile.h \ + dcKeyword.h dcKeywordList.h \ + dcLexer.lxx \ dcLexerDefs.h dcMolecularField.h dcParser.yxx dcParserDefs.h \ dcSubatomicType.h \ dcPackData.h dcPackData.I \ @@ -38,6 +40,7 @@ dcAtomicField.cxx dcClass.cxx \ dcDeclaration.cxx \ dcField.cxx dcFile.cxx \ + dcKeyword.cxx dcKeywordList.cxx \ dcMolecularField.cxx dcSubatomicType.cxx \ dcPackData.cxx \ dcPacker.cxx \ diff --git a/direct/src/dcparser/dcAtomicField.cxx b/direct/src/dcparser/dcAtomicField.cxx index 5c0c9eb91b..cd49a7debc 100644 --- a/direct/src/dcparser/dcAtomicField.cxx +++ b/direct/src/dcparser/dcAtomicField.cxx @@ -202,7 +202,7 @@ output(ostream &out, bool brief) const { } out << ")"; - output_flags(out); + output_keywords(out); } //////////////////////////////////////////////////////////////////// @@ -237,7 +237,8 @@ generate_hash(HashGenerator &hashgen) const { for (ei = _elements.begin(); ei != _elements.end(); ++ei) { (*ei)->generate_hash(hashgen); } - hashgen.add_int(get_flags()); + + DCKeywordList::generate_hash(hashgen); } //////////////////////////////////////////////////////////////////// diff --git a/direct/src/dcparser/dcField.cxx b/direct/src/dcparser/dcField.cxx index 2875ee99a8..6cfe255a5b 100644 --- a/direct/src/dcparser/dcField.cxx +++ b/direct/src/dcparser/dcField.cxx @@ -38,7 +38,6 @@ DCField() #endif { _number = -1; - _flags = 0; _has_default_value = false; _default_value_stale = true; @@ -65,7 +64,6 @@ DCField(const string &name, DCClass *dclass) : #endif { _number = -1; - _flags = 0; _has_default_value = false; _default_value_stale = true; @@ -288,7 +286,7 @@ get_default_value() const { //////////////////////////////////////////////////////////////////// bool DCField:: is_required() const { - return (_flags & F_required) != 0; + return has_keyword("required"); } //////////////////////////////////////////////////////////////////// @@ -299,7 +297,7 @@ is_required() const { //////////////////////////////////////////////////////////////////// bool DCField:: is_broadcast() const { - return (_flags & F_broadcast) != 0; + return has_keyword("broadcast"); } //////////////////////////////////////////////////////////////////// @@ -310,7 +308,7 @@ is_broadcast() const { //////////////////////////////////////////////////////////////////// bool DCField:: is_p2p() const { - return (_flags & F_p2p) != 0; + return has_keyword("p2p"); } //////////////////////////////////////////////////////////////////// @@ -321,7 +319,7 @@ is_p2p() const { //////////////////////////////////////////////////////////////////// bool DCField:: is_ram() const { - return (_flags & F_ram) != 0; + return has_keyword("ram"); } //////////////////////////////////////////////////////////////////// @@ -332,7 +330,7 @@ is_ram() const { //////////////////////////////////////////////////////////////////// bool DCField:: is_db() const { - return (_flags & F_db) != 0; + return has_keyword("db"); } //////////////////////////////////////////////////////////////////// @@ -343,7 +341,7 @@ is_db() const { //////////////////////////////////////////////////////////////////// bool DCField:: is_clsend() const { - return (_flags & F_clsend) != 0; + return has_keyword("clsend"); } //////////////////////////////////////////////////////////////////// @@ -354,7 +352,7 @@ is_clsend() const { //////////////////////////////////////////////////////////////////// bool DCField:: is_clrecv() const { - return (_flags & F_clrecv) != 0; + return has_keyword("clrecv"); } //////////////////////////////////////////////////////////////////// @@ -365,7 +363,7 @@ is_clrecv() const { //////////////////////////////////////////////////////////////////// bool DCField:: is_ownsend() const { - return (_flags & F_ownsend) != 0; + return has_keyword("ownsend"); } //////////////////////////////////////////////////////////////////// @@ -376,19 +374,7 @@ is_ownsend() const { //////////////////////////////////////////////////////////////////// bool DCField:: is_airecv() const { - return (_flags & F_airecv) != 0; -} - -//////////////////////////////////////////////////////////////////// -// Function: DCField::compare_flags -// Access: Published -// Description: Returns true if this field has the same flags -// settings as the other field, false if some flags -// differ. -//////////////////////////////////////////////////////////////////// -bool DCField:: -compare_flags(const DCField &other) const { - return _flags == other._flags; + return has_keyword("airecv"); } //////////////////////////////////////////////////////////////////// @@ -720,36 +706,6 @@ set_default_value(const string &default_value) { _default_value_stale = false; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::add_flag -// Access: Public -// Description: Adds a new flag to the field. -//////////////////////////////////////////////////////////////////// -void DCField:: -add_flag(enum Flags flag) { - _flags |= flag; -} - -//////////////////////////////////////////////////////////////////// -// Function: DCField::set_flags -// Access: Public -// Description: Resets the flag bitmask to the indicated value. -//////////////////////////////////////////////////////////////////// -void DCField:: -set_flags(int flags) { - _flags = flags; -} - -//////////////////////////////////////////////////////////////////// -// Function: DCField::get_flags -// Access: Public -// Description: Returns the complete flag bitmask. -//////////////////////////////////////////////////////////////////// -int DCField:: -get_flags() const { - return _flags; -} - //////////////////////////////////////////////////////////////////// // Function: DCField::refresh_default_value // Access: Protected @@ -768,39 +724,3 @@ refresh_default_value() { } _default_value_stale = false; } - -//////////////////////////////////////////////////////////////////// -// Function: DCField::output_flags -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// -void DCField:: -output_flags(ostream &out) const { - if ((_flags & F_required) != 0) { - out << " required"; - } - if ((_flags & F_broadcast) != 0) { - out << " broadcast"; - } - if ((_flags & F_p2p) != 0) { - out << " p2p"; - } - if ((_flags & F_ram) != 0) { - out << " ram"; - } - if ((_flags & F_db) != 0) { - out << " db"; - } - if ((_flags & F_clsend) != 0) { - out << " clsend"; - } - if ((_flags & F_clrecv) != 0) { - out << " clrecv"; - } - if ((_flags & F_ownsend) != 0) { - out << " ownsend"; - } - if ((_flags & F_airecv) != 0) { - out << " airecv"; - } -} diff --git a/direct/src/dcparser/dcField.h b/direct/src/dcparser/dcField.h index 26fd8d8f73..e1acc5ff42 100644 --- a/direct/src/dcparser/dcField.h +++ b/direct/src/dcparser/dcField.h @@ -21,6 +21,7 @@ #include "dcbase.h" #include "dcPackerInterface.h" +#include "dcKeywordList.h" #include "dcPython.h" #ifdef WITHIN_PANDA @@ -40,7 +41,7 @@ class HashGenerator; // Description : A single field of a Distributed Class, either atomic // or molecular. //////////////////////////////////////////////////////////////////// -class EXPCL_DIRECT DCField : public DCPackerInterface { +class EXPCL_DIRECT DCField : public DCPackerInterface, public DCKeywordList { public: DCField(); DCField(const string &name, DCClass *dclass); @@ -76,8 +77,6 @@ PUBLISHED: bool is_ownsend() const; bool is_airecv() const; - bool compare_flags(const DCField &other) const; - void output(ostream &out) const; void write(ostream &out, int indent_level) const; @@ -101,31 +100,8 @@ public: void set_number(int number); void set_default_value(const string &default_value); - enum Flags { - F_required = 0x0001, - F_broadcast = 0x0002, - F_p2p = 0x0004, - F_ram = 0x0008, - F_db = 0x0010, - F_clsend = 0x0020, - F_clrecv = 0x0040, - F_ownsend = 0x0080, - F_airecv = 0x0100, - - // These are reserved for client code use; they are not set or - // cleared by any code in this module. - F_user_1 = 0x1000, - F_user_2 = 0x2000, - F_user_3 = 0x4000, - F_user_4 = 0x8000, - }; - void add_flag(enum Flags flag); - void set_flags(int flags); - int get_flags() const; - protected: void refresh_default_value(); - void output_flags(ostream &out) const; protected: int _number; @@ -133,8 +109,6 @@ protected: bool _has_default_value; private: - int _flags; // A bitmask union of any of the above values. - string _default_value; #ifdef WITHIN_PANDA diff --git a/direct/src/dcparser/dcFile.cxx b/direct/src/dcparser/dcFile.cxx index 595fa0c9a1..e779c07058 100644 --- a/direct/src/dcparser/dcFile.cxx +++ b/direct/src/dcparser/dcFile.cxx @@ -22,6 +22,7 @@ #include "dcParserDefs.h" #include "dcLexerDefs.h" #include "dcTypedef.h" +#include "dcKeyword.h" #include "hashGenerator.h" #ifdef WITHIN_PANDA @@ -41,6 +42,8 @@ DCFile:: DCFile() { _all_objects_valid = true; + + setup_default_keywords(); } //////////////////////////////////////////////////////////////////// @@ -74,8 +77,10 @@ clear() { _things_by_name.clear(); _typedefs.clear(); _typedefs_by_name.clear(); + _keywords.clear_keywords(); _declarations.clear(); _things_to_delete.clear(); + setup_default_keywords(); _all_objects_valid = true; } @@ -439,6 +444,48 @@ get_typedef_by_name(const string &name) const { return NULL; } +//////////////////////////////////////////////////////////////////// +// Function: DCFile::get_num_keywords +// Access: Published +// Description: Returns the number of keywords read from the .dc +// file(s). +//////////////////////////////////////////////////////////////////// +int DCFile:: +get_num_keywords() const { + return _keywords.get_num_keywords(); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCFile::get_keyword +// Access: Published +// Description: Returns the nth keyword read from the .dc file(s). +//////////////////////////////////////////////////////////////////// +const DCKeyword *DCFile:: +get_keyword(int n) const { + return _keywords.get_keyword(n); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCFile::get_keyword_by_name +// Access: Published +// Description: Returns the keyword that has the indicated name, or +// NULL if there is no such keyword name. +//////////////////////////////////////////////////////////////////// +const DCKeyword *DCFile:: +get_keyword_by_name(const string &name) const { + const DCKeyword *keyword = _keywords.get_keyword_by_name(name); + if (keyword == (const DCKeyword *)NULL) { + keyword = _default_keywords.get_keyword_by_name(name); + if (keyword != (const DCKeyword *)NULL) { + // One of the historical default keywords was used, but wasn't + // defined. Define it implicitly right now. + ((DCFile *)this)->_keywords.add_keyword(keyword); + } + } + + return keyword; +} + //////////////////////////////////////////////////////////////////// // Function: DCFile::get_hash // Access: Published @@ -597,6 +644,28 @@ add_typedef(DCTypedef *dtypedef) { return true; } +//////////////////////////////////////////////////////////////////// +// Function: DCFile::add_keyword +// Access: Public +// Description: Adds the indicated keyword string to the list of +// keywords known to the DCFile. These keywords may +// then be added to DCFields. It is not an error to add +// a particular keyword more than once. +//////////////////////////////////////////////////////////////////// +bool DCFile:: +add_keyword(const string &name) { + DCKeyword *keyword = new DCKeyword(name); + bool added = _keywords.add_keyword(keyword); + + if (added) { + _declarations.push_back(keyword); + } else { + delete keyword; + } + + return added; +} + //////////////////////////////////////////////////////////////////// // Function: DCFile::add_thing_to_delete // Access: Public @@ -624,3 +693,39 @@ set_new_index_number(DCField *field) { field->set_number((int)_fields_by_index.size()); _fields_by_index.push_back(field); } + +//////////////////////////////////////////////////////////////////// +// Function: DCFile::setup_default_keywords +// Access: Public +// Description: Adds an entry for each of the default keywords that +// are defined for every DCFile for legacy reasons. +//////////////////////////////////////////////////////////////////// +void DCFile:: +setup_default_keywords() { + struct KeywordDef { + const char *name; + int flag; + }; + static KeywordDef default_keywords[] = { + { "required", 0x0001 }, + { "broadcast", 0x0002 }, + { "p2p", 0x0004 }, + { "ram", 0x0008 }, + { "db", 0x0010 }, + { "clsend", 0x0020 }, + { "clrecv", 0x0040 }, + { "ownsend", 0x0080 }, + { "airecv", 0x0100 }, + { NULL, 0 } + }; + + _default_keywords.clear_keywords(); + for (int i = 0; default_keywords[i].name != NULL; ++i) { + DCKeyword *keyword = + new DCKeyword(default_keywords[i].name, + default_keywords[i].flag); + + _default_keywords.add_keyword(keyword); + _things_to_delete.push_back(keyword); + } +} diff --git a/direct/src/dcparser/dcFile.h b/direct/src/dcparser/dcFile.h index 2a52e5ae16..93ddcdf942 100644 --- a/direct/src/dcparser/dcFile.h +++ b/direct/src/dcparser/dcFile.h @@ -20,12 +20,14 @@ #define DCFILE_H #include "dcbase.h" +#include "dcKeywordList.h" class DCClass; class DCSwitch; class DCField; class HashGenerator; class DCTypedef; +class DCKeyword; class DCDeclaration; //////////////////////////////////////////////////////////////////// @@ -68,6 +70,10 @@ PUBLISHED: DCTypedef *get_typedef(int n) const; DCTypedef *get_typedef_by_name(const string &name) const; + int get_num_keywords() const; + const DCKeyword *get_keyword(int n) const; + const DCKeyword *get_keyword_by_name(const string &name) const; + unsigned long get_hash() const; public: @@ -77,11 +83,14 @@ public: void add_import_module(const string &import_module); void add_import_symbol(const string &import_symbol); bool add_typedef(DCTypedef *dtypedef); + bool add_keyword(const string &name); void add_thing_to_delete(DCDeclaration *decl); void set_new_index_number(DCField *field); private: + void setup_default_keywords(); + typedef pvector Classes; Classes _classes; @@ -104,6 +113,9 @@ private: typedef pmap TypedefsByName; TypedefsByName _typedefs_by_name; + DCKeywordList _keywords; + DCKeywordList _default_keywords; + typedef pvector Declarations; Declarations _declarations; Declarations _things_to_delete; diff --git a/direct/src/dcparser/dcKeyword.cxx b/direct/src/dcparser/dcKeyword.cxx new file mode 100644 index 0000000000..1e15acb3f5 --- /dev/null +++ b/direct/src/dcparser/dcKeyword.cxx @@ -0,0 +1,111 @@ +// Filename: dcKeyword.cxx +// Created by: drose (22Jul05) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "dcKeyword.h" +#include "hashGenerator.h" +#include "dcindent.h" + +//////////////////////////////////////////////////////////////////// +// Function: DCKeyword::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +DCKeyword:: +DCKeyword(const string &name, int historical_flag) : + _name(name), + _historical_flag(historical_flag) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeyword::Destructor +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +DCKeyword:: +~DCKeyword() { +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeyword::get_name +// Access: Published +// Description: Returns the name of this keyword. +//////////////////////////////////////////////////////////////////// +const string &DCKeyword:: +get_name() const { + return _name; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeyword::get_historical_flag +// Access: Public +// Description: Returns the bitmask associated with this keyword, if +// any. This is the value that was historically +// associated with this keyword, and was used to +// generate a hash code before we had user-customizable +// keywords. It will return ~0 if this is not an +// historical keyword. +//////////////////////////////////////////////////////////////////// +int DCKeyword:: +get_historical_flag() const { + return _historical_flag; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeyword::clear_historical_flag +// Access: Public +// Description: Resets the historical flag to ~0, as if the keyword +// were not one of the historically defined keywords. +//////////////////////////////////////////////////////////////////// +void DCKeyword:: +clear_historical_flag() { + _historical_flag = ~0; +} + +//////////////////////////////////////////////////////////////////// +// Function : DCKeyword::output +// Access : Public, Virtual +// Description : Write a string representation of this instance to +// . +//////////////////////////////////////////////////////////////////// +void DCKeyword:: +output(ostream &out, bool brief) const { + out << "keyword " << _name; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeyword::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void DCKeyword:: +write(ostream &out, bool, int indent_level) const { + indent(out, indent_level) + << "keyword " << _name << ";\n"; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeyword::generate_hash +// Access: Public +// Description: Accumulates the properties of this keyword into the +// hash. +//////////////////////////////////////////////////////////////////// +void DCKeyword:: +generate_hash(HashGenerator &hashgen) const { + hashgen.add_string(_name); +} diff --git a/direct/src/dcparser/dcKeyword.h b/direct/src/dcparser/dcKeyword.h new file mode 100644 index 0000000000..2ce8ddab9a --- /dev/null +++ b/direct/src/dcparser/dcKeyword.h @@ -0,0 +1,59 @@ +// Filename: dcKeyword.h +// Created by: drose (22Jul05) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef DCKEYWORD_H +#define DCKEYWORD_H + +#include "dcbase.h" +#include "dcDeclaration.h" + +class DCParameter; +class HashGenerator; + +//////////////////////////////////////////////////////////////////// +// Class : DCKeyword +// Description : This represents a single keyword declaration in the +// dc file. It is used to define a communication +// property associated with a field, for instance +// "broadcast" or "airecv". +//////////////////////////////////////////////////////////////////// +class EXPCL_DIRECT DCKeyword : public DCDeclaration { +public: + DCKeyword(const string &name, int historical_flag = ~0); + virtual ~DCKeyword(); + +PUBLISHED: + const string &get_name() const; + +public: + int get_historical_flag() const; + void clear_historical_flag(); + + virtual void output(ostream &out, bool brief) const; + virtual void write(ostream &out, bool brief, int indent_level) const; + void generate_hash(HashGenerator &hashgen) const; + +private: + const string _name; + + // This flag is only kept for historical reasons, so we can preserve + // the file's hash code if no new flags are in use. + int _historical_flag; +}; + +#endif diff --git a/direct/src/dcparser/dcKeywordList.cxx b/direct/src/dcparser/dcKeywordList.cxx new file mode 100644 index 0000000000..9e45b4a253 --- /dev/null +++ b/direct/src/dcparser/dcKeywordList.cxx @@ -0,0 +1,220 @@ +// Filename: dcKeywordList.cxx +// Created by: drose (25Jul05) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "dcKeywordList.h" +#include "dcKeyword.h" +#include "hashGenerator.h" + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +DCKeywordList:: +DCKeywordList() : + _flags(0) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +DCKeywordList:: +DCKeywordList(const DCKeywordList ©) : + _keywords(copy._keywords), + _keywords_by_name(copy._keywords_by_name), + _flags(copy._flags) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::Copy Assignment Operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void DCKeywordList:: +operator = (const DCKeywordList ©) { + _keywords = copy._keywords; + _keywords_by_name = copy._keywords_by_name; + _flags = copy._flags; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::Destructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +DCKeywordList:: +~DCKeywordList() { + nassertv(_keywords_by_name.size() == _keywords.size()); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::has_keyword +// Access: Published +// Description: Returns true if this list includes the indicated +// keyword, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCKeywordList:: +has_keyword(const string &name) const { + return (_keywords_by_name.find(name) != _keywords_by_name.end()); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::has_keyword +// Access: Published +// Description: Returns true if this list includes the indicated +// keyword, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCKeywordList:: +has_keyword(const DCKeyword *keyword) const { + return has_keyword(keyword->get_name()); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::get_num_keywords +// Access: Published +// Description: Returns the number of keywords in the list. +//////////////////////////////////////////////////////////////////// +int DCKeywordList:: +get_num_keywords() const { + nassertr(_keywords_by_name.size() == _keywords.size(), 0); + return _keywords.size(); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::get_keyword +// Access: Published +// Description: Returns the nth keyword in the list. +//////////////////////////////////////////////////////////////////// +const DCKeyword *DCKeywordList:: +get_keyword(int n) const { + nassertr(n >= 0 && n < (int)_keywords.size(), NULL); + return _keywords[n]; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::get_keyword_by_name +// Access: Published +// Description: Returns the keyword in the list with the indicated +// name, or NULL if there is no keyword in the list with +// that name. +//////////////////////////////////////////////////////////////////// +const DCKeyword *DCKeywordList:: +get_keyword_by_name(const string &name) const { + KeywordsByName::const_iterator ni; + ni = _keywords_by_name.find(name); + if (ni != _keywords_by_name.end()) { + return (*ni).second; + } + + return NULL; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::compare_keywords +// Access: Published +// Description: Returns true if this list has the same keywords +// as the other list, false if some keywords differ. +// Order is not considered important. +//////////////////////////////////////////////////////////////////// +bool DCKeywordList:: +compare_keywords(const DCKeywordList &other) const { + return _keywords_by_name == other._keywords_by_name; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::copy_keywords +// Access: Public +// Description: Replaces this keyword list with those from the other +// list. +//////////////////////////////////////////////////////////////////// +void DCKeywordList:: +copy_keywords(const DCKeywordList &other) { + (*this) = other; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::add_keyword +// Access: Public +// Description: Adds the indicated keyword to the list. Returns true +// if it is added, false if it was already there. +//////////////////////////////////////////////////////////////////// +bool DCKeywordList:: +add_keyword(const DCKeyword *keyword) { + bool inserted = _keywords_by_name.insert(KeywordsByName::value_type(keyword->get_name(), keyword)).second; + if (inserted) { + _keywords.push_back(keyword); + _flags |= keyword->get_historical_flag(); + } + + return inserted; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::clear_keywords +// Access: Public +// Description: Removes all keywords from the field. +//////////////////////////////////////////////////////////////////// +void DCKeywordList:: +clear_keywords() { + _keywords.clear(); + _keywords_by_name.clear(); + _flags = 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::output_keywords +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void DCKeywordList:: +output_keywords(ostream &out) const { + Keywords::const_iterator ki; + for (ki = _keywords.begin(); ki != _keywords.end(); ++ki) { + out << " " << (*ki)->get_name(); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: DCKeywordList::generate_hash +// Access: Public +// Description: Accumulates the properties of these keywords into the +// hash. +//////////////////////////////////////////////////////////////////// +void DCKeywordList:: +generate_hash(HashGenerator &hashgen) const { + if (_flags != ~0) { + // All of the flags are historical flags only, so add just the + // flags bitmask to keep the hash code the same as it has + // historically been. + hashgen.add_int(_flags); + + } else { + // There is at least one custom flag, so go ahead and make the + // hash code reflect it. + + hashgen.add_int(_keywords_by_name.size()); + KeywordsByName::const_iterator ni; + for (ni = _keywords_by_name.begin(); ni != _keywords_by_name.end(); ++ni) { + (*ni).second->generate_hash(hashgen); + } + } +} diff --git a/direct/src/dcparser/dcKeywordList.h b/direct/src/dcparser/dcKeywordList.h new file mode 100644 index 0000000000..6d602d6e9c --- /dev/null +++ b/direct/src/dcparser/dcKeywordList.h @@ -0,0 +1,67 @@ +// Filename: dcKeywordList.h +// Created by: drose (25Jul05) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef DCKEYWORDLIST_H +#define DCKEYWORDLIST_H + +#include "dcbase.h" + +class DCKeyword; +class HashGenerator; + +//////////////////////////////////////////////////////////////////// +// Class : DCKeywordList +// Description : This is a list of keywords (see DCKeyword) that may +// be set on a particular field. +//////////////////////////////////////////////////////////////////// +class EXPCL_DIRECT DCKeywordList { +public: + DCKeywordList(); + DCKeywordList(const DCKeywordList ©); + void operator = (const DCKeywordList ©); + ~DCKeywordList(); + +PUBLISHED: + bool has_keyword(const string &name) const; + bool has_keyword(const DCKeyword *keyword) const; + int get_num_keywords() const; + const DCKeyword *get_keyword(int n) const; + const DCKeyword *get_keyword_by_name(const string &name) const; + + bool compare_keywords(const DCKeywordList &other) const; + +public: + void copy_keywords(const DCKeywordList &other); + + bool add_keyword(const DCKeyword *keyword); + void clear_keywords(); + + void output_keywords(ostream &out) const; + void generate_hash(HashGenerator &hashgen) const; + +private: + typedef pvector Keywords; + Keywords _keywords; + + typedef pmap KeywordsByName; + KeywordsByName _keywords_by_name; + + int _flags; +}; + +#endif diff --git a/direct/src/dcparser/dcLexer.cxx.prebuilt b/direct/src/dcparser/dcLexer.cxx.prebuilt index fa33bfc5a2..2ae48ecfe1 100644 --- a/direct/src/dcparser/dcLexer.cxx.prebuilt +++ b/direct/src/dcparser/dcLexer.cxx.prebuilt @@ -300,32 +300,28 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); *yy_cp = '\0'; \ yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 52 -#define YY_END_OF_BUFFER 53 -static yyconst short int yy_accept[201] = +#define YY_NUM_RULES 44 +#define YY_END_OF_BUFFER 45 +static yyconst short int yy_accept[165] = { 0, - 0, 0, 53, 51, 2, 1, 47, 48, 51, 51, - 51, 43, 43, 49, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 1, 0, 44, - 46, 4, 3, 46, 43, 45, 50, 50, 50, 50, - 50, 50, 50, 38, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 0, 3, - 45, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 36, 37, 50, 50, - 50, 50, 50, 0, 46, 50, 24, 50, 50, 11, - 33, 50, 50, 50, 50, 50, 7, 50, 50, 50, - - 50, 14, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 13, 50, 50, 50, 50, 50, 50, 50, 15, - 16, 17, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 18, 42, 25, 50, 40, 39, 5, 50, - 50, 8, 50, 50, 50, 50, 50, 23, 6, 10, - 50, 19, 20, 21, 50, 50, 12, 22, 50, 50, - 50, 41, 50, 9, 50, 50, 50, 50, 50, 50, - 50, 50, 34, 50, 50, 50, 50, 35, 50, 50, - 26, 50, 50, 50, 50, 27, 28, 50, 50, 50, - 29, 30, 31, 50, 50, 50, 50, 50, 32, 0 + 0, 0, 45, 43, 2, 1, 39, 40, 43, 43, + 43, 35, 35, 41, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 1, 0, 36, 38, 4, 3, + 38, 35, 37, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 0, + 3, 37, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 0, 38, 25, + 42, 12, 34, 42, 42, 42, 7, 42, 42, 42, + 42, 15, 42, 42, 42, 42, 42, 42, 42, 14, + 42, 42, 42, 42, 16, 17, 18, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 19, 26, 5, 42, + 42, 8, 42, 42, 42, 42, 24, 6, 11, 42, + 20, 21, 22, 42, 13, 23, 42, 42, 42, 9, + 10, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 27, 42, 42, 42, 42, 28, + 29, 42, 42, 42, 30, 31, 32, 42, 42, 42, + 42, 42, 33, 0 } ; static yyconst int yy_ec[256] = @@ -342,8 +338,8 @@ static yyconst int yy_ec[256] = 1, 1, 1, 1, 21, 1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 21, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 21, 1, 1, 1, 1, 1, 1, 1, 1, + 35, 36, 21, 37, 38, 39, 40, 21, 41, 42, + 43, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -360,137 +356,123 @@ static yyconst int yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst int yy_meta[46] = +static yyconst int yy_meta[44] = { 0, 1, 1, 2, 1, 1, 1, 3, 4, 1, 5, 5, 5, 5, 5, 5, 5, 5, 1, 6, 6, 7, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 8, 7 + 7, 8, 7 } ; -static yyconst short int yy_base[209] = +static yyconst short int yy_base[173] = { 0, - 0, 0, 244, 245, 245, 0, 245, 245, 235, 0, - 40, 39, 40, 245, 0, 212, 18, 29, 29, 22, - 29, 198, 228, 42, 26, 194, 208, 0, 0, 229, - 39, 245, 0, 0, 0, 0, 0, 198, 200, 41, - 195, 211, 32, 0, 200, 204, 195, 194, 192, 187, - 192, 189, 191, 186, 184, 191, 184, 185, 211, 0, - 0, 191, 193, 193, 192, 187, 174, 185, 184, 187, - 186, 185, 173, 170, 61, 165, 0, 0, 162, 45, - 162, 175, 160, 192, 191, 173, 183, 164, 169, 0, - 0, 169, 158, 152, 149, 149, 0, 150, 171, 174, + 0, 0, 209, 210, 210, 0, 210, 210, 200, 0, + 38, 37, 38, 210, 0, 16, 27, 26, 22, 24, + 181, 21, 163, 175, 0, 0, 196, 35, 210, 0, + 0, 0, 0, 0, 168, 176, 163, 178, 167, 171, + 162, 161, 159, 155, 150, 155, 161, 154, 155, 181, + 0, 0, 164, 164, 159, 147, 161, 160, 159, 147, + 144, 52, 137, 34, 138, 150, 136, 167, 166, 159, + 140, 0, 0, 132, 129, 129, 0, 130, 150, 153, + 150, 141, 127, 127, 136, 135, 133, 59, 145, 0, + 118, 123, 138, 114, 130, 129, 0, 113, 112, 120, - 171, 162, 157, 152, 147, 156, 155, 153, 74, 135, - 164, 0, 151, 132, 148, 133, 139, 154, 129, 146, - 145, 0, 128, 131, 126, 135, 122, 132, 134, 143, - 146, 143, 134, 0, 0, 133, 0, 0, 0, 114, - 139, 0, 114, 113, 112, 124, 122, 0, 0, 0, - 120, 124, 51, 0, 107, 105, 0, 0, 105, 104, - 119, 0, 115, 0, 101, 100, 107, 98, 95, 112, - 111, 87, 0, 93, 92, 95, 106, 0, 82, 81, - 0, 103, 101, 73, 61, 0, 0, 60, 49, 72, - 0, 0, 0, 66, 44, 43, 58, 34, 0, 245, - - 92, 97, 52, 99, 103, 111, 115, 119 + 108, 117, 119, 128, 131, 128, 119, 0, 0, 101, + 125, 0, 101, 100, 99, 110, 0, 0, 0, 107, + 111, 44, 0, 95, 0, 0, 94, 93, 107, 0, + 0, 91, 90, 96, 88, 102, 101, 79, 84, 83, + 85, 96, 74, 72, 0, 83, 76, 58, 43, 0, + 0, 40, 39, 64, 0, 0, 0, 56, 40, 36, + 49, 24, 0, 210, 84, 89, 46, 91, 95, 103, + 107, 111 } ; -static yyconst short int yy_def[209] = +static yyconst short int yy_def[173] = { 0, - 200, 1, 200, 200, 200, 201, 200, 200, 202, 203, - 200, 204, 204, 200, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 201, 203, 202, - 203, 200, 206, 31, 13, 207, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 208, 206, - 207, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 208, 208, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, + 164, 1, 164, 164, 164, 165, 164, 164, 166, 167, + 164, 168, 168, 164, 169, 169, 169, 169, 169, 169, + 169, 169, 169, 169, 165, 167, 166, 167, 164, 170, + 28, 13, 171, 169, 169, 169, 169, 169, 169, 169, + 169, 169, 169, 169, 169, 169, 169, 169, 169, 172, + 170, 171, 169, 169, 169, 169, 169, 169, 169, 169, + 169, 169, 169, 169, 169, 169, 169, 172, 172, 169, + 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, + 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, + 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 0, - - 200, 200, 200, 200, 200, 200, 200, 200 + 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, + 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, + 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, + 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, + 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, + 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, + 169, 169, 169, 0, 164, 164, 164, 164, 164, 164, + 164, 164 } ; -static yyconst short int yy_nxt[291] = +static yyconst short int yy_nxt[254] = { 0, 4, 5, 6, 7, 8, 4, 9, 10, 11, 12, 13, 13, 13, 13, 13, 13, 13, 14, 15, 15, - 15, 16, 17, 18, 19, 15, 20, 15, 15, 21, - 15, 15, 15, 15, 22, 23, 15, 24, 25, 26, - 27, 15, 15, 15, 15, 32, 34, 34, 33, 39, - 41, 44, 45, 47, 46, 40, 31, 42, 59, 48, - 43, 49, 50, 53, 59, 55, 64, 54, 56, 68, - 69, 99, 166, 100, 105, 65, 101, 102, 199, 198, - 197, 196, 36, 200, 130, 106, 131, 195, 194, 132, - 133, 167, 28, 193, 28, 28, 28, 28, 28, 28, + 15, 15, 16, 17, 18, 15, 19, 15, 15, 20, + 21, 15, 15, 15, 15, 15, 15, 22, 23, 24, + 15, 15, 15, 29, 31, 31, 30, 35, 37, 39, + 28, 40, 36, 41, 50, 38, 43, 44, 42, 46, + 50, 47, 79, 84, 80, 133, 163, 81, 82, 104, + 162, 105, 161, 85, 106, 107, 160, 159, 33, 164, + 158, 157, 156, 134, 25, 155, 25, 25, 25, 25, + 25, 25, 27, 27, 32, 32, 154, 153, 32, 34, - 30, 30, 35, 35, 192, 191, 35, 37, 37, 37, - 37, 60, 190, 60, 60, 60, 60, 60, 60, 61, - 61, 85, 189, 85, 188, 187, 186, 185, 184, 183, - 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, - 172, 171, 170, 169, 168, 165, 164, 163, 162, 161, - 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, - 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, - 140, 139, 138, 137, 136, 135, 134, 129, 128, 127, - 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, - 116, 115, 114, 113, 112, 111, 110, 200, 200, 109, + 34, 34, 34, 51, 152, 51, 51, 51, 51, 51, + 51, 52, 52, 69, 151, 69, 150, 149, 148, 147, + 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, + 136, 135, 132, 131, 130, 129, 128, 127, 126, 125, + 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, + 114, 113, 112, 111, 110, 109, 108, 103, 102, 101, + 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, + 90, 89, 164, 164, 88, 87, 86, 83, 78, 77, + 76, 75, 74, 73, 72, 71, 70, 68, 67, 66, + 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, - 108, 107, 104, 103, 98, 97, 96, 95, 94, 93, - 92, 91, 90, 89, 88, 87, 86, 84, 83, 82, - 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, - 71, 70, 67, 66, 63, 62, 34, 58, 57, 52, - 51, 38, 29, 200, 3, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 200, 200 + 55, 54, 53, 31, 49, 48, 45, 26, 164, 3, + 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, + 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, + 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, + 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, + 164, 164, 164 } ; -static yyconst short int yy_chk[291] = +static yyconst short int yy_chk[254] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 11, 12, 13, 11, 17, - 18, 19, 19, 20, 19, 17, 203, 18, 31, 20, - 18, 21, 21, 24, 31, 25, 40, 24, 25, 43, - 43, 75, 153, 75, 80, 40, 75, 75, 198, 197, - 196, 195, 12, 13, 109, 80, 109, 194, 190, 109, - 109, 153, 201, 189, 201, 201, 201, 201, 201, 201, + 1, 1, 1, 11, 12, 13, 11, 16, 17, 18, + 167, 18, 16, 19, 28, 17, 20, 20, 19, 22, + 28, 22, 62, 64, 62, 122, 162, 62, 62, 88, + 161, 88, 160, 64, 88, 88, 159, 158, 12, 13, + 154, 153, 152, 122, 165, 149, 165, 165, 165, 165, + 165, 165, 166, 166, 168, 168, 148, 147, 168, 169, - 202, 202, 204, 204, 188, 185, 204, 205, 205, 205, - 205, 206, 184, 206, 206, 206, 206, 206, 206, 207, - 207, 208, 183, 208, 182, 180, 179, 177, 176, 175, - 174, 172, 171, 170, 169, 168, 167, 166, 165, 163, - 161, 160, 159, 156, 155, 152, 151, 147, 146, 145, - 144, 143, 141, 140, 136, 133, 132, 131, 130, 129, - 128, 127, 126, 125, 124, 123, 121, 120, 119, 118, - 117, 116, 115, 114, 113, 111, 110, 108, 107, 106, - 105, 104, 103, 102, 101, 100, 99, 98, 96, 95, - 94, 93, 92, 89, 88, 87, 86, 85, 84, 83, + 169, 169, 169, 170, 146, 170, 170, 170, 170, 170, + 170, 171, 171, 172, 144, 172, 143, 142, 141, 140, + 139, 138, 137, 136, 135, 134, 133, 132, 129, 128, + 127, 124, 121, 120, 116, 115, 114, 113, 111, 110, + 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, + 96, 95, 94, 93, 92, 91, 89, 87, 86, 85, + 84, 83, 82, 81, 80, 79, 78, 76, 75, 74, + 71, 70, 69, 68, 67, 66, 65, 63, 61, 60, + 59, 58, 57, 56, 55, 54, 53, 50, 49, 48, + 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, - 82, 81, 79, 76, 74, 73, 72, 71, 70, 69, - 68, 67, 66, 65, 64, 63, 62, 59, 58, 57, - 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, - 46, 45, 42, 41, 39, 38, 30, 27, 26, 23, - 22, 16, 9, 3, 200, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 200, 200 + 37, 36, 35, 27, 24, 23, 21, 9, 3, 164, + 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, + 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, + 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, + 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, + 164, 164, 164 } ; static yy_state_type yy_last_accepting_state; @@ -516,6 +498,7 @@ char *yytext; #include "dcLexerDefs.h" #include "dcParserDefs.h" #include "dcParser.h" +#include "dcFile.h" #include "dcindent.h" @@ -903,7 +886,7 @@ inline void accept() { col_number += yyleng; } -#line 908 "lex.yy.c" +#line 891 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -1054,7 +1037,7 @@ YY_DECL register char *yy_cp = NULL, *yy_bp = NULL; register int yy_act; -#line 406 "dcLexer.lxx" +#line 407 "dcLexer.lxx" @@ -1065,7 +1048,7 @@ YY_DECL } -#line 1070 "lex.yy.c" +#line 1053 "lex.yy.c" if ( yy_init ) { @@ -1116,13 +1099,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 >= 201 ) + if ( yy_current_state >= 165 ) 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] != 245 ); + while ( yy_base[yy_current_state] != 210 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -1150,7 +1133,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 416 "dcLexer.lxx" +#line 417 "dcLexer.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. @@ -1167,7 +1150,7 @@ YY_RULE_SETUP YY_BREAK case 2: YY_RULE_SETUP -#line 430 "dcLexer.lxx" +#line 431 "dcLexer.lxx" { // Eat whitespace. accept(); @@ -1175,7 +1158,7 @@ YY_RULE_SETUP YY_BREAK case 3: YY_RULE_SETUP -#line 435 "dcLexer.lxx" +#line 436 "dcLexer.lxx" { // Eat C++-style comments. accept(); @@ -1183,7 +1166,7 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP -#line 440 "dcLexer.lxx" +#line 441 "dcLexer.lxx" { // Eat C-style comments. accept(); @@ -1192,7 +1175,7 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 447 "dcLexer.lxx" +#line 448 "dcLexer.lxx" { accept(); return KW_DCLASS; @@ -1200,7 +1183,7 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 452 "dcLexer.lxx" +#line 453 "dcLexer.lxx" { accept(); return KW_STRUCT; @@ -1208,7 +1191,7 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 457 "dcLexer.lxx" +#line 458 "dcLexer.lxx" { accept(); return KW_FROM; @@ -1216,7 +1199,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 462 "dcLexer.lxx" +#line 463 "dcLexer.lxx" { accept(); return KW_IMPORT; @@ -1224,279 +1207,215 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 467 "dcLexer.lxx" +#line 468 "dcLexer.lxx" +{ + accept(); + return KW_KEYWORD; +} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 473 "dcLexer.lxx" { accept(); return KW_TYPEDEF; } YY_BREAK -case 10: +case 11: YY_RULE_SETUP -#line 472 "dcLexer.lxx" +#line 478 "dcLexer.lxx" { accept(); return KW_SWITCH; } YY_BREAK -case 11: +case 12: YY_RULE_SETUP -#line 477 "dcLexer.lxx" +#line 483 "dcLexer.lxx" { accept(); return KW_CASE; } YY_BREAK -case 12: +case 13: YY_RULE_SETUP -#line 482 "dcLexer.lxx" +#line 488 "dcLexer.lxx" { accept(); return KW_DEFAULT; } YY_BREAK -case 13: +case 14: YY_RULE_SETUP -#line 487 "dcLexer.lxx" +#line 493 "dcLexer.lxx" { accept(); return KW_BREAK; } YY_BREAK -case 14: +case 15: YY_RULE_SETUP -#line 492 "dcLexer.lxx" +#line 498 "dcLexer.lxx" { accept(); return KW_INT8; } YY_BREAK -case 15: +case 16: YY_RULE_SETUP -#line 497 "dcLexer.lxx" +#line 503 "dcLexer.lxx" { accept(); return KW_INT16; } YY_BREAK -case 16: +case 17: YY_RULE_SETUP -#line 502 "dcLexer.lxx" +#line 508 "dcLexer.lxx" { accept(); return KW_INT32; } YY_BREAK -case 17: +case 18: YY_RULE_SETUP -#line 507 "dcLexer.lxx" +#line 513 "dcLexer.lxx" { accept(); return KW_INT64; } YY_BREAK -case 18: +case 19: YY_RULE_SETUP -#line 512 "dcLexer.lxx" +#line 518 "dcLexer.lxx" { accept(); return KW_UINT8; } YY_BREAK -case 19: +case 20: YY_RULE_SETUP -#line 517 "dcLexer.lxx" +#line 523 "dcLexer.lxx" { accept(); return KW_UINT16; } YY_BREAK -case 20: +case 21: YY_RULE_SETUP -#line 522 "dcLexer.lxx" +#line 528 "dcLexer.lxx" { accept(); return KW_UINT32; } YY_BREAK -case 21: +case 22: YY_RULE_SETUP -#line 527 "dcLexer.lxx" +#line 533 "dcLexer.lxx" { accept(); return KW_UINT64; } YY_BREAK -case 22: +case 23: YY_RULE_SETUP -#line 532 "dcLexer.lxx" +#line 538 "dcLexer.lxx" { accept(); return KW_FLOAT64; } YY_BREAK -case 23: +case 24: YY_RULE_SETUP -#line 537 "dcLexer.lxx" +#line 543 "dcLexer.lxx" { accept(); return KW_STRING; } YY_BREAK -case 24: +case 25: YY_RULE_SETUP -#line 542 "dcLexer.lxx" +#line 548 "dcLexer.lxx" { accept(); return KW_BLOB; } YY_BREAK -case 25: +case 26: YY_RULE_SETUP -#line 547 "dcLexer.lxx" +#line 553 "dcLexer.lxx" { accept(); return KW_BLOB32; } YY_BREAK -case 26: +case 27: YY_RULE_SETUP -#line 552 "dcLexer.lxx" +#line 558 "dcLexer.lxx" { accept(); return KW_INT8ARRAY; } YY_BREAK -case 27: +case 28: YY_RULE_SETUP -#line 557 "dcLexer.lxx" +#line 563 "dcLexer.lxx" { accept(); return KW_INT16ARRAY; } YY_BREAK -case 28: +case 29: YY_RULE_SETUP -#line 562 "dcLexer.lxx" +#line 568 "dcLexer.lxx" { accept(); return KW_INT32ARRAY; } YY_BREAK -case 29: +case 30: YY_RULE_SETUP -#line 567 "dcLexer.lxx" +#line 573 "dcLexer.lxx" { accept(); return KW_UINT8ARRAY; } YY_BREAK -case 30: +case 31: YY_RULE_SETUP -#line 572 "dcLexer.lxx" +#line 578 "dcLexer.lxx" { accept(); return KW_UINT16ARRAY; } YY_BREAK -case 31: +case 32: YY_RULE_SETUP -#line 577 "dcLexer.lxx" +#line 583 "dcLexer.lxx" { accept(); return KW_UINT32ARRAY; } YY_BREAK -case 32: +case 33: YY_RULE_SETUP -#line 582 "dcLexer.lxx" +#line 588 "dcLexer.lxx" { accept(); return KW_UINT32UINT8ARRAY; } YY_BREAK -case 33: +case 34: YY_RULE_SETUP -#line 587 "dcLexer.lxx" +#line 593 "dcLexer.lxx" { accept(); return KW_CHAR; } YY_BREAK -case 34: -YY_RULE_SETUP -#line 592 "dcLexer.lxx" -{ - accept(); - return KW_REQUIRED; -} - YY_BREAK case 35: YY_RULE_SETUP -#line 597 "dcLexer.lxx" -{ - accept(); - return KW_BROADCAST; -} - YY_BREAK -case 36: -YY_RULE_SETUP -#line 602 "dcLexer.lxx" -{ - accept(); - return KW_P2P; -} - YY_BREAK -case 37: -YY_RULE_SETUP -#line 607 "dcLexer.lxx" -{ - accept(); - return KW_RAM; -} - YY_BREAK -case 38: -YY_RULE_SETUP -#line 612 "dcLexer.lxx" -{ - accept(); - return KW_DB; -} - YY_BREAK -case 39: -YY_RULE_SETUP -#line 617 "dcLexer.lxx" -{ - accept(); - return KW_CLSEND; -} - YY_BREAK -case 40: -YY_RULE_SETUP -#line 622 "dcLexer.lxx" -{ - accept(); - return KW_CLRECV; -} - YY_BREAK -case 41: -YY_RULE_SETUP -#line 627 "dcLexer.lxx" -{ - accept(); - return KW_OWNSEND; -} - YY_BREAK -case 42: -YY_RULE_SETUP -#line 632 "dcLexer.lxx" -{ - accept(); - return KW_AIRECV; -} - YY_BREAK -case 43: -YY_RULE_SETUP -#line 637 "dcLexer.lxx" +#line 598 "dcLexer.lxx" { // An unsigned integer number. accept(); @@ -1520,9 +1439,9 @@ YY_RULE_SETUP return UNSIGNED_INTEGER; } YY_BREAK -case 44: +case 36: YY_RULE_SETUP -#line 660 "dcLexer.lxx" +#line 621 "dcLexer.lxx" { // A signed integer number. accept(); @@ -1569,9 +1488,9 @@ YY_RULE_SETUP return SIGNED_INTEGER; } YY_BREAK -case 45: +case 37: YY_RULE_SETUP -#line 706 "dcLexer.lxx" +#line 667 "dcLexer.lxx" { // A hexadecimal integer number. accept(); @@ -1599,9 +1518,9 @@ YY_RULE_SETUP return UNSIGNED_INTEGER; } YY_BREAK -case 46: +case 38: YY_RULE_SETUP -#line 733 "dcLexer.lxx" +#line 694 "dcLexer.lxx" { // A floating-point number. accept(); @@ -1610,9 +1529,9 @@ YY_RULE_SETUP return REAL; } YY_BREAK -case 47: +case 39: YY_RULE_SETUP -#line 741 "dcLexer.lxx" +#line 702 "dcLexer.lxx" { // Quoted string. accept(); @@ -1620,9 +1539,9 @@ YY_RULE_SETUP return STRING; } YY_BREAK -case 48: +case 40: YY_RULE_SETUP -#line 748 "dcLexer.lxx" +#line 709 "dcLexer.lxx" { // Single-quoted string. accept(); @@ -1630,9 +1549,9 @@ YY_RULE_SETUP return STRING; } YY_BREAK -case 49: +case 41: YY_RULE_SETUP -#line 755 "dcLexer.lxx" +#line 716 "dcLexer.lxx" { // Long hex string. accept(); @@ -1640,31 +1559,39 @@ YY_RULE_SETUP return HEX_STRING; } YY_BREAK -case 50: +case 42: YY_RULE_SETUP -#line 762 "dcLexer.lxx" +#line 723 "dcLexer.lxx" { - // Identifier. + // Identifier or keyword. accept(); dcyylval.str = dcyytext; + + if (dc_file != (DCFile *)NULL) { + const DCKeyword *keyword = dc_file->get_keyword_by_name(dcyylval.str); + if (keyword != (DCKeyword *)NULL) { + dcyylval.u.keyword = keyword; + return KEYWORD; + } + } return IDENTIFIER; } YY_BREAK -case 51: +case 43: YY_RULE_SETUP -#line 770 "dcLexer.lxx" +#line 739 "dcLexer.lxx" { // Send any other printable character as itself. accept(); return dcyytext[0]; } YY_BREAK -case 52: +case 44: YY_RULE_SETUP -#line 776 "dcLexer.lxx" +#line 745 "dcLexer.lxx" ECHO; YY_BREAK -#line 1669 "lex.yy.c" +#line 1596 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1956,7 +1883,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 >= 201 ) + if ( yy_current_state >= 165 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1991,11 +1918,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 >= 201 ) + if ( yy_current_state >= 165 ) 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 == 200); + yy_is_jam = (yy_current_state == 164); return yy_is_jam ? 0 : yy_current_state; } @@ -2046,6 +1973,7 @@ register char *yy_bp; #endif /* ifndef YY_NO_UNPUT */ +#ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput() #else @@ -2117,7 +2045,7 @@ static int input() return c; } - +#endif /* YY_NO_INPUT */ #ifdef YY_USE_PROTOS void yyrestart( FILE *input_file ) @@ -2545,4 +2473,4 @@ int main() return 0; } #endif -#line 776 "dcLexer.lxx" +#line 745 "dcLexer.lxx" diff --git a/direct/src/dcparser/dcLexer.lxx b/direct/src/dcparser/dcLexer.lxx index d1155ca21f..facbdefa1a 100644 --- a/direct/src/dcparser/dcLexer.lxx +++ b/direct/src/dcparser/dcLexer.lxx @@ -9,6 +9,7 @@ #include "dcLexerDefs.h" #include "dcParserDefs.h" #include "dcParser.h" +#include "dcFile.h" #include "dcindent.h" @@ -464,6 +465,11 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) return KW_IMPORT; } +"keyword" { + accept(); + return KW_KEYWORD; +} + "typedef" { accept(); return KW_TYPEDEF; @@ -589,51 +595,6 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) return KW_CHAR; } -"required" { - accept(); - return KW_REQUIRED; -} - -"broadcast" { - accept(); - return KW_BROADCAST; -} - -"p2p" { - accept(); - return KW_P2P; -} - -"ram" { - accept(); - return KW_RAM; -} - -"db" { - accept(); - return KW_DB; -} - -"clsend" { - accept(); - return KW_CLSEND; -} - -"clrecv" { - accept(); - return KW_CLRECV; -} - -"ownsend" { - accept(); - return KW_OWNSEND; -} - -"airecv" { - accept(); - return KW_AIRECV; -} - {UNSIGNED_INTEGERNUM} { // An unsigned integer number. accept(); @@ -760,9 +721,17 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) } [A-Za-z_][A-Za-z_0-9]* { - // Identifier. + // Identifier or keyword. accept(); dcyylval.str = dcyytext; + + if (dc_file != (DCFile *)NULL) { + const DCKeyword *keyword = dc_file->get_keyword_by_name(dcyylval.str); + if (keyword != (DCKeyword *)NULL) { + dcyylval.u.keyword = keyword; + return KEYWORD; + } + } return IDENTIFIER; } diff --git a/direct/src/dcparser/dcMolecularField.cxx b/direct/src/dcparser/dcMolecularField.cxx index 0fd2820e23..b4b656339a 100644 --- a/direct/src/dcparser/dcMolecularField.cxx +++ b/direct/src/dcparser/dcMolecularField.cxx @@ -95,7 +95,7 @@ get_atomic(int n) const { void DCMolecularField:: add_atomic(DCAtomicField *atomic) { if (_fields.empty()) { - set_flags(atomic->get_flags()); + copy_keywords(*atomic); } _fields.push_back(atomic); diff --git a/direct/src/dcparser/dcParameter.cxx b/direct/src/dcparser/dcParameter.cxx index 720a1e7a24..a13d993e43 100644 --- a/direct/src/dcparser/dcParameter.cxx +++ b/direct/src/dcparser/dcParameter.cxx @@ -232,7 +232,7 @@ write_instance(ostream &out, bool brief, int indent_level, const string &postname) const { indent(out, indent_level); output_instance(out, brief, prename, name, postname); - output_flags(out); + output_keywords(out); out << ";"; if (!brief && _number >= 0) { out << " // field " << _number; @@ -270,7 +270,7 @@ write_typedef_name(ostream &out, bool brief, int indent_level, if (!prename.empty() || !name.empty() || !postname.empty()) { out << " " << prename << name << postname; } - output_flags(out); + output_keywords(out); out << ";"; if (!brief && _number >= 0) { out << " // field " << _number; @@ -289,7 +289,7 @@ generate_hash(HashGenerator &hashgen) const { // We specifically don't call up to DCField::generate_hash(), since // the parameter name is not actually significant to the hash. - if (get_flags() != 0) { - hashgen.add_int(get_flags()); + if (get_num_keywords() != 0) { + DCKeywordList::generate_hash(hashgen); } } diff --git a/direct/src/dcparser/dcParser.cxx.prebuilt b/direct/src/dcparser/dcParser.cxx.prebuilt index 4a5702fdde..c3847785c1 100644 --- a/direct/src/dcparser/dcParser.cxx.prebuilt +++ b/direct/src/dcparser/dcParser.cxx.prebuilt @@ -1,63 +1,153 @@ -/* A Bison parser, made from dcParser.yxx - by GNU bison 1.35. */ +/* A Bison parser, made by GNU Bison 2.0. */ -#define YYBISON 1 /* Identify Bison output. */ +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ #define yyparse dcyyparse -#define yylex dcyylex +#define yylex dcyylex #define yyerror dcyyerror -#define yylval dcyylval -#define yychar dcyychar +#define yylval dcyylval +#define yychar dcyychar #define yydebug dcyydebug #define yynerrs dcyynerrs -# define UNSIGNED_INTEGER 257 -# define SIGNED_INTEGER 258 -# define REAL 259 -# define STRING 260 -# define HEX_STRING 261 -# define IDENTIFIER 262 -# define KW_DCLASS 263 -# define KW_STRUCT 264 -# define KW_FROM 265 -# define KW_IMPORT 266 -# define KW_TYPEDEF 267 -# define KW_SWITCH 268 -# define KW_CASE 269 -# define KW_DEFAULT 270 -# define KW_BREAK 271 -# define KW_INT8 272 -# define KW_INT16 273 -# define KW_INT32 274 -# define KW_INT64 275 -# define KW_UINT8 276 -# define KW_UINT16 277 -# define KW_UINT32 278 -# define KW_UINT64 279 -# define KW_FLOAT64 280 -# define KW_STRING 281 -# define KW_BLOB 282 -# define KW_BLOB32 283 -# define KW_INT8ARRAY 284 -# define KW_INT16ARRAY 285 -# define KW_INT32ARRAY 286 -# define KW_UINT8ARRAY 287 -# define KW_UINT16ARRAY 288 -# define KW_UINT32ARRAY 289 -# define KW_UINT32UINT8ARRAY 290 -# define KW_CHAR 291 -# define KW_REQUIRED 292 -# define KW_BROADCAST 293 -# define KW_P2P 294 -# define KW_RAM 295 -# define KW_DB 296 -# define KW_CLSEND 297 -# define KW_CLRECV 298 -# define KW_OWNSEND 299 -# define KW_AIRECV 300 -# define START_DC 301 -# define START_PARAMETER_VALUE 302 -# define START_PARAMETER_DESCRIPTION 303 + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + UNSIGNED_INTEGER = 258, + SIGNED_INTEGER = 259, + REAL = 260, + STRING = 261, + HEX_STRING = 262, + IDENTIFIER = 263, + KEYWORD = 264, + KW_DCLASS = 265, + KW_STRUCT = 266, + KW_FROM = 267, + KW_IMPORT = 268, + KW_TYPEDEF = 269, + KW_KEYWORD = 270, + KW_SWITCH = 271, + KW_CASE = 272, + KW_DEFAULT = 273, + KW_BREAK = 274, + KW_INT8 = 275, + KW_INT16 = 276, + KW_INT32 = 277, + KW_INT64 = 278, + KW_UINT8 = 279, + KW_UINT16 = 280, + KW_UINT32 = 281, + KW_UINT64 = 282, + KW_FLOAT64 = 283, + KW_STRING = 284, + KW_BLOB = 285, + KW_BLOB32 = 286, + KW_INT8ARRAY = 287, + KW_INT16ARRAY = 288, + KW_INT32ARRAY = 289, + KW_UINT8ARRAY = 290, + KW_UINT16ARRAY = 291, + KW_UINT32ARRAY = 292, + KW_UINT32UINT8ARRAY = 293, + KW_CHAR = 294, + START_DC = 295, + START_PARAMETER_VALUE = 296, + START_PARAMETER_DESCRIPTION = 297 + }; +#endif +#define UNSIGNED_INTEGER 258 +#define SIGNED_INTEGER 259 +#define REAL 260 +#define STRING 261 +#define HEX_STRING 262 +#define IDENTIFIER 263 +#define KEYWORD 264 +#define KW_DCLASS 265 +#define KW_STRUCT 266 +#define KW_FROM 267 +#define KW_IMPORT 268 +#define KW_TYPEDEF 269 +#define KW_KEYWORD 270 +#define KW_SWITCH 271 +#define KW_CASE 272 +#define KW_DEFAULT 273 +#define KW_BREAK 274 +#define KW_INT8 275 +#define KW_INT16 276 +#define KW_INT32 277 +#define KW_INT64 278 +#define KW_UINT8 279 +#define KW_UINT16 280 +#define KW_UINT32 281 +#define KW_UINT64 282 +#define KW_FLOAT64 283 +#define KW_STRING 284 +#define KW_BLOB 285 +#define KW_BLOB32 286 +#define KW_INT8ARRAY 287 +#define KW_INT16ARRAY 288 +#define KW_INT32ARRAY 289 +#define KW_UINT8ARRAY 290 +#define KW_UINT16ARRAY 291 +#define KW_UINT32ARRAY 292 +#define KW_UINT32UINT8ARRAY 293 +#define KW_CHAR 294 +#define START_DC 295 +#define START_PARAMETER_VALUE 296 +#define START_PARAMETER_DESCRIPTION 297 + + + + +/* Copy the first part of user declarations. */ #line 6 "dcParser.yxx" #include "dcLexerDefs.h" @@ -72,6 +162,7 @@ #include "dcArrayParameter.h" #include "dcSimpleParameter.h" #include "dcTypedef.h" +#include "dcKeyword.h" #include "dcPacker.h" #include "dcNumericRange.h" @@ -83,12 +174,13 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 -static DCFile *dc_file = (DCFile *)NULL; +DCFile *dc_file = (DCFile *)NULL; static DCClass *current_class = (DCClass *)NULL; static DCSwitch *current_switch = (DCSwitch *)NULL; static DCAtomicField *current_atomic = (DCAtomicField *)NULL; static DCMolecularField *current_molecular = (DCMolecularField *)NULL; static DCParameter *current_parameter = (DCParameter *)NULL; +static DCKeywordList current_keyword_list; static DCPacker default_packer; static DCPacker *current_packer; static DCDoubleRange double_range; @@ -133,505 +225,53 @@ dc_cleanup_parser() { dc_file = (DCFile *)NULL; } + + +/* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif - - -#define YYFINAL 284 -#define YYFLAG -32768 -#define YYNTBASE 65 - -/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ -#define YYTRANSLATE(x) ((unsigned)(x) <= 303 ? yytranslate[x] : 144) - -/* 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, 61, 2, 2, - 58, 59, 53, 2, 54, 62, 52, 51, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 57, 50, - 2, 60, 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, 63, 2, 64, 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, 55, 2, 56, 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, 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, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49 -}; - -#if YYDEBUG -static const short yyprhs[] = -{ - 0, 0, 3, 6, 9, 11, 14, 17, 20, 23, - 26, 28, 32, 34, 38, 41, 42, 48, 50, 52, - 54, 58, 61, 63, 65, 66, 74, 76, 78, 81, - 83, 87, 89, 92, 95, 98, 101, 105, 108, 109, - 117, 119, 121, 124, 126, 130, 132, 135, 138, 141, - 144, 148, 151, 152, 158, 160, 162, 164, 168, 170, - 171, 175, 177, 179, 180, 185, 187, 188, 193, 195, - 197, 199, 201, 203, 205, 208, 211, 214, 216, 221, - 225, 229, 231, 233, 235, 237, 239, 241, 245, 248, - 252, 258, 263, 265, 267, 271, 274, 278, 284, 289, - 291, 296, 298, 302, 306, 311, 313, 315, 317, 319, - 321, 323, 325, 327, 329, 331, 333, 335, 336, 341, - 343, 345, 347, 349, 351, 352, 357, 358, 363, 364, - 369, 373, 377, 381, 385, 387, 390, 392, 394, 396, - 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, - 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, - 440, 442, 445, 448, 451, 454, 457, 460, 463, 466, - 469, 471, 472, 477, 479, 481, 485, 487, 489, 490, - 500, 502, 505, 508, 511, 514, 517, 518, 523, 526, - 529, 532, 534 -}; -static const short yyrhs[] = -{ - 47, 66, 0, 48, 118, 0, 49, 104, 0, 143, - 0, 66, 50, 0, 66, 74, 0, 66, 135, 0, - 66, 69, 0, 66, 73, 0, 8, 0, 67, 51, - 8, 0, 67, 0, 68, 52, 67, 0, 12, 68, - 0, 0, 11, 68, 12, 70, 71, 0, 72, 0, - 53, 0, 67, 0, 72, 54, 67, 0, 13, 102, - 0, 75, 0, 82, 0, 0, 9, 134, 76, 78, - 55, 80, 56, 0, 8, 0, 143, 0, 57, 79, - 0, 77, 0, 79, 54, 77, 0, 143, 0, 80, - 50, 0, 80, 81, 0, 89, 128, 0, 130, 129, - 0, 99, 128, 50, 0, 97, 128, 0, 0, 10, - 134, 83, 85, 55, 87, 56, 0, 8, 0, 143, - 0, 57, 86, 0, 84, 0, 86, 54, 84, 0, - 143, 0, 87, 50, 0, 87, 88, 0, 89, 129, - 0, 130, 129, 0, 99, 129, 50, 0, 97, 129, - 0, 0, 134, 58, 90, 91, 59, 0, 143, 0, - 92, 0, 93, 0, 92, 54, 93, 0, 102, 0, - 0, 109, 95, 110, 0, 109, 0, 94, 0, 0, - 94, 60, 98, 118, 0, 96, 0, 0, 96, 60, - 100, 118, 0, 94, 0, 96, 0, 97, 0, 99, - 0, 101, 0, 89, 0, 89, 129, 0, 99, 129, - 0, 97, 129, 0, 127, 0, 105, 58, 107, 59, - 0, 105, 51, 112, 0, 105, 61, 116, 0, 105, - 0, 8, 0, 82, 0, 135, 0, 143, 0, 117, - 0, 117, 62, 117, 0, 117, 116, 0, 107, 54, - 117, 0, 107, 54, 117, 62, 117, 0, 107, 54, - 117, 116, 0, 143, 0, 111, 0, 111, 62, 111, - 0, 111, 113, 0, 108, 54, 111, 0, 108, 54, - 111, 62, 111, 0, 108, 54, 111, 113, 0, 106, - 0, 109, 63, 108, 64, 0, 8, 0, 110, 51, - 112, 0, 110, 61, 116, 0, 110, 63, 108, 64, - 0, 6, 0, 112, 0, 3, 0, 4, 0, 4, - 0, 3, 0, 115, 0, 114, 0, 5, 0, 6, - 0, 116, 0, 120, 0, 0, 8, 60, 119, 120, - 0, 114, 0, 115, 0, 5, 0, 6, 0, 7, - 0, 0, 55, 121, 124, 56, 0, 0, 63, 122, - 124, 64, 0, 0, 58, 123, 124, 59, 0, 114, - 53, 112, 0, 115, 53, 112, 0, 5, 53, 112, - 0, 7, 53, 112, 0, 125, 0, 126, 125, 0, - 143, 0, 54, 0, 118, 0, 126, 54, 118, 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, 36, 0, 37, 0, - 143, 0, 128, 38, 0, 128, 39, 0, 128, 40, - 0, 128, 41, 0, 128, 42, 0, 128, 43, 0, - 128, 44, 0, 128, 45, 0, 128, 46, 0, 128, - 0, 0, 8, 57, 131, 133, 0, 8, 0, 132, - 0, 133, 54, 132, 0, 143, 0, 8, 0, 0, - 14, 134, 58, 103, 59, 55, 136, 137, 56, 0, - 143, 0, 137, 50, 0, 137, 138, 0, 137, 140, - 0, 137, 141, 0, 137, 142, 0, 0, 15, 139, - 118, 57, 0, 16, 57, 0, 17, 50, 0, 99, - 50, 0, 97, 0, 0 -}; - +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 #endif -#if YYDEBUG -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const short yyrline[] = -{ - 0, 175, 177, 178, 184, 186, 187, 198, 204, 205, - 208, 210, 216, 218, 224, 229, 229, 236, 238, 244, - 249, 255, 273, 275, 278, 278, 291, 314, 316, 319, - 326, 339, 341, 342, 354, 365, 366, 374, 383, 383, - 396, 419, 421, 424, 431, 439, 441, 442, 452, 460, - 461, 465, 471, 471, 490, 492, 495, 497, 500, 509, - 509, 520, 524, 526, 526, 554, 556, 556, 584, 586, - 589, 591, 594, 599, 605, 610, 614, 620, 625, 634, - 650, 664, 666, 698, 714, 732, 737, 744, 751, 760, - 766, 772, 782, 787, 794, 801, 808, 814, 820, 828, - 830, 840, 846, 861, 876, 882, 892, 895, 906, 920, - 924, 928, 933, 937, 940, 950, 954, 959, 959, 974, - 979, 983, 987, 991, 995, 995, 1003, 1003, 1011, 1011, - 1019, 1025, 1031, 1037, 1045, 1047, 1050, 1052, 1055, 1057, - 1060, 1065, 1069, 1073, 1077, 1081, 1085, 1089, 1093, 1097, - 1101, 1105, 1109, 1113, 1117, 1121, 1125, 1129, 1133, 1137, - 1143, 1148, 1152, 1156, 1160, 1164, 1168, 1172, 1176, 1180, - 1186, 1196, 1196, 1207, 1223, 1230, 1243, 1248, 1251, 1251, - 1265, 1267, 1268, 1269, 1270, 1271, 1283, 1283, 1304, 1313, - 1320, 1325, 1331 -}; +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 #endif -#if (YYDEBUG) || defined YYERROR_VERBOSE -/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ -static const char *const yytname[] = -{ - "$", "error", "$undefined.", "UNSIGNED_INTEGER", "SIGNED_INTEGER", "REAL", - "STRING", "HEX_STRING", "IDENTIFIER", "KW_DCLASS", "KW_STRUCT", - "KW_FROM", "KW_IMPORT", "KW_TYPEDEF", "KW_SWITCH", "KW_CASE", - "KW_DEFAULT", "KW_BREAK", "KW_INT8", "KW_INT16", "KW_INT32", "KW_INT64", - "KW_UINT8", "KW_UINT16", "KW_UINT32", "KW_UINT64", "KW_FLOAT64", - "KW_STRING", "KW_BLOB", "KW_BLOB32", "KW_INT8ARRAY", "KW_INT16ARRAY", - "KW_INT32ARRAY", "KW_UINT8ARRAY", "KW_UINT16ARRAY", "KW_UINT32ARRAY", - "KW_UINT32UINT8ARRAY", "KW_CHAR", "KW_REQUIRED", "KW_BROADCAST", - "KW_P2P", "KW_RAM", "KW_DB", "KW_CLSEND", "KW_CLRECV", "KW_OWNSEND", - "KW_AIRECV", "START_DC", "START_PARAMETER_VALUE", - "START_PARAMETER_DESCRIPTION", "';'", "'/'", "'.'", "'*'", "','", "'{'", - "'}'", "':'", "'('", "')'", "'='", "'%'", "'-'", "'['", "']'", - "grammar", "dc", "slash_identifier", "import_identifier", "import", - "@1", "import_symbol_list_or_star", "import_symbol_list", - "typedef_decl", "dclass_or_struct", "dclass", "@2", "dclass_name", - "dclass_derivation", "dclass_base_list", "dclass_fields", - "dclass_field", "struct", "@3", "struct_name", "struct_derivation", - "struct_base_list", "struct_fields", "struct_field", "atomic_field", - "@4", "parameter_list", "nonempty_parameter_list", "atomic_element", - "named_parameter", "@5", "unnamed_parameter", - "named_parameter_with_default", "@6", "unnamed_parameter_with_default", - "@7", "parameter", "parameter_with_default", "parameter_or_atomic", - "parameter_description", "simple_type_name", "type_name", - "double_range", "uint_range", "type_definition", "parameter_definition", - "char_or_uint", "small_unsigned_integer", "small_negative_integer", - "signed_integer", "unsigned_integer", "number", "char_or_number", - "parameter_value", "@8", "parameter_actual_value", "@9", "@10", "@11", - "array", "maybe_comma", "array_def", "type_token", "server_flags", - "no_server_flags", "molecular_field", "@12", "atomic_name", - "molecular_atom_list", "optional_name", "switch", "@13", - "switch_fields", "switch_case", "@14", "switch_default", "switch_break", - "switch_field", "empty", 0 -}; -#endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const short yyr1[] = -{ - 0, 65, 65, 65, 66, 66, 66, 66, 66, 66, - 67, 67, 68, 68, 69, 70, 69, 71, 71, 72, - 72, 73, 74, 74, 76, 75, 77, 78, 78, 79, - 79, 80, 80, 80, 81, 81, 81, 81, 83, 82, - 84, 85, 85, 86, 86, 87, 87, 87, 88, 88, - 88, 88, 90, 89, 91, 91, 92, 92, 93, 95, - 94, 96, 97, 98, 97, 99, 100, 99, 101, 101, - 102, 102, 103, 103, 104, 104, 104, 105, 105, 105, - 105, 106, 106, 106, 106, 107, 107, 107, 107, 107, - 107, 107, 108, 108, 108, 108, 108, 108, 108, 109, - 109, 110, 110, 110, 110, 111, 111, 112, 113, 114, - 115, 116, 116, 116, 117, 117, 118, 119, 118, 120, - 120, 120, 120, 120, 121, 120, 122, 120, 123, 120, - 120, 120, 120, 120, 124, 124, 125, 125, 126, 126, - 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 129, 131, 130, 132, 133, 133, 134, 134, 136, 135, - 137, 137, 137, 137, 137, 137, 139, 138, 140, 141, - 142, 142, 143 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const short yyr2[] = -{ - 0, 2, 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, 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, 1, 2, 2, 2, 1, 4, 3, - 3, 1, 1, 1, 1, 1, 1, 3, 2, 3, - 5, 4, 1, 1, 3, 2, 3, 5, 4, 1, - 4, 1, 3, 3, 4, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 0, 4, 1, - 1, 1, 1, 1, 0, 4, 0, 4, 0, 4, - 3, 3, 3, 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, - 1, 0, 4, 1, 1, 3, 1, 1, 0, 9, - 1, 2, 2, 2, 2, 2, 0, 4, 2, 2, - 2, 1, 0 -}; - -/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE - doesn't specify something else to do. Zero means the default is an - error. */ -static const short yydefact[] = -{ - 0, 192, 0, 192, 1, 4, 110, 109, 121, 122, - 123, 0, 124, 128, 126, 119, 120, 2, 116, 82, - 192, 192, 140, 141, 142, 143, 144, 145, 146, 147, - 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, - 158, 159, 83, 192, 62, 65, 192, 192, 3, 81, - 99, 61, 77, 0, 84, 176, 192, 0, 0, 0, - 5, 8, 9, 6, 22, 23, 7, 0, 0, 117, - 192, 192, 192, 0, 0, 177, 38, 0, 170, 74, - 160, 63, 66, 76, 75, 0, 192, 0, 192, 0, - 52, 24, 10, 12, 0, 14, 82, 70, 71, 21, - 107, 132, 133, 0, 137, 138, 0, 134, 192, 136, - 0, 0, 130, 131, 192, 192, 161, 162, 163, 164, - 165, 166, 167, 168, 169, 0, 0, 79, 113, 114, - 0, 112, 111, 115, 86, 85, 80, 105, 0, 93, - 106, 92, 101, 60, 192, 192, 0, 15, 0, 118, - 125, 137, 135, 129, 127, 0, 0, 41, 73, 68, - 69, 72, 0, 64, 67, 0, 78, 0, 88, 0, - 100, 108, 0, 95, 0, 0, 192, 0, 55, 56, - 58, 54, 0, 0, 27, 11, 0, 13, 139, 40, - 43, 42, 192, 0, 89, 87, 96, 94, 102, 103, - 0, 53, 0, 26, 29, 28, 192, 18, 19, 16, - 17, 0, 192, 45, 178, 0, 91, 0, 98, 104, - 57, 0, 192, 31, 0, 44, 82, 46, 39, 47, - 192, 192, 192, 192, 192, 90, 97, 30, 32, 25, - 33, 192, 192, 192, 192, 20, 171, 48, 51, 0, - 49, 0, 180, 34, 37, 0, 35, 0, 50, 186, - 0, 0, 181, 179, 191, 0, 182, 183, 184, 185, - 36, 173, 174, 172, 0, 188, 189, 190, 0, 0, - 175, 187, 0, 0, 0 -}; - -static const short yydefgoto[] = -{ - 282, 4, 93, 94, 61, 186, 209, 210, 62, 63, - 64, 145, 204, 183, 205, 222, 240, 42, 114, 190, - 156, 191, 212, 229, 43, 144, 177, 178, 179, 44, - 89, 45, 97, 125, 98, 126, 161, 180, 162, 48, - 49, 50, 130, 138, 51, 143, 139, 140, 173, 15, - 16, 133, 134, 105, 103, 18, 70, 72, 71, 106, - 107, 108, 52, 78, 79, 233, 257, 272, 273, 53, - 54, 234, 251, 266, 274, 267, 268, 269, 80 -}; - -static const short yypact[] = -{ - 96,-32768, 42, 376, 122,-32768,-32768,-32768, -28,-32768, - -19, -18,-32768,-32768,-32768, 2, 9,-32768,-32768, 6, - 49, 49,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768, 10, 26,-32768,-32768,-32768, 52, - -32768, 27,-32768, 41,-32768,-32768, 49, 77, 77, 406, - -32768,-32768,-32768,-32768,-32768,-32768,-32768, 101, 101,-32768, - 25, 25, 25, 101, 101,-32768,-32768, 62, 125,-32768, - -32768,-32768,-32768,-32768,-32768, 101, 134, 156, 37, 114, - -32768,-32768,-32768, 90, 29, 128,-32768,-32768,-32768,-32768, - -32768,-32768,-32768, 123,-32768,-32768, 126,-32768, 129,-32768, - 130, 120,-32768,-32768, 131, 376,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768, 42, 42,-32768,-32768,-32768, - 28,-32768,-32768,-32768, 16,-32768,-32768,-32768, 4, 7, - -32768,-32768,-32768, -7, 406, 133, 177,-32768, 77,-32768, - -32768, 42,-32768,-32768,-32768, 179, 141,-32768,-32768,-32768, - -32768,-32768, 138,-32768,-32768, 134,-32768, 134,-32768, 37, - -32768,-32768, 37,-32768, 101, 156, 37, 139, 145,-32768, - -32768,-32768, 192, 146,-32768,-32768, 14, 90,-32768,-32768, - -32768, 148,-32768, 149, 33,-32768, 22,-32768,-32768,-32768, - 12,-32768, 406,-32768,-32768, 152,-32768,-32768, 90,-32768, - 153, 179, 298,-32768,-32768, 134,-32768, 37,-32768,-32768, - -32768, 192, 337,-32768, 77,-32768, 57,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768, 90,-32768,-32768,-32768, 158, - -32768, 259,-32768, 125, 125, 112,-32768, 195,-32768,-32768, - 157, 160,-32768,-32768,-32768, 163,-32768,-32768,-32768,-32768, - -32768,-32768,-32768, 162, 42,-32768,-32768,-32768, 195, 161, - -32768,-32768, 217, 219,-32768 -}; - -static const short yypgoto[] = -{ - -32768,-32768, -147, 165,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768, 5,-32768,-32768,-32768,-32768, 216,-32768, 13, - -32768,-32768,-32768,-32768, -103,-32768,-32768,-32768, 30, 113, - -32768, 115, -1,-32768, 0,-32768,-32768, 168,-32768,-32768, - -32768,-32768,-32768, 53,-32768,-32768, -109, -58, 35, -73, - -69, -82, -114, -2,-32768, 132,-32768,-32768,-32768, 105, - 135,-32768,-32768, -68, -39, 11,-32768, -44,-32768, 51, - 232,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 3 -}; +/* Copy the second part of user declarations. */ -#define YYLAST 443 +/* Line 213 of yacc.c. */ +#line 257 "y.tab.c" +#if ! defined (yyoverflow) || YYERROR_VERBOSE -static const short yytable[] = -{ - 17, 187, 46, 47, 5, 136, 55, 83, 84, 101, - 102, 171, 158, 131, 131, 112, 113, 132, 132, 6, - 7, 128, 92, 55, 55, 67, 171, 127, 6, 7, - 8, 9, 10, 11, 68, -59, 6, 7, 128, 208, - 100, 147, 69, 137, 174, 6, 7, 8, 9, 10, - 11, 194, 168, 195, 175, 73, 176, 75, 169, 55, - 196, 131, 74, 197, -177, 132, 169, 207, 170, 172, - 81, 76, 77, 109, 109, 109, 219, 245, 167, 104, - 12, 148, 165, 13, 217, 92, 82, 166, 14, 135, - 88, 141, 131, 199, 131, 215, 132, 12, 132, 90, - 13, 235, 131, 85, 100, 14, 132, 91, 236, 230, - 86, 109, 216, 87, 246, -177, 198, 157, 55, 241, - 115, 131, 142, 163, 164, 132, 6, 7, 8, 9, - 10, 56, 20, 57, 58, 59, 21, 6, 7, 128, - 129, 146, 131, 1, 2, 3, 132, 181, 184, 188, - 116, 117, 118, 119, 120, 121, 122, 123, 124, 6, - 7, 128, 270, 116, 117, 118, 119, 120, 121, 122, - 123, 124, 60, 253, 254, 255, 110, 111, 12, 141, - 148, 13, 150, 151, 154, 185, 14, 189, 155, 153, - 182, 247, 248, 249, 250, 213, 192, 193, 201, 202, - 203, 206, 211, 271, 214, 256, 221, 224, 258, 223, - 276, 231, 232, 277, 275, 55, 278, 283, 281, 284, - 65, 242, 243, 95, 225, 55, 237, 99, 159, 200, - 160, 218, 220, 244, 280, 149, 66, 252, 0, 0, - 0, 0, 0, 152, 0, 0, 0, 0, 0, 0, - 264, 265, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 96, 0, 20, - 0, 0, 279, 21, 259, 260, 261, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 226, 0, 20, 262, - 0, 0, 21, 0, 0, 263, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 226, 0, 20, 227, 0, - 0, 21, 0, 0, 228, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 19, 0, 20, 238, 0, 0, - 21, 0, 0, 239, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 96, 0, 20, 0, 0, 0, - 21, 0, 0, 0, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41 -}; - -static const short yycheck[] = -{ - 2, 148, 3, 3, 1, 87, 3, 46, 47, 67, - 68, 4, 115, 86, 87, 73, 74, 86, 87, 3, - 4, 5, 8, 20, 21, 53, 4, 85, 3, 4, - 5, 6, 7, 8, 53, 8, 3, 4, 5, 186, - 3, 12, 60, 6, 51, 3, 4, 5, 6, 7, - 8, 165, 134, 167, 61, 53, 63, 8, 54, 56, - 169, 134, 53, 172, 58, 134, 54, 53, 64, 62, - 60, 20, 21, 70, 71, 72, 64, 224, 62, 54, - 55, 52, 54, 58, 62, 8, 60, 59, 63, 86, - 63, 88, 165, 175, 167, 62, 165, 55, 167, 58, - 58, 215, 175, 51, 3, 63, 175, 56, 217, 212, - 58, 108, 194, 61, 57, 58, 174, 114, 115, 222, - 58, 194, 8, 125, 126, 194, 3, 4, 5, 6, - 7, 9, 10, 11, 12, 13, 14, 3, 4, 5, - 6, 51, 215, 47, 48, 49, 215, 144, 145, 151, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 3, - 4, 5, 50, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 50, 241, 242, 243, 71, 72, 55, 176, - 52, 58, 56, 54, 64, 8, 63, 8, 57, 59, - 57, 230, 231, 232, 233, 192, 55, 59, 59, 54, - 8, 55, 54, 8, 55, 244, 54, 54, 50, 206, - 50, 212, 212, 50, 57, 212, 54, 0, 57, 0, - 4, 222, 222, 58, 211, 222, 221, 59, 115, 176, - 115, 196, 202, 222, 278, 103, 4, 234, -1, -1, - -1, -1, -1, 108, -1, -1, -1, -1, -1, -1, - 251, 251, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 8, -1, 10, - -1, -1, 274, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 8, -1, 10, 50, - -1, -1, 14, -1, -1, 56, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 8, -1, 10, 50, -1, - -1, 14, -1, -1, 56, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 8, -1, 10, 50, -1, -1, - 14, -1, -1, 56, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 8, -1, 10, -1, -1, -1, - 14, -1, -1, -1, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37 -}; -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/share/bison/bison.simple" - -/* Skeleton output parser for bison, - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* This is the parser code that is written into each bison parser when - the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif /* The parser invokes alloca or malloc; define the necessary symbols. */ -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# else -# ifndef YYSTACK_USE_ALLOCA -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca # else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif +# define YYSTACK_ALLOC alloca # endif # endif # endif @@ -644,45 +284,36 @@ static const short yycheck[] = # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE # endif -#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ #if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ - || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { - short yyss; + short int yyss; YYSTYPE yyvs; -# if YYLSP_NEEDED - YYLTYPE yyls; -# endif -}; + }; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ -# if YYLSP_NEEDED -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ - + 2 * YYSTACK_GAP_MAX) -# else -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAX) -# endif +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY -# if 1 < __GNUC__ +# if defined (__GNUC__) && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else @@ -708,13 +339,519 @@ union yyalloc YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short int yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 57 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 430 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 58 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 81 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 188 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 282 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 297 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned 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, 54, 2, 2, + 51, 52, 46, 2, 47, 55, 45, 44, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 50, 43, + 2, 53, 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, 56, 2, 57, 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, 48, 2, 49, 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, 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, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned short int yyprhs[] = +{ + 0, 0, 3, 6, 9, 12, 14, 17, 20, 23, + 26, 29, 32, 34, 38, 40, 44, 47, 48, 54, + 56, 58, 60, 64, 67, 70, 73, 75, 77, 78, + 86, 88, 90, 93, 95, 99, 101, 104, 108, 111, + 114, 118, 121, 122, 130, 132, 134, 137, 139, 143, + 145, 148, 152, 155, 158, 162, 165, 166, 172, 174, + 176, 178, 182, 184, 185, 189, 191, 193, 194, 199, + 201, 202, 207, 209, 211, 213, 215, 217, 219, 222, + 225, 228, 230, 235, 239, 243, 245, 247, 249, 251, + 253, 255, 259, 262, 266, 272, 277, 279, 281, 285, + 288, 292, 298, 303, 305, 310, 312, 316, 320, 325, + 327, 329, 331, 333, 335, 337, 339, 341, 343, 345, + 347, 349, 350, 355, 357, 359, 361, 363, 365, 366, + 371, 372, 377, 378, 383, 387, 391, 395, 399, 401, + 404, 406, 408, 410, 414, 416, 418, 420, 422, 424, + 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, + 446, 448, 450, 452, 454, 456, 459, 461, 462, 467, + 469, 471, 475, 477, 479, 480, 490, 492, 495, 498, + 501, 504, 507, 508, 513, 516, 519, 522, 524 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const short int yyrhs[] = +{ + 59, 0, -1, 40, 60, -1, 41, 113, -1, 42, + 99, -1, 138, -1, 60, 43, -1, 60, 69, -1, + 60, 130, -1, 60, 63, -1, 60, 67, -1, 60, + 68, -1, 8, -1, 61, 44, 8, -1, 61, -1, + 62, 45, 61, -1, 13, 62, -1, -1, 12, 62, + 13, 64, 65, -1, 66, -1, 46, -1, 61, -1, + 66, 47, 61, -1, 14, 97, -1, 15, 8, -1, + 15, 9, -1, 70, -1, 77, -1, -1, 10, 129, + 71, 73, 48, 75, 49, -1, 8, -1, 138, -1, + 50, 74, -1, 72, -1, 74, 47, 72, -1, 138, + -1, 75, 43, -1, 75, 76, 43, -1, 84, 123, + -1, 125, 124, -1, 94, 123, 43, -1, 92, 123, + -1, -1, 11, 129, 78, 80, 48, 82, 49, -1, + 8, -1, 138, -1, 50, 81, -1, 79, -1, 81, + 47, 79, -1, 138, -1, 82, 43, -1, 82, 83, + 43, -1, 84, 124, -1, 125, 124, -1, 94, 124, + 43, -1, 92, 124, -1, -1, 129, 51, 85, 86, + 52, -1, 138, -1, 87, -1, 88, -1, 87, 47, + 88, -1, 97, -1, -1, 104, 90, 105, -1, 104, + -1, 89, -1, -1, 89, 53, 93, 113, -1, 91, + -1, -1, 91, 53, 95, 113, -1, 89, -1, 91, + -1, 92, -1, 94, -1, 96, -1, 84, -1, 84, + 124, -1, 94, 124, -1, 92, 124, -1, 122, -1, + 100, 51, 102, 52, -1, 100, 44, 107, -1, 100, + 54, 111, -1, 100, -1, 8, -1, 77, -1, 130, + -1, 138, -1, 112, -1, 112, 55, 112, -1, 112, + 111, -1, 102, 47, 112, -1, 102, 47, 112, 55, + 112, -1, 102, 47, 112, 111, -1, 138, -1, 106, + -1, 106, 55, 106, -1, 106, 108, -1, 103, 47, + 106, -1, 103, 47, 106, 55, 106, -1, 103, 47, + 106, 108, -1, 101, -1, 104, 56, 103, 57, -1, + 8, -1, 105, 44, 107, -1, 105, 54, 111, -1, + 105, 56, 103, 57, -1, 6, -1, 107, -1, 3, + -1, 4, -1, 4, -1, 3, -1, 110, -1, 109, + -1, 5, -1, 6, -1, 111, -1, 115, -1, -1, + 8, 53, 114, 115, -1, 109, -1, 110, -1, 5, + -1, 6, -1, 7, -1, -1, 48, 116, 119, 49, + -1, -1, 56, 117, 119, 57, -1, -1, 51, 118, + 119, 52, -1, 109, 46, 107, -1, 110, 46, 107, + -1, 5, 46, 107, -1, 7, 46, 107, -1, 120, + -1, 121, 120, -1, 138, -1, 47, -1, 113, -1, + 121, 47, 113, -1, 20, -1, 21, -1, 22, -1, + 23, -1, 24, -1, 25, -1, 26, -1, 27, -1, + 28, -1, 29, -1, 30, -1, 31, -1, 32, -1, + 33, -1, 34, -1, 35, -1, 36, -1, 37, -1, + 38, -1, 39, -1, 138, -1, 123, 9, -1, 123, + -1, -1, 8, 50, 126, 128, -1, 8, -1, 127, + -1, 128, 47, 127, -1, 138, -1, 8, -1, -1, + 16, 129, 51, 98, 52, 48, 131, 132, 49, -1, + 138, -1, 132, 43, -1, 132, 133, -1, 132, 135, + -1, 132, 136, -1, 132, 137, -1, -1, 17, 134, + 113, 50, -1, 18, 50, -1, 19, 43, -1, 94, + 43, -1, 92, -1, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short int yyrline[] = +{ + 0, 168, 168, 169, 170, 177, 178, 179, 190, 196, + 197, 198, 202, 203, 210, 211, 218, 223, 222, 230, + 231, 238, 242, 249, 267, 271, 282, 283, 288, 287, + 300, 323, 324, 328, 334, 348, 349, 350, 363, 373, + 374, 382, 393, 392, 405, 428, 429, 433, 439, 448, + 449, 450, 461, 468, 469, 473, 481, 480, 499, 500, + 504, 505, 509, 519, 518, 529, 533, 535, 534, 563, + 565, 564, 593, 594, 598, 599, 603, 607, 614, 618, + 622, 629, 633, 642, 658, 673, 674, 706, 722, 741, + 745, 752, 759, 768, 774, 780, 791, 795, 802, 809, + 816, 822, 828, 837, 838, 849, 854, 869, 884, 891, + 900, 904, 915, 929, 933, 937, 941, 945, 949, 958, + 963, 968, 967, 983, 987, 991, 995, 999, 1004, 1003, + 1012, 1011, 1020, 1019, 1027, 1033, 1039, 1045, 1054, 1055, + 1059, 1060, 1064, 1065, 1069, 1073, 1077, 1081, 1085, 1089, + 1093, 1097, 1101, 1105, 1109, 1113, 1117, 1121, 1125, 1129, + 1133, 1137, 1141, 1145, 1152, 1156, 1163, 1173, 1172, 1183, + 1199, 1205, 1219, 1223, 1228, 1227, 1241, 1242, 1243, 1244, + 1245, 1246, 1260, 1259, 1280, 1289, 1296, 1300, 1306 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "UNSIGNED_INTEGER", "SIGNED_INTEGER", + "REAL", "STRING", "HEX_STRING", "IDENTIFIER", "KEYWORD", "KW_DCLASS", + "KW_STRUCT", "KW_FROM", "KW_IMPORT", "KW_TYPEDEF", "KW_KEYWORD", + "KW_SWITCH", "KW_CASE", "KW_DEFAULT", "KW_BREAK", "KW_INT8", "KW_INT16", + "KW_INT32", "KW_INT64", "KW_UINT8", "KW_UINT16", "KW_UINT32", + "KW_UINT64", "KW_FLOAT64", "KW_STRING", "KW_BLOB", "KW_BLOB32", + "KW_INT8ARRAY", "KW_INT16ARRAY", "KW_INT32ARRAY", "KW_UINT8ARRAY", + "KW_UINT16ARRAY", "KW_UINT32ARRAY", "KW_UINT32UINT8ARRAY", "KW_CHAR", + "START_DC", "START_PARAMETER_VALUE", "START_PARAMETER_DESCRIPTION", + "';'", "'/'", "'.'", "'*'", "','", "'{'", "'}'", "':'", "'('", "')'", + "'='", "'%'", "'-'", "'['", "']'", "$accept", "grammar", "dc", + "slash_identifier", "import_identifier", "import", "@1", + "import_symbol_list_or_star", "import_symbol_list", "typedef_decl", + "keyword_decl", "dclass_or_struct", "dclass", "@2", "dclass_name", + "dclass_derivation", "dclass_base_list", "dclass_fields", "dclass_field", + "struct", "@3", "struct_name", "struct_derivation", "struct_base_list", + "struct_fields", "struct_field", "atomic_field", "@4", "parameter_list", + "nonempty_parameter_list", "atomic_element", "named_parameter", "@5", + "unnamed_parameter", "named_parameter_with_default", "@6", + "unnamed_parameter_with_default", "@7", "parameter", + "parameter_with_default", "parameter_or_atomic", "parameter_description", + "simple_type_name", "type_name", "double_range", "uint_range", + "type_definition", "parameter_definition", "char_or_uint", + "small_unsigned_integer", "small_negative_integer", "signed_integer", + "unsigned_integer", "number", "char_or_number", "parameter_value", "@8", + "parameter_actual_value", "@9", "@10", "@11", "array", "maybe_comma", + "array_def", "type_token", "keyword_list", "no_keyword_list", + "molecular_field", "@12", "atomic_name", "molecular_atom_list", + "optional_name", "switch", "@13", "switch_fields", "switch_case", "@14", + "switch_default", "switch_break", "switch_field", "empty", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short int yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 59, 47, 46, 42, 44, 123, 125, + 58, 40, 41, 61, 37, 45, 91, 93 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 58, 59, 59, 59, 60, 60, 60, 60, 60, + 60, 60, 61, 61, 62, 62, 63, 64, 63, 65, + 65, 66, 66, 67, 68, 68, 69, 69, 71, 70, + 72, 73, 73, 74, 74, 75, 75, 75, 76, 76, + 76, 76, 78, 77, 79, 80, 80, 81, 81, 82, + 82, 82, 83, 83, 83, 83, 85, 84, 86, 86, + 87, 87, 88, 90, 89, 91, 92, 93, 92, 94, + 95, 94, 96, 96, 97, 97, 98, 98, 99, 99, + 99, 100, 100, 100, 100, 101, 101, 101, 101, 102, + 102, 102, 102, 102, 102, 102, 103, 103, 103, 103, + 103, 103, 103, 104, 104, 105, 105, 105, 105, 106, + 106, 107, 108, 109, 110, 111, 111, 111, 112, 112, + 113, 114, 113, 115, 115, 115, 115, 115, 116, 115, + 117, 115, 118, 115, 115, 115, 115, 115, 119, 119, + 120, 120, 121, 121, 122, 122, 122, 122, 122, 122, + 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, + 122, 122, 122, 122, 123, 123, 124, 126, 125, 127, + 128, 128, 129, 129, 131, 130, 132, 132, 132, 132, + 132, 132, 134, 133, 135, 136, 137, 137, 138 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 2, 2, 2, 1, 2, 2, 2, 2, + 2, 2, 1, 3, 1, 3, 2, 0, 5, 1, + 1, 1, 3, 2, 2, 2, 1, 1, 0, 7, + 1, 1, 2, 1, 3, 1, 2, 3, 2, 2, + 3, 2, 0, 7, 1, 1, 2, 1, 3, 1, + 2, 3, 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, 1, 2, 2, + 2, 1, 4, 3, 3, 1, 1, 1, 1, 1, + 1, 3, 2, 3, 5, 4, 1, 1, 3, 2, + 3, 5, 4, 1, 4, 1, 3, 3, 4, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 4, 1, 1, 1, 1, 1, 0, 4, + 0, 4, 0, 4, 3, 3, 3, 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, 1, 0, 4, 1, + 1, 3, 1, 1, 0, 9, 1, 2, 2, 2, + 2, 2, 0, 4, 2, 2, 2, 1, 0 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 0, 188, 0, 188, 0, 2, 5, 114, 113, 125, + 126, 127, 0, 128, 132, 130, 123, 124, 3, 120, + 86, 188, 188, 144, 145, 146, 147, 148, 149, 150, + 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, + 161, 162, 163, 87, 188, 66, 69, 188, 188, 4, + 85, 103, 65, 81, 0, 88, 172, 1, 188, 0, + 0, 0, 0, 6, 9, 10, 11, 7, 26, 27, + 8, 0, 0, 121, 188, 188, 188, 0, 0, 173, + 42, 0, 166, 78, 164, 67, 70, 80, 79, 0, + 188, 0, 188, 0, 56, 28, 12, 14, 0, 16, + 86, 74, 75, 23, 24, 25, 111, 136, 137, 0, + 141, 142, 0, 138, 188, 140, 0, 0, 134, 135, + 188, 188, 165, 0, 0, 83, 117, 118, 0, 116, + 115, 119, 90, 89, 84, 109, 0, 97, 110, 96, + 105, 64, 188, 188, 0, 17, 0, 122, 129, 141, + 139, 133, 131, 0, 0, 45, 77, 72, 73, 76, + 0, 68, 71, 0, 82, 0, 92, 0, 104, 112, + 0, 99, 0, 0, 188, 0, 59, 60, 62, 58, + 0, 0, 31, 13, 0, 15, 143, 44, 47, 46, + 188, 0, 93, 91, 100, 98, 106, 107, 0, 57, + 0, 30, 33, 32, 188, 20, 21, 18, 19, 0, + 188, 49, 174, 0, 95, 0, 102, 108, 61, 0, + 188, 35, 0, 48, 86, 50, 43, 0, 188, 188, + 188, 188, 188, 94, 101, 34, 36, 29, 0, 188, + 188, 188, 188, 22, 167, 51, 52, 55, 0, 53, + 0, 176, 37, 38, 41, 0, 39, 0, 54, 182, + 0, 0, 177, 175, 187, 0, 178, 179, 180, 181, + 40, 169, 170, 168, 0, 184, 185, 186, 0, 0, + 171, 183 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const short int yydefgoto[] = +{ + -1, 4, 5, 97, 98, 64, 184, 207, 208, 65, + 66, 67, 68, 143, 202, 181, 203, 220, 238, 43, + 120, 188, 154, 189, 210, 227, 44, 142, 175, 176, + 177, 45, 93, 46, 101, 123, 102, 124, 159, 178, + 160, 49, 50, 51, 128, 136, 52, 141, 137, 138, + 171, 16, 17, 131, 132, 111, 109, 19, 74, 76, + 75, 112, 113, 114, 53, 82, 83, 231, 257, 272, + 273, 54, 55, 232, 250, 266, 274, 267, 268, 269, + 84 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -141 +static const short int yypact[] = +{ + 93, -141, 122, 359, 32, 138, -141, -141, -141, 4, + -141, 6, 1, -141, -141, -141, 10, 12, -141, -141, + -6, 52, 52, -141, -141, -141, -141, -141, -141, -141, + -141, -141, -141, -141, -141, -141, -141, -141, -141, -141, + -141, -141, -141, -141, -141, 27, 61, -141, -141, -141, + -7, -141, 8, -141, 46, -141, -141, -141, 52, 108, + 108, 391, 31, -141, -141, -141, -141, -141, -141, -141, + -141, 116, 116, -141, 62, 62, 62, 116, 116, -141, + -141, 69, 128, -141, -141, -141, -141, -141, -141, 116, + 102, 152, 84, 123, -141, -141, -141, 94, 44, 99, + -141, -141, -141, -141, -141, -141, -141, -141, -141, 136, + -141, -141, 109, -141, 117, -141, 113, 110, -141, -141, + 118, 359, -141, 122, 122, -141, -141, -141, 51, -141, + -141, -141, 16, -141, -141, -141, -16, 18, -141, -141, + -141, -8, 391, 119, 158, -141, 108, -141, -141, 122, + -141, -141, -141, 163, 124, -141, -141, -141, -141, -141, + 127, -141, -141, 102, -141, 102, -141, 84, -141, -141, + 84, -141, 116, 152, 84, 130, 129, -141, -141, -141, + 166, 132, -141, -141, 35, 94, -141, -141, -141, 139, + -141, 135, 30, -141, 19, -141, -141, -141, 2, -141, + 391, -141, -141, 147, -141, -141, 94, -141, 148, 163, + 291, -141, -141, 102, -141, 84, -141, -141, -141, 166, + 325, -141, 108, -141, 50, -141, -141, 142, -141, -141, + -141, -141, -141, -141, -141, -141, -141, -141, 153, -141, + -141, -141, -141, 94, -141, -141, -141, -141, 154, -141, + 257, -141, -141, 128, 128, 29, -141, 167, -141, -141, + 149, 155, -141, -141, -141, 157, -141, -141, -141, -141, + -141, -141, -141, 156, 122, -141, -141, -141, 167, 151, + -141, -141 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const short int yypgoto[] = +{ + -141, -141, -141, -131, 144, -141, -141, -141, -141, -141, + -141, -141, -141, -141, -14, -141, -141, -141, -141, 201, + -141, 5, -141, -141, -141, -141, -116, -141, -141, -141, + 11, 91, -141, 95, -1, -141, 0, -141, -141, 160, + -141, -141, -141, -141, -141, 34, -141, -141, -140, -60, + 21, -81, -77, -90, -137, -2, -141, 115, -141, -141, + -141, 87, 103, -141, -141, -80, -40, 7, -141, -56, + -141, 41, 213, -141, -141, -141, -141, -141, -141, -141, + 3 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -174 +static const short int yytable[] = +{ + 18, 134, 47, 48, 6, 156, 56, 87, 88, 129, + 129, 107, 108, 130, 130, 185, -63, 118, 119, 7, + 8, 126, 169, 169, 56, 56, 192, 194, 193, 125, + 195, 167, 57, 7, 8, 126, 172, 89, 122, 104, + 105, 168, 166, 96, 90, -173, 173, 91, 174, 167, + 71, 129, 72, 206, 73, 130, 77, 145, 78, 217, + 79, 56, 80, 81, 92, 7, 8, 9, 10, 11, + 12, 165, 270, 170, 215, 234, 233, 115, 115, 115, + 85, 205, 129, 197, 129, 213, 130, 106, 130, 146, + 135, 243, 129, 133, 228, 139, 130, 94, 163, 95, + 244, -173, 214, 164, 239, 7, 8, 126, 127, 110, + 13, 129, 196, 14, 86, 130, 96, 115, 15, 106, + 121, 161, 162, 155, 56, 7, 8, 9, 10, 11, + 12, 140, 129, 1, 2, 3, 130, 122, 144, 7, + 8, 9, 10, 11, 146, 179, 182, 186, 58, 21, + 59, 60, 61, 62, 22, 7, 8, 126, 148, 253, + 254, 255, 116, 117, 149, 151, 183, 152, 153, 180, + 13, 187, 190, 14, 201, 271, 200, 139, 15, 191, + 204, 63, 199, 212, 13, 245, 209, 14, 246, 247, + 248, 249, 15, 211, 219, 222, 252, 258, 276, 275, + 277, 281, 256, 278, 99, 235, 69, 221, 198, 229, + 230, 218, 157, 56, 223, 216, 158, 150, 70, 240, + 241, 103, 280, 56, 147, 0, 0, 242, 0, 0, + 0, 0, 0, 0, 0, 251, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 264, + 265, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 100, 0, 0, 21, 0, + 0, 0, 279, 22, 259, 260, 261, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 0, 0, 224, + 262, 0, 21, 0, 0, 0, 263, 22, 0, 0, + 0, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 0, 0, 224, 225, 0, 21, 0, 0, 0, + 226, 22, 0, 0, 0, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 0, 0, 20, 236, 0, + 21, 0, 0, 0, 237, 22, 0, 0, 0, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 100, + 0, 0, 21, 0, 0, 0, 0, 22, 0, 0, + 0, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42 +}; + +static const short int yycheck[] = +{ + 2, 91, 3, 3, 1, 121, 3, 47, 48, 90, + 91, 71, 72, 90, 91, 146, 8, 77, 78, 3, + 4, 5, 4, 4, 21, 22, 163, 167, 165, 89, + 170, 47, 0, 3, 4, 5, 44, 44, 9, 8, + 9, 57, 132, 8, 51, 51, 54, 54, 56, 47, + 46, 132, 46, 184, 53, 132, 46, 13, 46, 57, + 8, 58, 21, 22, 56, 3, 4, 5, 6, 7, + 8, 55, 43, 55, 55, 215, 213, 74, 75, 76, + 53, 46, 163, 173, 165, 55, 163, 3, 165, 45, + 6, 222, 173, 90, 210, 92, 173, 51, 47, 58, + 50, 51, 192, 52, 220, 3, 4, 5, 6, 47, + 48, 192, 172, 51, 53, 192, 8, 114, 56, 3, + 51, 123, 124, 120, 121, 3, 4, 5, 6, 7, + 8, 8, 213, 40, 41, 42, 213, 9, 44, 3, + 4, 5, 6, 7, 45, 142, 143, 149, 10, 11, + 12, 13, 14, 15, 16, 3, 4, 5, 49, 239, + 240, 241, 75, 76, 47, 52, 8, 57, 50, 50, + 48, 8, 48, 51, 8, 8, 47, 174, 56, 52, + 48, 43, 52, 48, 48, 43, 47, 51, 228, 229, + 230, 231, 56, 190, 47, 47, 43, 43, 43, 50, + 43, 50, 242, 47, 60, 219, 5, 204, 174, 210, + 210, 200, 121, 210, 209, 194, 121, 114, 5, 220, + 220, 61, 278, 220, 109, -1, -1, 220, -1, -1, + -1, -1, -1, -1, -1, 232, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 250, + 250, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 8, -1, -1, 11, -1, + -1, -1, 274, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, -1, -1, 8, + 43, -1, 11, -1, -1, -1, 49, 16, -1, -1, + -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, -1, -1, 8, 43, -1, 11, -1, -1, -1, + 49, 16, -1, -1, -1, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, -1, -1, 8, 43, -1, + 11, -1, -1, -1, 49, 16, -1, -1, -1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 8, + -1, -1, 11, -1, -1, -1, -1, 16, -1, -1, + -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 40, 41, 42, 59, 60, 138, 3, 4, 5, + 6, 7, 8, 48, 51, 56, 109, 110, 113, 115, + 8, 11, 16, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 77, 84, 89, 91, 92, 94, 99, + 100, 101, 104, 122, 129, 130, 138, 0, 10, 12, + 13, 14, 15, 43, 63, 67, 68, 69, 70, 77, + 130, 46, 46, 53, 116, 118, 117, 46, 46, 8, + 129, 129, 123, 124, 138, 53, 53, 124, 124, 44, + 51, 54, 56, 90, 51, 129, 8, 61, 62, 62, + 8, 92, 94, 97, 8, 9, 3, 107, 107, 114, + 47, 113, 119, 120, 121, 138, 119, 119, 107, 107, + 78, 51, 9, 93, 95, 107, 5, 6, 102, 109, + 110, 111, 112, 138, 111, 6, 103, 106, 107, 138, + 8, 105, 85, 71, 44, 13, 45, 115, 49, 47, + 120, 52, 57, 50, 80, 138, 84, 89, 91, 96, + 98, 113, 113, 47, 52, 55, 111, 47, 57, 4, + 55, 108, 44, 54, 56, 86, 87, 88, 97, 138, + 50, 73, 138, 8, 64, 61, 113, 8, 79, 81, + 48, 52, 112, 112, 106, 106, 107, 111, 103, 52, + 47, 8, 72, 74, 48, 46, 61, 65, 66, 47, + 82, 138, 48, 55, 111, 55, 108, 57, 88, 47, + 75, 138, 47, 79, 8, 43, 49, 83, 84, 92, + 94, 125, 131, 112, 106, 72, 43, 49, 76, 84, + 92, 94, 125, 61, 50, 43, 124, 124, 124, 124, + 132, 138, 43, 123, 123, 123, 124, 126, 43, 17, + 18, 19, 43, 49, 92, 94, 133, 135, 136, 137, + 43, 8, 127, 128, 134, 50, 43, 43, 47, 113, + 127, 50 +}; #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ @@ -734,71 +871,93 @@ union yyalloc #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 +#define YYEMPTY (-2) #define YYEOF 0 + #define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ + #define YYFAIL goto yyerrlab + #define YYRECOVERING() (!!yyerrstatus) + #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ - yychar1 = YYTRANSLATE (yychar); \ + yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ - yyerror ("syntax error: cannot back up"); \ + yyerror ("syntax error: cannot back up");\ YYERROR; \ } \ while (0) + #define YYTERROR 1 #define YYERRCODE 256 -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). - - When YYLLOC_DEFAULT is run, CURRENT is set the location of the - first token. By default, to implement support for ranges, extend - its range to the last symbol. */ +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - Current.last_line = Rhs[N].last_line; \ - Current.last_column = Rhs[N].last_column; +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (0) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif #endif /* YYLEX -- calling `yylex' with the right arguments. */ -#if YYPURE -# if YYLSP_NEEDED -# ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) -# else -# define YYLEX yylex (&yylval, &yylloc) -# endif -# else /* !YYLSP_NEEDED */ -# ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -# else -# define YYLEX yylex (&yylval) -# endif -# endif /* !YYLSP_NEEDED */ -#else /* !YYPURE */ -# define YYLEX yylex () -#endif /* !YYPURE */ - +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif /* Enable debugging if requested. */ #if YYDEBUG @@ -813,13 +972,86 @@ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short int *bottom, short int *top) +#else +static void +yy_stack_print (bottom, top) + short int *bottom; + short int *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ + /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 @@ -832,15 +1064,13 @@ int yydebug; SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ -#if YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif + -#ifdef YYERROR_VERBOSE + +#if YYERROR_VERBOSE # ifndef yystrlen # if defined (__GLIBC__) && defined (_STRING_H) @@ -890,86 +1120,139 @@ yystpcpy (yydest, yysrc) } # endif # endif -#endif + +#endif /* !YYERROR_VERBOSE */ + -#line 315 "/usr/share/bison/bison.simple" + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) -# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -# define YYPARSE_PARAM_DECL +int yyparse (void *YYPARSE_PARAM); # else -# define YYPARSE_PARAM_ARG YYPARSE_PARAM -# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +int yyparse (); # endif -#else /* !YYPARSE_PARAM */ -# define YYPARSE_PARAM_ARG -# define YYPARSE_PARAM_DECL -#endif /* !YYPARSE_PARAM */ - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -# ifdef YYPARSE_PARAM -int yyparse (void *); -# else +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) int yyparse (void); -# endif +#else +int yyparse (); #endif +#endif /* ! YYPARSE_PARAM */ -/* YY_DECL_VARIABLES -- depending whether we use a pure parser, - variables are global, or local to YYPARSE. */ -#define YY_DECL_NON_LSP_VARIABLES \ -/* The lookahead symbol. */ \ -int yychar; \ - \ -/* The semantic value of the lookahead symbol. */ \ -YYSTYPE yylval; \ - \ -/* Number of parse errors so far. */ \ + +/* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ int yynerrs; -#if YYLSP_NEEDED -# define YY_DECL_VARIABLES \ -YY_DECL_NON_LSP_VARIABLES \ - \ -/* Location data for the lookahead symbol. */ \ -YYLTYPE yylloc; -#else -# define YY_DECL_VARIABLES \ -YY_DECL_NON_LSP_VARIABLES -#endif -/* If nonreentrant, generate the variables here. */ - -#if !YYPURE -YY_DECL_VARIABLES -#endif /* !YYPURE */ +/*----------. +| yyparse. | +`----------*/ +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) int -yyparse (YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - /* If reentrant, generate the variables here. */ -#if YYPURE - YY_DECL_VARIABLES -#endif /* !YYPURE */ +yyparse (void) +#else +int +yyparse () +#endif +#endif +{ + register int yystate; register int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yychar1 = 0; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; /* Three stacks and their tools: `yyss': related to states, @@ -979,41 +1262,29 @@ yyparse (YYPARSE_PARAM_ARG) Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ - /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; + /* The state stack. */ + short int yyssa[YYINITDEPTH]; + short int *yyss = yyssa; + register short int *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; register YYSTYPE *yyvsp; -#if YYLSP_NEEDED - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; -#endif -#if YYLSP_NEEDED -# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -# define YYPOPSTACK (yyvsp--, yyssp--) -#endif + +#define YYPOPSTACK (yyvsp--, yyssp--) YYSIZE_T yystacksize = YYINITDEPTH; - /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; -#if YYLSP_NEEDED - YYLTYPE yyloc; -#endif + /* When reducing, the number of symbols on the RHS of the reduced - rule. */ + rule. */ int yylen; YYDPRINTF ((stderr, "Starting parse\n")); @@ -1030,9 +1301,10 @@ yyparse (YYPARSE_PARAM_ARG) yyssp = yyss; yyvsp = yyvs; -#if YYLSP_NEEDED - yylsp = yyls; -#endif + + + yyvsp[0] = yylval; + goto yysetstate; /*------------------------------------------------------------. @@ -1047,7 +1319,7 @@ yyparse (YYPARSE_PARAM_ARG) yysetstate: *yyssp = yystate; - if (yyssp >= yyss + yystacksize - 1) + if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; @@ -1058,26 +1330,19 @@ yyparse (YYPARSE_PARAM_ARG) these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; + short int *yyss1 = yyss; + /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. */ -# if YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yyls1, yysize * sizeof (*yylsp), + &yystacksize); - yyls = yyls1; -# else - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); -# endif + yyss = yyss1; yyvs = yyvs1; } @@ -1086,24 +1351,22 @@ yyparse (YYPARSE_PARAM_ARG) goto yyoverflowlab; # else /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) + if (YYMAXDEPTH <= yystacksize) goto yyoverflowlab; yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) + if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { - short *yyss1 = yyss; + short int *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyoverflowlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); -# if YYLSP_NEEDED - YYSTACK_RELOCATE (yyls); -# endif -# undef YYSTACK_RELOCATE + +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } @@ -1112,14 +1375,12 @@ yyparse (YYPARSE_PARAM_ARG) yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; -#if YYLSP_NEEDED - yylsp = yyls + yysize - 1; -#endif + YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); - if (yyssp >= yyss + yystacksize - 1) + if (yyss + yystacksize - 1 <= yyssp) YYABORT; } @@ -1127,101 +1388,67 @@ yyparse (YYPARSE_PARAM_ARG) goto yybackup; - /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ +/* Read a look-ahead token if we need one and don't already have one. */ /* yyresume: */ - /* First try to decide what to do without reference to lookahead token. */ + /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; - if (yyn == YYFLAG) + if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ + /* Not known => get a look-ahead token if don't already have one. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ + if (yychar <= YYEOF) { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - + yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { - yychar1 = YYTRANSLATE (yychar); - -#if YYDEBUG - /* We have to keep this `#if YYDEBUG', since we use variables - which are defined only if `YYDEBUG' is set. */ - if (yydebug) - { - YYFPRINTF (stderr, "Next token is %d (%s", - yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise - meaning of a token, for further debugging info. */ -# ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -# endif - YYFPRINTF (stderr, ")\n"); - } -#endif + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) + if (yyn <= 0) { - if (yyn == YYFLAG) + if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } - else if (yyn == 0) - goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %d (%s), ", - yychar, yytname[yychar1])); + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; -#if YYLSP_NEEDED - *++yylsp = yylloc; -#endif + /* Count tokens shifted since error; after three, turn off error status. */ @@ -1252,113 +1479,101 @@ yyreduce: /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. - Otherwise, the following line sets YYVAL to the semantic value of - the lookahead token. This behavior is undocumented and Bison + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; -#if YYLSP_NEEDED - /* Similarly for the default location. Let the user run additional - commands if for instance locations are ranges. */ - yyloc = yylsp[1-yylen]; - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); -#endif -#if YYDEBUG - /* We have to keep this `#if YYDEBUG', since we use variables which - are defined only if `YYDEBUG' is set. */ - if (yydebug) + YY_REDUCE_PRINT (yyn); + switch (yyn) { - int yyi; - - YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) - YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); - YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - switch (yyn) { - -case 3: -#line 179 "dcParser.yxx" -{ - parameter_description = yyvsp[0].u.field; + case 4: +#line 171 "dcParser.yxx" + { + parameter_description = (yyvsp[0].u.field); } break; -case 6: -#line 188 "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()); + + case 7: +#line 180 "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()); if (old_class != (DCClass *)NULL && old_class->is_bogus_class()) { - yyerror("Base class defined after its first reference: " + yyvsp[0].u.dclass->get_name()); + yyerror("Base class defined after its first reference: " + (yyvsp[0].u.dclass)->get_name()); } else { - yyerror("Duplicate class name: " + yyvsp[0].u.dclass->get_name()); + yyerror("Duplicate class name: " + (yyvsp[0].u.dclass)->get_name()); } } } break; -case 7: -#line 199 "dcParser.yxx" -{ - if (!dc_file->add_switch(yyvsp[0].u.dswitch)) { - yyerror("Duplicate class name: " + yyvsp[0].u.dswitch->get_name()); + + case 8: +#line 191 "dcParser.yxx" + { + if (!dc_file->add_switch((yyvsp[0].u.dswitch))) { + yyerror("Duplicate class name: " + (yyvsp[0].u.dswitch)->get_name()); } } break; -case 11: -#line 211 "dcParser.yxx" -{ - yyval.str = yyvsp[-2].str + string("/") + yyvsp[0].str; + + case 13: +#line 204 "dcParser.yxx" + { + (yyval.str) = (yyvsp[-2].str) + string("/") + (yyvsp[0].str); } break; -case 13: + + case 15: +#line 212 "dcParser.yxx" + { + (yyval.str) = (yyvsp[-2].str) + string(".") + (yyvsp[0].str); +} + break; + + case 16: #line 219 "dcParser.yxx" -{ - yyval.str = yyvsp[-2].str + string(".") + yyvsp[0].str; + { + dc_file->add_import_module((yyvsp[0].str)); } break; -case 14: -#line 226 "dcParser.yxx" -{ - dc_file->add_import_module(yyvsp[0].str); + + case 17: +#line 223 "dcParser.yxx" + { + dc_file->add_import_module((yyvsp[-1].str)); } break; -case 15: -#line 230 "dcParser.yxx" -{ - dc_file->add_import_module(yyvsp[-1].str); -} - break; -case 18: -#line 239 "dcParser.yxx" -{ + + case 20: +#line 232 "dcParser.yxx" + { dc_file->add_import_symbol("*"); } break; -case 19: -#line 246 "dcParser.yxx" -{ - dc_file->add_import_symbol(yyvsp[0].str); + + case 21: +#line 239 "dcParser.yxx" + { + dc_file->add_import_symbol((yyvsp[0].str)); } break; -case 20: + + case 22: +#line 243 "dcParser.yxx" + { + dc_file->add_import_symbol((yyvsp[0].str)); +} + break; + + case 23: #line 250 "dcParser.yxx" -{ - dc_file->add_import_symbol(yyvsp[0].str); -} - break; -case 21: -#line 257 "dcParser.yxx" -{ - if (yyvsp[0].u.parameter != (DCParameter *)NULL) { - DCTypedef *dtypedef = new DCTypedef(yyvsp[0].u.parameter); + { + if ((yyvsp[0].u.parameter) != (DCParameter *)NULL) { + DCTypedef *dtypedef = new DCTypedef((yyvsp[0].u.parameter)); if (!dc_file->add_typedef(dtypedef)) { DCTypedef *old_typedef = dc_file->get_typedef_by_name(dtypedef->get_name()); @@ -1371,278 +1586,291 @@ case 21: } } break; -case 24: -#line 280 "dcParser.yxx" -{ - yyval.u.dclass = current_class; - current_class = new DCClass(dc_file, yyvsp[0].str, false, false); + + case 24: +#line 268 "dcParser.yxx" + { + dc_file->add_keyword((yyvsp[0].str)); } break; -case 25: -#line 285 "dcParser.yxx" -{ - yyval.u.dclass = current_class; - current_class = yyvsp[-4].u.dclass; + + case 25: +#line 272 "dcParser.yxx" + { + // This keyword has already been defined. But since we are now + // explicitly defining it, clear its bitmask, so that we will have a + // new hash code--doing this will allow us to phase out the + // historical hash code support later. + ((DCKeyword *)(yyvsp[0].u.keyword))->clear_historical_flag(); } break; -case 26: + + case 28: +#line 288 "dcParser.yxx" + { + (yyval.u.dclass) = current_class; + current_class = new DCClass(dc_file, (yyvsp[0].str), false, false); +} + break; + + case 29: #line 293 "dcParser.yxx" -{ + { + (yyval.u.dclass) = current_class; + current_class = (yyvsp[-4].u.dclass); +} + break; + + case 30: +#line 301 "dcParser.yxx" + { if (dc_file == (DCFile *)NULL) { yyerror("No DCFile available, so no class names are predefined."); - yyval.u.dclass = NULL; + (yyval.u.dclass) = NULL; } else { - DCClass *dclass = dc_file->get_class_by_name(yyvsp[0].str); + DCClass *dclass = dc_file->get_class_by_name((yyvsp[0].str)); if (dclass == (DCClass *)NULL) { // Create a bogus class as a forward reference. - dclass = new DCClass(dc_file, yyvsp[0].str, false, true); + dclass = new DCClass(dc_file, (yyvsp[0].str), false, true); dc_file->add_class(dclass); } if (dclass->is_struct()) { yyerror("struct name not allowed"); } - yyval.u.dclass = dclass; + (yyval.u.dclass) = dclass; } } break; -case 29: -#line 321 "dcParser.yxx" -{ - if (yyvsp[0].u.dclass != (DCClass *)NULL) { - current_class->add_parent(yyvsp[0].u.dclass); + + case 33: +#line 329 "dcParser.yxx" + { + if ((yyvsp[0].u.dclass) != (DCClass *)NULL) { + current_class->add_parent((yyvsp[0].u.dclass)); } } break; -case 30: -#line 327 "dcParser.yxx" -{ + + case 34: +#line 335 "dcParser.yxx" + { if (!dc_multiple_inheritance) { yyerror("Multiple inheritance is not supported without \"dc-multiple-inheritance 1\" in your Config.prc file."); } else { - if (yyvsp[0].u.dclass != (DCClass *)NULL) { - current_class->add_parent(yyvsp[0].u.dclass); + if ((yyvsp[0].u.dclass) != (DCClass *)NULL) { + current_class->add_parent((yyvsp[0].u.dclass)); } } } break; -case 33: -#line 343 "dcParser.yxx" -{ - if (yyvsp[0].u.field == (DCField *)NULL) { + + case 37: +#line 351 "dcParser.yxx" + { + if ((yyvsp[-1].u.field) == (DCField *)NULL) { // Pass this error up. - } else 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) { + } else if (!current_class->add_field((yyvsp[-1].u.field))) { + yyerror("Duplicate field name: " + (yyvsp[-1].u.field)->get_name()); + } else if ((yyvsp[-1].u.field)->get_number() < 0) { yyerror("A non-network field cannot be stored on a dclass"); } } break; -case 34: -#line 356 "dcParser.yxx" -{ - if (yyvsp[-1].u.field != (DCField *)NULL) { - if (yyvsp[-1].u.field->get_name().empty()) { + + case 38: +#line 364 "dcParser.yxx" + { + if ((yyvsp[-1].u.field) != (DCField *)NULL) { + if ((yyvsp[-1].u.field)->get_name().empty()) { yyerror("Field name required."); } - yyvsp[-1].u.field->set_flags(yyvsp[0].u.s_int); + (yyvsp[-1].u.field)->copy_keywords(current_keyword_list); } - yyval.u.field = yyvsp[-1].u.field; + (yyval.u.field) = (yyvsp[-1].u.field); } break; -case 36: -#line 367 "dcParser.yxx" -{ - yyerror("Unnamed parameters are not allowed on a dclass"); - if (yyvsp[-2].u.parameter != (DCField *)NULL) { - yyvsp[-2].u.parameter->set_flags(yyvsp[-1].u.s_int); - } - yyval.u.field = yyvsp[-2].u.parameter; -} - break; -case 37: + + case 40: #line 375 "dcParser.yxx" -{ - if (yyvsp[-1].u.parameter != (DCField *)NULL) { - yyvsp[-1].u.parameter->set_flags(yyvsp[0].u.s_int); + { + yyerror("Unnamed parameters are not allowed on a dclass"); + if ((yyvsp[-2].u.parameter) != (DCField *)NULL) { + (yyvsp[-2].u.parameter)->copy_keywords(current_keyword_list); } - yyval.u.field = yyvsp[-1].u.parameter; + (yyval.u.field) = (yyvsp[-2].u.parameter); } break; -case 38: -#line 385 "dcParser.yxx" -{ - yyval.u.dclass = current_class; - current_class = new DCClass(dc_file, yyvsp[0].str, true, false); + + case 41: +#line 383 "dcParser.yxx" + { + if ((yyvsp[-1].u.parameter) != (DCField *)NULL) { + (yyvsp[-1].u.parameter)->copy_keywords(current_keyword_list); + } + (yyval.u.field) = (yyvsp[-1].u.parameter); } break; -case 39: -#line 390 "dcParser.yxx" -{ - yyval.u.dclass = current_class; - current_class = yyvsp[-4].u.dclass; + + case 42: +#line 393 "dcParser.yxx" + { + (yyval.u.dclass) = current_class; + current_class = new DCClass(dc_file, (yyvsp[0].str), true, false); } break; -case 40: + + case 43: #line 398 "dcParser.yxx" -{ + { + (yyval.u.dclass) = current_class; + current_class = (yyvsp[-4].u.dclass); +} + break; + + case 44: +#line 406 "dcParser.yxx" + { if (dc_file == (DCFile *)NULL) { yyerror("No DCFile available, so no struct names are predefined."); - yyval.u.dclass = NULL; + (yyval.u.dclass) = NULL; } else { - DCClass *dstruct = dc_file->get_class_by_name(yyvsp[0].str); + DCClass *dstruct = dc_file->get_class_by_name((yyvsp[0].str)); if (dstruct == (DCClass *)NULL) { // Create a bogus class as a forward reference. - dstruct = new DCClass(dc_file, yyvsp[0].str, false, true); + dstruct = new DCClass(dc_file, (yyvsp[0].str), false, true); dc_file->add_class(dstruct); } if (!dstruct->is_struct()) { yyerror("struct name required"); } - yyval.u.dclass = dstruct; + (yyval.u.dclass) = dstruct; } } break; -case 43: -#line 426 "dcParser.yxx" -{ - if (yyvsp[0].u.dclass != (DCClass *)NULL) { - current_class->add_parent(yyvsp[0].u.dclass); + + case 47: +#line 434 "dcParser.yxx" + { + if ((yyvsp[0].u.dclass) != (DCClass *)NULL) { + current_class->add_parent((yyvsp[0].u.dclass)); } } break; -case 44: -#line 432 "dcParser.yxx" -{ - if (yyvsp[0].u.dclass != (DCClass *)NULL) { - current_class->add_parent(yyvsp[0].u.dclass); + + case 48: +#line 440 "dcParser.yxx" + { + if ((yyvsp[0].u.dclass) != (DCClass *)NULL) { + current_class->add_parent((yyvsp[0].u.dclass)); } } break; -case 47: -#line 443 "dcParser.yxx" -{ - if (yyvsp[0].u.field == (DCField *)NULL) { + + case 51: +#line 451 "dcParser.yxx" + { + if ((yyvsp[-1].u.field) == (DCField *)NULL) { // Pass this error up. - } else if (!current_class->add_field(yyvsp[0].u.field)) { - yyerror("Duplicate field name: " + yyvsp[0].u.field->get_name()); + } else if (!current_class->add_field((yyvsp[-1].u.field))) { + yyerror("Duplicate field name: " + (yyvsp[-1].u.field)->get_name()); } } break; -case 48: -#line 454 "dcParser.yxx" -{ - if (yyvsp[-1].u.field->get_name().empty()) { + + case 52: +#line 462 "dcParser.yxx" + { + if ((yyvsp[-1].u.field)->get_name().empty()) { yyerror("Field name required."); } - yyval.u.field = yyvsp[-1].u.field; + (yyval.u.field) = (yyvsp[-1].u.field); } break; -case 50: -#line 462 "dcParser.yxx" -{ - yyval.u.field = yyvsp[-2].u.parameter; + + case 54: +#line 470 "dcParser.yxx" + { + (yyval.u.field) = (yyvsp[-2].u.parameter); } break; -case 51: -#line 466 "dcParser.yxx" -{ - yyval.u.field = yyvsp[-1].u.parameter; + + case 55: +#line 474 "dcParser.yxx" + { + (yyval.u.field) = (yyvsp[-1].u.parameter); } break; -case 52: -#line 473 "dcParser.yxx" -{ - yyval.u.field = current_atomic; + + case 56: +#line 481 "dcParser.yxx" + { + (yyval.u.field) = current_atomic; if (current_class == (DCClass *)NULL) { yyerror("Cannot define a method outside of a struct or class."); DCClass *temp_class = new DCClass(dc_file, "temp", false, false); // memory leak. - current_atomic = new DCAtomicField(yyvsp[-1].str, temp_class); + current_atomic = new DCAtomicField((yyvsp[-1].str), temp_class); } else { - current_atomic = new DCAtomicField(yyvsp[-1].str, current_class); + current_atomic = new DCAtomicField((yyvsp[-1].str), current_class); } } break; -case 53: -#line 484 "dcParser.yxx" -{ - yyval.u.field = current_atomic; - current_atomic = yyvsp[-2].u.atomic; + + case 57: +#line 492 "dcParser.yxx" + { + (yyval.u.field) = current_atomic; + current_atomic = (yyvsp[-2].u.atomic); } break; -case 58: -#line 502 "dcParser.yxx" -{ - if (yyvsp[0].u.parameter != (DCParameter *)NULL) { - current_atomic->add_element(yyvsp[0].u.parameter); + + case 62: +#line 510 "dcParser.yxx" + { + if ((yyvsp[0].u.parameter) != (DCParameter *)NULL) { + current_atomic->add_element((yyvsp[0].u.parameter)); } } break; -case 59: -#line 511 "dcParser.yxx" -{ - current_parameter = yyvsp[0].u.parameter; + + case 63: +#line 519 "dcParser.yxx" + { + current_parameter = (yyvsp[0].u.parameter); } break; -case 60: -#line 515 "dcParser.yxx" -{ - yyval.u.parameter = yyvsp[0].u.parameter; + + case 64: +#line 523 "dcParser.yxx" + { + (yyval.u.parameter) = (yyvsp[0].u.parameter); } break; -case 63: -#line 527 "dcParser.yxx" -{ - current_packer = &default_packer; - current_packer->clear_data(); - if (yyvsp[-1].u.parameter != (DCField *)NULL) { - current_packer->begin_pack(yyvsp[-1].u.parameter); - } -} - break; -case 64: + + case 67: #line 535 "dcParser.yxx" -{ - bool is_valid = false; - if (yyvsp[-3].u.parameter != (DCField *)NULL) { - is_valid = yyvsp[-3].u.parameter->is_valid(); - } - if (current_packer->end_pack()) { - yyvsp[-3].u.parameter->set_default_value(current_packer->get_string()); - - } else { - if (is_valid) { - yyerror("Invalid default value for type"); - } - // If the current parameter isn't valid, we don't mind a pack - // error (there's no way for us to validate the syntax). So we'll - // just ignore the default value in this case. - } -} - break; -case 66: -#line 557 "dcParser.yxx" -{ + { current_packer = &default_packer; current_packer->clear_data(); - if (yyvsp[-1].u.parameter != (DCField *)NULL) { - current_packer->begin_pack(yyvsp[-1].u.parameter); + if ((yyvsp[-1].u.parameter) != (DCField *)NULL) { + current_packer->begin_pack((yyvsp[-1].u.parameter)); } } break; -case 67: -#line 565 "dcParser.yxx" -{ + + case 68: +#line 543 "dcParser.yxx" + { bool is_valid = false; - if (yyvsp[-3].u.parameter != (DCField *)NULL) { - is_valid = yyvsp[-3].u.parameter->is_valid(); + if ((yyvsp[-3].u.parameter) != (DCField *)NULL) { + is_valid = (yyvsp[-3].u.parameter)->is_valid(); } if (current_packer->end_pack()) { - yyvsp[-3].u.parameter->set_default_value(current_packer->get_string()); + (yyvsp[-3].u.parameter)->set_default_value(current_packer->get_string()); } else { if (is_valid) { @@ -1654,294 +1882,355 @@ case 67: } } break; -case 72: -#line 596 "dcParser.yxx" -{ - yyval.u.field = yyvsp[0].u.parameter; + + case 70: +#line 565 "dcParser.yxx" + { + current_packer = &default_packer; + current_packer->clear_data(); + if ((yyvsp[-1].u.parameter) != (DCField *)NULL) { + current_packer->begin_pack((yyvsp[-1].u.parameter)); + } } break; -case 73: -#line 600 "dcParser.yxx" -{ - yyval.u.field = yyvsp[0].u.field; + + case 71: +#line 573 "dcParser.yxx" + { + bool is_valid = false; + if ((yyvsp[-3].u.parameter) != (DCField *)NULL) { + is_valid = (yyvsp[-3].u.parameter)->is_valid(); + } + if (current_packer->end_pack()) { + (yyvsp[-3].u.parameter)->set_default_value(current_packer->get_string()); + + } else { + if (is_valid) { + yyerror("Invalid default value for type"); + } + // If the current parameter isn't valid, we don't mind a pack + // error (there's no way for us to validate the syntax). So we'll + // just ignore the default value in this case. + } } break; -case 74: -#line 607 "dcParser.yxx" -{ - yyval.u.field = yyvsp[-1].u.field; + + case 76: +#line 604 "dcParser.yxx" + { + (yyval.u.field) = (yyvsp[0].u.parameter); } break; -case 75: -#line 611 "dcParser.yxx" -{ - yyval.u.field = yyvsp[-1].u.parameter; + + case 77: +#line 608 "dcParser.yxx" + { + (yyval.u.field) = (yyvsp[0].u.field); } break; -case 76: + + case 78: #line 615 "dcParser.yxx" -{ - yyval.u.field = yyvsp[-1].u.parameter; + { + (yyval.u.field) = (yyvsp[-1].u.field); } break; -case 77: -#line 622 "dcParser.yxx" -{ - yyval.u.parameter = new DCSimpleParameter(yyvsp[0].u.subatomic); + + case 79: +#line 619 "dcParser.yxx" + { + (yyval.u.field) = (yyvsp[-1].u.parameter); } break; -case 78: -#line 626 "dcParser.yxx" -{ - DCSimpleParameter *simple_param = yyvsp[-3].u.parameter->as_simple_parameter(); + + case 80: +#line 623 "dcParser.yxx" + { + (yyval.u.field) = (yyvsp[-1].u.parameter); +} + break; + + case 81: +#line 630 "dcParser.yxx" + { + (yyval.u.parameter) = new DCSimpleParameter((yyvsp[0].u.subatomic)); +} + break; + + case 82: +#line 634 "dcParser.yxx" + { + DCSimpleParameter *simple_param = (yyvsp[-3].u.parameter)->as_simple_parameter(); nassertr(simple_param != (DCSimpleParameter *)NULL, 0); if (!simple_param->set_range(double_range)) { yyerror("Inappropriate range for type"); } - yyval.u.parameter = simple_param; + (yyval.u.parameter) = simple_param; } break; -case 79: -#line 635 "dcParser.yxx" -{ - DCSimpleParameter *simple_param = yyvsp[-2].u.parameter->as_simple_parameter(); + + case 83: +#line 643 "dcParser.yxx" + { + DCSimpleParameter *simple_param = (yyvsp[-2].u.parameter)->as_simple_parameter(); nassertr(simple_param != (DCSimpleParameter *)NULL, 0); if (!simple_param->is_numeric_type()) { yyerror("A divisor is only valid on a numeric type."); - } else if (!simple_param->set_divisor(yyvsp[0].u.s_uint)) { + } else if (!simple_param->set_divisor((yyvsp[0].u.s_uint))) { yyerror("Invalid divisor."); } else if (simple_param->has_modulus() && !simple_param->set_modulus(simple_param->get_modulus())) { // Changing the divisor may change the valid range for the modulus. yyerror("Invalid modulus."); } - yyval.u.parameter = simple_param; + (yyval.u.parameter) = simple_param; } break; -case 80: -#line 651 "dcParser.yxx" -{ - DCSimpleParameter *simple_param = yyvsp[-2].u.parameter->as_simple_parameter(); + + case 84: +#line 659 "dcParser.yxx" + { + DCSimpleParameter *simple_param = (yyvsp[-2].u.parameter)->as_simple_parameter(); nassertr(simple_param != (DCSimpleParameter *)NULL, 0); if (!simple_param->is_numeric_type()) { yyerror("A divisor is only valid on a numeric type."); - } else if (!simple_param->set_modulus(yyvsp[0].u.real)) { + } else if (!simple_param->set_modulus((yyvsp[0].u.real))) { yyerror("Invalid modulus."); } - yyval.u.parameter = simple_param; + (yyval.u.parameter) = simple_param; } break; -case 82: -#line 667 "dcParser.yxx" -{ + + case 86: +#line 675 "dcParser.yxx" + { if (dc_file == (DCFile *)NULL) { yyerror("Invalid type."); - yyval.u.parameter = NULL; + (yyval.u.parameter) = NULL; } else { - DCTypedef *dtypedef = dc_file->get_typedef_by_name(yyvsp[0].str); + DCTypedef *dtypedef = dc_file->get_typedef_by_name((yyvsp[0].str)); if (dtypedef == (DCTypedef *)NULL) { // Maybe it's a class name. - DCClass *dclass = dc_file->get_class_by_name(yyvsp[0].str); + DCClass *dclass = dc_file->get_class_by_name((yyvsp[0].str)); if (dclass != (DCClass *)NULL) { // Create an implicit typedef for this. dtypedef = new DCTypedef(new DCClassParameter(dclass), true); } else { // Maybe it's a switch name. - DCSwitch *dswitch = dc_file->get_switch_by_name(yyvsp[0].str); + DCSwitch *dswitch = dc_file->get_switch_by_name((yyvsp[0].str)); if (dswitch != (DCSwitch *)NULL) { // This also gets an implicit typedef. dtypedef = new DCTypedef(new DCSwitchParameter(dswitch), true); } else { // It's an undefined typedef. Create a bogus forward reference. - dtypedef = new DCTypedef(yyvsp[0].str); + dtypedef = new DCTypedef((yyvsp[0].str)); } } dc_file->add_typedef(dtypedef); } - yyval.u.parameter = dtypedef->make_new_parameter(); + (yyval.u.parameter) = dtypedef->make_new_parameter(); } } break; -case 83: -#line 699 "dcParser.yxx" -{ + + case 87: +#line 707 "dcParser.yxx" + { // This is an inline struct definition. - if (yyvsp[0].u.dclass == (DCClass *)NULL) { - yyval.u.parameter = NULL; + if ((yyvsp[0].u.dclass) == (DCClass *)NULL) { + (yyval.u.parameter) = NULL; } else { if (dc_file != (DCFile *)NULL) { - dc_file->add_thing_to_delete(yyvsp[0].u.dclass); + dc_file->add_thing_to_delete((yyvsp[0].u.dclass)); } else { // This is a memory leak--this happens when we put an anonymous // struct reference within the string passed to // DCPackerInterface::check_match(). Maybe it doesn't really matter. } - yyval.u.parameter = new DCClassParameter(yyvsp[0].u.dclass); + (yyval.u.parameter) = new DCClassParameter((yyvsp[0].u.dclass)); } } break; -case 84: -#line 715 "dcParser.yxx" -{ + + case 88: +#line 723 "dcParser.yxx" + { // This is an inline switch definition. - if (yyvsp[0].u.dswitch == (DCSwitch *)NULL) { - yyval.u.parameter = NULL; + if ((yyvsp[0].u.dswitch) == (DCSwitch *)NULL) { + (yyval.u.parameter) = NULL; } else { if (dc_file != (DCFile *)NULL) { - dc_file->add_thing_to_delete(yyvsp[0].u.dswitch); + dc_file->add_thing_to_delete((yyvsp[0].u.dswitch)); } else { // This is a memory leak--this happens when we put an anonymous // switch reference within the string passed to // DCPackerInterface::check_match(). Maybe it doesn't really matter. } - yyval.u.parameter = new DCSwitchParameter(yyvsp[0].u.dswitch); + (yyval.u.parameter) = new DCSwitchParameter((yyvsp[0].u.dswitch)); } } break; -case 85: -#line 734 "dcParser.yxx" -{ + + case 89: +#line 742 "dcParser.yxx" + { double_range.clear(); } break; -case 86: -#line 738 "dcParser.yxx" -{ + + case 90: +#line 746 "dcParser.yxx" + { double_range.clear(); - if (!double_range.add_range(yyvsp[0].u.real, yyvsp[0].u.real)) { + if (!double_range.add_range((yyvsp[0].u.real), (yyvsp[0].u.real))) { yyerror("Overlapping range"); } } break; -case 87: -#line 745 "dcParser.yxx" -{ + + case 91: +#line 753 "dcParser.yxx" + { double_range.clear(); - if (!double_range.add_range(yyvsp[-2].u.real, yyvsp[0].u.real)) { + if (!double_range.add_range((yyvsp[-2].u.real), (yyvsp[0].u.real))) { yyerror("Overlapping range"); } } break; -case 88: -#line 752 "dcParser.yxx" -{ + + case 92: +#line 760 "dcParser.yxx" + { double_range.clear(); - if (yyvsp[0].u.real >= 0) { + if ((yyvsp[0].u.real) >= 0) { yyerror("Syntax error"); - } else if (!double_range.add_range(yyvsp[-1].u.real, -yyvsp[0].u.real)) { + } else if (!double_range.add_range((yyvsp[-1].u.real), -(yyvsp[0].u.real))) { yyerror("Overlapping range"); } } break; -case 89: -#line 761 "dcParser.yxx" -{ - if (!double_range.add_range(yyvsp[0].u.real, yyvsp[0].u.real)) { + + case 93: +#line 769 "dcParser.yxx" + { + if (!double_range.add_range((yyvsp[0].u.real), (yyvsp[0].u.real))) { yyerror("Overlapping range"); } } break; -case 90: -#line 767 "dcParser.yxx" -{ - if (!double_range.add_range(yyvsp[-2].u.real, yyvsp[0].u.real)) { + + case 94: +#line 775 "dcParser.yxx" + { + if (!double_range.add_range((yyvsp[-2].u.real), (yyvsp[0].u.real))) { yyerror("Overlapping range"); } } break; -case 91: -#line 773 "dcParser.yxx" -{ - if (yyvsp[0].u.real >= 0) { + + case 95: +#line 781 "dcParser.yxx" + { + if ((yyvsp[0].u.real) >= 0) { yyerror("Syntax error"); - } else if (!double_range.add_range(yyvsp[-1].u.real, -yyvsp[0].u.real)) { + } else if (!double_range.add_range((yyvsp[-1].u.real), -(yyvsp[0].u.real))) { yyerror("Overlapping range"); } } break; -case 92: -#line 784 "dcParser.yxx" -{ + + case 96: +#line 792 "dcParser.yxx" + { uint_range.clear(); } break; -case 93: -#line 788 "dcParser.yxx" -{ + + case 97: +#line 796 "dcParser.yxx" + { uint_range.clear(); - if (!uint_range.add_range(yyvsp[0].u.s_uint, yyvsp[0].u.s_uint)) { + if (!uint_range.add_range((yyvsp[0].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } break; -case 94: -#line 795 "dcParser.yxx" -{ + + case 98: +#line 803 "dcParser.yxx" + { uint_range.clear(); - if (!uint_range.add_range(yyvsp[-2].u.s_uint, yyvsp[0].u.s_uint)) { + if (!uint_range.add_range((yyvsp[-2].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } break; -case 95: -#line 802 "dcParser.yxx" -{ + + case 99: +#line 810 "dcParser.yxx" + { uint_range.clear(); - if (!uint_range.add_range(yyvsp[-1].u.s_uint, yyvsp[0].u.s_uint)) { + if (!uint_range.add_range((yyvsp[-1].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } break; -case 96: -#line 809 "dcParser.yxx" -{ - if (!uint_range.add_range(yyvsp[0].u.s_uint, yyvsp[0].u.s_uint)) { + + case 100: +#line 817 "dcParser.yxx" + { + if (!uint_range.add_range((yyvsp[0].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } break; -case 97: -#line 815 "dcParser.yxx" -{ - if (!uint_range.add_range(yyvsp[-2].u.s_uint, yyvsp[0].u.s_uint)) { + + case 101: +#line 823 "dcParser.yxx" + { + if (!uint_range.add_range((yyvsp[-2].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } break; -case 98: -#line 821 "dcParser.yxx" -{ - if (!uint_range.add_range(yyvsp[-1].u.s_uint, yyvsp[0].u.s_uint)) { + + case 102: +#line 829 "dcParser.yxx" + { + if (!uint_range.add_range((yyvsp[-1].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } break; -case 100: -#line 831 "dcParser.yxx" -{ - if (yyvsp[-3].u.parameter == (DCParameter *)NULL) { - yyval.u.parameter = NULL; + + case 104: +#line 839 "dcParser.yxx" + { + if ((yyvsp[-3].u.parameter) == (DCParameter *)NULL) { + (yyval.u.parameter) = NULL; } else { - yyval.u.parameter = yyvsp[-3].u.parameter->append_array_specification(uint_range); + (yyval.u.parameter) = (yyvsp[-3].u.parameter)->append_array_specification(uint_range); } } break; -case 101: -#line 842 "dcParser.yxx" -{ - current_parameter->set_name(yyvsp[0].str); - yyval.u.parameter = current_parameter; + + case 105: +#line 850 "dcParser.yxx" + { + current_parameter->set_name((yyvsp[0].str)); + (yyval.u.parameter) = current_parameter; } break; -case 102: -#line 847 "dcParser.yxx" -{ - DCSimpleParameter *simple_param = yyvsp[-2].u.parameter->as_simple_parameter(); + + case 106: +#line 855 "dcParser.yxx" + { + DCSimpleParameter *simple_param = (yyvsp[-2].u.parameter)->as_simple_parameter(); if (simple_param == NULL || simple_param->get_typedef() != (DCTypedef *)NULL) { yyerror("A divisor is only allowed on a primitive type."); @@ -1949,16 +2238,17 @@ case 102: yyerror("A divisor is only valid on a numeric type."); } else { - if (!simple_param->set_divisor(yyvsp[0].u.s_uint)) { + if (!simple_param->set_divisor((yyvsp[0].u.s_uint))) { yyerror("Invalid divisor."); } } } break; -case 103: -#line 862 "dcParser.yxx" -{ - DCSimpleParameter *simple_param = yyvsp[-2].u.parameter->as_simple_parameter(); + + case 107: +#line 870 "dcParser.yxx" + { + DCSimpleParameter *simple_param = (yyvsp[-2].u.parameter)->as_simple_parameter(); if (simple_param == NULL || simple_param->get_typedef() != (DCTypedef *)NULL) { yyerror("A modulus is only allowed on a primitive type."); @@ -1966,476 +2256,486 @@ case 103: yyerror("A modulus is only valid on a numeric type."); } else { - if (!simple_param->set_modulus(yyvsp[0].u.real)) { + if (!simple_param->set_modulus((yyvsp[0].u.real))) { yyerror("Invalid modulus."); } } } break; -case 104: -#line 877 "dcParser.yxx" -{ - yyval.u.parameter = yyvsp[-3].u.parameter->append_array_specification(uint_range); + + case 108: +#line 885 "dcParser.yxx" + { + (yyval.u.parameter) = (yyvsp[-3].u.parameter)->append_array_specification(uint_range); } break; -case 105: -#line 884 "dcParser.yxx" -{ - if (yyvsp[0].str.length() != 1) { + + case 109: +#line 892 "dcParser.yxx" + { + if ((yyvsp[0].str).length() != 1) { yyerror("Single character required."); - yyval.u.s_uint = 0; + (yyval.u.s_uint) = 0; } else { - yyval.u.s_uint = (unsigned char)yyvsp[0].str[0]; + (yyval.u.s_uint) = (unsigned char)(yyvsp[0].str)[0]; } } break; -case 107: -#line 897 "dcParser.yxx" -{ - yyval.u.s_uint = (unsigned int)yyvsp[0].u.uint64; - if (yyval.u.s_uint != yyvsp[0].u.uint64) { + + case 111: +#line 905 "dcParser.yxx" + { + (yyval.u.s_uint) = (unsigned int)(yyvsp[0].u.uint64); + if ((yyval.u.s_uint) != (yyvsp[0].u.uint64)) { yyerror("Number out of range."); - yyval.u.s_uint = 1; + (yyval.u.s_uint) = 1; } } break; -case 108: -#line 908 "dcParser.yxx" -{ - yyval.u.s_uint = (unsigned int)-yyvsp[0].u.int64; - if (yyvsp[0].u.int64 >= 0) { + + case 112: +#line 916 "dcParser.yxx" + { + (yyval.u.s_uint) = (unsigned int)-(yyvsp[0].u.int64); + if ((yyvsp[0].u.int64) >= 0) { yyerror("Syntax error."); - } else if (yyval.u.s_uint != -yyvsp[0].u.int64) { + } else if ((yyval.u.s_uint) != -(yyvsp[0].u.int64)) { yyerror("Number out of range."); - yyval.u.s_uint = 1; + (yyval.u.s_uint) = 1; } } break; -case 111: -#line 930 "dcParser.yxx" -{ - yyval.u.real = (double)yyvsp[0].u.uint64; + + case 115: +#line 938 "dcParser.yxx" + { + (yyval.u.real) = (double)(yyvsp[0].u.uint64); } break; -case 112: -#line 934 "dcParser.yxx" -{ - yyval.u.real = (double)yyvsp[0].u.int64; -} - break; -case 114: + + case 116: #line 942 "dcParser.yxx" -{ - if (yyvsp[0].str.length() != 1) { + { + (yyval.u.real) = (double)(yyvsp[0].u.int64); +} + break; + + case 118: +#line 950 "dcParser.yxx" + { + if ((yyvsp[0].str).length() != 1) { yyerror("Single character required."); - yyval.u.real = 0; + (yyval.u.real) = 0; } else { - yyval.u.real = (double)(unsigned char)yyvsp[0].str[0]; + (yyval.u.real) = (double)(unsigned char)(yyvsp[0].str)[0]; } } break; -case 116: -#line 956 "dcParser.yxx" -{ - yyval = yyvsp[0]; + + case 120: +#line 964 "dcParser.yxx" + { + (yyval) = (yyvsp[0]); } break; -case 117: -#line 960 "dcParser.yxx" -{ - if (yyvsp[-1].str != current_packer->get_current_field_name()) { + + case 121: +#line 968 "dcParser.yxx" + { + if ((yyvsp[-1].str) != current_packer->get_current_field_name()) { ostringstream strm; - strm << "Got '" << yyvsp[-1].str << "', expected '" + strm << "Got '" << (yyvsp[-1].str) << "', expected '" << current_packer->get_current_field_name() << "'"; yyerror(strm.str()); } } break; -case 118: -#line 969 "dcParser.yxx" -{ - yyval = yyvsp[0]; + + case 122: +#line 977 "dcParser.yxx" + { + (yyval) = (yyvsp[0]); } break; -case 119: -#line 976 "dcParser.yxx" -{ - current_packer->pack_int64(yyvsp[0].u.int64); -} - break; -case 120: -#line 980 "dcParser.yxx" -{ - current_packer->pack_uint64(yyvsp[0].u.uint64); -} - break; -case 121: + + case 123: #line 984 "dcParser.yxx" -{ - current_packer->pack_double(yyvsp[0].u.real); + { + current_packer->pack_int64((yyvsp[0].u.int64)); } break; -case 122: + + case 124: #line 988 "dcParser.yxx" -{ - current_packer->pack_string(yyvsp[0].str); + { + current_packer->pack_uint64((yyvsp[0].u.uint64)); } break; -case 123: + + case 125: #line 992 "dcParser.yxx" -{ - current_packer->pack_literal_value(yyvsp[0].str); + { + current_packer->pack_double((yyvsp[0].u.real)); } break; -case 124: + + case 126: #line 996 "dcParser.yxx" -{ - current_packer->push(); + { + current_packer->pack_string((yyvsp[0].str)); } break; -case 125: + + case 127: #line 1000 "dcParser.yxx" -{ - current_packer->pop(); + { + current_packer->pack_literal_value((yyvsp[0].str)); } break; -case 126: + + case 128: #line 1004 "dcParser.yxx" -{ + { current_packer->push(); } break; -case 127: + + case 129: #line 1008 "dcParser.yxx" -{ + { current_packer->pop(); } break; -case 128: + + case 130: #line 1012 "dcParser.yxx" -{ + { current_packer->push(); } break; -case 129: + + case 131: #line 1016 "dcParser.yxx" -{ + { current_packer->pop(); } break; -case 130: + + case 132: #line 1020 "dcParser.yxx" -{ - for (unsigned int i = 0; i < yyvsp[0].u.s_uint; i++) { - current_packer->pack_int64(yyvsp[-2].u.int64); + { + current_packer->push(); +} + break; + + case 133: +#line 1024 "dcParser.yxx" + { + current_packer->pop(); +} + break; + + case 134: +#line 1028 "dcParser.yxx" + { + for (unsigned int i = 0; i < (yyvsp[0].u.s_uint); i++) { + current_packer->pack_int64((yyvsp[-2].u.int64)); } } break; -case 131: -#line 1026 "dcParser.yxx" -{ - for (unsigned int i = 0; i < yyvsp[0].u.s_uint; i++) { - current_packer->pack_uint64(yyvsp[-2].u.uint64); + + case 135: +#line 1034 "dcParser.yxx" + { + for (unsigned int i = 0; i < (yyvsp[0].u.s_uint); i++) { + current_packer->pack_uint64((yyvsp[-2].u.uint64)); } } break; -case 132: -#line 1032 "dcParser.yxx" -{ - for (unsigned int i = 0; i < yyvsp[0].u.s_uint; i++) { - current_packer->pack_double(yyvsp[-2].u.real); + + case 136: +#line 1040 "dcParser.yxx" + { + for (unsigned int i = 0; i < (yyvsp[0].u.s_uint); i++) { + current_packer->pack_double((yyvsp[-2].u.real)); } } break; -case 133: -#line 1038 "dcParser.yxx" -{ - for (unsigned int i = 0; i < yyvsp[0].u.s_uint; i++) { - current_packer->pack_literal_value(yyvsp[-2].str); + + case 137: +#line 1046 "dcParser.yxx" + { + for (unsigned int i = 0; i < (yyvsp[0].u.s_uint); i++) { + current_packer->pack_literal_value((yyvsp[-2].str)); } } break; -case 140: -#line 1062 "dcParser.yxx" -{ - yyval.u.subatomic = ST_int8; -} - break; -case 141: -#line 1066 "dcParser.yxx" -{ - yyval.u.subatomic = ST_int16; -} - break; -case 142: + + case 144: #line 1070 "dcParser.yxx" -{ - yyval.u.subatomic = ST_int32; + { + (yyval.u.subatomic) = ST_int8; } break; -case 143: + + case 145: #line 1074 "dcParser.yxx" -{ - yyval.u.subatomic = ST_int64; + { + (yyval.u.subatomic) = ST_int16; } break; -case 144: + + case 146: #line 1078 "dcParser.yxx" -{ - yyval.u.subatomic = ST_uint8; + { + (yyval.u.subatomic) = ST_int32; } break; -case 145: + + case 147: #line 1082 "dcParser.yxx" -{ - yyval.u.subatomic = ST_uint16; + { + (yyval.u.subatomic) = ST_int64; } break; -case 146: + + case 148: #line 1086 "dcParser.yxx" -{ - yyval.u.subatomic = ST_uint32; + { + (yyval.u.subatomic) = ST_uint8; } break; -case 147: + + case 149: #line 1090 "dcParser.yxx" -{ - yyval.u.subatomic = ST_uint64; + { + (yyval.u.subatomic) = ST_uint16; } break; -case 148: + + case 150: #line 1094 "dcParser.yxx" -{ - yyval.u.subatomic = ST_float64; + { + (yyval.u.subatomic) = ST_uint32; } break; -case 149: + + case 151: #line 1098 "dcParser.yxx" -{ - yyval.u.subatomic = ST_string; + { + (yyval.u.subatomic) = ST_uint64; } break; -case 150: + + case 152: #line 1102 "dcParser.yxx" -{ - yyval.u.subatomic = ST_blob; + { + (yyval.u.subatomic) = ST_float64; } break; -case 151: + + case 153: #line 1106 "dcParser.yxx" -{ - yyval.u.subatomic = ST_blob32; + { + (yyval.u.subatomic) = ST_string; } break; -case 152: + + case 154: #line 1110 "dcParser.yxx" -{ - yyval.u.subatomic = ST_int8array; + { + (yyval.u.subatomic) = ST_blob; } break; -case 153: + + case 155: #line 1114 "dcParser.yxx" -{ - yyval.u.subatomic = ST_int16array; + { + (yyval.u.subatomic) = ST_blob32; } break; -case 154: + + case 156: #line 1118 "dcParser.yxx" -{ - yyval.u.subatomic = ST_int32array; + { + (yyval.u.subatomic) = ST_int8array; } break; -case 155: + + case 157: #line 1122 "dcParser.yxx" -{ - yyval.u.subatomic = ST_uint8array; + { + (yyval.u.subatomic) = ST_int16array; } break; -case 156: + + case 158: #line 1126 "dcParser.yxx" -{ - yyval.u.subatomic = ST_uint16array; + { + (yyval.u.subatomic) = ST_int32array; } break; -case 157: + + case 159: #line 1130 "dcParser.yxx" -{ - yyval.u.subatomic = ST_uint32array; + { + (yyval.u.subatomic) = ST_uint8array; } break; -case 158: + + case 160: #line 1134 "dcParser.yxx" -{ - yyval.u.subatomic = ST_uint32uint8array; + { + (yyval.u.subatomic) = ST_uint16array; } break; -case 159: + + case 161: #line 1138 "dcParser.yxx" -{ - yyval.u.subatomic = ST_char; + { + (yyval.u.subatomic) = ST_uint32array; } break; -case 160: -#line 1145 "dcParser.yxx" -{ - yyval.u.s_int = 0; + + case 162: +#line 1142 "dcParser.yxx" + { + (yyval.u.subatomic) = ST_uint32uint8array; } break; -case 161: -#line 1149 "dcParser.yxx" -{ - yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_required; + + case 163: +#line 1146 "dcParser.yxx" + { + (yyval.u.subatomic) = ST_char; } break; -case 162: + + case 164: #line 1153 "dcParser.yxx" -{ - yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_broadcast; + { + current_keyword_list.clear_keywords(); } break; -case 163: + + case 165: #line 1157 "dcParser.yxx" -{ - yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_p2p; + { + current_keyword_list.add_keyword((yyvsp[0].u.keyword)); } break; -case 164: -#line 1161 "dcParser.yxx" -{ - yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_ram; + + case 166: +#line 1164 "dcParser.yxx" + { + if (current_keyword_list.get_num_keywords() != 0) { + yyerror("Communication keywords are not allowed here."); + } } break; -case 165: -#line 1165 "dcParser.yxx" -{ - yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_db; -} - break; -case 166: -#line 1169 "dcParser.yxx" -{ - yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_clsend; -} - break; -case 167: + + case 167: #line 1173 "dcParser.yxx" -{ - yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_clrecv; + { + current_molecular = new DCMolecularField((yyvsp[-1].str), current_class); } break; -case 168: + + case 168: #line 1177 "dcParser.yxx" -{ - yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_ownsend; + { + (yyval.u.field) = current_molecular; } break; -case 169: -#line 1181 "dcParser.yxx" -{ - yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_airecv; -} - break; -case 170: -#line 1188 "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 171: -#line 1198 "dcParser.yxx" -{ - current_molecular = new DCMolecularField(yyvsp[-1].str, current_class); -} - break; -case 172: -#line 1202 "dcParser.yxx" -{ - yyval.u.field = current_molecular; -} - break; -case 173: -#line 1209 "dcParser.yxx" -{ - DCField *field = current_class->get_field_by_name(yyvsp[0].str); - yyval.u.atomic = (DCAtomicField *)NULL; + + case 169: +#line 1184 "dcParser.yxx" + { + DCField *field = current_class->get_field_by_name((yyvsp[0].str)); + (yyval.u.atomic) = (DCAtomicField *)NULL; if (field == (DCField *)NULL) { - yyerror("Unknown field: " + yyvsp[0].str); + yyerror("Unknown field: " + (yyvsp[0].str)); } else { - yyval.u.atomic = field->as_atomic_field(); - if (yyval.u.atomic == (DCAtomicField *)NULL) { - yyerror("Not an atomic field: " + yyvsp[0].str); + (yyval.u.atomic) = field->as_atomic_field(); + if ((yyval.u.atomic) == (DCAtomicField *)NULL) { + yyerror("Not an atomic field: " + (yyvsp[0].str)); } } } break; -case 174: -#line 1225 "dcParser.yxx" -{ - if (yyvsp[0].u.atomic != (DCAtomicField *)NULL) { - current_molecular->add_atomic(yyvsp[0].u.atomic); + + case 170: +#line 1200 "dcParser.yxx" + { + if ((yyvsp[0].u.atomic) != (DCAtomicField *)NULL) { + current_molecular->add_atomic((yyvsp[0].u.atomic)); } } break; -case 175: -#line 1231 "dcParser.yxx" -{ - if (yyvsp[0].u.atomic != (DCAtomicField *)NULL) { - current_molecular->add_atomic(yyvsp[0].u.atomic); - if (!current_molecular->compare_flags(*yyvsp[0].u.atomic)) { - yyerror("Mismatched flags in molecule between " + + + case 171: +#line 1206 "dcParser.yxx" + { + if ((yyvsp[0].u.atomic) != (DCAtomicField *)NULL) { + current_molecular->add_atomic((yyvsp[0].u.atomic)); + if (!current_molecular->compare_keywords(*(yyvsp[0].u.atomic))) { + yyerror("Mismatched keywords in molecule between " + current_molecular->get_atomic(0)->get_name() + " and " + - yyvsp[0].u.atomic->get_name()); + (yyvsp[0].u.atomic)->get_name()); } } } break; -case 176: -#line 1245 "dcParser.yxx" -{ - yyval.str = ""; + + case 172: +#line 1220 "dcParser.yxx" + { + (yyval.str) = ""; } break; -case 178: -#line 1253 "dcParser.yxx" -{ - yyval.u.dswitch = current_switch; - current_switch = new DCSwitch(yyvsp[-4].str, yyvsp[-2].u.field); + + case 174: +#line 1228 "dcParser.yxx" + { + (yyval.u.dswitch) = current_switch; + current_switch = new DCSwitch((yyvsp[-4].str), (yyvsp[-2].u.field)); } break; -case 179: -#line 1258 "dcParser.yxx" -{ - yyval.u.dswitch = current_switch; - current_switch = (DCSwitch *)yyvsp[-2].u.parameter; + + case 175: +#line 1233 "dcParser.yxx" + { + (yyval.u.dswitch) = current_switch; + current_switch = (DCSwitch *)(yyvsp[-2].u.parameter); } break; -case 185: -#line 1272 "dcParser.yxx" -{ + + case 181: +#line 1247 "dcParser.yxx" + { if (!current_switch->is_field_valid()) { yyerror("case declaration required before first element"); - } else if (yyvsp[0].u.field != (DCField *)NULL) { - if (!current_switch->add_field(yyvsp[0].u.field)) { - yyerror("Duplicate field name: " + yyvsp[0].u.field->get_name()); + } else if ((yyvsp[0].u.field) != (DCField *)NULL) { + if (!current_switch->add_field((yyvsp[0].u.field))) { + yyerror("Duplicate field name: " + (yyvsp[0].u.field)->get_name()); } } } break; -case 186: -#line 1285 "dcParser.yxx" -{ + + case 182: +#line 1260 "dcParser.yxx" + { current_packer = &default_packer; current_packer->clear_data(); current_packer->begin_pack(current_switch->get_key_parameter()); } break; -case 187: -#line 1291 "dcParser.yxx" -{ + + case 183: +#line 1266 "dcParser.yxx" + { if (!current_packer->end_pack()) { yyerror("Invalid value for switch parameter"); current_switch->add_invalid_case(); @@ -2447,58 +2747,51 @@ case 187: } } break; -case 188: -#line 1306 "dcParser.yxx" -{ + + case 184: +#line 1281 "dcParser.yxx" + { if (!current_switch->add_default()) { yyerror("Default case already defined"); } } break; -case 189: -#line 1315 "dcParser.yxx" -{ + + case 185: +#line 1290 "dcParser.yxx" + { current_switch->add_break(); } break; -case 190: -#line 1322 "dcParser.yxx" -{ - yyval.u.field = yyvsp[-1].u.parameter; + + case 186: +#line 1297 "dcParser.yxx" + { + (yyval.u.field) = (yyvsp[-1].u.parameter); } break; -case 191: -#line 1326 "dcParser.yxx" -{ - yyval.u.field = yyvsp[0].u.parameter; + + case 187: +#line 1301 "dcParser.yxx" + { + (yyval.u.field) = (yyvsp[0].u.parameter); } break; -} -#line 705 "/usr/share/bison/bison.simple" + } + +/* Line 1037 of yacc.c. */ +#line 2786 "y.tab.c" yyvsp -= yylen; yyssp -= yylen; -#if YYLSP_NEEDED - yylsp -= yylen; -#endif -#if YYDEBUG - if (yydebug) - { - short *yyssp1 = yyss - 1; - YYFPRINTF (stderr, "state stack now"); - while (yyssp1 != yyssp) - YYFPRINTF (stderr, " %d", *++yyssp1); - YYFPRINTF (stderr, "\n"); - } -#endif + + YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; -#if YYLSP_NEEDED - *++yylsp = yyloc; -#endif + /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule @@ -2506,11 +2799,11 @@ case 191: yyn = yyr1[yyn]; - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else - yystate = yydefgoto[yyn - YYNTBASE]; + yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; @@ -2523,155 +2816,159 @@ yyerrlab: if (!yyerrstatus) { ++yynerrs; - -#ifdef YYERROR_VERBOSE +#if YYERROR_VERBOSE yyn = yypact[yystate]; - if (yyn > YYFLAG && yyn < YYLAST) + if (YYPACT_NINF < yyn && yyn < YYLAST) { YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; char *yymsg; - int yyx, yycount; + int yyx; - yycount = 0; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) - if (yycheck[yyx + yyn] == yyx) - yysize += yystrlen (yytname[yyx]) + 15, yycount++; - yysize += yystrlen ("parse error, unexpected ") + 1; - yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { - char *yyp = yystpcpy (yymsg, "parse error, unexpected "); - yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); if (yycount < 5) { - yycount = 0; - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); - yyx++) - if (yycheck[yyx + yyn] == yyx) + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { - const char *yyq = ! yycount ? ", expecting " : " or "; - yyp = yystpcpy (yyp, yyq); + yyp = yystpcpy (yyp, yyprefix); yyp = yystpcpy (yyp, yytname[yyx]); - yycount++; + yyprefix = " or "; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else - yyerror ("parse error; also virtual memory exhausted"); + yyerror ("syntax error; also virtual memory exhausted"); } else -#endif /* defined (YYERROR_VERBOSE) */ - yyerror ("parse error"); +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + yydestruct ("Error: popping", + yystos[*yyssp], yyvsp); + } + } + else + { + yydestruct ("Error: discarding", yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ goto yyerrlab1; -/*--------------------------------------------------. -| yyerrlab1 -- error raised explicitly by an action | -`--------------------------------------------------*/ +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + +yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ yyerrlab1: - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ - /* return failure if at end of input */ - if (yychar == YYEOF) + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) YYABORT; - YYDPRINTF ((stderr, "Discarding token %d (%s).\n", - yychar, yytname[yychar1])); - yychar = YYEMPTY; + + + yydestruct ("Error: popping", yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); } - /* Else will try to reuse lookahead token after shifting the error - token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - - -/*-------------------------------------------------------------------. -| yyerrdefault -- current state does not do anything special for the | -| error token. | -`-------------------------------------------------------------------*/ -yyerrdefault: -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - - /* If its default is to accept any token, ok. Otherwise pop it. */ - yyn = yydefact[yystate]; - if (yyn) - goto yydefault; -#endif - - -/*---------------------------------------------------------------. -| yyerrpop -- pop the current state because it cannot handle the | -| error token | -`---------------------------------------------------------------*/ -yyerrpop: - if (yyssp == yyss) - YYABORT; - yyvsp--; - yystate = *--yyssp; -#if YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG - if (yydebug) - { - short *yyssp1 = yyss - 1; - YYFPRINTF (stderr, "Error: state stack now"); - while (yyssp1 != yyssp) - YYFPRINTF (stderr, " %d", *++yyssp1); - YYFPRINTF (stderr, "\n"); - } -#endif - -/*--------------. -| yyerrhandle. | -`--------------*/ -yyerrhandle: - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - if (yyn == YYFINAL) YYACCEPT; - YYDPRINTF ((stderr, "Shifting error token, ")); - *++yyvsp = yylval; -#if YYLSP_NEEDED - *++yylsp = yylloc; -#endif + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -2688,16 +2985,21 @@ yyacceptlab: | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: + yydestruct ("Error: discarding lookahead", + yytoken, &yylval); + yychar = YYEMPTY; yyresult = 1; goto yyreturn; -/*---------------------------------------------. -| yyoverflowab -- parser overflow comes here. | -`---------------------------------------------*/ +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */ +#endif yyreturn: #ifndef yyoverflow @@ -2706,4 +3008,6 @@ yyreturn: #endif return yyresult; } -#line 1334 "dcParser.yxx" + + + diff --git a/direct/src/dcparser/dcParser.h.prebuilt b/direct/src/dcparser/dcParser.h.prebuilt index 0362b3d840..339e62c0e5 100644 --- a/direct/src/dcparser/dcParser.h.prebuilt +++ b/direct/src/dcparser/dcParser.h.prebuilt @@ -1,55 +1,128 @@ -#ifndef BISON_Y_TAB_H -# define BISON_Y_TAB_H +/* A Bison parser, made by GNU Bison 2.0. */ -# define UNSIGNED_INTEGER 257 -# define SIGNED_INTEGER 258 -# define REAL 259 -# define STRING 260 -# define HEX_STRING 261 -# define IDENTIFIER 262 -# define KW_DCLASS 263 -# define KW_STRUCT 264 -# define KW_FROM 265 -# define KW_IMPORT 266 -# define KW_TYPEDEF 267 -# define KW_SWITCH 268 -# define KW_CASE 269 -# define KW_DEFAULT 270 -# define KW_BREAK 271 -# define KW_INT8 272 -# define KW_INT16 273 -# define KW_INT32 274 -# define KW_INT64 275 -# define KW_UINT8 276 -# define KW_UINT16 277 -# define KW_UINT32 278 -# define KW_UINT64 279 -# define KW_FLOAT64 280 -# define KW_STRING 281 -# define KW_BLOB 282 -# define KW_BLOB32 283 -# define KW_INT8ARRAY 284 -# define KW_INT16ARRAY 285 -# define KW_INT32ARRAY 286 -# define KW_UINT8ARRAY 287 -# define KW_UINT16ARRAY 288 -# define KW_UINT32ARRAY 289 -# define KW_UINT32UINT8ARRAY 290 -# define KW_CHAR 291 -# define KW_REQUIRED 292 -# define KW_BROADCAST 293 -# define KW_P2P 294 -# define KW_RAM 295 -# define KW_DB 296 -# define KW_CLSEND 297 -# define KW_CLRECV 298 -# define KW_OWNSEND 299 -# define KW_AIRECV 300 -# define START_DC 301 -# define START_PARAMETER_VALUE 302 -# define START_PARAMETER_DESCRIPTION 303 +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + UNSIGNED_INTEGER = 258, + SIGNED_INTEGER = 259, + REAL = 260, + STRING = 261, + HEX_STRING = 262, + IDENTIFIER = 263, + KEYWORD = 264, + KW_DCLASS = 265, + KW_STRUCT = 266, + KW_FROM = 267, + KW_IMPORT = 268, + KW_TYPEDEF = 269, + KW_KEYWORD = 270, + KW_SWITCH = 271, + KW_CASE = 272, + KW_DEFAULT = 273, + KW_BREAK = 274, + KW_INT8 = 275, + KW_INT16 = 276, + KW_INT32 = 277, + KW_INT64 = 278, + KW_UINT8 = 279, + KW_UINT16 = 280, + KW_UINT32 = 281, + KW_UINT64 = 282, + KW_FLOAT64 = 283, + KW_STRING = 284, + KW_BLOB = 285, + KW_BLOB32 = 286, + KW_INT8ARRAY = 287, + KW_INT16ARRAY = 288, + KW_INT32ARRAY = 289, + KW_UINT8ARRAY = 290, + KW_UINT16ARRAY = 291, + KW_UINT32ARRAY = 292, + KW_UINT32UINT8ARRAY = 293, + KW_CHAR = 294, + START_DC = 295, + START_PARAMETER_VALUE = 296, + START_PARAMETER_DESCRIPTION = 297 + }; +#endif +#define UNSIGNED_INTEGER 258 +#define SIGNED_INTEGER 259 +#define REAL 260 +#define STRING 261 +#define HEX_STRING 262 +#define IDENTIFIER 263 +#define KEYWORD 264 +#define KW_DCLASS 265 +#define KW_STRUCT 266 +#define KW_FROM 267 +#define KW_IMPORT 268 +#define KW_TYPEDEF 269 +#define KW_KEYWORD 270 +#define KW_SWITCH 271 +#define KW_CASE 272 +#define KW_DEFAULT 273 +#define KW_BREAK 274 +#define KW_INT8 275 +#define KW_INT16 276 +#define KW_INT32 277 +#define KW_INT64 278 +#define KW_UINT8 279 +#define KW_UINT16 280 +#define KW_UINT32 281 +#define KW_UINT64 282 +#define KW_FLOAT64 283 +#define KW_STRING 284 +#define KW_BLOB 285 +#define KW_BLOB32 286 +#define KW_INT8ARRAY 287 +#define KW_INT16ARRAY 288 +#define KW_INT32ARRAY 289 +#define KW_UINT8ARRAY 290 +#define KW_UINT16ARRAY 291 +#define KW_UINT32ARRAY 292 +#define KW_UINT32UINT8ARRAY 293 +#define KW_CHAR 294 +#define START_DC 295 +#define START_PARAMETER_VALUE 296 +#define START_PARAMETER_DESCRIPTION 297 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif extern YYSTYPE dcyylval; -#endif /* not BISON_Y_TAB_H */ + + diff --git a/direct/src/dcparser/dcParser.yxx b/direct/src/dcparser/dcParser.yxx index 7397123d61..ecc814bbc6 100644 --- a/direct/src/dcparser/dcParser.yxx +++ b/direct/src/dcparser/dcParser.yxx @@ -16,6 +16,7 @@ #include "dcArrayParameter.h" #include "dcSimpleParameter.h" #include "dcTypedef.h" +#include "dcKeyword.h" #include "dcPacker.h" #include "dcNumericRange.h" @@ -27,12 +28,13 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 -static DCFile *dc_file = (DCFile *)NULL; +DCFile *dc_file = (DCFile *)NULL; static DCClass *current_class = (DCClass *)NULL; static DCSwitch *current_switch = (DCSwitch *)NULL; static DCAtomicField *current_atomic = (DCAtomicField *)NULL; static DCMolecularField *current_molecular = (DCMolecularField *)NULL; static DCParameter *current_parameter = (DCParameter *)NULL; +static DCKeywordList current_keyword_list; static DCPacker default_packer; static DCPacker *current_packer; static DCDoubleRange double_range; @@ -83,12 +85,14 @@ dc_cleanup_parser() { %token SIGNED_INTEGER %token REAL %token STRING HEX_STRING IDENTIFIER +%token KEYWORD %token KW_DCLASS %token KW_STRUCT %token KW_FROM %token KW_IMPORT %token KW_TYPEDEF +%token KW_KEYWORD %token KW_SWITCH %token KW_CASE %token KW_DEFAULT @@ -115,16 +119,6 @@ dc_cleanup_parser() { %token KW_UINT32UINT8ARRAY %token KW_CHAR -%token KW_REQUIRED -%token KW_BROADCAST -%token KW_P2P -%token KW_RAM -%token KW_DB -%token KW_CLSEND -%token KW_CLRECV -%token KW_OWNSEND -%token KW_AIRECV - /* These special tokens are used to set the starting state of the parser. The lexer places the appropriate one of these on the head of the input stream. */ @@ -133,8 +127,6 @@ dc_cleanup_parser() { %token START_PARAMETER_DESCRIPTION %type atomic_name -%type server_flags -%type no_server_flags %type dclass_or_struct %type dclass_name %type dclass @@ -203,6 +195,7 @@ dc: } | dc import | dc typedef_decl + | dc keyword_decl ; slash_identifier: @@ -270,6 +263,21 @@ typedef_decl: } ; +keyword_decl: + KW_KEYWORD IDENTIFIER +{ + dc_file->add_keyword($2); +} + | KW_KEYWORD KEYWORD +{ + // This keyword has already been defined. But since we are now + // explicitly defining it, clear its bitmask, so that we will have a + // new hash code--doing this will allow us to phase out the + // historical hash code support later. + ((DCKeyword *)$2)->clear_historical_flag(); +} + ; + dclass_or_struct: dclass | struct @@ -339,7 +347,7 @@ dclass_base_list: dclass_fields: empty | dclass_fields ';' - | dclass_fields dclass_field + | dclass_fields dclass_field ';' { if ($2 == (DCField *)NULL) { // Pass this error up. @@ -352,29 +360,29 @@ dclass_fields: ; dclass_field: - atomic_field server_flags + atomic_field keyword_list { if ($1 != (DCField *)NULL) { if ($1->get_name().empty()) { yyerror("Field name required."); } - $1->set_flags($2); + $1->copy_keywords(current_keyword_list); } $$ = $1; } - | molecular_field no_server_flags - | unnamed_parameter_with_default server_flags ';' + | molecular_field no_keyword_list + | unnamed_parameter_with_default keyword_list ';' { yyerror("Unnamed parameters are not allowed on a dclass"); if ($1 != (DCField *)NULL) { - $1->set_flags($2); + $1->copy_keywords(current_keyword_list); } $$ = $1; } - | named_parameter_with_default server_flags + | named_parameter_with_default keyword_list { if ($1 != (DCField *)NULL) { - $1->set_flags($2); + $1->copy_keywords(current_keyword_list); } $$ = $1; } @@ -439,7 +447,7 @@ struct_base_list: struct_fields: empty | struct_fields ';' - | struct_fields struct_field + | struct_fields struct_field ';' { if ($2 == (DCField *)NULL) { // Pass this error up. @@ -450,19 +458,19 @@ struct_fields: ; struct_field: - atomic_field no_server_flags + atomic_field no_keyword_list { if ($1->get_name().empty()) { yyerror("Field name required."); } $$ = $1; } - | molecular_field no_server_flags - | unnamed_parameter_with_default no_server_flags ';' + | molecular_field no_keyword_list + | unnamed_parameter_with_default no_keyword_list ';' { $$ = $1; } - | named_parameter_with_default no_server_flags + | named_parameter_with_default no_keyword_list { $$ = $1; } @@ -603,15 +611,15 @@ parameter_or_atomic: ; parameter_description: - atomic_field no_server_flags + atomic_field no_keyword_list { $$ = $1; } - | unnamed_parameter_with_default no_server_flags + | unnamed_parameter_with_default no_keyword_list { $$ = $1; } - | named_parameter_with_default no_server_flags + | named_parameter_with_default no_keyword_list { $$ = $1; } @@ -1140,56 +1148,23 @@ type_token: } ; -server_flags: +keyword_list: empty { - $$ = 0; + current_keyword_list.clear_keywords(); } - | server_flags KW_REQUIRED + | keyword_list KEYWORD { - $$ = $1 | DCAtomicField::F_required; + current_keyword_list.add_keyword($2); } - | server_flags KW_BROADCAST -{ - $$ = $1 | DCAtomicField::F_broadcast; -} - | server_flags KW_P2P -{ - $$ = $1 | DCAtomicField::F_p2p; -} - | server_flags KW_RAM -{ - $$ = $1 | DCAtomicField::F_ram; -} - | server_flags KW_DB -{ - $$ = $1 | DCAtomicField::F_db; -} - | server_flags KW_CLSEND -{ - $$ = $1 | DCAtomicField::F_clsend; -} - | server_flags KW_CLRECV -{ - $$ = $1 | DCAtomicField::F_clrecv; -} - | server_flags KW_OWNSEND -{ - $$ = $1 | DCAtomicField::F_ownsend; -} - | server_flags KW_AIRECV -{ - $$ = $1 | DCAtomicField::F_airecv; -} - ; + ; -no_server_flags: - server_flags +no_keyword_list: + keyword_list { - if ($1 != 0) { - yyerror("Server flags are not allowed here."); + if (current_keyword_list.get_num_keywords() != 0) { + yyerror("Communication keywords are not allowed here."); } - $$ = $1; } ; @@ -1231,8 +1206,8 @@ molecular_atom_list: { if ($3 != (DCAtomicField *)NULL) { current_molecular->add_atomic($3); - if (!current_molecular->compare_flags(*$3)) { - yyerror("Mismatched flags in molecule between " + + if (!current_molecular->compare_keywords(*$3)) { + yyerror("Mismatched keywords in molecule between " + current_molecular->get_atomic(0)->get_name() + " and " + $3->get_name()); } diff --git a/direct/src/dcparser/dcParserDefs.h b/direct/src/dcparser/dcParserDefs.h index bc29789d56..ec70ea9c26 100644 --- a/direct/src/dcparser/dcParserDefs.h +++ b/direct/src/dcparser/dcParserDefs.h @@ -28,6 +28,7 @@ class DCSwitch; class DCField; class DCAtomicField; class DCParameter; +class DCKeyword; class DCPacker; void dc_init_parser(istream &in, const string &filename, DCFile &file); @@ -39,6 +40,8 @@ DCField *dc_get_parameter_description(); void dc_cleanup_parser(); int dcyyparse(); +extern DCFile *dc_file; + // This structure holds the return value for each token. // Traditionally, this is a union, and is declared with the %union // declaration in the parser.y file, but unions are pretty worthless @@ -61,6 +64,7 @@ public: DCAtomicField *atomic; DCSubatomicType subatomic; DCParameter *parameter; + const DCKeyword *keyword; } u; string str; }; diff --git a/direct/src/dcparser/dcbase.h b/direct/src/dcparser/dcbase.h index 9cd86a21b9..05319c8a68 100644 --- a/direct/src/dcparser/dcbase.h +++ b/direct/src/dcparser/dcbase.h @@ -36,6 +36,7 @@ #include "numeric_types.h" #include "pvector.h" #include "pmap.h" +#include "pset.h" #else // WITHIN_PANDA @@ -100,8 +101,10 @@ typedef string Filename; #include #include +#include #define pvector vector #define pmap map +#define pset set #ifdef WIN32 typedef __int64 PN_int64; diff --git a/direct/src/dcparser/dcparser_composite1.cxx b/direct/src/dcparser/dcparser_composite1.cxx index f18f90d13d..f1530a8960 100644 --- a/direct/src/dcparser/dcparser_composite1.cxx +++ b/direct/src/dcparser/dcparser_composite1.cxx @@ -4,6 +4,8 @@ #include "dcAtomicField.cxx" #include "dcClass.cxx" #include "dcDeclaration.cxx" +#include "dcKeyword.cxx" +#include "dcKeywordList.cxx" #include "dcPackData.cxx" #include "dcPacker.cxx" #include "dcPackerCatalog.cxx"