[antlr-interest] Subclassing from CPPParser

Ric Klaren klaren at cs.utwente.nl
Tue Dec 23 11:59:55 PST 2003


Hi,

On Tue, Dec 23, 2003 at 07:08:15PM -0000, wiggjd at lsbu.ac.uk wrote:
> e:\java\antlr-2.7.1\java-cpp\mycode.cpp(9) : error C2512:
> 'CPPParser' : no appropriate default constructor available
> 
> However, if I supply a default constructor for CPPParser I
> then get a similar message for LLkParser but this doesn't
> happen without the Mycode subclass!
> 
> I would be grateful if someone could suggest what I might be
> doing wrong.

You could work around this by explicitly calling the right constructor for
the super class from the constructor from Mycode or mimic the constructors
from the superclasses in Mycode and then just pass on the constructor
arguments:

Mycode( antlr::TokenStream& lexer, int k )
: CPPParser( lexer, k )
{
}

(not 100% sure if the k is in that constructor per default, check the
generated constructors for CPPParser to see which one you need)

> ----------
> #include "CPPParser.hpp"
> 
> class Mycode : public CPPParser
>     {
>     Mycode();
>     };

So here a implicit call to the default constructor of CPPParser is made
which probably does not exist. Another option is to call one of the
existing constructors from the CppParser with some more or less sane
defaults from the default constructor from MyCode.

Mycode()
: CPPParser( some_lexer, some_k )
{
}

Hope this helps you back on track, sorry I'm not very specific on the
constructors I don't have the code handy at the moment.

Cheers,

Ric
-- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  Wit is cultured insolence. --- Aristotle


 

Yahoo! Groups Links

To visit your group on the web, go to:
 http://groups.yahoo.com/group/antlr-interest/

To unsubscribe from this group, send an email to:
 antlr-interest-unsubscribe at yahoogroups.com

Your use of Yahoo! Groups is subject to:
 http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list