Loading ...
Sorry, an error occurred while loading the content.

Newbie: Multiple Inheritance Error.

Expand Messages
  • BLade X
    Hi, I am trying to write a directx .X file parser using antlr. 1. I am using antlr 2.7.2 with GCC 3.x on MinGW. I am getting multiple inheritance errors when I
    Message 1 of 2 , Mar 5, 2003
    • 0 Attachment
      Hi,
      I am trying to write a directx .X file parser using
      antlr.
      1. I am using antlr 2.7.2 with GCC 3.x on MinGW. I am
      getting multiple inheritance errors when I try to
      compile the code generated by my program. I am trying
      to parse the directx .X format. I seem to have been
      able to trubleshoot most of the errors but this one
      really has me stumped.

      Here are the errors...
      ----------------------------------------------------------
      g++ -g -o dxparse main.cpp DXLexer.cpp
      DXFileParser.cpp -I/usr/
      local/include -lantlr -L/usr/local/lib

      DXFileParser.cpp: In member function `void
      DXFileParser::file()':
      DXFileParser.cpp:43: request for member `LT' is
      ambiguous in multiple
      inheritance lattice
      DXFileParserTokenTypes.hpp:36: candidates are:
      DXFileParserTokenTypes::<anonymous enum>
      DXFileParserTokenTypes::LT
      C:/MSYS/local/include/antlr/LLkParser.hpp:50:
      virtual
      antlr::RefToken antlr::LLkParser::LT(int)
      DXFileParser.cpp: In member function `void
      DXFileParser::statements()':
      DXFileParser.cpp:130: request for member `LT' is
      ambiguous in multiple
      inheritance lattice
      DXFileParserTokenTypes.hpp:36: candidates are:
      DXFileParserTokenTypes::<anonymous enum>
      DXFileParserTokenTypes::LT
      C:/MSYS/local/include/antlr/LLkParser.hpp:50:
      virtual
      antlr::RefToken antlr::LLkParser::LT(int)
      DXFileParser.cpp: In member function `void
      DXFileParser::templateDef()':

      ...
      --------------------------------------------------------

      Any suggestions will be very welcome. I have attached
      the dxlexer.g and dxfile.g to this e-mail in case one
      needs it.

      2. My second suggestion is to give the users the
      ability to build and install only the cpp libraries, I
      do not have jdk installed and it cannot find
      javac.exe. I don't need java libraries. This is just a
      suggestion.

      3. In the directx format, there are these things
      called templates, which are equivalent to variable
      declarations.

      For example I can say
      --------------------------------------------
      Template DancingMonkey {
      Shake behind;
      }

      DancingMonkey niceMonkey;
      --------------------------------------------
      My question is when I am parsing I want to give an
      error message if I see some template that has not been
      declared before, I am not exactly sure how to do that.
      Any suggestions or pointers to example where that kind
      of stuff is done (preferrably C++).

      Forgive my english it is 3 AM and I am currently
      thinking only antlr grammar.

      Thanks in advance,
      Manju

      __________________________________________________
      Do you Yahoo!?
      Yahoo! Tax Center - forms, calculators, tips, more
      http://taxes.yahoo.com/
    • Ric Klaren
      Hi, ... You probably have a LT token somewhere in your lexer/parser? Rename it to something else and it will fix this. ... Just run configure and a submake in
      Message 2 of 2 , Mar 5, 2003
      • 0 Attachment
        Hi,

        On Wed, Mar 05, 2003 at 09:00:07AM -0800, BLade X wrote:
        > DXFileParser::file()':
        > DXFileParser.cpp:43: request for member `LT' is
        > ambiguous in multiple
        > inheritance lattice
        > DXFileParserTokenTypes.hpp:36: candidates are:
        > DXFileParserTokenTypes::<anonymous enum>
        > DXFileParserTokenTypes::LT
        > C:/MSYS/local/include/antlr/LLkParser.hpp:50:
        > virtual
        > antlr::RefToken antlr::LLkParser::LT(int)
        > DXFileParser.cpp: In member function `void
        > DXFileParser::statements()':
        > DXFileParser.cpp:130: request for member `LT' is
        > ambiguous in multiple
        > inheritance lattice
        > DXFileParserTokenTypes.hpp:36: candidates are:
        > DXFileParserTokenTypes::<anonymous enum>
        > DXFileParserTokenTypes::LT

        You probably have a LT token somewhere in your lexer/parser? Rename it to
        something else and it will fix this.

        > 2. My second suggestion is to give the users the
        > ability to build and install only the cpp libraries, I
        > do not have jdk installed and it cannot find
        > javac.exe. I don't need java libraries. This is just a
        > suggestion.

        Just run configure and a submake in the lib/cpp directory. Afterwards
        install by hand. E.g. copy the lib/cpp/antlr/* to /usr/include/antlr/* and the
        libantlr.a to /usr/lib.

        > 3. In the directx format, there are these things
        > called templates, which are equivalent to variable
        > declarations.
        >
        > For example I can say
        > --------------------------------------------
        > Template DancingMonkey {
        > Shake behind;
        > }
        >
        > DancingMonkey niceMonkey;
        > --------------------------------------------
        > My question is when I am parsing I want to give an
        > error message if I see some template that has not been
        > declared before, I am not exactly sure how to do that.
        > Any suggestions or pointers to example where that kind
        > of stuff is done (preferrably C++).

        Track definition of a template in a set or something. And when you see a
        reference to one check the set. (if there's scope like things you might
        have to make something of a nested structure for correct resolving)

        Very rough setup (but it should give you the general idea):

        // define this in your parser as attribute. (see the C++ specific part of
        // docs)
        std::set<std::string> template_defs;

        // then in your template definition rule
        template_def: "Template" id:ID "{" ...stuff... "}"
        {
        if( ! template_defs.insert(id->getText()).second )
        throw antlr::RecognitionException("double definition of template",id->getFilename(),id->getLine(),id->getColumn());
        }
        ;

        // rule where the template is referenced
        template_ref: id:ID
        {
        if( template_defs.find(id->getText()) == template_defs.end() )
        throw antlr::RecognitionException("Undefined template",id->getFilename(),id->getLine(),id->getColumn());
        }
        ;

        Cheers,

        Ric
        --
        -----+++++*****************************************************+++++++++-------
        ---- Ric Klaren ----- j.klaren@... ----- +31 53 4893722 ----
        -----+++++*****************************************************+++++++++-------
        "You know how to use that thing?" [pointing to the sword]
        "Sure.. The pointy end goes into the other guy."
        --- The Mask of Zorro
      Your message has been successfully submitted and would be delivered to recipients shortly.