[antlr-interest] Newbie: Multiple Inheritance Error.

Ric Klaren klaren at cs.utwente.nl
Wed Mar 5 09:21:28 PST 2003


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 at utwente.nl ----- +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 use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list