[antlr-interest] C++ puzzle
yjargudo at tiscali.es
yjargudo at tiscali.es
Wed Jul 6 06:23:36 PDT 2005
Hello,
I think the problem is that simple_type_specifier rule of the grammar can't
parse the string "typedef typename" , because it has a different option
in the rule for each case. When antlr read "typedef" token it enters to
the typedef option but then It waits for a type and it reads "typename"
token instead.
I think that you must rewrite this rule in case that this instruction was
correct in C++.
Regards,
Yolanda
>-- Mensaje Original --
>Date: Wed, 29 Jun 2005 13:17:09 +0100
>From: David Wigg <wiggjd at lsbu.ac.uk>
>To: antlr-interest at antlr.org
>Subject: [antlr-interest] C++ puzzle
>
>
>Hi,
>
>I'm trying to parse the following extract from a C++
>preprocessed file. I wonder if someone could explain what the
>problem statement indicated might mean.
>
>#line 6 "C:\\Program Files\\Microsoft Visual Studio .NET
>2003\\VC7\\INCLUDE\\xstring"
>
>#pragma pack(push,8)
>#pragma warning(push,3)
>namespace std {
>
>#pragma warning(disable:4251)
>
>class _String_base
> {
>public:
> void _Xlen() const;
> void _Xran() const;
> };
>
>template<class _Ty,
> class _Alloc>
> class _String_val
> : public _String_base
> {
>protected:
> typedef typename _Alloc::template
> rebind<_Ty>::other _Alty; // Problem statement
>
> _String_val(_Alty _Al = _Alty())
> : _Alval(_Al)
> {
> }
>
> _Alty _Alval;
> };
>etc.
>
>
>I can't see how "_Alloc::template" can be a typename
>("template" is a reserved word), but what does it mean?
>
>I presume the syntax is legal but I have not been able to find
>any similar examples either in my include files in ...\Microsoft
>Visual Studio\VC98\include or in Stroustrup, Third Edition,
>Deitel & Deitel, Third Edition, or in "C++ in a Nutshell" First
>Edition.
>
>This preprocessed file was sent to me as a problem. It is
>interesting that I have not received this problem from anyone
>else.
>
>I wonder if anyone can identify the compiler and version?
>
>I also find it confusing that _Alty is a type as well as the
>name of a function and _Alval is a variable as well as the name
>of a function!
>
>Thanks,
>
>David.
>
>
>
>
>
>
>
>
>
¿Quieres conocer el futuro inmediato de la radio digital? Reportajes y
noticias del mundo de la Tecnología. ¡Ponte al día!
http://tecnologia.tiscali.es/
More information about the antlr-interest
mailing list