[antlr-interest] static casts in heterogeneous AST parser
John Lambert
johnl at jbase.com
Mon Oct 8 13:11:57 PDT 2001
The code is generated by the ANTLR compiler and works on all other
platforms..
If I try (on Windows) to use any other type of cast it objects.
Cheers,
John
-----Original Message-----
From: Ruslan Zasukhin [mailto:sunshine at public.kherson.ua]
Sent: Monday, October 08, 2001 12:48 PM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] static casts in heterogeneous AST parser
on 10/8/01 19:06, John Lambert at johnl at jbase.com wrote:
> I have problems compiling a parser using heterogeneous ASTs on HPUX.
>
> It is objecting to all static_cast operations between ASTRefcount<AST>
and
> ASTRefcount< derivedAST>
>
> HP support claim they are correct and that it should be a
reinterpret_cast. I
> disagree, this works fine on lots of other platforms and a quick test of
> reinterpret_cast on other platforms produces compilation errors.
>
> Has anyone else encountered this ?
If I am not mistake (and I think I am not) rule is next:
if a class has at least one virtual function
then e must use dynamic_cast<>, otherwise static_cast<>
This is annoying frankly saying...
Let I have class A with no virtual functions and use it in a lots of places.
Later if I will need virtual function in this class, all static_cast for it
must be replaced on dynamic_cast<>.
Compiler do not allow us to have only one type_cast<> for all cases. :-(
> Thanks,
>
> John Lambert
>
>
> Here's a sample:
>
> Error 746: "AcorrParser.cpp", line 41 #
> Cannot use static_cast to convert class ASTRefCount<antlr::AST> to class
> ASTRefCount<ConvAST>.
> returnAST =
> static_cast<RefConvAST>(ANTLR_USE_NAMESPACE(antlr)nullAST);
--
Best regards,
Ruslan Zasukhin
-------------------------
Paradigma.
e-mail: ruslan at paradigmasoft.com
web : http://www.paradigmasoft.com
To subscribe to the Valentina mail list
send a letter to valentina-on at lists.macserve.net
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list