From: Alexander V. <al...@se...> - 2005-02-25 11:15:35
|
Hello! We are using OpenC++ in our project for some intellectual C++ code preprocessing. Recently, I've found that OpenC++ (2.8) can not parse following code: class X { public: template <typename T> int g() { return 123; } }; template <typename T> class A { public: X x; X& getx() { return x; } void f() { getx().g<T>(); } }; int main() { A<int> a; a.f(); } It says: [alex@lorien ~]$ ./occ -c 1.cpp 1.cpp: In member function `void A<T>::f()': 1.cpp:12: error: parse error before `;' token The 12th line corresponds to getx().g<T>() Is this a correct code? I have 4 compilers on my machine (gcc 3.3.5, gcc 3.4.3, gcc 4.0.0 snapshot, Intel C/C++ 8.1). All of them compile this code cleanly. I will be glad to provide any additional information about my problem or opencxx configuration. May be there is also some CVS, SVN or other "bleeding-edge" source that I can try? With best regards, Alexander. |
From: Stefan S. <se...@sy...> - 2005-02-25 16:31:57
|
Alexander Vodomerov wrote: > Recently, I've found that OpenC++ (2.8) can not parse following code: > > class X > { > public: > template <typename T> int g() { return 123; } > }; > > template <typename T> class A > { > public: > X x; > X& getx() { return x; } > void f() { getx().g<T>(); } > }; > > int main() > { > A<int> a; > a.f(); > } > > It says: > [alex@lorien ~]$ ./occ -c 1.cpp > 1.cpp: In member function `void A<T>::f()': > 1.cpp:12: error: parse error before `;' token > > The 12th line corresponds to getx().g<T>() > > Is this a correct code? I have 4 compilers on my machine (gcc 3.3.5, > gcc 3.4.3, gcc 4.0.0 snapshot, Intel C/C++ 8.1). All of them > compile this code cleanly. The OpenC++ parser is indeed not powerful enough to understand that line. The reason is that to be able to decide whether '<' is a relational operator or the start of a template parameter spec, it has to figure out what 'g' is. That requires symbol lookup, which OpenC++ doesn't do during parsing. Regards, Stefan |
From: J D. <ja...@ja...> - 2005-02-25 21:01:22
|
has anyone thought about integrating boosts spirit/wave with openc++ wave is a fully ansi compliant preprocessor as far as i understand Ive been thinking about adding metaobjects to a modified wave preprocessor, openc++ just doesnt have a powerfull enough parser Stefan Seefeld wrote: > Alexander Vodomerov wrote: > >> Recently, I've found that OpenC++ (2.8) can not parse following code: >> >> class X >> { >> public: >> template <typename T> int g() { return 123; } >> }; >> >> template <typename T> class A >> { >> public: >> X x; >> X& getx() { return x; } >> void f() { getx().g<T>(); } >> }; >> >> int main() >> { >> A<int> a; >> a.f(); >> } >> >> It says: >> [alex@lorien ~]$ ./occ -c 1.cpp >> 1.cpp: In member function `void A<T>::f()': >> 1.cpp:12: error: parse error before `;' token >> >> The 12th line corresponds to getx().g<T>() >> >> Is this a correct code? I have 4 compilers on my machine (gcc 3.3.5, >> gcc 3.4.3, gcc 4.0.0 snapshot, Intel C/C++ 8.1). All of them >> compile this code cleanly. > > > The OpenC++ parser is indeed not powerful enough to understand that line. > The reason is that to be able to decide whether '<' is a relational > operator > or the start of a template parameter spec, it has to figure out what 'g' > is. That requires symbol lookup, which OpenC++ doesn't do during parsing. > > Regards, > Stefan > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Opencxx-users mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/opencxx-users > |
From: Stefan S. <se...@sy...> - 2005-02-26 02:37:53
|
J Duncan wrote: > has anyone thought about integrating boosts spirit/wave with openc++ > wave is a fully ansi compliant preprocessor as far as i understand No, but the author of wave expressed interest in adding wave support to synopsis, which is somewhat based on OpenC++ (note that synopsis currently uses ucpp as preprocessor library). > Ive been thinking about adding metaobjects to a modified wave > preprocessor, openc++ just doesnt have a powerfull enough parser I'm not sure what you mean. We are talking about parsing C++ here, not preprocessing, right ? And while OpenC++ doesn't support some important aspects of C++ parsing, wave doesn't either (if only because that is not its scope). You still need symbol lookup, overload resolution, template instantiation, etc., etc. Regards, Stefan |
From: Grzegorz J. <ja...@ac...> - 2005-02-26 03:56:09
|
>> has anyone thought about integrating boosts spirit/wave with openc++ >> wave is a fully ansi compliant preprocessor as far as i understand > > No, but the author of wave expressed interest in adding wave support > to synopsis, which is somewhat based on OpenC++ (note that synopsis > currently uses ucpp as preprocessor library). Word of caution: Synopsis is has much more restrictive license than OpenC++, think twice before investing your time. BR Grzegorz |
From: Grzegorz J. <ja...@ac...> - 2005-02-26 03:24:20
|
Hello, J Duncan wrote: > has anyone thought about integrating boosts spirit/wave with openc++ > wave is a fully ansi compliant preprocessor as far as i understand Curently preprocessing is out of the scope of OpenC++. OpenC++ works on preprocessed stream. It uses external preprocessor, so feel free to use Wave (or more precisely Wave CLI wrapper) as the preprocessor for OpenC++ if you like. Another story is that some time ago there were proposals to incorporate preprocessing into OpenC++ flow to enable deparsing without expansion of preprocessor constructs. Wave would fit this space well, but there are nontrivial problems with interposing preprocessor structure over the AST. The initiative is on hold now, if you want to go in this direction I can provide help with orientation in OpenC++ architecture. > Ive been thinking about adding metaobjects to a modified wave > preprocessor, openc++ just doesnt have a powerfull enough parser Sorry, I don't understand your point here. In what aspects is OpenC++ preprocessor too weak? What kind of metaobjects would you like to add? Why? Best regards Grzegorz > > > Stefan Seefeld wrote: > >> Alexander Vodomerov wrote: >> >>> Recently, I've found that OpenC++ (2.8) can not parse following code: >>> >>> class X >>> { >>> public: >>> template <typename T> int g() { return 123; } >>> }; >>> >>> template <typename T> class A >>> { >>> public: >>> X x; >>> X& getx() { return x; } >>> void f() { getx().g<T>(); } >>> }; >>> >>> int main() >>> { >>> A<int> a; >>> a.f(); >>> } >>> >>> It says: >>> [alex@lorien ~]$ ./occ -c 1.cpp >>> 1.cpp: In member function `void A<T>::f()': >>> 1.cpp:12: error: parse error before `;' token >>> >>> The 12th line corresponds to getx().g<T>() >>> >>> Is this a correct code? I have 4 compilers on my machine (gcc 3.3.5, >>> gcc 3.4.3, gcc 4.0.0 snapshot, Intel C/C++ 8.1). All of them >>> compile this code cleanly. >> >> >> >> The OpenC++ parser is indeed not powerful enough to understand that line. >> The reason is that to be able to decide whether '<' is a relational >> operator >> or the start of a template parameter spec, it has to figure out what 'g' >> is. That requires symbol lookup, which OpenC++ doesn't do during parsing. >> >> Regards, >> Stefan >> >> >> ------------------------------------------------------- >> SF email is sponsored by - The IT Product Guide >> Read honest & candid reviews on hundreds of IT Products from real users. >> Discover which products truly live up to the hype. Start reading now. >> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click >> _______________________________________________ >> Opencxx-users mailing list >> Ope...@li... >> https://lists.sourceforge.net/lists/listinfo/opencxx-users >> > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Opencxx-users mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/opencxx-users |